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

Commit f1ae1064 authored by Romain Guy's avatar Romain Guy
Browse files

Add an API to force Views to render their layer.

Change-Id: Id5776f3b0880fdf75835f16560a1d03a3175d139
parent 84962f2f
Loading
Loading
Loading
Loading
+12 −1
Original line number Original line Diff line number Diff line
@@ -220707,6 +220707,17 @@
<parameter name="autoScale" type="boolean">
<parameter name="autoScale" type="boolean">
</parameter>
</parameter>
</method>
</method>
<method name="buildLayer"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="cancelLongPress"
<method name="cancelLongPress"
 return="void"
 return="void"
 abstract="false"
 abstract="false"
@@ -266669,7 +266680,7 @@
 deprecated="not deprecated"
 deprecated="not deprecated"
 visibility="public"
 visibility="public"
>
>
<parameter name="t" type="T">
<parameter name="arg0" type="T">
</parameter>
</parameter>
</method>
</method>
</interface>
</interface>
+31 −0
Original line number Original line Diff line number Diff line
@@ -8488,6 +8488,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
     *         {@link #LAYER_TYPE_HARDWARE}
     *         {@link #LAYER_TYPE_HARDWARE}
     *
     *
     * @see #setLayerType(int, android.graphics.Paint)
     * @see #setLayerType(int, android.graphics.Paint)
     * @see #buildLayer() 
     * @see #LAYER_TYPE_NONE
     * @see #LAYER_TYPE_NONE
     * @see #LAYER_TYPE_SOFTWARE
     * @see #LAYER_TYPE_SOFTWARE
     * @see #LAYER_TYPE_HARDWARE
     * @see #LAYER_TYPE_HARDWARE
@@ -8496,6 +8497,36 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
        return mLayerType;
        return mLayerType;
    }
    }


    /**
     * Forces this view's layer to be created and this view to be rendered
     * into its layer. If this view's layer type is set to {@link #LAYER_TYPE_NONE},
     * invoking this method will have no effect.
     * 
     * This method can for instance be used to render a view into its layer before
     * starting an animation. If this view is complex, rendering into the layer
     * before starting the animation will avoid skipping frames.
     * 
     * @throws IllegalStateException If this view is not attached to a window
     * 
     * @see #setLayerType(int, android.graphics.Paint) 
     */
    public void buildLayer() {
        if (mLayerType == LAYER_TYPE_NONE) return;

        if (mAttachInfo == null) {
            throw new IllegalStateException("This view must be attached to a window first");
        }

        switch (mLayerType) {
            case LAYER_TYPE_HARDWARE:
                getHardwareLayer();
                break;
            case LAYER_TYPE_SOFTWARE:
                buildDrawingCache(true);
                break;
        }
    }

    /**
    /**
     * <p>Returns a hardware layer that can be used to draw this view again
     * <p>Returns a hardware layer that can be used to draw this view again
     * without executing its draw method.</p>
     * without executing its draw method.</p>