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

Commit 679f9863 authored by Chris Craik's avatar Chris Craik Committed by Android (Google) Code Review
Browse files

Merge "Add more RenderNode property support in OpReorderer path"

parents 7058e4ca 76caecf4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -359,7 +359,7 @@ void OpReorderer::onViewportInitialized() {}
void OpReorderer::onSnapshotRestored(const Snapshot& removed, const Snapshot& restored) {}

void OpReorderer::deferNodePropsAndOps(RenderNode& node) {
    if (node.applyViewProperties(mCanvasState)) {
    if (node.applyViewProperties(mCanvasState, mAllocator)) {
        // not rejected so render
        if (node.getLayer()) {
            // HW layer
+49 −5
Original line number Diff line number Diff line
@@ -282,9 +282,11 @@ void RenderNode::pushLayerUpdate(TreeInfo& info) {
            damageSelf(info);
            transformUpdateNeeded = true;
#if HWUI_NEW_OPS
    } else if (mLayer->viewportWidth != getWidth() || mLayer->viewportHeight != getHeight()) {
        // TODO: allow it to grow larger
        if (getWidth() > mLayer->texture.width || getHeight() > mLayer->texture.height) {
    } else if (mLayer->viewportWidth != (uint32_t) getWidth()
            || mLayer->viewportHeight != (uint32_t)getHeight()) {
        // TODO: allow node's layer to grow larger
        if ((uint32_t)getWidth() > mLayer->texture.width
                || (uint32_t)getHeight() > mLayer->texture.height) {
#else
    } else if (mLayer->layer.getWidth() != getWidth() || mLayer->layer.getHeight() != getHeight()) {
        if (!LayerRenderer::resizeLayer(mLayer, getWidth(), getHeight())) {
@@ -304,7 +306,7 @@ void RenderNode::pushLayerUpdate(TreeInfo& info) {
        if (info.errorHandler) {
            std::ostringstream err;
            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) {
                err << ", size " << getWidth() << "x" << getHeight()
                        << " 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();
    if (properties().getAlpha() <= 0
            || (outline.getShouldClip() && outline.isEmpty())
@@ -542,6 +544,48 @@ bool RenderNode::applyViewProperties(CanvasState& canvasState) const {
            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(
            0, 0, properties().getWidth(), properties().getHeight());
}
+3 −3
Original line number Diff line number Diff line
@@ -171,11 +171,11 @@ public:
        return mStagingProperties;
    }

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

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

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

    // 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;

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

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

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

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

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

    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
                && mPrimitiveFields.mWidth <= maxTextureSize
                && mPrimitiveFields.mHeight <= maxTextureSize
                && mPrimitiveFields.mWidth <= deviceInfo->maxTextureSize()
                && mPrimitiveFields.mHeight <= deviceInfo->maxTextureSize()
                && (mComputedFields.mNeedLayerForFunctors
                        || (!MathUtils::isZero(mPrimitiveFields.mAlpha)
                                && mPrimitiveFields.mAlpha < 1
+3 −5
Original line number Diff line number Diff line
@@ -14,8 +14,7 @@
 * limitations under the License.
 */


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

#include <gtest/gtest.h>

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

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