Skia jni SkCanvas::drawString() 在形状工作时不渲染
我已经为 Android api 24 构建了 Skia 将从 java 创建的位图传递给 jni,这段代码可以很好地绘制除字符串之外的所有内容:
void draw(JNIEnv *env, jobject bmp) {
AndroidBitmapInfo dstInfo;
void *dstPixels;
AndroidBitmap_getInfo(env, bmp, &dstInfo);
AndroidBitmap_lockPixels(env, bmp, &dstPixels);
SkImageInfo info = SkImageInfo::MakeN32Premul(dstInfo.width, dstInfo.height);
sk_sp<SkSurface> surface(SkSurface::MakeRasterDirect(info, dstPixels, dstInfo.stride));
SkCanvas *canvas = surface->getCanvas();
canvas->drawColor(0xFFcccccc);
SkFont font;
SkPaint paint;
paint.setColor(SK_ColorGREEN);
paint.setStrokeWidth(30.f);
paint.setAntiAlias(true);
canvas->drawString("Skia is Best!", 99, 99, font, paint);
cvs->drawLine(100, 100, 300, 300, paint);
cvs->drawRoundRect(r, 11.f, 11.f, paint);
cvs->drawCircle(500, 600, 99.f, point);
AndroidBitmap_unlockPixels(env, bmp);
}
没有生成崩溃或错误,知道可能是什么原因造成的吗?
测试平台:小米 Mi10t Android 10
I've built Skia for Android api 24
Passing a bitmap created from java to jni, this code draws everything fine except strings:
void draw(JNIEnv *env, jobject bmp) {
AndroidBitmapInfo dstInfo;
void *dstPixels;
AndroidBitmap_getInfo(env, bmp, &dstInfo);
AndroidBitmap_lockPixels(env, bmp, &dstPixels);
SkImageInfo info = SkImageInfo::MakeN32Premul(dstInfo.width, dstInfo.height);
sk_sp<SkSurface> surface(SkSurface::MakeRasterDirect(info, dstPixels, dstInfo.stride));
SkCanvas *canvas = surface->getCanvas();
canvas->drawColor(0xFFcccccc);
SkFont font;
SkPaint paint;
paint.setColor(SK_ColorGREEN);
paint.setStrokeWidth(30.f);
paint.setAntiAlias(true);
canvas->drawString("Skia is Best!", 99, 99, font, paint);
cvs->drawLine(100, 100, 300, 300, paint);
cvs->drawRoundRect(r, 11.f, 11.f, paint);
cvs->drawCircle(500, 600, 99.f, point);
AndroidBitmap_unlockPixels(env, bmp);
}
No crashes or errors generated, any idea what may be causing that?
Tested on: Xiaomi Mi10t Android 10
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经解决了这个问题 如果有人遇到同样的问题
我在没有
expat
的情况下编译 Skia (skia_use_expat=false
),因为它在编译时出现了一些错误,修复错误后,然后使用expat
重新编译 Skia ,效果很好。I've fixed the issue, if anyone having the same problem,
I was compiling Skia without
expat
(skia_use_expat=false
) because it had some errors while compiling, after fixing the errors, and recompiling Skia withexpat
, it worked like just fine.