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

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

Fix out of range glCopyTexImage2D

Bug #9425270

A better solution would be to use glCopyTexImage2D whenever possible but
this change would be a little more dangerous.

Change-Id: Ib1aaceda39d838716285ef97f356721416822dbb
parent e6cb43a1
Loading
Loading
Loading
Loading
+9 −6
Original line number Original line Diff line number Diff line
@@ -882,14 +882,17 @@ bool OpenGLRenderer::createLayer(float left, float top, float right, float botto
        layer->bindTexture();
        layer->bindTexture();
        if (!bounds.isEmpty()) {
        if (!bounds.isEmpty()) {
            if (layer->isEmpty()) {
            if (layer->isEmpty()) {
                glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
                // Workaround for some GL drivers. When reading pixels lying outside
                        bounds.left, mSnapshot->height - bounds.bottom,
                // of the window we should get undefined values for those pixels.
                        layer->getWidth(), layer->getHeight(), 0);
                // Unfortunately some drivers will turn the entire target texture black
                // when reading outside of the window.
                glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, layer->getWidth(), layer->getHeight(),
                        0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
                layer->setEmpty(false);
                layer->setEmpty(false);
            } else {
            }

            glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, bounds.left,
            glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, bounds.left,
                    mSnapshot->height - bounds.bottom, bounds.getWidth(), bounds.getHeight());
                    mSnapshot->height - bounds.bottom, bounds.getWidth(), bounds.getHeight());
            }


            // Enqueue the buffer coordinates to clear the corresponding region later
            // Enqueue the buffer coordinates to clear the corresponding region later
            mLayers.push(new Rect(bounds));
            mLayers.push(new Rect(bounds));