static void android_view_GLES20Canvas_drawBitmapData(JNIEnv* env, jobject clazz, jlong rendererPtr, jintArray colors, jint offset, jint stride, jfloat left, jfloat top, jint width, jint height, jboolean hasAlpha, jlong paintPtr) { // Note: If hasAlpha is false, kRGB_565_SkColorType will be used, which will // correct the alphaType to kOpaque_SkAlphaType. const SkImageInfo info = SkImageInfo::Make(width, height, hasAlpha ? kN32_SkColorType : kRGB_565_SkColorType, kPremul_SkAlphaType); SkBitmap* bitmap = new SkBitmap; if (!bitmap->allocPixels(info)) { delete bitmap; return; } if (!GraphicsJNI::SetPixels(env, colors, offset, stride, 0, 0, width, height, *bitmap)) { delete bitmap; return; } DisplayListRenderer* renderer = reinterpret_cast<DisplayListRenderer*>(rendererPtr); Paint* paint = reinterpret_cast<Paint*>(paintPtr); // apply transform directly to canvas, so it affects shaders correctly renderer->save(SkCanvas::kMatrix_SaveFlag); renderer->translate(left, top); renderer->drawBitmapData(bitmap, paint); renderer->restore(); // Note - bitmap isn't deleted as DisplayListRenderer owns it now }
static void android_view_GLES20Canvas_drawBitmap(JNIEnv* env, jobject clazz, jlong rendererPtr, jlong bitmapPtr, jfloat left, jfloat top, jlong paintPtr) { SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapPtr); DisplayListRenderer* renderer = reinterpret_cast<DisplayListRenderer*>(rendererPtr); Paint* paint = reinterpret_cast<Paint*>(paintPtr); // apply transform directly to canvas, so it affects shaders correctly renderer->save(SkCanvas::kMatrix_SaveFlag); renderer->translate(left, top); renderer->drawBitmap(bitmap, paint); renderer->restore(); }
static void android_view_GLES20Canvas_drawBitmap(JNIEnv* env, jobject clazz, jlong rendererPtr, jlong bitmapPtr, jbyteArray buffer, jfloat left, jfloat top, jlong paintPtr) { SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapPtr); // This object allows the renderer to allocate a global JNI ref to the buffer object. JavaHeapBitmapRef bitmapRef(env, bitmap, buffer); DisplayListRenderer* renderer = reinterpret_cast<DisplayListRenderer*>(rendererPtr); Paint* paint = reinterpret_cast<Paint*>(paintPtr); // apply transform directly to canvas, so it affects shaders correctly renderer->save(SkCanvas::kMatrix_SaveFlag); renderer->translate(left, top); renderer->drawBitmap(bitmap, paint); renderer->restore(); }
static void android_view_GLES20Canvas_translate(JNIEnv* env, jobject clazz, jlong rendererPtr, jfloat dx, jfloat dy) { DisplayListRenderer* renderer = reinterpret_cast<DisplayListRenderer*>(rendererPtr); renderer->translate(dx, dy); }