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

Commit f2c351ab authored by John Reck's avatar John Reck Committed by Android (Google) Code Review
Browse files

Merge "Make RenderNode public API"

parents fe0efe6b ddeaa487
Loading
Loading
Loading
Loading
+77 −0
Original line number Diff line number Diff line
@@ -13434,6 +13434,7 @@ package android.graphics {
    method public boolean clipRect(float, float, float, float);
    method public boolean clipRect(int, int, int, int);
    method public void concat(android.graphics.Matrix);
    method public void disableZ();
    method public void drawARGB(int, int, int, int);
    method public void drawArc(android.graphics.RectF, float, float, boolean, android.graphics.Paint);
    method public void drawArc(float, float, float, float, float, float, boolean, android.graphics.Paint);
@@ -13468,6 +13469,7 @@ package android.graphics {
    method public void drawRect(android.graphics.RectF, android.graphics.Paint);
    method public void drawRect(android.graphics.Rect, android.graphics.Paint);
    method public void drawRect(float, float, float, float, android.graphics.Paint);
    method public void drawRenderNode(android.graphics.RenderNode);
    method public void drawRoundRect(android.graphics.RectF, float, float, android.graphics.Paint);
    method public void drawRoundRect(float, float, float, float, float, float, android.graphics.Paint);
    method public void drawText(char[], int, int, float, float, android.graphics.Paint);
@@ -13479,6 +13481,7 @@ package android.graphics {
    method public void drawTextRun(char[], int, int, int, int, float, float, boolean, android.graphics.Paint);
    method public void drawTextRun(java.lang.CharSequence, int, int, int, int, float, float, boolean, android.graphics.Paint);
    method public void drawVertices(android.graphics.Canvas.VertexMode, int, float[], int, float[], int, int[], int, short[], int, int, android.graphics.Paint);
    method public void enableZ();
    method public boolean getClipBounds(android.graphics.Rect);
    method public final android.graphics.Rect getClipBounds();
    method public int getDensity();
@@ -14468,6 +14471,9 @@ package android.graphics {
    ctor public RadialGradient(float, float, float, int, int, android.graphics.Shader.TileMode);
  }
  public final class RecordingCanvas extends android.graphics.Canvas {
  }
  public final class Rect implements android.os.Parcelable {
    ctor public Rect();
    ctor public Rect(int, int, int, int);
@@ -14604,6 +14610,77 @@ package android.graphics {
    method public final boolean next(android.graphics.Rect);
  }
  public class RenderNode {
    method public int computeApproximateMemoryUsage();
    method public static android.graphics.RenderNode create(java.lang.String);
    method public void discardDisplayList();
    method public void endRecording();
    method public float getAlpha();
    method public int getAmbientShadowColor();
    method public int getBottom();
    method public float getCameraDistance();
    method public boolean getClipToOutline();
    method public float getElevation();
    method public int getHeight();
    method public void getInverseMatrix(android.graphics.Matrix);
    method public int getLeft();
    method public void getMatrix(android.graphics.Matrix);
    method public float getPivotX();
    method public float getPivotY();
    method public int getRight();
    method public float getRotation();
    method public float getRotationX();
    method public float getRotationY();
    method public float getScaleX();
    method public float getScaleY();
    method public int getSpotShadowColor();
    method public int getTop();
    method public float getTranslationX();
    method public float getTranslationY();
    method public float getTranslationZ();
    method public int getWidth();
    method public boolean hasDisplayList();
    method public boolean hasIdentityMatrix();
    method public boolean hasOverlappingRendering();
    method public boolean hasShadow();
    method public boolean isForceDarkAllowed();
    method public boolean isPivotExplicitlySet();
    method public boolean offsetLeftAndRight(int);
    method public boolean offsetTopAndBottom(int);
    method public boolean resetPivot();
    method public boolean setAlpha(float);
    method public boolean setAmbientShadowColor(int);
    method public boolean setBottom(int);
    method public boolean setCameraDistance(float);
    method public boolean setClipBounds(android.graphics.Rect);
    method public boolean setClipToBounds(boolean);
    method public boolean setClipToOutline(boolean);
    method public boolean setElevation(float);
    method public boolean setForceDarkAllowed(boolean);
    method public boolean setHasOverlappingRendering(boolean);
    method public boolean setLeft(int);
    method public boolean setLeftTopRightBottom(int, int, int, int);
    method public boolean setOutline(android.graphics.Outline);
    method public boolean setPivotX(float);
    method public boolean setPivotY(float);
    method public boolean setProjectBackwards(boolean);
    method public boolean setProjectionReceiver(boolean);
    method public boolean setRight(int);
    method public boolean setRotation(float);
    method public boolean setRotationX(float);
    method public boolean setRotationY(float);
    method public boolean setScaleX(float);
    method public boolean setScaleY(float);
    method public boolean setSpotShadowColor(int);
    method public boolean setTop(int);
    method public boolean setTranslationX(float);
    method public boolean setTranslationY(float);
    method public boolean setTranslationZ(float);
    method public boolean setUseCompositingLayer(boolean, android.graphics.Paint);
    method public android.graphics.RecordingCanvas startRecording(int, int);
    method public android.graphics.RecordingCanvas startRecording();
  }
  public class Shader {
    ctor public deprecated Shader();
    method public boolean getLocalMatrix(android.graphics.Matrix);
+2 −2
Original line number Diff line number Diff line
@@ -14730,7 +14730,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
    public float getCameraDistance() {
        final float dpi = mResources.getDisplayMetrics().densityDpi;
        return -(mRenderNode.getCameraDistance() * dpi);
        return mRenderNode.getCameraDistance() * dpi;
    }
    /**
@@ -14776,7 +14776,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        final float dpi = mResources.getDisplayMetrics().densityDpi;
        invalidateViewProperty(true, false);
        mRenderNode.setCameraDistance(-Math.abs(distance) / dpi);
        mRenderNode.setCameraDistance(Math.abs(distance) / dpi);
        invalidateViewProperty(false, false);
        invalidateParentIfNeededAndWasQuickRejected();
+1 −1
Original line number Diff line number Diff line
@@ -6877,7 +6877,7 @@ public final class ViewRootImpl implements ViewParent,
        RenderNode renderNode = view.mRenderNode;
        info[0]++;
        if (renderNode != null) {
            info[1] += renderNode.getDebugSize();
            info[1] += renderNode.computeApproximateMemoryUsage();
        }

        if (view instanceof ViewGroup) {
+20 −0
Original line number Diff line number Diff line
@@ -295,6 +295,22 @@ static jboolean android_view_RenderNode_setBottom(jlong renderNodePtr, int botto
    return SET_AND_DIRTY(setBottom, bottom, RenderNode::Y);
}

static jint android_view_RenderNode_getLeft(jlong renderNodePtr) {
    return reinterpret_cast<RenderNode*>(renderNodePtr)->stagingProperties().getLeft();
}

static jint android_view_RenderNode_getTop(jlong renderNodePtr) {
    return reinterpret_cast<RenderNode*>(renderNodePtr)->stagingProperties().getTop();
}

static jint android_view_RenderNode_getRight(jlong renderNodePtr) {
    return reinterpret_cast<RenderNode*>(renderNodePtr)->stagingProperties().getRight();
}

static jint android_view_RenderNode_getBottom(jlong renderNodePtr) {
    return reinterpret_cast<RenderNode*>(renderNodePtr)->stagingProperties().getBottom();
}

static jboolean android_view_RenderNode_setLeftTopRightBottom(jlong renderNodePtr,
        int left, int top, int right, int bottom) {
    RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr);
@@ -645,6 +661,10 @@ static const JNINativeMethod gMethods[] = {
    { "nSetTop",               "(JI)Z",  (void*) android_view_RenderNode_setTop },
    { "nSetRight",             "(JI)Z",  (void*) android_view_RenderNode_setRight },
    { "nSetBottom",            "(JI)Z",  (void*) android_view_RenderNode_setBottom },
    { "nGetLeft",              "(J)I",  (void*) android_view_RenderNode_getLeft },
    { "nGetTop",               "(J)I",  (void*) android_view_RenderNode_getTop },
    { "nGetRight",             "(J)I",  (void*) android_view_RenderNode_getRight },
    { "nGetBottom",            "(J)I",  (void*) android_view_RenderNode_getBottom },
    { "nSetLeftTopRightBottom","(JIIII)Z", (void*) android_view_RenderNode_setLeftTopRightBottom },
    { "nOffsetLeftAndRight",   "(JI)Z",  (void*) android_view_RenderNode_offsetLeftAndRight },
    { "nOffsetTopAndBottom",   "(JI)Z",  (void*) android_view_RenderNode_offsetTopAndBottom },
+76 −4
Original line number Diff line number Diff line
@@ -205,11 +205,70 @@ public class Canvas extends BaseCanvas {
        mBitmap = bitmap;
    }

    /** @hide */
    public void insertReorderBarrier() {}
    /**
     * @deprecated use {@link #enableZ()} instead
     * @hide */
    @Deprecated
    public void insertReorderBarrier() {
        enableZ();
    }

    /** @hide */
    public void insertInorderBarrier() {}
    /**
     * @deprecated use {@link #disableZ()} instead
     * @hide */
    @Deprecated
    public void insertInorderBarrier() {
        disableZ();
    }

    /**
     * <p>Enables Z support which defaults to disabled. This allows for RenderNodes drawn with
     * {@link #drawRenderNode(RenderNode)} to be re-arranged based off of their
     * {@link RenderNode#getElevation()} and {@link RenderNode#getTranslationZ()}
     * values. It also enables rendering of shadows for RenderNodes with an elevation or
     * translationZ.</p>
     *
     * <p>Any draw reordering will not be moved before this call. A typical usage of this might
     * look something like:
     *
     * <pre class="prettyprint">
     *     void draw(Canvas canvas) {
     *         // Draw any background content
     *         canvas.drawColor(backgroundColor);
     *
     *         // Begin drawing that may be reordered based off of Z
     *         canvas.enableZ();
     *         for (RenderNode child : children) {
     *             canvas.drawRenderNode(child);
     *         }
     *         // End drawing that may be reordered based off of Z
     *         canvas.disableZ();
     *
     *         // Draw any overlays
     *         canvas.drawText("I'm on top of everything!", 0, 0, paint);
     *     }
     * </pre>
     * </p>
     *
     * Note: This is not impacted by any {@link #save()} or {@link #restore()} calls as it is not
     * considered to be part of the current matrix or clip.
     *
     * See {@link #disableZ()}
     */
    public void enableZ() {
    }

    /**
     * Disables Z support, preventing any RenderNodes drawn after this point from being
     * visually reordered or having shadows rendered.
     *
     * Note: This is not impacted by any {@link #save()} or {@link #restore()} calls as it is not
     * considered to be part of the current matrix or clip.
     *
     * See {@link #enableZ()}
     */
    public void disableZ() {
    }

    /**
     * Return true if the device that the current layer draws into is opaque
@@ -2110,4 +2169,17 @@ public class Canvas extends BaseCanvas {
        super.drawVertices(mode, vertexCount, verts, vertOffset, texs, texOffset,
                colors, colorOffset, indices, indexOffset, indexCount, paint);
    }

    /**
     * Draws the given RenderNode. This is only supported in hardware rendering, which can be
     * verified by asserting that {@link #isHardwareAccelerated()} is true. If
     * {@link #isHardwareAccelerated()} is false then this throws an exception.
     *
     * See {@link RenderNode} for more information on what a RenderNode is and how to use it.
     *
     * @param renderNode The RenderNode to draw, must be non-null.
     */
    public void drawRenderNode(@NonNull RenderNode renderNode) {
        throw new IllegalArgumentException("Software rendering doesn't support drawRenderNode");
    }
}
Loading