diff options
Diffstat (limited to 'tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java')
-rw-r--r-- | tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java index 368c0384..c6dd54b 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Shader_Delegate.java @@ -76,13 +76,38 @@ public abstract class Shader_Delegate { // ---- native methods ---- @LayoutlibDelegate - /*package*/ static void nativeDestructor(int native_shader, int native_skiaShader) { + /*package*/ static void nativeDestructor(int native_shader) { sManager.removeJavaReferenceFor(native_shader); } @LayoutlibDelegate - /*package*/ static void nativeSetLocalMatrix(int native_shader, int native_skiaShader, - int matrix_instance) { + /*package*/ static boolean nativeGetLocalMatrix(int native_shader, int matrix_instance) { + // get the delegate from the native int. + Shader_Delegate shaderDelegate = sManager.getDelegate(native_shader); + if (shaderDelegate == null) { + return false; + } + + // get the (optional) out matrix. + Matrix_Delegate outMatrixDelegate = Matrix_Delegate.getDelegate(matrix_instance); + + if (shaderDelegate.mLocalMatrix == null || shaderDelegate.mLocalMatrix.isIdentity()) { + if (outMatrixDelegate != null) { + outMatrixDelegate.reset(); + } + return false; + } + + if (outMatrixDelegate != null) { + outMatrixDelegate.set(shaderDelegate.mLocalMatrix); + } + + return true; + } + + + @LayoutlibDelegate + /*package*/ static void nativeSetLocalMatrix(int native_shader, int matrix_instance) { // get the delegate from the native int. Shader_Delegate shaderDelegate = sManager.getDelegate(native_shader); if (shaderDelegate == null) { |