Merge "Added View#setRenderEffect API"

This commit is contained in:
Nader Jawad
2020-12-15 18:37:04 +00:00
committed by Android (Google) Code Review
4 changed files with 23 additions and 5 deletions

View File

@@ -15731,7 +15731,7 @@ package android.graphics {
method public boolean setPosition(@NonNull android.graphics.Rect);
method public boolean setProjectBackwards(boolean);
method public boolean setProjectionReceiver(boolean);
method public void setRenderEffect(@Nullable android.graphics.RenderEffect);
method public boolean setRenderEffect(@Nullable android.graphics.RenderEffect);
method public boolean setRotationX(float);
method public boolean setRotationY(float);
method public boolean setRotationZ(float);
@@ -48451,6 +48451,7 @@ package android.view {
method public void setPivotY(float);
method public void setPointerIcon(android.view.PointerIcon);
method public void setPressed(boolean);
method public void setRenderEffect(@Nullable android.graphics.RenderEffect);
method public final void setRevealOnFocusHint(boolean);
method public final void setRight(int);
method public void setRotation(float);

View File

@@ -73,6 +73,7 @@ import android.graphics.RecordingCanvas;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Region;
import android.graphics.RenderEffect;
import android.graphics.RenderNode;
import android.graphics.Shader;
import android.graphics.drawable.ColorDrawable;
@@ -21064,6 +21065,21 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
invalidate(true);
}
/**
* Configure the {@link android.graphics.RenderEffect} to apply to this View.
* This will apply a visual effect to the results of the View before it is drawn. For example if
* {@link RenderEffect#createBlurEffect(float, float, RenderEffect, Shader.TileMode)}
* is provided, the contents will be drawn in a separate layer, then this layer will be blurred
* when this View is drawn.
* @param renderEffect to be applied to the View. Passing null clears the previously configured
* {@link RenderEffect}
*/
public void setRenderEffect(@Nullable RenderEffect renderEffect) {
if (mRenderNode.setRenderEffect(renderEffect)) {
invalidateViewProperty(true, true);
}
}
/**
* Updates the {@link Paint} object used with the current layer (used only if the current
* layer type is not set to {@link #LAYER_TYPE_NONE}). Changed properties of the Paint

View File

@@ -858,9 +858,10 @@ public final class RenderNode {
* be blurred when this RenderNode is drawn into the destination.
* @param renderEffect to be applied to the RenderNode. Passing null clears all previously
* configured RenderEffects
* @return True if the value changed, false if the new value was the same as the previous value.
*/
public void setRenderEffect(@Nullable RenderEffect renderEffect) {
nSetRenderEffect(mNativeRenderNode,
public boolean setRenderEffect(@Nullable RenderEffect renderEffect) {
return nSetRenderEffect(mNativeRenderNode,
renderEffect != null ? renderEffect.getNativeInstance() : 0);
}
@@ -1670,7 +1671,7 @@ public final class RenderNode {
private static native boolean nSetAlpha(long renderNode, float alpha);
@CriticalNative
private static native void nSetRenderEffect(long renderNode, long renderEffect);
private static native boolean nSetRenderEffect(long renderNode, long renderEffect);
@CriticalNative
private static native boolean nSetHasOverlappingRendering(long renderNode,

View File

@@ -696,7 +696,7 @@ static const JNINativeMethod gMethods[] = {
{ "nSetRevealClip", "(JZFFF)Z", (void*) android_view_RenderNode_setRevealClip },
{ "nSetAlpha", "(JF)Z", (void*) android_view_RenderNode_setAlpha },
{ "nSetRenderEffect", "(JJ)V", (void*) android_view_RenderNode_setRenderEffect },
{ "nSetRenderEffect", "(JJ)Z", (void*) android_view_RenderNode_setRenderEffect },
{ "nSetHasOverlappingRendering", "(JZ)Z",
(void*) android_view_RenderNode_setHasOverlappingRendering },
{ "nSetUsageHint", "(JI)V", (void*) android_view_RenderNode_setUsageHint },