开发者

Memory crash while drawing with skia on honeycomb

I have a function that instantiates an object of "SkPath" on stack. After that I call few functions such as "moveTo", "lineTo", "cubicTo" ( which is simply adds new points to inner array inside of the SkPath object). Then I instantiate object of "SkPaint" class also on the stack.

Then I call "drawPath" function of "SkCanvas" object and pass SkPath and SkPaint objects as args and, it crashes.

I've done some investigation. It turns out that array inside SkPath is not valid anymore because the constructor of SkPaint is nulling its (SkPaint's) object by calling sk_bzero(this, sizeof(*this)); ("memset" to 0 for "pointer" with size of "*pointer") by doing this it also somehow cleans up pointer to array that belongs to previ开发者_开发知识库ously declared object of SkPath.

I have fixed it by instantiation SkPaint before SkPath but problem still remains, since I have few more issues similar to this one and well... I want to understand what is going on. The same code works fine on Android 2.2.

I'm not using hardware acceleration.

SkPath skPath;  
skPath.setFillType(fillType);
skPath.moveTo(x1, y1);
skPath.cubicTo(x1, y1, x2, y2, x3, y3);
skPath.lineTo(x1, y1);
skPath.close();

SkPaint paint; //<- will call constructor that cleans up pointer to array

paint.setAntiAlias(true);
GfxRGB rgb;
state->getFillRGB(&rgb);
paint.setColor(GfxRGB2SkColor(rgb));
paint.setStyle(SkPaint::kFill_Style);
paint.setAlpha((U8CPU) (state->getFillOpacity() * 255));

canvas->drawPath(skPath, paint); // <- will crash here
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜