Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c294d128 authored by John Reck's avatar John Reck
Browse files

A bunch more cleanups

Switch a few places to using android::canvas
instead of SkCanvas as well which eliminated
some JNI

Change-Id: I8f98b56442a06362b82b984cd1bd3a92398d8dbc
parent 4fc266bb
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -360,7 +360,7 @@ public class ThreadedRenderer extends HardwareRenderer {
    @Override
    boolean copyLayerInto(final HardwareLayer layer, final Bitmap bitmap) {
        return nCopyLayerInto(mNativeProxy,
                layer.getDeferredLayerUpdater(), bitmap.getSkBitmap());
                layer.getDeferredLayerUpdater(), bitmap);
    }

    @Override
@@ -531,7 +531,7 @@ public class ThreadedRenderer extends HardwareRenderer {

    private static native long nCreateTextureLayer(long nativeProxy);
    private static native void nBuildLayer(long nativeProxy, long node);
    private static native boolean nCopyLayerInto(long nativeProxy, long layer, long bitmap);
    private static native boolean nCopyLayerInto(long nativeProxy, long layer, Bitmap bitmap);
    private static native void nPushLayerUpdate(long nativeProxy, long layer);
    private static native void nCancelLayerUpdate(long nativeProxy, long layer);
    private static native void nDetachSurfaceTexture(long nativeProxy, long layer);
+2 −4
Original line number Diff line number Diff line
@@ -373,7 +373,7 @@ SkColorType GraphicsJNI::getNativeBitmapColorType(JNIEnv* env, jobject jconfig)
    return legacyBitmapConfigToColorType(c);
}

SkCanvas* GraphicsJNI::getNativeCanvas(JNIEnv* env, jobject canvas) {
android::Canvas* GraphicsJNI::getNativeCanvas(JNIEnv* env, jobject canvas) {
    SkASSERT(env);
    SkASSERT(canvas);
    SkASSERT(env->IsInstanceOf(canvas, gCanvas_class));
@@ -381,9 +381,7 @@ SkCanvas* GraphicsJNI::getNativeCanvas(JNIEnv* env, jobject canvas) {
    if (!canvasHandle) {
        return NULL;
    }
    SkCanvas* c = reinterpret_cast<android::Canvas*>(canvasHandle)->asSkCanvas();
    SkASSERT(c);
    return c;
    return reinterpret_cast<android::Canvas*>(canvasHandle);
}

SkRegion* GraphicsJNI::getNativeRegion(JNIEnv* env, jobject region)
+2 −1
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
#include "SkPoint.h"
#include "SkRect.h"
#include "SkImageDecoder.h"
#include <Canvas.h>
#include <jni.h>

class SkBitmapRegionDecoder;
@@ -47,7 +48,7 @@ public:
    static SkPoint* jpointf_to_point(JNIEnv*, jobject jpointf, SkPoint* point);
    static void point_to_jpointf(const SkPoint& point, JNIEnv*, jobject jpointf);

    static SkCanvas* getNativeCanvas(JNIEnv*, jobject canvas);
    static android::Canvas* getNativeCanvas(JNIEnv*, jobject canvas);
    static SkBitmap* getSkBitmapDeprecated(JNIEnv*, jobject bitmap);
    static void getSkBitmap(JNIEnv*, jobject bitmap, SkBitmap* outBitmap);
    static SkPixelRef* getSkPixelRef(JNIEnv*, jobject bitmap);
+5 −4
Original line number Diff line number Diff line
@@ -80,11 +80,12 @@ static jlong Shader_setLocalMatrix(JNIEnv* env, jobject o, jlong shaderHandle, j

///////////////////////////////////////////////////////////////////////////////////////////////

static jlong BitmapShader_constructor(JNIEnv* env, jobject o, jlong bitmapHandle,
static jlong BitmapShader_constructor(JNIEnv* env, jobject o, jobject jbitmap,
                                      jint tileModeX, jint tileModeY)
{
    const SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
    SkShader* s = SkShader::CreateBitmapShader(*bitmap,
    SkBitmap bitmap;
    GraphicsJNI::getSkBitmap(env, jbitmap, &bitmap);
    SkShader* s = SkShader::CreateBitmapShader(bitmap,
                                        (SkShader::TileMode)tileModeX,
                                        (SkShader::TileMode)tileModeY);

@@ -249,7 +250,7 @@ static JNINativeMethod gShaderMethods[] = {
};

static JNINativeMethod gBitmapShaderMethods[] = {
    { "nativeCreate",     "(JII)J",  (void*)BitmapShader_constructor },
    { "nativeCreate",     "(Landroid/graphics/Bitmap;II)J",  (void*)BitmapShader_constructor },
};

static JNINativeMethod gLinearGradientMethods[] = {
+13 −8
Original line number Diff line number Diff line
@@ -39,17 +39,22 @@ static void finalizer(JNIEnv* env, jobject clazz, jlong canvasHandle) {
}

// Native wrapper constructor used by Canvas(Bitmap)
static jlong initRaster(JNIEnv* env, jobject, jlong bitmapHandle) {
    SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
static jlong initRaster(JNIEnv* env, jobject, jobject jbitmap) {
    SkBitmap bitmap;
    if (jbitmap != NULL) {
        GraphicsJNI::getSkBitmap(env, jbitmap, &bitmap);
    }
    return reinterpret_cast<jlong>(Canvas::create_canvas(bitmap));
}

// Set the given bitmap as the new draw target (wrapped in a new SkCanvas),
// optionally copying canvas matrix & clip state.
static void setBitmap(JNIEnv* env, jobject, jlong canvasHandle, jlong bitmapHandle,
                      jboolean copyState) {
    SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
    get_canvas(canvasHandle)->setBitmap(bitmap, copyState);
static void setBitmap(JNIEnv* env, jobject, jlong canvasHandle, jobject jbitmap) {
    SkBitmap bitmap;
    if (jbitmap != NULL) {
        GraphicsJNI::getSkBitmap(env, jbitmap, &bitmap);
    }
    get_canvas(canvasHandle)->setBitmap(bitmap);
}

static jboolean isOpaque(JNIEnv*, jobject, jlong canvasHandle) {
@@ -658,8 +663,8 @@ static void freeTextLayoutCaches(JNIEnv* env, jobject) {

static JNINativeMethod gMethods[] = {
    {"finalizer", "(J)V", (void*) CanvasJNI::finalizer},
    {"initRaster", "(J)J", (void*) CanvasJNI::initRaster},
    {"native_setBitmap", "(JJZ)V", (void*) CanvasJNI::setBitmap},
    {"initRaster", "(Landroid/graphics/Bitmap;)J", (void*) CanvasJNI::initRaster},
    {"native_setBitmap", "(JLandroid/graphics/Bitmap;)V", (void*) CanvasJNI::setBitmap},
    {"native_isOpaque","(J)Z", (void*) CanvasJNI::isOpaque},
    {"native_getWidth","(J)I", (void*) CanvasJNI::getWidth},
    {"native_getHeight","(J)I", (void*) CanvasJNI::getHeight},
Loading