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

Commit a30e7e0b authored by Romain Guy's avatar Romain Guy Committed by Android (Google) Code Review
Browse files

Merge "Prevent memory leak with ComposeShader."

parents d07fb882 de0547c0
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -20,6 +20,9 @@ package android.graphics;
    an {@link android.graphics.Xfermode} subclass.
*/
public class ComposeShader extends Shader {
    private final Shader mShaderA;
    private final Shader mShaderB;

    /** Create a new compose shader, given shaders A, B, and a combining mode.
        When the mode is applied, it will be given the result from shader A as its
        "dst", and the result of from shader B as its "src".
@@ -29,6 +32,8 @@ public class ComposeShader extends Shader {
                        is null, then SRC_OVER is assumed.
    */
    public ComposeShader(Shader shaderA, Shader shaderB, Xfermode mode) {
        mShaderA = shaderA;
        mShaderB = shaderB;
        native_instance = nativeCreate1(shaderA.native_instance, shaderB.native_instance,
                (mode != null) ? mode.native_instance : 0);
        native_shader = nativePostCreate1(native_instance, shaderA.native_shader,
@@ -43,6 +48,8 @@ public class ComposeShader extends Shader {
        @param mode     The PorterDuff mode that combines the colors from the two shaders.
    */
    public ComposeShader(Shader shaderA, Shader shaderB, PorterDuff.Mode mode) {
        mShaderA = shaderA;
        mShaderB = shaderB;
        native_instance = nativeCreate2(shaderA.native_instance, shaderB.native_instance,
                mode.nativeInt);
        native_shader = nativePostCreate2(native_instance, shaderA.native_shader,