diff options
author | Romain Guy <romainguy@google.com> | 2011-01-04 15:02:59 -0800 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2011-01-04 15:02:59 -0800 |
commit | a9ebfa6bcce62d7fee69693fe3dee6027afd3f0e (patch) | |
tree | 08937fdff6c33566fe39295e5bf91c22c7f926a5 | |
parent | 068a73555a3ed79710fb511c7684f4d0048fc7d6 (diff) | |
download | frameworks_base-a9ebfa6bcce62d7fee69693fe3dee6027afd3f0e.zip frameworks_base-a9ebfa6bcce62d7fee69693fe3dee6027afd3f0e.tar.gz frameworks_base-a9ebfa6bcce62d7fee69693fe3dee6027afd3f0e.tar.bz2 |
Keep a reference to the local matrix.
Bug #3299324
This is needed for ADT, which does not rely on Skia's reference counting
to correctly keep track of the native objects.
Change-Id: Ia2fc5c1ec2b80bad226bc549fefc6bb064784609
-rw-r--r-- | core/jni/android/graphics/Shader.cpp | 6 | ||||
-rw-r--r-- | graphics/java/android/graphics/Shader.java | 11 |
2 files changed, 8 insertions, 9 deletions
diff --git a/core/jni/android/graphics/Shader.cpp b/core/jni/android/graphics/Shader.cpp index 4be1321..3efc41d 100644 --- a/core/jni/android/graphics/Shader.cpp +++ b/core/jni/android/graphics/Shader.cpp @@ -64,11 +64,6 @@ static void Shader_destructor(JNIEnv* env, jobject o, SkShader* shader, SkiaShad #endif } -static bool Shader_getLocalMatrix(JNIEnv* env, jobject, const SkShader* shader, SkMatrix* matrix) -{ - return shader ? shader->getLocalMatrix(matrix) : false; -} - static void Shader_setLocalMatrix(JNIEnv* env, jobject o, SkShader* shader, SkiaShader* skiaShader, const SkMatrix* matrix) { @@ -471,7 +466,6 @@ static JNINativeMethod gColorMethods[] = { static JNINativeMethod gShaderMethods[] = { { "nativeDestructor", "(II)V", (void*)Shader_destructor }, - { "nativeGetLocalMatrix", "(II)Z", (void*)Shader_getLocalMatrix }, { "nativeSetLocalMatrix", "(III)V", (void*)Shader_setLocalMatrix } }; diff --git a/graphics/java/android/graphics/Shader.java b/graphics/java/android/graphics/Shader.java index 0400b5c..3acf1ea 100644 --- a/graphics/java/android/graphics/Shader.java +++ b/graphics/java/android/graphics/Shader.java @@ -34,6 +34,8 @@ public class Shader { */ public int native_shader; + private Matrix mLocalMatrix; + public enum TileMode { /** * replicate the edge color if the shader draws outside of its @@ -62,7 +64,11 @@ public class Shader { * @return true if the shader has a non-identity local matrix */ public boolean getLocalMatrix(Matrix localM) { - return nativeGetLocalMatrix(native_instance, localM.native_instance); + if (mLocalMatrix != null) { + localM.set(mLocalMatrix); + return true; + } + return false; } /** @@ -71,6 +77,7 @@ public class Shader { * @param localM The shader's new local matrix, or null to specify identity */ public void setLocalMatrix(Matrix localM) { + mLocalMatrix = localM; nativeSetLocalMatrix(native_instance, native_shader, localM == null ? 0 : localM.native_instance); } @@ -84,8 +91,6 @@ public class Shader { } private static native void nativeDestructor(int native_shader, int native_skiaShader); - private static native boolean nativeGetLocalMatrix(int native_shader, - int matrix_instance); private static native void nativeSetLocalMatrix(int native_shader, int native_skiaShader, int matrix_instance); } |