@@ -313,6 +313,7 @@ status_t OpenGLRenderer::callDrawGLFunction(Functor* functor, Rect& dirty) {
313313 interrupt ();
314314 detachFunctor (functor);
315315
316+ mCaches .enableScissor ();
316317 if (mDirtyClip ) {
317318 setScissorFromClip ();
318319 }
@@ -982,7 +983,7 @@ void OpenGLRenderer::clearLayerRegions() {
982983 // The list contains bounds that have already been clipped
983984 // against their initial clip rect, and the current clip
984985 // is likely different so we need to disable clipping here
985- mCaches .disableScissor ();
986+ bool scissorChanged = mCaches .disableScissor ();
986987
987988 Vertex mesh[count * 6 ];
988989 Vertex* vertex = mesh;
@@ -1009,6 +1010,8 @@ void OpenGLRenderer::clearLayerRegions() {
10091010 setupDrawVertices (&mesh[0 ].position [0 ]);
10101011
10111012 glDrawArrays (GL_TRIANGLES, 0 , count * 6 );
1013+
1014+ if (scissorChanged) mCaches .enableScissor ();
10121015 } else {
10131016 for (uint32_t i = 0 ; i < count; i++) {
10141017 delete mLayers .itemAt (i);
@@ -1065,16 +1068,31 @@ void OpenGLRenderer::setScissorFromClip() {
10651068 Rect clip (*mSnapshot ->clipRect );
10661069 clip.snapToPixelBoundaries ();
10671070
1068- mCaches .setScissor (clip.left , mSnapshot ->height - clip.bottom ,
1069- clip.getWidth (), clip.getHeight ());
1070-
1071- mDirtyClip = false ;
1071+ if ( mCaches .setScissor (clip.left , mSnapshot ->height - clip.bottom ,
1072+ clip.getWidth (), clip.getHeight ())) {
1073+ mDirtyClip = false ;
1074+ }
10721075}
10731076
10741077const Rect& OpenGLRenderer::getClipBounds () {
10751078 return mSnapshot ->getLocalClip ();
10761079}
10771080
1081+ bool OpenGLRenderer::quickRejectNoScissor (float left, float top, float right, float bottom) {
1082+ if (mSnapshot ->isIgnored ()) {
1083+ return true ;
1084+ }
1085+
1086+ Rect r (left, top, right, bottom);
1087+ mSnapshot ->transform ->mapRect (r);
1088+ r.snapToPixelBoundaries ();
1089+
1090+ Rect clipRect (*mSnapshot ->clipRect );
1091+ clipRect.snapToPixelBoundaries ();
1092+
1093+ return !clipRect.intersects (r);
1094+ }
1095+
10781096bool OpenGLRenderer::quickReject (float left, float top, float right, float bottom) {
10791097 if (mSnapshot ->isIgnored ()) {
10801098 return true ;
@@ -1112,6 +1130,8 @@ Rect* OpenGLRenderer::getClipRect() {
11121130// /////////////////////////////////////////////////////////////////////////////
11131131
11141132void OpenGLRenderer::setupDraw (bool clear) {
1133+ // TODO: It would be best if we could do this before quickReject()
1134+ // changes the scissor test state
11151135 if (clear) clearLayerRegions ();
11161136 if (mDirtyClip ) {
11171137 setScissorFromClip ();
0 commit comments