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

Commit 76caecf4 authored by Chris Craik's avatar Chris Craik
Browse files

Add more RenderNode property support in OpReorderer path

Change-Id: I0163fe91d8145e33019739c191bbab0432a5f9aa
parent 429c5b93
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -359,7 +359,7 @@ void OpReorderer::onViewportInitialized() {}
void OpReorderer::onSnapshotRestored(const Snapshot& removed, const Snapshot& restored) {}
void OpReorderer::onSnapshotRestored(const Snapshot& removed, const Snapshot& restored) {}


void OpReorderer::deferNodePropsAndOps(RenderNode& node) {
void OpReorderer::deferNodePropsAndOps(RenderNode& node) {
    if (node.applyViewProperties(mCanvasState)) {
    if (node.applyViewProperties(mCanvasState, mAllocator)) {
        // not rejected so render
        // not rejected so render
        if (node.getLayer()) {
        if (node.getLayer()) {
            // HW layer
            // HW layer
+49 −5
Original line number Original line Diff line number Diff line
@@ -282,9 +282,11 @@ void RenderNode::pushLayerUpdate(TreeInfo& info) {
            damageSelf(info);
            damageSelf(info);
            transformUpdateNeeded = true;
            transformUpdateNeeded = true;
#if HWUI_NEW_OPS
#if HWUI_NEW_OPS
    } else if (mLayer->viewportWidth != getWidth() || mLayer->viewportHeight != getHeight()) {
    } else if (mLayer->viewportWidth != (uint32_t) getWidth()
        // TODO: allow it to grow larger
            || mLayer->viewportHeight != (uint32_t)getHeight()) {
        if (getWidth() > mLayer->texture.width || getHeight() > mLayer->texture.height) {
        // TODO: allow node's layer to grow larger
        if ((uint32_t)getWidth() > mLayer->texture.width
                || (uint32_t)getHeight() > mLayer->texture.height) {
#else
#else
    } else if (mLayer->layer.getWidth() != getWidth() || mLayer->layer.getHeight() != getHeight()) {
    } else if (mLayer->layer.getWidth() != getWidth() || mLayer->layer.getHeight() != getHeight()) {
        if (!LayerRenderer::resizeLayer(mLayer, getWidth(), getHeight())) {
        if (!LayerRenderer::resizeLayer(mLayer, getWidth(), getHeight())) {
@@ -304,7 +306,7 @@ void RenderNode::pushLayerUpdate(TreeInfo& info) {
        if (info.errorHandler) {
        if (info.errorHandler) {
            std::ostringstream err;
            std::ostringstream err;
            err << "Unable to create layer for " << getName();
            err << "Unable to create layer for " << getName();
            const uint32_t  maxTextureSize = Caches::getInstance().maxTextureSize;
            const int maxTextureSize = Caches::getInstance().maxTextureSize;
            if (getWidth() > maxTextureSize || getHeight() > maxTextureSize) {
            if (getWidth() > maxTextureSize || getHeight() > maxTextureSize) {
                err << ", size " << getWidth() << "x" << getHeight()
                err << ", size " << getWidth() << "x" << getHeight()
                        << " exceeds max size " << maxTextureSize;
                        << " exceeds max size " << maxTextureSize;
@@ -518,7 +520,7 @@ void RenderNode::decParentRefCount() {
    }
    }
}
}


bool RenderNode::applyViewProperties(CanvasState& canvasState) const {
bool RenderNode::applyViewProperties(CanvasState& canvasState, LinearAllocator& allocator) const {
    const Outline& outline = properties().getOutline();
    const Outline& outline = properties().getOutline();
    if (properties().getAlpha() <= 0
    if (properties().getAlpha() <= 0
            || (outline.getShouldClip() && outline.isEmpty())
            || (outline.getShouldClip() && outline.isEmpty())
@@ -542,6 +544,48 @@ bool RenderNode::applyViewProperties(CanvasState& canvasState) const {
            canvasState.concatMatrix(*properties().getTransformMatrix());
            canvasState.concatMatrix(*properties().getTransformMatrix());
        }
        }
    }
    }

    const bool isLayer = properties().effectiveLayerType() != LayerType::None;
    int clipFlags = properties().getClippingFlags();
    if (properties().getAlpha() < 1) {
        if (isLayer) {
            clipFlags &= ~CLIP_TO_BOUNDS; // bounds clipping done by layer
        }
        if (CC_LIKELY(isLayer || !properties().getHasOverlappingRendering())) {
            // simply scale rendering content's alpha
            canvasState.scaleAlpha(properties().getAlpha());
        } else {
            // savelayer needed to create an offscreen buffer
            Rect layerBounds(0, 0, getWidth(), getHeight());
            if (clipFlags) {
                properties().getClippingRectForFlags(clipFlags, &layerBounds);
                clipFlags = 0; // all clipping done by savelayer
            }
            LOG_ALWAYS_FATAL("TODO: savelayer");
        }

        if (CC_UNLIKELY(ATRACE_ENABLED() && properties().promotedToLayer())) {
            // pretend alpha always causes savelayer to warn about
            // performance problem affecting old versions
            ATRACE_FORMAT("%s alpha caused saveLayer %dx%d", getName(), getWidth(), getHeight());
        }
    }
    if (clipFlags) {
        Rect clipRect;
        properties().getClippingRectForFlags(clipFlags, &clipRect);
        canvasState.clipRect(clipRect.left, clipRect.top, clipRect.right, clipRect.bottom,
                SkRegion::kIntersect_Op);
    }

    // TODO: support nesting round rect clips
    if (mProperties.getRevealClip().willClip()) {
        Rect bounds;
        mProperties.getRevealClip().getBounds(&bounds);
        canvasState.setClippingRoundRect(allocator,
                bounds, mProperties.getRevealClip().getRadius());
    } else if (mProperties.getOutline().willClip()) {
        canvasState.setClippingOutline(allocator, &(mProperties.getOutline()));
    }
    return !canvasState.quickRejectConservative(
    return !canvasState.quickRejectConservative(
            0, 0, properties().getWidth(), properties().getHeight());
            0, 0, properties().getWidth(), properties().getHeight());
}
}
+3 −3
Original line number Original line Diff line number Diff line
@@ -171,11 +171,11 @@ public:
        return mStagingProperties;
        return mStagingProperties;
    }
    }


    uint32_t getWidth() {
    int getWidth() const {
        return properties().getWidth();
        return properties().getWidth();
    }
    }


    uint32_t getHeight() {
    int getHeight() const {
        return properties().getHeight();
        return properties().getHeight();
    }
    }


@@ -188,7 +188,7 @@ public:
    AnimatorManager& animators() { return mAnimatorManager; }
    AnimatorManager& animators() { return mAnimatorManager; }


    // Returns false if the properties dictate the subtree contained in this RenderNode won't render
    // Returns false if the properties dictate the subtree contained in this RenderNode won't render
    bool applyViewProperties(CanvasState& canvasState) const;
    bool applyViewProperties(CanvasState& canvasState, LinearAllocator& allocator) const;


    void applyViewPropertyTransforms(mat4& matrix, bool true3dTransform = false) const;
    void applyViewPropertyTransforms(mat4& matrix, bool true3dTransform = false) const;


+16 −14
Original line number Original line Diff line number Diff line
@@ -16,23 +16,24 @@
#ifndef RENDERNODEPROPERTIES_H
#ifndef RENDERNODEPROPERTIES_H
#define RENDERNODEPROPERTIES_H
#define RENDERNODEPROPERTIES_H


#include <algorithm>
#include "Caches.h"
#include <stddef.h>
#include "DeviceInfo.h"
#include <vector>
#include "Rect.h"
#include <cutils/compiler.h>
#include "RevealClip.h"
#include <androidfw/ResourceTypes.h>
#include "Outline.h"
#include <utils/Log.h>
#include "utils/MathUtils.h"


#include <SkCamera.h>
#include <SkCamera.h>
#include <SkMatrix.h>
#include <SkMatrix.h>
#include <SkRegion.h>
#include <SkRegion.h>
#include <SkXfermode.h>
#include <SkXfermode.h>


#include "Caches.h"
#include <algorithm>
#include "Rect.h"
#include <stddef.h>
#include "RevealClip.h"
#include <vector>
#include "Outline.h"
#include <cutils/compiler.h>
#include "utils/MathUtils.h"
#include <androidfw/ResourceTypes.h>
#include <utils/Log.h>


class SkBitmap;
class SkBitmap;
class SkColorFilter;
class SkColorFilter;
@@ -608,10 +609,11 @@ public:
    }
    }


    bool promotedToLayer() const {
    bool promotedToLayer() const {
        const int maxTextureSize = Caches::getInstance().maxTextureSize;
        const DeviceInfo* deviceInfo = DeviceInfo::get();
        LOG_ALWAYS_FATAL_IF(!deviceInfo, "DeviceInfo uninitialized");
        return mLayerProperties.mType == LayerType::None
        return mLayerProperties.mType == LayerType::None
                && mPrimitiveFields.mWidth <= maxTextureSize
                && mPrimitiveFields.mWidth <= deviceInfo->maxTextureSize()
                && mPrimitiveFields.mHeight <= maxTextureSize
                && mPrimitiveFields.mHeight <= deviceInfo->maxTextureSize()
                && (mComputedFields.mNeedLayerForFunctors
                && (mComputedFields.mNeedLayerForFunctors
                        || (!MathUtils::isZero(mPrimitiveFields.mAlpha)
                        || (!MathUtils::isZero(mPrimitiveFields.mAlpha)
                                && mPrimitiveFields.mAlpha < 1
                                && mPrimitiveFields.mAlpha < 1
+3 −5
Original line number Original line Diff line number Diff line
@@ -14,8 +14,7 @@
 * limitations under the License.
 * limitations under the License.
 */
 */



#include <DeviceInfo.h>
#include "DeviceInfo.h"


#include <gtest/gtest.h>
#include <gtest/gtest.h>


@@ -23,10 +22,9 @@ using namespace android;
using namespace android::uirenderer;
using namespace android::uirenderer;


TEST(DeviceInfo, basic) {
TEST(DeviceInfo, basic) {
    const DeviceInfo* di = DeviceInfo::get();
    // can't assert state before init - another test may have initialized the singleton
    EXPECT_EQ(nullptr, di) << "DeviceInfo was already initialized?";
    DeviceInfo::initialize();
    DeviceInfo::initialize();
    di = DeviceInfo::get();
    const DeviceInfo* di = DeviceInfo::get();
    ASSERT_NE(nullptr, di) << "DeviceInfo initialization failed";
    ASSERT_NE(nullptr, di) << "DeviceInfo initialization failed";
    EXPECT_EQ(2048, di->maxTextureSize()) << "Max texture size didn't match";
    EXPECT_EQ(2048, di->maxTextureSize()) << "Max texture size didn't match";
}
}
Loading