diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/DisplayListRenderer.cpp | 13 | ||||
-rw-r--r-- | libs/hwui/DisplayListRenderer.h | 12 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 49 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.h | 12 | ||||
-rw-r--r-- | libs/hwui/ProgramCache.h | 2 |
5 files changed, 40 insertions, 48 deletions
diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp index 737fa02..868290b 100644 --- a/libs/hwui/DisplayListRenderer.cpp +++ b/libs/hwui/DisplayListRenderer.cpp @@ -285,9 +285,12 @@ bool DisplayList::replay(OpenGLRenderer& renderer, Rect& dirty, uint32_t level) break; case DrawDisplayList: { DisplayList* displayList = getDisplayList(); - DISPLAY_LIST_LOGD("%s%s %p, %d", (char*) indent, OP_NAMES[op], - displayList, level + 1); - needsInvalidate |= renderer.drawDisplayList(displayList, dirty, level + 1); + uint32_t width = getUInt(); + uint32_t height = getUInt(); + DISPLAY_LIST_LOGD("%s%s %p, %dx%d, %d", (char*) indent, OP_NAMES[op], + displayList, width, height, level + 1); + needsInvalidate |= renderer.drawDisplayList(displayList, width, height, + dirty, level + 1); } break; case DrawLayer: { @@ -674,11 +677,13 @@ bool DisplayListRenderer::clipRect(float left, float top, float right, float bot return OpenGLRenderer::clipRect(left, top, right, bottom, op); } -bool DisplayListRenderer::drawDisplayList(DisplayList* displayList, Rect& dirty, uint32_t level) { +bool DisplayListRenderer::drawDisplayList(DisplayList* displayList, + uint32_t width, uint32_t height, Rect& dirty, uint32_t level) { // dirty is an out parameter and should not be recorded, // it matters only when replaying the display list addOp(DisplayList::DrawDisplayList); addDisplayList(displayList); + addSize(width, height); return false; } diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h index f24545d..6fc315c 100644 --- a/libs/hwui/DisplayListRenderer.h +++ b/libs/hwui/DisplayListRenderer.h @@ -144,6 +144,10 @@ private: return mReader.readInt(); } + inline uint32_t getUInt() { + return mReader.readU32(); + } + SkMatrix* getMatrix() { return (SkMatrix*) getInt(); } @@ -238,7 +242,8 @@ public: bool clipRect(float left, float top, float right, float bottom, SkRegion::Op op); - bool drawDisplayList(DisplayList* displayList, Rect& dirty, uint32_t level = 0); + bool drawDisplayList(DisplayList* displayList, uint32_t width, uint32_t height, + Rect& dirty, uint32_t level = 0); void drawLayer(Layer* layer, float x, float y, SkPaint* paint); void drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint); void drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint); @@ -323,6 +328,11 @@ private: mWriter.writeInt(value); } + inline void addSize(uint32_t w, uint32_t h) { + mWriter.writeInt(w); + mWriter.writeInt(h); + } + void addInts(const int32_t* values, uint32_t count) { mWriter.writeInt(count); for (uint32_t i = 0; i < count; i++) { diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 1f65201..5d9522e 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -403,10 +403,7 @@ bool OpenGLRenderer::createLayer(sp<Snapshot> snapshot, float left, float top, // Window coordinates of the layer Rect bounds(left, top, right, bottom); - if (fboLayer) { - // Clear the previous layer regions before we change the viewport - clearLayerRegions(); - } else { + if (!fboLayer) { mSnapshot->transform->mapRect(bounds); // Layers only make sense if they are in the framebuffer's bounds @@ -464,8 +461,14 @@ bool OpenGLRenderer::createLayer(sp<Snapshot> snapshot, float left, float top, glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, bounds.left, snapshot->height - bounds.bottom, bounds.getWidth(), bounds.getHeight()); } - // Enqueue the buffer coordinates to clear the corresponding region later - mLayers.push(new Rect(bounds)); + + // Clear the framebuffer where the layer will draw + glScissor(bounds.left, mSnapshot->height - bounds.bottom, + bounds.getWidth(), bounds.getHeight()); + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + glClear(GL_COLOR_BUFFER_BIT); + + dirtyClip(); } } @@ -760,31 +763,6 @@ void OpenGLRenderer::dirtyLayerUnchecked(Rect& bounds, Region* region) { #endif } -void OpenGLRenderer::clearLayerRegions() { - if (mLayers.size() == 0 || mSnapshot->isIgnored()) return; - - Rect clipRect(*mSnapshot->clipRect); - clipRect.snapToPixelBoundaries(); - - for (uint32_t i = 0; i < mLayers.size(); i++) { - Rect* bounds = mLayers.itemAt(i); - if (clipRect.intersects(*bounds)) { - // Clear the framebuffer where the layer will draw - glScissor(bounds->left, mSnapshot->height - bounds->bottom, - bounds->getWidth(), bounds->getHeight()); - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - glClear(GL_COLOR_BUFFER_BIT); - - // Restore the clip - dirtyClip(); - } - - delete bounds; - } - - mLayers.clear(); -} - /////////////////////////////////////////////////////////////////////////////// // Transforms /////////////////////////////////////////////////////////////////////////////// @@ -870,7 +848,6 @@ bool OpenGLRenderer::clipRect(float left, float top, float right, float bottom, /////////////////////////////////////////////////////////////////////////////// void OpenGLRenderer::setupDraw() { - clearLayerRegions(); if (mDirtyClip) { setScissorFromClip(); } @@ -1064,12 +1041,18 @@ void OpenGLRenderer::finishDrawTexture() { // Drawing /////////////////////////////////////////////////////////////////////////////// -bool OpenGLRenderer::drawDisplayList(DisplayList* displayList, Rect& dirty, uint32_t level) { +bool OpenGLRenderer::drawDisplayList(DisplayList* displayList, uint32_t width, uint32_t height, + Rect& dirty, uint32_t level) { + if (quickReject(0.0f, 0.0f, width, height)) { + return false; + } + // All the usual checks and setup operations (quickReject, setupDraw, etc.) // will be performed by the display list itself if (displayList) { return displayList->replay(*this, dirty, level); } + return false; } diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h index 9d86388..7362473 100644 --- a/libs/hwui/OpenGLRenderer.h +++ b/libs/hwui/OpenGLRenderer.h @@ -96,7 +96,8 @@ public: bool quickReject(float left, float top, float right, float bottom); virtual bool clipRect(float left, float top, float right, float bottom, SkRegion::Op op); - virtual bool drawDisplayList(DisplayList* displayList, Rect& dirty, uint32_t level = 0); + virtual bool drawDisplayList(DisplayList* displayList, uint32_t width, uint32_t height, + Rect& dirty, uint32_t level = 0); virtual void drawLayer(Layer* layer, float x, float y, SkPaint* paint); virtual void drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint); virtual void drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, SkPaint* paint); @@ -247,12 +248,6 @@ private: void composeLayerRect(Layer* layer, const Rect& rect, bool swap = false); /** - * Clears all the regions corresponding to the current list of layers. - * This method MUST be invoked before any drawing operation. - */ - void clearLayerRegions(); - - /** * Mark the layer as dirty at the specified coordinates. The coordinates * are transformed with the supplied matrix. */ @@ -499,9 +494,6 @@ private: // Various caches Caches& mCaches; - // List of rectangles to clear due to calls to saveLayer() - Vector<Rect*> mLayers; - // Indentity matrix const mat4 mIdentity; diff --git a/libs/hwui/ProgramCache.h b/libs/hwui/ProgramCache.h index 3acd18a..ead5b92 100644 --- a/libs/hwui/ProgramCache.h +++ b/libs/hwui/ProgramCache.h @@ -231,9 +231,11 @@ struct ProgramDescription { * Logs the specified message followed by the key identifying this program. */ void log(const char* message) const { +#if DEBUG_PROGRAMS programid k = key(); PROGRAM_LOGD("%s (key = 0x%.8x%.8x)", message, uint32_t(k >> 32), uint32_t(k & 0xffffffff)); +#endif } private: |