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

Commit 8e2b203c authored by Romain Guy's avatar Romain Guy Committed by Android (Google) Code Review
Browse files

Merge "Correctly initialize/refresh layers."

parents 0de6582c 38c85b90
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -82,6 +82,10 @@ struct Layer {
     * Indicates whether this layer should be blended.
     */
    bool blend;
    /**
     * Indicates that this layer has never been used before.
     */
    bool empty;
}; // struct Layer

}; // namespace uirenderer
+3 −5
Original line number Diff line number Diff line
@@ -109,18 +109,16 @@ Layer* LayerCache::get(LayerSize& size) {

        layer = new Layer;
        layer->blend = true;
        layer->empty = true;

        glGenTextures(1, &layer->texture);
        glBindTexture(GL_TEXTURE_2D, layer->texture);

        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size.width, size.height, 0,
                GL_RGBA, GL_UNSIGNED_BYTE, NULL);
    }

    return layer;
+9 −2
Original line number Diff line number Diff line
@@ -381,8 +381,15 @@ bool OpenGLRenderer::createLayer(sp<Snapshot> snapshot, float left, float top,

    // Copy the framebuffer into the layer
    glBindTexture(GL_TEXTURE_2D, layer->texture);

    if (layer->empty) {
        glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bounds.left, mHeight - bounds.bottom,
                bounds.getWidth(), bounds.getHeight(), 0);
        layer->empty = false;
    } else {
        glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, bounds.left, mHeight - bounds.bottom,
                bounds.getWidth(), bounds.getHeight());
    }

    if (flags & SkCanvas::kClipToLayer_SaveFlag) {
        if (mSnapshot->clipTransformed(bounds)) setScissorFromClip();