Loading core/java/android/view/HardwareLayer.java +3 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.view; import android.annotation.Nullable; import android.graphics.Bitmap; import android.graphics.Matrix; import android.graphics.Paint; Loading Loading @@ -51,8 +52,8 @@ final class HardwareLayer { * @param paint The paint used when the layer is drawn into the destination canvas. * @see View#setLayerPaint(android.graphics.Paint) */ public void setLayerPaint(Paint paint) { nSetLayerPaint(mFinalizer.get(), paint.getNativeInstance()); public void setLayerPaint(@Nullable Paint paint) { nSetLayerPaint(mFinalizer.get(), paint != null ? paint.getNativeInstance() : 0); mRenderer.pushLayerUpdate(this); } Loading core/java/android/view/RenderNode.java +1 −1 Original line number Diff line number Diff line Loading @@ -259,7 +259,7 @@ public class RenderNode { return nSetLayerType(mNativeRenderNode, layerType); } public boolean setLayerPaint(Paint paint) { public boolean setLayerPaint(@Nullable Paint paint) { return nSetLayerPaint(mNativeRenderNode, paint != null ? paint.getNativeInstance() : 0); } Loading core/java/android/view/TextureView.java +9 −16 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.view; import android.annotation.Nullable; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; Loading Loading @@ -133,7 +134,6 @@ public class TextureView extends View { */ public TextureView(Context context) { super(context); init(); } /** Loading @@ -144,7 +144,6 @@ public class TextureView extends View { */ public TextureView(Context context, AttributeSet attrs) { super(context, attrs); init(); } /** Loading @@ -158,7 +157,6 @@ public class TextureView extends View { */ public TextureView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } /** Loading @@ -176,11 +174,6 @@ public class TextureView extends View { */ public TextureView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); init(); } private void init() { mLayerPaint = new Paint(); } /** Loading Loading @@ -260,7 +253,7 @@ public class TextureView extends View { * method will however be taken into account when rendering the content of * this TextureView. * * @param layerType The ype of layer to use with this view, must be one of * @param layerType The type of layer to use with this view, must be one of * {@link #LAYER_TYPE_NONE}, {@link #LAYER_TYPE_SOFTWARE} or * {@link #LAYER_TYPE_HARDWARE} * @param paint The paint used to compose the layer. This argument is optional Loading @@ -268,16 +261,16 @@ public class TextureView extends View { * {@link #LAYER_TYPE_NONE} */ @Override public void setLayerType(int layerType, Paint paint) { if (paint != mLayerPaint) { mLayerPaint = paint == null ? new Paint() : paint; invalidate(); } public void setLayerType(int layerType, @Nullable Paint paint) { setLayerPaint(paint); } @Override public void setLayerPaint(Paint paint) { setLayerType(/* ignored */ 0, paint); public void setLayerPaint(@Nullable Paint paint) { if (paint != mLayerPaint) { mLayerPaint = paint; invalidate(); } } /** Loading core/java/android/view/View.java +7 −8 Original line number Diff line number Diff line Loading @@ -15626,7 +15626,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * * @attr ref android.R.styleable#View_layerType */ public void setLayerType(int layerType, Paint paint) { public void setLayerType(int layerType, @Nullable Paint paint) { if (layerType < LAYER_TYPE_NONE || layerType > LAYER_TYPE_HARDWARE) { throw new IllegalArgumentException("Layer type can only be one of: LAYER_TYPE_NONE, " + "LAYER_TYPE_SOFTWARE or LAYER_TYPE_HARDWARE"); Loading @@ -15645,8 +15645,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } mLayerType = layerType; final boolean layerDisabled = (mLayerType == LAYER_TYPE_NONE); mLayerPaint = layerDisabled ? null : (paint == null ? new Paint() : paint); mLayerPaint = mLayerType == LAYER_TYPE_NONE ? null : paint; mRenderNode.setLayerPaint(mLayerPaint); // draw() behaves differently if we are on a layer, so we need to Loading Loading @@ -15680,12 +15679,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * * @see #setLayerType(int, android.graphics.Paint) */ public void setLayerPaint(Paint paint) { public void setLayerPaint(@Nullable Paint paint) { int layerType = getLayerType(); if (layerType != LAYER_TYPE_NONE) { mLayerPaint = paint == null ? new Paint() : paint; mLayerPaint = paint; if (layerType == LAYER_TYPE_HARDWARE) { if (mRenderNode.setLayerPaint(mLayerPaint)) { if (mRenderNode.setLayerPaint(paint)) { invalidateViewProperty(false, false); } } else { Loading Loading @@ -16855,7 +16854,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, canvas.drawBitmap(cache, 0.0f, 0.0f, cachePaint); } else { // use layer paint to draw the bitmap, merging the two alphas, but also restore int layerPaintAlpha = mLayerPaint.getAlpha(); int layerPaintAlpha = mLayerPaint != null ? mLayerPaint.getAlpha() : 255; mLayerPaint.setAlpha((int) (alpha * layerPaintAlpha)); canvas.drawBitmap(cache, 0.0f, 0.0f, mLayerPaint); mLayerPaint.setAlpha(layerPaintAlpha); Loading
core/java/android/view/HardwareLayer.java +3 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.view; import android.annotation.Nullable; import android.graphics.Bitmap; import android.graphics.Matrix; import android.graphics.Paint; Loading Loading @@ -51,8 +52,8 @@ final class HardwareLayer { * @param paint The paint used when the layer is drawn into the destination canvas. * @see View#setLayerPaint(android.graphics.Paint) */ public void setLayerPaint(Paint paint) { nSetLayerPaint(mFinalizer.get(), paint.getNativeInstance()); public void setLayerPaint(@Nullable Paint paint) { nSetLayerPaint(mFinalizer.get(), paint != null ? paint.getNativeInstance() : 0); mRenderer.pushLayerUpdate(this); } Loading
core/java/android/view/RenderNode.java +1 −1 Original line number Diff line number Diff line Loading @@ -259,7 +259,7 @@ public class RenderNode { return nSetLayerType(mNativeRenderNode, layerType); } public boolean setLayerPaint(Paint paint) { public boolean setLayerPaint(@Nullable Paint paint) { return nSetLayerPaint(mNativeRenderNode, paint != null ? paint.getNativeInstance() : 0); } Loading
core/java/android/view/TextureView.java +9 −16 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.view; import android.annotation.Nullable; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; Loading Loading @@ -133,7 +134,6 @@ public class TextureView extends View { */ public TextureView(Context context) { super(context); init(); } /** Loading @@ -144,7 +144,6 @@ public class TextureView extends View { */ public TextureView(Context context, AttributeSet attrs) { super(context, attrs); init(); } /** Loading @@ -158,7 +157,6 @@ public class TextureView extends View { */ public TextureView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } /** Loading @@ -176,11 +174,6 @@ public class TextureView extends View { */ public TextureView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); init(); } private void init() { mLayerPaint = new Paint(); } /** Loading Loading @@ -260,7 +253,7 @@ public class TextureView extends View { * method will however be taken into account when rendering the content of * this TextureView. * * @param layerType The ype of layer to use with this view, must be one of * @param layerType The type of layer to use with this view, must be one of * {@link #LAYER_TYPE_NONE}, {@link #LAYER_TYPE_SOFTWARE} or * {@link #LAYER_TYPE_HARDWARE} * @param paint The paint used to compose the layer. This argument is optional Loading @@ -268,16 +261,16 @@ public class TextureView extends View { * {@link #LAYER_TYPE_NONE} */ @Override public void setLayerType(int layerType, Paint paint) { if (paint != mLayerPaint) { mLayerPaint = paint == null ? new Paint() : paint; invalidate(); } public void setLayerType(int layerType, @Nullable Paint paint) { setLayerPaint(paint); } @Override public void setLayerPaint(Paint paint) { setLayerType(/* ignored */ 0, paint); public void setLayerPaint(@Nullable Paint paint) { if (paint != mLayerPaint) { mLayerPaint = paint; invalidate(); } } /** Loading
core/java/android/view/View.java +7 −8 Original line number Diff line number Diff line Loading @@ -15626,7 +15626,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * * @attr ref android.R.styleable#View_layerType */ public void setLayerType(int layerType, Paint paint) { public void setLayerType(int layerType, @Nullable Paint paint) { if (layerType < LAYER_TYPE_NONE || layerType > LAYER_TYPE_HARDWARE) { throw new IllegalArgumentException("Layer type can only be one of: LAYER_TYPE_NONE, " + "LAYER_TYPE_SOFTWARE or LAYER_TYPE_HARDWARE"); Loading @@ -15645,8 +15645,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } mLayerType = layerType; final boolean layerDisabled = (mLayerType == LAYER_TYPE_NONE); mLayerPaint = layerDisabled ? null : (paint == null ? new Paint() : paint); mLayerPaint = mLayerType == LAYER_TYPE_NONE ? null : paint; mRenderNode.setLayerPaint(mLayerPaint); // draw() behaves differently if we are on a layer, so we need to Loading Loading @@ -15680,12 +15679,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * * @see #setLayerType(int, android.graphics.Paint) */ public void setLayerPaint(Paint paint) { public void setLayerPaint(@Nullable Paint paint) { int layerType = getLayerType(); if (layerType != LAYER_TYPE_NONE) { mLayerPaint = paint == null ? new Paint() : paint; mLayerPaint = paint; if (layerType == LAYER_TYPE_HARDWARE) { if (mRenderNode.setLayerPaint(mLayerPaint)) { if (mRenderNode.setLayerPaint(paint)) { invalidateViewProperty(false, false); } } else { Loading Loading @@ -16855,7 +16854,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, canvas.drawBitmap(cache, 0.0f, 0.0f, cachePaint); } else { // use layer paint to draw the bitmap, merging the two alphas, but also restore int layerPaintAlpha = mLayerPaint.getAlpha(); int layerPaintAlpha = mLayerPaint != null ? mLayerPaint.getAlpha() : 255; mLayerPaint.setAlpha((int) (alpha * layerPaintAlpha)); canvas.drawBitmap(cache, 0.0f, 0.0f, mLayerPaint); mLayerPaint.setAlpha(layerPaintAlpha);