Skip to content

Commit e5a4a3d

Browse files
Romain GuyAndroid (Google) Code Review
authored andcommitted
Merge "Ensure we always set the proper blending mode Bug #6527305" into jb-dev
2 parents 638e012 + ddf7437 commit e5a4a3d

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
@@ -176,14 +176,26 @@ void OpenGLRenderer::prepareDirty(float left, float top, float right, float bott
176176
mSnapshot->fbo = getTargetFbo();
177177
mSaveCount = 1;
178178

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

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

@@ -290,11 +302,6 @@ status_t OpenGLRenderer::invokeFunctors(Rect& dirty) {
290302
}
291303
}
292304

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

300307
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)