skia的源码:
https://github.com/google/skia/blob/master/src/gpu/ops/GrOvalOpFactory.cpp
crash发生在this->setVertexAttributes(&fInPosition, 7)里面,实现代码根据fInPosition地址偏移去遍历下一个Attribute发现是一个非法指针导致的,也就是说这个代码编译的7个Attribute没有连续,想知道是为什么;
CircleGeometryProcessor(bool stroke, bool clipPlane, bool isectPlane, bool unionPlane,
bool roundCaps, bool wideColor, const SkMatrix& localMatrix)
: INHERITED(kCircleGeometryProcessor_ClassID)
, fLocalMatrix(localMatrix)
, fStroke(stroke) {
fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
fInColor = MakeColorAttribute("inColor", wideColor);
fInCircleEdge = {"inCircleEdge", kFloat4_GrVertexAttribType, kFloat4_GrSLType};
if (clipPlane) {
fInClipPlane = {"inClipPlane", kFloat3_GrVertexAttribType, kHalf3_GrSLType};
}
if (isectPlane) {
fInIsectPlane = {"inIsectPlane", kFloat3_GrVertexAttribType, kHalf3_GrSLType};
}
if (unionPlane) {
fInUnionPlane = {"inUnionPlane", kFloat3_GrVertexAttribType, kHalf3_GrSLType};
}
if (roundCaps) {
SkASSERT(stroke);
SkASSERT(clipPlane);
fInRoundCapCenters =
{"inRoundCapCenters", kFloat4_GrVertexAttribType, kFloat4_GrSLType};
}
this->setVertexAttributes(&fInPosition, 7);
}
...
Attribute fInPosition;
Attribute fInColor;
Attribute fInCircleEdge;
// Optional attributes.
Attribute fInClipPlane;
Attribute fInIsectPlane;
Attribute fInUnionPlane;
Attribute fInRoundCapCenters;
this->setVertexAttributes(&fInPosition, 7)的实现部分:
void init(const Attribute* attrs, int count) {
fAttributes = attrs;
fRawCount = count;
fCount = 0;
fStride = 0;
for (int i = 0; i < count; ++i) {
if (attrs[i].isInitialized()) {
fCount++;
fStride += attrs[i].sizeAlign4();
}
}
}