diff options
author | John Reck <jreck@google.com> | 2014-08-22 11:15:37 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2014-08-22 11:15:37 -0700 |
commit | 01edef10b9724fa5607d7918addc31a3b0c991dc (patch) | |
tree | 93bce27d472d1d52b5629aca1a93c1adf68bf001 | |
parent | 91d065bcbfa0223d2fc2be8f3bba70a77fcb9355 (diff) | |
download | frameworks_base-01edef10b9724fa5607d7918addc31a3b0c991dc.zip frameworks_base-01edef10b9724fa5607d7918addc31a3b0c991dc.tar.gz frameworks_base-01edef10b9724fa5607d7918addc31a3b0c991dc.tar.bz2 |
Revert immutable Shader change
Bug: 16733996
Change-Id: I51686aaf8f6ae8d0e390e298ad70f98f81c5f555
-rw-r--r-- | core/jni/android/graphics/Shader.cpp | 21 | ||||
-rw-r--r-- | graphics/java/android/graphics/Shader.java | 20 |
2 files changed, 11 insertions, 30 deletions
diff --git a/core/jni/android/graphics/Shader.cpp b/core/jni/android/graphics/Shader.cpp index fbb243a..e02aa5e 100644 --- a/core/jni/android/graphics/Shader.cpp +++ b/core/jni/android/graphics/Shader.cpp @@ -54,26 +54,19 @@ static void Shader_destructor(JNIEnv* env, jobject o, jlong shaderHandle, jlong { 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 oldLocalMatrixShaderHandle, jlong matrixHandle) +static void Shader_setLocalMatrix(JNIEnv* env, jobject o, jlong shaderHandle, 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) { - if (NULL == matrix) { - matrix = &SkMatrix::I(); + if (matrix) { + shader->setLocalMatrix(*matrix); + } else { + shader->resetLocalMatrix(); } - SkShader* newShader = SkShader::CreateLocalMatrixShader(shader, *matrix); - shader = newShader; } - return reinterpret_cast<jlong>(shader); } /////////////////////////////////////////////////////////////////////////////////////////////// @@ -243,8 +236,8 @@ static JNINativeMethod gColorMethods[] = { }; static JNINativeMethod gShaderMethods[] = { - { "nativeDestructor", "(JJ)V", (void*)Shader_destructor }, - { "nativeSetLocalMatrix", "(JJJ)J", (void*)Shader_setLocalMatrix } + { "nativeDestructor", "(J)V", (void*)Shader_destructor }, + { "nativeSetLocalMatrix", "(JJ)V", (void*)Shader_setLocalMatrix } }; static JNINativeMethod gBitmapShaderMethods[] = { diff --git a/graphics/java/android/graphics/Shader.java b/graphics/java/android/graphics/Shader.java index 265a564..6934955 100644 --- a/graphics/java/android/graphics/Shader.java +++ b/graphics/java/android/graphics/Shader.java @@ -28,8 +28,6 @@ public class Shader { */ private long native_instance; - private long native_with_local_matrix; - /** * Initialization step that should be called by subclasses in their * constructors. Calling again may result in memory leaks. @@ -80,24 +78,18 @@ public class Shader { * Set the shader's local matrix. Passing null will reset the shader's * matrix to identity. * - * Starting with {@link android.os.Build.VERSION_CODES#L}, this does not - * modify any Paints which use this Shader. In order to modify the Paint, - * you need to call {@link Paint#setShader} again. Further, any {@link ComposeShader}s - * created with this Shader will be unaffected. - * * @param localM The shader's new local matrix, or null to specify identity */ public void setLocalMatrix(Matrix localM) { mLocalMatrix = localM; - native_with_local_matrix = nativeSetLocalMatrix(native_instance, - native_with_local_matrix, localM == null ? 0 : localM.native_instance); + nativeSetLocalMatrix(native_instance, localM == null ? 0 : localM.native_instance); } protected void finalize() throws Throwable { try { super.finalize(); } finally { - nativeDestructor(native_instance, native_with_local_matrix); + nativeDestructor(native_instance); } } @@ -124,13 +116,9 @@ public class Shader { } /* package */ long getNativeInstance() { - if (native_with_local_matrix != 0) { - return native_with_local_matrix; - } return native_instance; } - private static native void nativeDestructor(long native_shader, long native_with_local_matrix); - private static native long nativeSetLocalMatrix(long native_shader, - long native_with_local_matrix, long matrix_instance); + private static native void nativeDestructor(long native_shader); + private static native void nativeSetLocalMatrix(long native_shader, long matrix_instance); } |