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

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

Merge "Put WebViews with on a HW layer if stencil/shader clipping is needed" into mnc-dev

parents 1a3048f3 a766cb2b
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -155,8 +155,9 @@ public:
    inline bool currentlyIgnored() const { return currentSnapshot()->isIgnored(); }
    int getViewportWidth() const { return currentSnapshot()->getViewportWidth(); }
    int getViewportHeight() const { return currentSnapshot()->getViewportHeight(); }
    int getWidth() { return mWidth; }
    int getHeight() { return mHeight; }
    int getWidth() const { return mWidth; }
    int getHeight() const { return mHeight; }
    bool clipIsSimple() const { return currentSnapshot()->clipIsSimple(); }

    inline const Snapshot* currentSnapshot() const {
        return mSnapshot != nullptr ? mSnapshot.get() : mFirstSnapshot.get();
+4 −4
Original line number Diff line number Diff line
@@ -203,10 +203,10 @@ bool DisplayListCanvas::clipRegion(const SkRegion* region, SkRegion::Op op) {

void DisplayListCanvas::drawRenderNode(RenderNode* renderNode) {
    LOG_ALWAYS_FATAL_IF(!renderNode, "missing rendernode");

    // dirty is an out parameter and should not be recorded,
    // it matters only when replaying the display list
    DrawRenderNodeOp* op = new (alloc()) DrawRenderNodeOp(renderNode, *mState.currentTransform());
    DrawRenderNodeOp* op = new (alloc()) DrawRenderNodeOp(
            renderNode,
            *mState.currentTransform(),
            mState.clipIsSimple());
    addRenderNodeOp(op);
}

+16 −1
Original line number Diff line number Diff line
@@ -1398,9 +1398,10 @@ class DrawRenderNodeOp : public DrawBoundedOp {
    friend class RenderNode; // grant RenderNode access to info of child
    friend class DisplayListData; // grant DisplayListData access to info of child
public:
    DrawRenderNodeOp(RenderNode* renderNode, const mat4& transformFromParent)
    DrawRenderNodeOp(RenderNode* renderNode, const mat4& transformFromParent, bool clipIsSimple)
            : DrawBoundedOp(0, 0, renderNode->getWidth(), renderNode->getHeight(), nullptr)
            , mRenderNode(renderNode)
            , mRecordedWithPotentialStencilClip(!clipIsSimple || !transformFromParent.isSimple())
            , mTransformFromParent(transformFromParent)
            , mSkipInOrderDraw(false) {}

@@ -1436,6 +1437,20 @@ public:
private:
    RenderNode* mRenderNode;

    /**
     * This RenderNode was drawn into a DisplayList with the canvas in a state that will likely
     * require rendering with stencil clipping. Either:
     *
     * 1) A path clip or rotated rect clip was in effect on the canvas at record time
     * 2) The RenderNode was recorded with a non-simple canvas transform (e.g. rotation)
     *
     * Note: even if this is false, non-rect clipping may still be applied applied either due to
     * property-driven rotation (either in this RenderNode, or any ancestor), or record time
     * clipping in an ancestor. These are handled in RenderNode::prepareTreeImpl since they are
     * dynamic (relative to a static DisplayList of a parent), and don't affect this flag.
     */
    bool mRecordedWithPotentialStencilClip;

    ///////////////////////////
    // Properties below are used by RenderNode::computeOrderingImpl() and issueOperations()
    ///////////////////////////
+25 −5
Original line number Diff line number Diff line
@@ -120,7 +120,10 @@ void RenderNode::prepareTree(TreeInfo& info) {
    ATRACE_CALL();
    LOG_ALWAYS_FATAL_IF(!info.damageAccumulator, "DamageAccumulator missing");

    prepareTreeImpl(info);
    // Functors don't correctly handle stencil usage of overdraw debugging - shove 'em in a layer.
    bool functorsNeedLayer = Properties::debugOverdraw;

    prepareTreeImpl(info, functorsNeedLayer);
}

void RenderNode::addAnimator(const sp<BaseRenderNodeAnimator>& animator) {
@@ -219,7 +222,15 @@ void RenderNode::pushLayerUpdate(TreeInfo& info) {
    }
}

void RenderNode::prepareTreeImpl(TreeInfo& info) {
/**
 * Traverse down the the draw tree to prepare for a frame.
 *
 * MODE_FULL = UI Thread-driven (thus properties must be synced), otherwise RT driven
 *
 * While traversing down the tree, functorsNeedLayer flag is set to true if anything that uses the
 * stencil buffer may be needed. Views that use a functor to draw will be forced onto a layer.
 */
void RenderNode::prepareTreeImpl(TreeInfo& info, bool functorsNeedLayer) {
    info.damageAccumulator->pushTransform(this);

    if (info.mode == TreeInfo::MODE_FULL) {
@@ -229,11 +240,17 @@ void RenderNode::prepareTreeImpl(TreeInfo& info) {
    if (CC_LIKELY(info.runAnimations)) {
        animatorDirtyMask = mAnimatorManager.animate(info);
    }

    bool willHaveFunctor = info.mode == TreeInfo::MODE_FULL && mStagingDisplayListData
            ? !mStagingDisplayListData->functors.isEmpty() : !mDisplayListData->functors.isEmpty();
    bool childFunctorsNeedLayer = mProperties.prepareForFunctorPresence(
            willHaveFunctor, functorsNeedLayer);

    prepareLayer(info, animatorDirtyMask);
    if (info.mode == TreeInfo::MODE_FULL) {
        pushStagingDisplayListChanges(info);
    }
    prepareSubTree(info, mDisplayListData);
    prepareSubTree(info, childFunctorsNeedLayer, mDisplayListData);
    pushLayerUpdate(info);

    info.damageAccumulator->popTransform();
@@ -313,7 +330,7 @@ void RenderNode::deleteDisplayListData() {
    mDisplayListData = nullptr;
}

void RenderNode::prepareSubTree(TreeInfo& info, DisplayListData* subtree) {
void RenderNode::prepareSubTree(TreeInfo& info, bool functorsNeedLayer, DisplayListData* subtree) {
    if (subtree) {
        TextureCache& cache = Caches::getInstance().textureCache;
        info.out.hasFunctors |= subtree->functors.size();
@@ -324,7 +341,10 @@ void RenderNode::prepareSubTree(TreeInfo& info, DisplayListData* subtree) {
            DrawRenderNodeOp* op = subtree->children()[i];
            RenderNode* childNode = op->mRenderNode;
            info.damageAccumulator->pushTransform(&op->mTransformFromParent);
            childNode->prepareTreeImpl(info);
            bool childFunctorsNeedLayer = functorsNeedLayer
                    // Recorded with non-rect clip, or canvas-rotated by parent
                    || op->mRecordedWithPotentialStencilClip;
            childNode->prepareTreeImpl(info, childFunctorsNeedLayer);
            info.damageAccumulator->popTransform();
        }
    }
+2 −2
Original line number Diff line number Diff line
@@ -235,10 +235,10 @@ private:
        const char* mText;
    };

    void prepareTreeImpl(TreeInfo& info);
    void prepareTreeImpl(TreeInfo& info, bool functorsNeedLayer);
    void pushStagingPropertiesChanges(TreeInfo& info);
    void pushStagingDisplayListChanges(TreeInfo& info);
    void prepareSubTree(TreeInfo& info, DisplayListData* subtree);
    void prepareSubTree(TreeInfo& info, bool functorsNeedLayer, DisplayListData* subtree);
    void applyLayerPropertiesToLayer(TreeInfo& info);
    void prepareLayer(TreeInfo& info, uint32_t dirtyMask);
    void pushLayerUpdate(TreeInfo& info);
Loading