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

Commit 408eb126 authored by Chris Craik's avatar Chris Craik
Browse files

Set ignore flag during deferred savelayer

bug:8471552

Additionally, add ignore check for draw functor

In deferred mode, if we don't set ignore, a 0 alpha displayList won't
be quickRejected, and not only would its contents be needlessly
deferred, but upon playback any functors would be drawn, ignoring the
state of the snapshot.

Change-Id: Ib1edb3252080f674254086edee6f965f0efcce78
parent 05191053
Loading
Loading
Loading
Loading
+17 −10
Original line number Diff line number Diff line
@@ -406,6 +406,8 @@ status_t OpenGLRenderer::invokeFunctors(Rect& dirty) {
}

status_t OpenGLRenderer::callDrawGLFunction(Functor* functor, Rect& dirty) {
    if (mSnapshot->isIgnored()) return DrawGlInfo::kStatusDone;

    interrupt();
    detachFunctor(functor);

@@ -679,6 +681,17 @@ void OpenGLRenderer::calculateLayerBoundsAndClip(Rect& bounds, Rect& clip, bool
    }
}

void OpenGLRenderer::updateSnapshotIgnoreForLayer(const Rect& bounds, const Rect& clip,
        bool fboLayer, int alpha) {
    if (bounds.isEmpty() || bounds.getWidth() > mCaches.maxTextureSize ||
            bounds.getHeight() > mCaches.maxTextureSize ||
            (fboLayer && clip.isEmpty())) {
        mSnapshot->empty = fboLayer;
    } else {
        mSnapshot->invisible = mSnapshot->invisible || (alpha <= ALPHA_THRESHOLD && fboLayer);
    }
}

int OpenGLRenderer::saveLayerDeferred(float left, float top, float right, float bottom,
        int alpha, SkXfermode::Mode mode, int flags) {
    const GLuint previousFbo = mSnapshot->fbo;
@@ -692,8 +705,9 @@ int OpenGLRenderer::saveLayerDeferred(float left, float top, float right, float
        Rect bounds(left, top, right, bottom);
        Rect clip;
        calculateLayerBoundsAndClip(bounds, clip, true);
        updateSnapshotIgnoreForLayer(bounds, clip, true, alpha);

        if (!bounds.isEmpty() && !clip.isEmpty()) {
        if (!mSnapshot->isIgnored()) {
            mSnapshot->resetTransform(-bounds.left, -bounds.top, 0.0f);
            mSnapshot->resetClip(clip.left, clip.top, clip.right, clip.bottom);
        }
@@ -765,17 +779,10 @@ bool OpenGLRenderer::createLayer(float left, float top, float right, float botto
    Rect clip;
    Rect bounds(left, top, right, bottom);
    calculateLayerBoundsAndClip(bounds, clip, fboLayer);

    if (bounds.isEmpty() || bounds.getWidth() > mCaches.maxTextureSize ||
            bounds.getHeight() > mCaches.maxTextureSize ||
            (fboLayer && clip.isEmpty())) {
        mSnapshot->empty = fboLayer;
    } else {
        mSnapshot->invisible = mSnapshot->invisible || (alpha <= ALPHA_THRESHOLD && fboLayer);
    }
    updateSnapshotIgnoreForLayer(bounds, clip, fboLayer, alpha);

    // Bail out if we won't draw in this snapshot
    if (mSnapshot->invisible || mSnapshot->empty) {
    if (mSnapshot->isIgnored()) {
        return false;
    }

+7 −1
Original line number Diff line number Diff line
@@ -544,10 +544,16 @@ private:
    bool quickRejectPreStroke(float left, float top, float right, float bottom, SkPaint* paint);

    /**
     * given the local bounds of the layer, calculates ...
     * Given the local bounds of the layer, calculates ...
     */
    void calculateLayerBoundsAndClip(Rect& bounds, Rect& clip, bool fboLayer);

    /**
     * Given the local bounds + clip of the layer, updates current snapshot's empty/invisible
     */
    void updateSnapshotIgnoreForLayer(const Rect& bounds, const Rect& clip,
            bool fboLayer, int alpha);

    /**
     * Creates a new layer stored in the specified snapshot.
     *