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

Commit 470a9191 authored by John Reck's avatar John Reck
Browse files

Add missing getter & improve docs

Also fix SkiaDisplayList::getUsedSize()

Bug: 120865963
Test: atest android.uirendering.cts.testclasses.RenderNodeTests
Change-Id: I3cdbd8d330da9a00367199087c9ae1e0a2cacf46
parent 832c1733
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -14753,6 +14753,7 @@ package android.graphics {
    method public int getAmbientShadowColor();
    method public int getBottom();
    method public float getCameraDistance();
    method public boolean getClipToBounds();
    method public boolean getClipToOutline();
    method public float getElevation();
    method public int getHeight();
@@ -14773,6 +14774,7 @@ package android.graphics {
    method public float getTranslationY();
    method public float getTranslationZ();
    method public long getUniqueId();
    method public boolean getUseCompositingLayer();
    method public int getWidth();
    method public boolean hasDisplayList();
    method public boolean hasIdentityMatrix();
+12 −0
Original line number Diff line number Diff line
@@ -338,6 +338,11 @@ static jboolean android_view_RenderNode_hasOverlappingRendering(jlong renderNode
    return renderNode->stagingProperties().hasOverlappingRendering();
}

static jboolean android_view_RenderNode_getClipToBounds(jlong renderNodePtr) {
    RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr);
    return renderNode->stagingProperties().getClipToBounds();
}

static jboolean android_view_RenderNode_getClipToOutline(jlong renderNodePtr) {
    RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr);
    return renderNode->stagingProperties().getOutline().getShouldClip();
@@ -409,6 +414,11 @@ static jboolean android_view_RenderNode_hasIdentityMatrix(jlong renderNodePtr) {
    return !renderNode->stagingProperties().hasTransformMatrix();
}

static jint android_view_RenderNode_getLayerType(jlong renderNodePtr) {
    RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr);
    return static_cast<int>(renderNode->stagingProperties().layerProperties().type());
}

// ----------------------------------------------------------------------------
// RenderProperties - computed getters
// ----------------------------------------------------------------------------
@@ -623,10 +633,12 @@ static const JNINativeMethod gMethods[] = {
// ----------------------------------------------------------------------------
    { "nIsValid",              "(J)Z",   (void*) android_view_RenderNode_isValid },
    { "nSetLayerType",         "(JI)Z",  (void*) android_view_RenderNode_setLayerType },
    { "nGetLayerType",         "(J)I",   (void*) android_view_RenderNode_getLayerType },
    { "nSetLayerPaint",        "(JJ)Z",  (void*) android_view_RenderNode_setLayerPaint },
    { "nSetStaticMatrix",      "(JJ)Z",  (void*) android_view_RenderNode_setStaticMatrix },
    { "nSetAnimationMatrix",   "(JJ)Z",  (void*) android_view_RenderNode_setAnimationMatrix },
    { "nSetClipToBounds",      "(JZ)Z",  (void*) android_view_RenderNode_setClipToBounds },
    { "nGetClipToBounds",      "(J)Z",   (void*) android_view_RenderNode_getClipToBounds },
    { "nSetClipBounds",        "(JIIII)Z", (void*) android_view_RenderNode_setClipBounds },
    { "nSetClipBoundsEmpty",   "(J)Z",   (void*) android_view_RenderNode_setClipBoundsEmpty },
    { "nSetProjectBackwards",  "(JZ)Z",  (void*) android_view_RenderNode_setProjectBackwards },
+38 −4
Original line number Diff line number Diff line
@@ -446,7 +446,21 @@ public final class RenderNode {
    }

    /**
     * Sets the clip bounds of the RenderNode.
     * Gets whether or not a compositing layer is forced to be used. The default & recommended
     * is false, as it is typically faster to avoid using compositing layers.
     * See {@link #setUseCompositingLayer(boolean, Paint)}.
     *
     * @return true if a compositing layer is forced, false otherwise
     */
    public boolean getUseCompositingLayer() {
        return nGetLayerType(mNativeRenderNode) != 0;
    }

    /**
     * Sets the clip bounds of the RenderNode. If null, the clip bounds is removed from the
     * RenderNode. If non-null, the RenderNode will be clipped to this rect. If
     * {@link #setClipToBounds(boolean)} is true, then the RenderNode will be clipped to the
     * intersection of this rectangle and the bounds of the render node.
     *
     * @param rect the bounds to clip to. If null, the clip bounds are reset
     * @return True if the clip bounds changed, false otherwise
@@ -460,15 +474,29 @@ public final class RenderNode {
    }

    /**
     * Set whether the Render node should clip itself to its bounds. This property is controlled by
     * the view's parent.
     * Set whether the Render node should clip itself to its bounds. This defaults to true,
     * and is useful to the renderer in enable quick-rejection of chunks of the tree as well as
     * better partial invalidation support. Clipping can be further restricted or controlled
     * through the combination of this property as well as {@link #setClipBounds(Rect)}, which
     * allows for a different clipping rectangle to be used in addition to or instead of the
     * {@link #setLeftTopRightBottom(int, int, int, int)} or the RenderNode.
     *
     * @param clipToBounds true if the display list should clip to its bounds
     * @param clipToBounds true if the display list should clip to its bounds, false otherwise.
     */
    public boolean setClipToBounds(boolean clipToBounds) {
        return nSetClipToBounds(mNativeRenderNode, clipToBounds);
    }

    /**
     * Returns whether or not the RenderNode is clipping to its bounds. See
     * {@link #setClipToBounds(boolean)} and {@link #setLeftTopRightBottom(int, int, int, int)}
     *
     * @return true if the render node clips to its bounds, false otherwise.
     */
    public boolean getClipToBounds() {
        return nGetClipToBounds(mNativeRenderNode);
    }

    /**
     * Sets whether the RenderNode should be drawn immediately after the
     * closest ancestor RenderNode containing a projection receiver.
@@ -1338,12 +1366,18 @@ public final class RenderNode {
    @CriticalNative
    private static native boolean nSetLayerType(long renderNode, int layerType);

    @CriticalNative
    private static native int nGetLayerType(long renderNode);

    @CriticalNative
    private static native boolean nSetLayerPaint(long renderNode, long paint);

    @CriticalNative
    private static native boolean nSetClipToBounds(long renderNode, boolean clipToBounds);

    @CriticalNative
    private static native boolean nGetClipToBounds(long renderNode);

    @CriticalNative
    private static native boolean nSetClipBounds(long renderNode, int left, int top,
            int right, int bottom);
+1 −0
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ public:
    void applyColorTransform(ColorTransform transform);

    bool hasText() const { return mHasText; }
    size_t usedSize() const { return fUsed; }

private:
    friend class RecordingCanvas;
+3 −3
Original line number Diff line number Diff line
@@ -98,15 +98,15 @@ public:

    LayerProperties& operator=(const LayerProperties& other);

    // Strongly recommend using effectiveLayerType instead
    LayerType type() const { return mType; }

private:
    LayerProperties();
    ~LayerProperties();
    void reset();
    bool setColorFilter(SkColorFilter* filter);

    // Private since external users should go through properties().effectiveLayerType()
    LayerType type() const { return mType; }

    friend class RenderProperties;

    LayerType mType = LayerType::None;
Loading