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

Commit 0e87f00f authored by Chris Craik's avatar Chris Craik
Browse files

Initialize MergingDrawBatch clip with viewport bounds

This allows merged, clipped operations to behave correctly within a
savelayer, even if the base viewport has a large offset.

Additionally, disregard opaqueness when within a
complexclip/savelayer, as the coverage can't be trusted.

Change-Id: Ic908b82a4bb410bc7fac1b4295f4874ed166efc5
parent 2c290392
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -152,8 +152,9 @@ private:

class MergingDrawBatch : public DrawBatch {
public:
    MergingDrawBatch(DeferInfo& deferInfo, Rect viewport) :
           DrawBatch(deferInfo), mClipRect(viewport), mClipSideFlags(kClipSide_None) {}
    MergingDrawBatch(DeferInfo& deferInfo, int width, int height) :
            DrawBatch(deferInfo), mClipRect(width, height),
            mClipSideFlags(kClipSide_None) {}

    /*
     * Helper for determining if a new op can merge with a MergingDrawBatch based on their bounds
@@ -489,6 +490,7 @@ void DeferredDisplayList::addDrawOp(OpenGLRenderer& renderer, DrawOp* op) {
    // complex clip has a complex set of expectations on the renderer state - for now, avoid taking
    // the merge path in those cases
    deferInfo.mergeable &= !recordingComplexClip();
    deferInfo.opaqueOverBounds &= !recordingComplexClip() && mSaveStack.isEmpty();

    if (CC_LIKELY(mAvoidOverdraw) && mBatches.size() &&
            op->state.mClipSideFlags != kClipSide_ConservativeFull &&
@@ -570,7 +572,8 @@ void DeferredDisplayList::addDrawOp(OpenGLRenderer& renderer, DrawOp* op) {

    if (!targetBatch) {
        if (deferInfo.mergeable) {
            targetBatch = new MergingDrawBatch(deferInfo, mBounds);
            targetBatch = new MergingDrawBatch(deferInfo,
                    renderer.getViewportWidth(), renderer.getViewportHeight());
            mMergingBatches[deferInfo.batchId].put(deferInfo.mergeId, targetBatch);
        } else {
            targetBatch = new DrawBatch(deferInfo);
+1 −0
Original line number Diff line number Diff line
@@ -827,6 +827,7 @@ int OpenGLRenderer::saveLayerDeferred(float left, float top, float right, float
        if (!mSnapshot->isIgnored()) {
            mSnapshot->resetTransform(-bounds.left, -bounds.top, 0.0f);
            mSnapshot->resetClip(clip.left, clip.top, clip.right, clip.bottom);
            mSnapshot->viewport.set(0.0f, 0.0f, bounds.getWidth(), bounds.getHeight());
        }
    }

+3 −0
Original line number Diff line number Diff line
@@ -360,6 +360,9 @@ public:
        return mSnapshot->clipRegion->isEmpty();
    }

    int getViewportWidth() { return getSnapshot()->viewport.getWidth(); }
    int getViewportHeight() { return getSnapshot()->viewport.getHeight(); }

    /**
     * Scales the alpha on the current snapshot. This alpha value will be modulated
     * with other alpha values when drawing primitives.