简体   繁体   中英

Skia jni SkCanvas::drawString() not rendering while shapes works

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

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 with expat , it worked like just fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM