diff options
author | 2014-07-29 10:35:13 -0700 | |
---|---|---|
committer | 2014-07-29 17:42:22 +0000 | |
commit | 62d307c2402777d5e53b4590af5f32f8c55afd81 (patch) | |
tree | fbf89a15003e9e4e3b665bd271c41693dc992dbe | |
parent | f4bf67012b2109ead9a4cb9c4407563fc3671255 (diff) |
Fix behavior of stencil clipping within clearLayerRegions
bug:16376960
The draw within clearLayerRegions should never be affected by the
current stencil clip, since it's just ensuring that the content of the
layer is cleared, and not doing real content drawing.
Also, add optional verbose GL event logging
Change-Id: I538b1bc631fc091340b76e12db6af0c219851b57
-rw-r--r-- | libs/hwui/Debug.h | 3 | ||||
-rwxr-xr-x | libs/hwui/OpenGLRenderer.cpp | 54 | ||||
-rwxr-xr-x | libs/hwui/OpenGLRenderer.h | 5 | ||||
-rw-r--r-- | libs/hwui/Rect.h | 2 | ||||
-rw-r--r-- | libs/hwui/StatefulBaseRenderer.cpp | 1 |
5 files changed, 56 insertions, 9 deletions
diff --git a/libs/hwui/Debug.h b/libs/hwui/Debug.h index d6dc6ad2d67c..5808aaca76be 100644 --- a/libs/hwui/Debug.h +++ b/libs/hwui/Debug.h @@ -82,6 +82,9 @@ // Turn on to insert an event marker for each display list op #define DEBUG_DISPLAY_LIST_OPS_AS_EVENTS 0 +// Turn on to insert detailed event markers +#define DEBUG_DETAILED_EVENTS 0 + // Turn on to highlight drawing batches and merged batches with different colors #define DEBUG_MERGE_BEHAVIOR 0 diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 41f89c254c14..de777f0f538d 100755 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -45,6 +45,12 @@ #include "Vector.h" #include "VertexBuffer.h" +#if DEBUG_DETAILED_EVENTS + #define EVENT_LOGD(...) eventMarkDEBUG(__VA_ARGS__) +#else + #define EVENT_LOGD(...) +#endif + namespace android { namespace uirenderer { @@ -389,6 +395,21 @@ status_t OpenGLRenderer::callDrawGLFunction(Functor* functor, Rect& dirty) { // Debug /////////////////////////////////////////////////////////////////////////////// +void OpenGLRenderer::eventMarkDEBUG(const char* fmt, ...) const { +#if DEBUG_DETAILED_EVENTS + const int BUFFER_SIZE = 256; + va_list ap; + char buf[BUFFER_SIZE]; + + va_start(ap, fmt); + vsnprintf(buf, BUFFER_SIZE, fmt, ap); + va_end(ap); + + eventMark(buf); +#endif +} + + void OpenGLRenderer::eventMark(const char* name) const { mCaches.eventMark(0, name); } @@ -977,7 +998,13 @@ void OpenGLRenderer::drawTextureLayer(Layer* layer, const Rect& rect) { } void OpenGLRenderer::composeLayerRect(Layer* layer, const Rect& rect, bool swap) { - if (!layer->isTextureLayer()) { + if (layer->isTextureLayer()) { + EVENT_LOGD("composeTextureLayerRect"); + resetDrawTextureTexCoords(0.0f, 1.0f, 1.0f, 0.0f); + drawTextureLayer(layer, rect); + resetDrawTextureTexCoords(0.0f, 0.0f, 1.0f, 1.0f); + } else { + EVENT_LOGD("composeHardwareLayerRect"); const Rect& texCoords = layer->texCoords; resetDrawTextureTexCoords(texCoords.left, texCoords.top, texCoords.right, texCoords.bottom); @@ -1012,10 +1039,6 @@ void OpenGLRenderer::composeLayerRect(Layer* layer, const Rect& rect, bool swap) GL_TRIANGLE_STRIP, gMeshCount, swap, swap || simpleTransform); resetDrawTextureTexCoords(0.0f, 0.0f, 1.0f, 1.0f); - } else { - resetDrawTextureTexCoords(0.0f, 1.0f, 1.0f, 0.0f); - drawTextureLayer(layer, rect); - resetDrawTextureTexCoords(0.0f, 0.0f, 1.0f, 1.0f); } } @@ -1115,6 +1138,7 @@ void OpenGLRenderer::composeLayerRegion(Layer* layer, const Rect& rect) { return; } + EVENT_LOGD("composeLayerRegion"); // standard Region based draw size_t count; const android::Rect* rects; @@ -1288,6 +1312,7 @@ void OpenGLRenderer::clearLayerRegions() { if (count == 0) return; if (!currentSnapshot()->isIgnored()) { + EVENT_LOGD("clearLayerRegions"); // Doing several glScissor/glClear here can negatively impact // GPUs with a tiler architecture, instead we draw quads with // the Clear blending mode @@ -1465,6 +1490,8 @@ void OpenGLRenderer::attachStencilBufferToLayer(Layer* layer) { void OpenGLRenderer::setStencilFromClip() { if (!mCaches.debugOverdraw) { if (!currentSnapshot()->clipRegion->isEmpty()) { + EVENT_LOGD("setStencilFromClip - enabling"); + // NOTE: The order here is important, we must set dirtyClip to false // before any draw call to avoid calling back into this method mDirtyClip = false; @@ -1510,6 +1537,7 @@ void OpenGLRenderer::setStencilFromClip() { drawRegionRects(*(currentSnapshot()->clipRegion), paint); } } else { + EVENT_LOGD("setStencilFromClip - disabling"); mCaches.stencil.disable(); } } @@ -1561,17 +1589,24 @@ void OpenGLRenderer::debugClip() { // Drawing commands /////////////////////////////////////////////////////////////////////////////// -void OpenGLRenderer::setupDraw(bool clear) { +void OpenGLRenderer::setupDraw(bool clearLayer) { // TODO: It would be best if we could do this before quickRejectSetupScissor() // changes the scissor test state - if (clear) clearLayerRegions(); + if (clearLayer) clearLayerRegions(); // Make sure setScissor & setStencil happen at the beginning of // this method if (mDirtyClip) { if (mCaches.scissorEnabled) { setScissorFromClip(); } - setStencilFromClip(); + + if (clearLayer) { + setStencilFromClip(); + } else { + // While clearing layer, force disable stencil buffer, since + // it's invalid to stencil-clip *during* the layer clear + mCaches.stencil.disable(); + } } mDescription.reset(); @@ -2964,6 +2999,9 @@ status_t OpenGLRenderer::drawLayer(Layer* layer, float x, float y) { return DrawGlInfo::kStatusDone; } + EVENT_LOGD("drawLayer," RECT_STRING ", clipRequired %d", x, y, + x + layer->layer.getWidth(), y + layer->layer.getHeight(), clipRequired); + updateLayer(layer, true); mCaches.setScissorEnabled(mScissorOptimizationDisabled || clipRequired); diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h index f698b457ebd8..3bc591f45e63 100755 --- a/libs/hwui/OpenGLRenderer.h +++ b/libs/hwui/OpenGLRenderer.h @@ -256,6 +256,11 @@ public: void eventMark(const char* name) const; /** + * Inserts a formatted event marker in the stream of GL commands. + */ + void eventMarkDEBUG(const char *fmt, ...) const; + + /** * Inserts a named group marker in the stream of GL commands. This marker * can be used by tools to group commands into logical groups. A call to * this method must always be followed later on by a call to endMark(). diff --git a/libs/hwui/Rect.h b/libs/hwui/Rect.h index 9311f992760c..13265a96b05c 100644 --- a/libs/hwui/Rect.h +++ b/libs/hwui/Rect.h @@ -27,7 +27,7 @@ namespace android { namespace uirenderer { -#define RECT_STRING "%7.2f %7.2f %7.2f %7.2f" +#define RECT_STRING "%5.2f %5.2f %5.2f %5.2f" #define RECT_ARGS(r) \ (r).left, (r).top, (r).right, (r).bottom #define SK_RECT_ARGS(r) \ diff --git a/libs/hwui/StatefulBaseRenderer.cpp b/libs/hwui/StatefulBaseRenderer.cpp index 140c6e82f538..473005cf2c93 100644 --- a/libs/hwui/StatefulBaseRenderer.cpp +++ b/libs/hwui/StatefulBaseRenderer.cpp @@ -178,6 +178,7 @@ bool StatefulBaseRenderer::clipPath(const SkPath* path, SkRegion::Op op) { SkRegion region; region.setPath(transformed, clip); + // region is the transformed input path, masked by the previous clip mDirtyClip |= mSnapshot->clipRegionTransformed(region, op); return !mSnapshot->clipRect->isEmpty(); } |