DG
Size: a a a
DG
MG
DG
MG
MG
MG
public void draw(Canvas canvas, TextPaint textPaint) {
Instant before = Instant.now();
Bitmap bitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
drawLine(bitmap, text == null ? null : text.toString(), textPaint);
canvas.drawBitmap(bitmap, 0, 0, null);
bitmap.recycle();
Instant after = Instant.now();
Log.d(TAG, "draw: completed in " + Duration.between(before, after).toMillis() + " milliseconds");
}
MG
MG
D/Skia: draw: read pixels in 213 milliseconds
Instant before = Instant.now();
int[] pixels = getPixels(native_skia_ptr);
Instant after = Instant.now();
Log.d(TAG, "draw: read pixels in " + Duration.between(before, after).toMillis() + " milliseconds");
jintArray SkiaInstance::getPixels(JNIEnv *env) {
auto sRGB = SkColorSpace::MakeSRGB();
SkImageInfo dstInfo = SkImageInfo::Make(
width, height, kBGRA_8888_SkColorType, kUnpremul_SkAlphaType, sRGB);
size_t dstRowBytes = dstInfo.minRowBytes();
auto length = dstInfo.computeMinByteSize();
uint32_t * dst = new SkColor[length];
bitmap.readPixels(dstInfo, dst, dstRowBytes, 0, 0);
jintArray array = env->NewIntArray(length);
env->SetIntArrayRegion(array, 0, length, reinterpret_cast<const jint *>(dst));
delete[] dst;
return array;
}
MG
MG
DG
MG
MG
MG
MG
MG
MG
MG
MG
MG