@@ -157,7 +157,6 @@ void OpenGLRenderer::setViewport(int width, int height) {
157157 mFirstSnapshot ->viewport .set (0 , 0 , width, height);
158158
159159 glDisable (GL_DITHER);
160- glEnable (GL_SCISSOR_TEST);
161160 glClearColor (0 .0f , 0 .0f , 0 .0f , 0 .0f );
162161
163162 glEnableVertexAttribArray (Program::kBindingPosition );
@@ -181,6 +180,7 @@ int OpenGLRenderer::prepareDirty(float left, float top, float right, float botto
181180 syncState ();
182181
183182 if (!opaque) {
183+ mCaches .enableScissor ();
184184 mCaches .setScissor (left, mSnapshot ->height - bottom, right - left, bottom - top);
185185 glClear (GL_COLOR_BUFFER_BIT);
186186 return DrawGlInfo::kStatusDrew ;
@@ -250,7 +250,7 @@ void OpenGLRenderer::resume() {
250250 glViewport (0 , 0 , snapshot->viewport .getWidth (), snapshot->viewport .getHeight ());
251251 glClearColor (0 .0f , 0 .0f , 0 .0f , 0 .0f );
252252
253- glEnable (GL_SCISSOR_TEST );
253+ mCaches . enableScissor ( );
254254 mCaches .resetScissor ();
255255 dirtyClip ();
256256
@@ -651,6 +651,7 @@ bool OpenGLRenderer::createFboLayer(Layer* layer, Rect& bounds, sp<Snapshot> sna
651651#endif
652652
653653 // Clear the FBO, expand the clear region by 1 to get nice bilinear filtering
654+ mCaches .enableScissor ();
654655 mCaches .setScissor (clip.left - 1 .0f , bounds.getHeight () - clip.bottom - 1 .0f ,
655656 clip.getWidth () + 2 .0f , clip.getHeight () + 2 .0f );
656657 glClear (GL_COLOR_BUFFER_BIT);
@@ -981,7 +982,7 @@ void OpenGLRenderer::clearLayerRegions() {
981982 // The list contains bounds that have already been clipped
982983 // against their initial clip rect, and the current clip
983984 // is likely different so we need to disable clipping here
984- glDisable (GL_SCISSOR_TEST );
985+ mCaches . disableScissor ( );
985986
986987 Vertex mesh[count * 6 ];
987988 Vertex* vertex = mesh;
@@ -1008,8 +1009,6 @@ void OpenGLRenderer::clearLayerRegions() {
10081009 setupDrawVertices (&mesh[0 ].position [0 ]);
10091010
10101011 glDrawArrays (GL_TRIANGLES, 0 , count * 6 );
1011-
1012- glEnable (GL_SCISSOR_TEST);
10131012 } else {
10141013 for (uint32_t i = 0 ; i < count; i++) {
10151014 delete mLayers .itemAt (i);
@@ -1088,7 +1087,12 @@ bool OpenGLRenderer::quickReject(float left, float top, float right, float botto
10881087 Rect clipRect (*mSnapshot ->clipRect );
10891088 clipRect.snapToPixelBoundaries ();
10901089
1091- return !clipRect.intersects (r);
1090+ bool rejected = !clipRect.intersects (r);
1091+ if (!isDeferred () && !rejected) {
1092+ mCaches .setScissorEnabled (!clipRect.contains (r));
1093+ }
1094+
1095+ return rejected;
10921096}
10931097
10941098bool OpenGLRenderer::clipRect (float left, float top, float right, float bottom, SkRegion::Op op) {
0 commit comments