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

Commit af636ebf authored by Romain Guy's avatar Romain Guy
Browse files

Don't set the invisible flag when saving an empty layer.

Bug #3270371

Change-Id: I65e85671c2fb70d74553c91213e5e759e0ac64ee
parent 3eb31061
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -6421,6 +6421,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
            mPrivateFlags &= ~DRAWING_CACHE_VALID;
            final ViewParent p = mParent;
            final AttachInfo ai = mAttachInfo;
            if (p != null && ai != null && ai.mHardwareAccelerated) {
                // fast-track for GL-enabled applications; just invalidate the whole hierarchy
                // with a null dirty rect, which tells the ViewRoot to redraw everything
                p.invalidateChild(this, null);
                return;
            }
            if (p != null && ai != null) {
                final int scrollX = mScrollX;
                final int scrollY = mScrollY;
+13 −9
Original line number Diff line number Diff line
@@ -268,7 +268,7 @@ int OpenGLRenderer::saveLayer(float left, float top, float right, float bottom,
    const GLuint previousFbo = mSnapshot->fbo;
    const int count = saveSnapshot(flags);

    if (!mSnapshot->invisible) {
    if (!mSnapshot->isIgnored()) {
        int alpha = 255;
        SkXfermode::Mode mode;

@@ -385,13 +385,17 @@ bool OpenGLRenderer::createLayer(sp<Snapshot> snapshot, float left, float top,

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

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

@@ -731,7 +735,7 @@ void OpenGLRenderer::setupDraw() {
}

void OpenGLRenderer::clearLayerRegions() {
    if (mLayers.size() == 0 || mSnapshot->invisible) return;
    if (mLayers.size() == 0 || mSnapshot->isIgnored()) return;

    Rect clipRect(*mSnapshot->clipRect);
    clipRect.snapToPixelBoundaries();
@@ -809,7 +813,7 @@ const Rect& OpenGLRenderer::getClipBounds() {
}

bool OpenGLRenderer::quickReject(float left, float top, float right, float bottom) {
    if (mSnapshot->invisible) {
    if (mSnapshot->isIgnored()) {
        return true;
    }

@@ -988,7 +992,7 @@ void OpenGLRenderer::drawPatch(SkBitmap* bitmap, const int32_t* xDivs, const int

void OpenGLRenderer::drawLines(float* points, int count, SkPaint* paint) {
    // TODO: Should do quickReject for each line
    if (mSnapshot->invisible) return;
    if (mSnapshot->isIgnored()) return;

    const bool isAA = paint->isAntiAlias();
    const float strokeWidth = paint->getStrokeWidth() * 0.5f;
@@ -1112,7 +1116,7 @@ void OpenGLRenderer::drawLines(float* points, int count, SkPaint* paint) {

void OpenGLRenderer::drawColor(int color, SkXfermode::Mode mode) {
    // No need to check against the clip, we fill the clip region
    if (mSnapshot->invisible) return;
    if (mSnapshot->isIgnored()) return;

    Rect& clip(*mSnapshot->clipRect);
    clip.snapToPixelBoundaries();
@@ -1150,7 +1154,7 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count,
    if (text == NULL || count == 0 || (paint->getAlpha() == 0 && paint->getXfermode() == NULL)) {
        return;
    }
    if (mSnapshot->invisible) return;
    if (mSnapshot->isIgnored()) return;

    paint->setAntiAlias(true);

@@ -1253,7 +1257,7 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count,
}

void OpenGLRenderer::drawPath(SkPath* path, SkPaint* paint) {
    if (mSnapshot->invisible) return;
    if (mSnapshot->isIgnored()) return;

    GLuint textureUnit = 0;
    glActiveTexture(gTextureUnits[textureUnit]);
+14 −3
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ namespace uirenderer {
 */
class Snapshot: public LightRefBase<Snapshot> {
public:
    Snapshot(): flags(0), previous(NULL), layer(NULL), fbo(0), invisible(false) {
    Snapshot(): flags(0), previous(NULL), layer(NULL), fbo(0), invisible(false), empty(false) {
        transform = &mTransformRoot;
        clipRect = &mClipRectRoot;
        region = NULL;
@@ -55,7 +55,7 @@ public:
     */
    Snapshot(const sp<Snapshot>& s, int saveFlags):
            flags(0), previous(s), layer(NULL), fbo(s->fbo),
            invisible(s->invisible), viewport(s->viewport), height(s->height) {
            invisible(s->invisible), empty(false), viewport(s->viewport), height(s->height) {
        if (saveFlags & SkCanvas::kMatrix_SaveFlag) {
            mTransformRoot.load(*s->transform);
            transform = &mTransformRoot;
@@ -203,6 +203,10 @@ public:
        flags |= Snapshot::kFlagClipSet | Snapshot::kFlagDirtyLocalClip;
    }

    bool isIgnored() const {
        return invisible || empty;
    }

    /**
     * Dirty flags.
     */
@@ -225,10 +229,17 @@ public:

    /**
     * Indicates that this snapshot is invisible and nothing should be drawn
     * inside it.
     * inside it. This flag is set only when the layer clips drawing to its
     * bounds and is passed to subsequent snapshots.
     */
    bool invisible;

    /**
     * If set to true, the layer will not be composited. This is similar to
     * invisible but this flag is not passed to subsequent snapshots.
     */
    bool empty;

    /**
     * Current viewport.
     */