Skip to content

Commit ddf7437

Browse files
author
Romain Guy
committed
Ensure we always set the proper blending mode
Bug #6527305 At the beginning of a frame, always set the blending mode that we think GL is using just in case it was modified by another entity (for instance a WebView functor.) Change-Id: I0e1d0abee8a2abb2b8e7622aed28346e89562c06
1 parent 51f7c6b commit ddf7437

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

libs/hwui/DisplayListRenderer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,8 @@ void DisplayList::output(OpenGLRenderer& renderer, uint32_t level) {
296296
indent[i] = ' ';
297297
}
298298
indent[count] = '\0';
299-
ALOGD("%sStart display list (%p, %s)", (char*) indent + 2, this, mName.string());
299+
ALOGD("%sStart display list (%p, %s, render=%d)", (char*) indent + 2, this,
300+
mName.string(), isRenderable());
300301

301302
ALOGD("%s%s %d", indent, "Save", SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
302303
int saveCount = renderer.getSaveCount() - 1;

libs/hwui/OpenGLRenderer.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,26 @@ void OpenGLRenderer::prepareDirty(float left, float top, float right, float bott
177177
mSnapshot->fbo = getTargetFbo();
178178
mSaveCount = 1;
179179

180-
glViewport(0, 0, mWidth, mHeight);
181-
mCaches.setScissor(left, mSnapshot->height - bottom, right - left, bottom - top);
182-
183180
mSnapshot->setClip(left, top, right, bottom);
184-
mDirtyClip = false;
181+
mDirtyClip = opaque;
182+
183+
syncState();
185184

186185
if (!opaque) {
186+
mCaches.setScissor(left, mSnapshot->height - bottom, right - left, bottom - top);
187187
glClear(GL_COLOR_BUFFER_BIT);
188+
} else {
189+
mCaches.resetScissor();
190+
}
191+
}
192+
193+
void OpenGLRenderer::syncState() {
194+
glViewport(0, 0, mWidth, mHeight);
195+
196+
if (mCaches.blend) {
197+
glEnable(GL_BLEND);
198+
} else {
199+
glDisable(GL_BLEND);
188200
}
189201
}
190202

@@ -291,11 +303,6 @@ status_t OpenGLRenderer::invokeFunctors(Rect& dirty) {
291303
}
292304
}
293305

294-
// Restore state possibly changed by the functors in process mode
295-
GLboolean value;
296-
glGetBooleanv(GL_BLEND, &value);
297-
mCaches.blend = value;
298-
299306
mCaches.activeTexture(0);
300307

301308
return result;

libs/hwui/OpenGLRenderer.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,12 @@ class OpenGLRenderer {
214214
void drawTextureLayer(Layer* layer, const Rect& rect);
215215

216216
private:
217+
/**
218+
* Ensures the state of the renderer is the same as the state of
219+
* the GL context.
220+
*/
221+
void syncState();
222+
217223
/**
218224
* Saves the current state of the renderer as a new snapshot.
219225
* The new snapshot is saved in mSnapshot and the previous snapshot

0 commit comments

Comments
 (0)