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

Commit 73c2a11b authored by Leon Scroggins III's avatar Leon Scroggins III Committed by Android Git Automerger
Browse files

am 3b88245f: Make updateLocalMatrix replace the current Matrix.

* commit '3b88245f5eec3b71cd7ede2502d87a02f34f0868':
  Make updateLocalMatrix replace the current Matrix.
parents c32d0a1c 866cf65c
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -50,15 +50,20 @@ static jint Color_HSVToColor(JNIEnv* env, jobject, jint alpha, jfloatArray hsvAr

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

static void Shader_destructor(JNIEnv* env, jobject o, jlong shaderHandle)
static void Shader_destructor(JNIEnv* env, jobject o, jlong shaderHandle, jlong shaderWithLMHandle)
{
    SkShader* shader = reinterpret_cast<SkShader*>(shaderHandle);
    SkSafeUnref(shader);
    SkShader* shaderWithLM = reinterpret_cast<SkShader*>(shaderWithLMHandle);
    SkSafeUnref(shaderWithLM);
}

static jlong Shader_setLocalMatrix(JNIEnv* env, jobject o, jlong shaderHandle,
        jlong matrixHandle)
        jlong oldLocalMatrixShaderHandle, jlong matrixHandle)
{
    // The old shader with local matrix is no longer needed, so unref it.
    SkSafeUnref(reinterpret_cast<SkShader*>(oldLocalMatrixShaderHandle));

    SkShader* shader       = reinterpret_cast<SkShader*>(shaderHandle);
    const SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
    if (shader) {
@@ -66,7 +71,6 @@ static jlong Shader_setLocalMatrix(JNIEnv* env, jobject o, jlong shaderHandle,
            matrix = &SkMatrix::I();
        }
        SkShader* newShader = SkShader::CreateLocalMatrixShader(shader, *matrix);
        shader->unref();
        shader = newShader;
    }
    return reinterpret_cast<jlong>(shader);
@@ -239,8 +243,8 @@ static JNINativeMethod gColorMethods[] = {
};

static JNINativeMethod gShaderMethods[] = {
    { "nativeDestructor",        "(J)V",    (void*)Shader_destructor        },
    { "nativeSetLocalMatrix",    "(JJ)J",   (void*)Shader_setLocalMatrix    }
    { "nativeDestructor",        "(JJ)V",    (void*)Shader_destructor        },
    { "nativeSetLocalMatrix",    "(JJJ)J",   (void*)Shader_setLocalMatrix    }
};

static JNINativeMethod gBitmapShaderMethods[] = {
+1 −1
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ public class BitmapShader extends Shader {
        mTileX = tileX;
        mTileY = tileY;
        final long b = bitmap.ni();
        native_instance = nativeCreate(b, tileX.nativeInt, tileY.nativeInt);
        init(nativeCreate(b, tileX.nativeInt, tileY.nativeInt));
    }

    /**
+4 −4
Original line number Diff line number Diff line
@@ -53,8 +53,8 @@ public class ComposeShader extends Shader {
        mShaderA = shaderA;
        mShaderB = shaderB;
        mXferMode = mode;
        native_instance = nativeCreate1(shaderA.native_instance, shaderB.native_instance,
                (mode != null) ? mode.native_instance : 0);
        init(nativeCreate1(shaderA.getNativeInstance(), shaderB.getNativeInstance(),
                (mode != null) ? mode.native_instance : 0));
    }

    /** Create a new compose shader, given shaders A, B, and a combining PorterDuff mode.
@@ -69,8 +69,8 @@ public class ComposeShader extends Shader {
        mShaderA = shaderA;
        mShaderB = shaderB;
        mPorterDuffMode = mode;
        native_instance = nativeCreate2(shaderA.native_instance, shaderB.native_instance,
                mode.nativeInt);
        init(nativeCreate2(shaderA.getNativeInstance(), shaderB.getNativeInstance(),
                mode.nativeInt));
    }

    /**
+2 −2
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ public class LinearGradient extends Shader {
        mColors = colors;
        mPositions = positions;
        mTileMode = tile;
        native_instance = nativeCreate1(x0, y0, x1, y1, colors, positions, tile.nativeInt);
        init(nativeCreate1(x0, y0, x1, y1, colors, positions, tile.nativeInt));
    }

    /** Create a shader that draws a linear gradient along a line.
@@ -87,7 +87,7 @@ public class LinearGradient extends Shader {
        mColor0 = color0;
        mColor1 = color1;
        mTileMode = tile;
        native_instance = nativeCreate2(x0, y0, x1, y1, color0, color1, tile.nativeInt);
        init(nativeCreate2(x0, y0, x1, y1, color0, color1, tile.nativeInt));
    }

    /**
+1 −1
Original line number Diff line number Diff line
@@ -919,7 +919,7 @@ public class Paint {
    public Shader setShader(Shader shader) {
        long shaderNative = 0;
        if (shader != null)
            shaderNative = shader.native_instance;
            shaderNative = shader.getNativeInstance();
        native_setShader(mNativePaint, shaderNative);
        mShader = shader;
        return shader;
Loading