Revert immutable Shader change

 Bug: 16733996

Change-Id: I51686aaf8f6ae8d0e390e298ad70f98f81c5f555
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 @@
 {
     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 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 @@
      */
     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 @@
      * 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 @@
     }
 
     /* 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);
 }