Loading libs/hwui/Caches.cpp +24 −4 Original line number Diff line number Diff line Loading @@ -50,9 +50,9 @@ namespace uirenderer { Caches::Caches(): Singleton<Caches>(), mExtensions(Extensions::getInstance()), mInitialized(false) { init(); initFont(); initExtensions(); initConstraints(); initProperties(); initExtensions(); mDebugLevel = readDebugLevel(); ALOGD("Enabling debug mode %d", mDebugLevel); Loading Loading @@ -103,15 +103,21 @@ void Caches::initFont() { void Caches::initExtensions() { if (mExtensions.hasDebugMarker()) { eventMark = glInsertEventMarkerEXT; if ((drawDeferDisabled || drawReorderDisabled)) { startMark = glPushGroupMarkerEXT; endMark = glPopGroupMarkerEXT; } else { startMark = startMarkNull; endMark = endMarkNull; } } else { eventMark = eventMarkNull; startMark = startMarkNull; endMark = endMarkNull; } if (mExtensions.hasDebugLabel()) { if (mExtensions.hasDebugLabel() && (drawDeferDisabled || drawReorderDisabled)) { setLabel = glLabelObjectEXT; getLabel = glGetObjectLabelEXT; } else { Loading Loading @@ -164,6 +170,20 @@ bool Caches::initProperties() { debugStencilClip = kStencilHide; } if (property_get(PROPERTY_DISABLE_DRAW_DEFER, property, "false")) { drawDeferDisabled = !strcasecmp(property, "true"); INIT_LOGD(" Draw defer %s", drawDeferDisabled ? "disabled" : "enabled"); } else { INIT_LOGD(" Draw defer enabled"); } if (property_get(PROPERTY_DISABLE_DRAW_REORDER, property, "false")) { drawReorderDisabled = !strcasecmp(property, "true"); INIT_LOGD(" Draw reorder %s", drawReorderDisabled ? "disabled" : "enabled"); } else { INIT_LOGD(" Draw reorder enabled"); } return (prevDebugLayersUpdates != debugLayersUpdates) || (prevDebugOverdraw != debugOverdraw) || (prevDebugStencilClip != debugStencilClip); Loading libs/hwui/Caches.h +3 −0 Original line number Diff line number Diff line Loading @@ -240,6 +240,9 @@ public: Program* currentProgram; bool scissorEnabled; bool drawDeferDisabled; bool drawReorderDisabled; // VBO to draw with GLuint meshBuffer; Loading libs/hwui/DeferredDisplayList.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -146,6 +146,8 @@ status_t DeferredDisplayList::flush(OpenGLRenderer& renderer, Rect& dirty, int32 if (isEmpty()) return status; // nothing to flush DEFER_LOGD("--flushing"); renderer.eventMark("Flush"); DrawModifiers restoreDrawModifiers = renderer.getDrawModifiers(); int restoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag); int opCount = 0; Loading @@ -166,6 +168,7 @@ status_t DeferredDisplayList::flush(OpenGLRenderer& renderer, Rect& dirty, int32 } DEFER_LOGD("--flushed, drew %d batches (total %d ops)", mBatches.size(), opCount); renderer.restoreToCount(restoreTo); renderer.setDrawModifiers(restoreDrawModifiers); clear(); Loading libs/hwui/DisplayListOp.h +24 −1 Original line number Diff line number Diff line Loading @@ -147,7 +147,8 @@ public: if (!renderer.storeDisplayState(state)) { // op wasn't quick-rejected, so defer deferredList->add(this, renderer.disallowReorder()); deferredList->add(this, renderer.getCaches().drawReorderDisabled); onDrawOpDeferred(renderer); } return DrawGlInfo::kStatusDone; Loading @@ -156,6 +157,9 @@ public: virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level, bool caching, int multipliedAlpha) = 0; virtual void onDrawOpDeferred(OpenGLRenderer& renderer) { } // returns true if bounds exist virtual bool getLocalBounds(Rect& localBounds) { return false; } Loading Loading @@ -1081,6 +1085,12 @@ public: OP_LOG("Draw some text, %d bytes", mBytesCount); } virtual void onDrawOpDeferred(OpenGLRenderer& renderer) { SkPaint* paint = getPaint(renderer); FontRenderer& fontRenderer = renderer.getCaches().fontRenderer->getFontRenderer(paint); fontRenderer.precache(paint, mText, mCount, mat4::identity()); } virtual DeferredDisplayList::OpBatchId getBatchId() { return mPaint->getColor() == 0xff000000 ? DeferredDisplayList::kOpBatch_Text : Loading Loading @@ -1156,6 +1166,19 @@ public: mLocalBounds.set(x, mY + metrics.fTop, x + length, mY + metrics.fBottom); } /* * When this method is invoked the state field is initialized to have the * final rendering state. We can thus use it to process data as it will be * used at draw time. */ virtual void onDrawOpDeferred(OpenGLRenderer& renderer) { SkPaint* paint = getPaint(renderer); FontRenderer& fontRenderer = renderer.getCaches().fontRenderer->getFontRenderer(paint); const bool pureTranslate = state.mMatrix.isPureTranslate(); fontRenderer.precache(paint, mText, mCount, pureTranslate ? mat4::identity() : state.mMatrix); } virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level, bool caching, int multipliedAlpha) { return renderer.drawText(mText, mBytesCount, mCount, mX, mY, Loading libs/hwui/DisplayListRenderer.cpp +5 −21 Original line number Diff line number Diff line Loading @@ -403,11 +403,7 @@ status_t DisplayListRenderer::drawTextOnPath(const char* text, int bytesCount, i DrawOp* op = new (alloc()) DrawTextOnPathOp(text, bytesCount, count, path, hOffset, vOffset, paint); if (addDrawOp(op)) { // precache if draw operation is visible FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(paint); fontRenderer.precache(paint, text, count, mat4::identity()); } addDrawOp(op); return DrawGlInfo::kStatusDone; } Loading @@ -420,11 +416,7 @@ status_t DisplayListRenderer::drawPosText(const char* text, int bytesCount, int paint = refPaint(paint); DrawOp* op = new (alloc()) DrawPosTextOp(text, bytesCount, count, positions, paint); if (addDrawOp(op)) { // precache if draw operation is visible FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(paint); fontRenderer.precache(paint, text, count, mat4::identity()); } addDrawOp(op); return DrawGlInfo::kStatusDone; } Loading @@ -439,13 +431,7 @@ status_t DisplayListRenderer::drawText(const char* text, int bytesCount, int cou paint = refPaint(paint); DrawOp* op = new (alloc()) DrawTextOp(text, bytesCount, count, x, y, positions, paint, length); if (addDrawOp(op)) { // precache if draw operation is visible FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(paint); const bool pureTranslate = mSnapshot->transform->isPureTranslate(); fontRenderer.precache(paint, text, count, pureTranslate ? mat4::identity() : *mSnapshot->transform); } addDrawOp(op); return DrawGlInfo::kStatusDone; } Loading Loading @@ -515,17 +501,15 @@ void DisplayListRenderer::addStateOp(StateOp* op) { addOpInternal(op); } bool DisplayListRenderer::addDrawOp(DrawOp* op) { bool rejected = false; void DisplayListRenderer::addDrawOp(DrawOp* op) { Rect localBounds; if (op->getLocalBounds(localBounds)) { rejected = quickRejectNoScissor(localBounds.left, localBounds.top, bool rejected = quickRejectNoScissor(localBounds.left, localBounds.top, localBounds.right, localBounds.bottom); op->setQuickRejected(rejected); } mHasDrawOps = true; addOpInternal(op); return !rejected; } }; // namespace uirenderer Loading Loading
libs/hwui/Caches.cpp +24 −4 Original line number Diff line number Diff line Loading @@ -50,9 +50,9 @@ namespace uirenderer { Caches::Caches(): Singleton<Caches>(), mExtensions(Extensions::getInstance()), mInitialized(false) { init(); initFont(); initExtensions(); initConstraints(); initProperties(); initExtensions(); mDebugLevel = readDebugLevel(); ALOGD("Enabling debug mode %d", mDebugLevel); Loading Loading @@ -103,15 +103,21 @@ void Caches::initFont() { void Caches::initExtensions() { if (mExtensions.hasDebugMarker()) { eventMark = glInsertEventMarkerEXT; if ((drawDeferDisabled || drawReorderDisabled)) { startMark = glPushGroupMarkerEXT; endMark = glPopGroupMarkerEXT; } else { startMark = startMarkNull; endMark = endMarkNull; } } else { eventMark = eventMarkNull; startMark = startMarkNull; endMark = endMarkNull; } if (mExtensions.hasDebugLabel()) { if (mExtensions.hasDebugLabel() && (drawDeferDisabled || drawReorderDisabled)) { setLabel = glLabelObjectEXT; getLabel = glGetObjectLabelEXT; } else { Loading Loading @@ -164,6 +170,20 @@ bool Caches::initProperties() { debugStencilClip = kStencilHide; } if (property_get(PROPERTY_DISABLE_DRAW_DEFER, property, "false")) { drawDeferDisabled = !strcasecmp(property, "true"); INIT_LOGD(" Draw defer %s", drawDeferDisabled ? "disabled" : "enabled"); } else { INIT_LOGD(" Draw defer enabled"); } if (property_get(PROPERTY_DISABLE_DRAW_REORDER, property, "false")) { drawReorderDisabled = !strcasecmp(property, "true"); INIT_LOGD(" Draw reorder %s", drawReorderDisabled ? "disabled" : "enabled"); } else { INIT_LOGD(" Draw reorder enabled"); } return (prevDebugLayersUpdates != debugLayersUpdates) || (prevDebugOverdraw != debugOverdraw) || (prevDebugStencilClip != debugStencilClip); Loading
libs/hwui/Caches.h +3 −0 Original line number Diff line number Diff line Loading @@ -240,6 +240,9 @@ public: Program* currentProgram; bool scissorEnabled; bool drawDeferDisabled; bool drawReorderDisabled; // VBO to draw with GLuint meshBuffer; Loading
libs/hwui/DeferredDisplayList.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -146,6 +146,8 @@ status_t DeferredDisplayList::flush(OpenGLRenderer& renderer, Rect& dirty, int32 if (isEmpty()) return status; // nothing to flush DEFER_LOGD("--flushing"); renderer.eventMark("Flush"); DrawModifiers restoreDrawModifiers = renderer.getDrawModifiers(); int restoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag); int opCount = 0; Loading @@ -166,6 +168,7 @@ status_t DeferredDisplayList::flush(OpenGLRenderer& renderer, Rect& dirty, int32 } DEFER_LOGD("--flushed, drew %d batches (total %d ops)", mBatches.size(), opCount); renderer.restoreToCount(restoreTo); renderer.setDrawModifiers(restoreDrawModifiers); clear(); Loading
libs/hwui/DisplayListOp.h +24 −1 Original line number Diff line number Diff line Loading @@ -147,7 +147,8 @@ public: if (!renderer.storeDisplayState(state)) { // op wasn't quick-rejected, so defer deferredList->add(this, renderer.disallowReorder()); deferredList->add(this, renderer.getCaches().drawReorderDisabled); onDrawOpDeferred(renderer); } return DrawGlInfo::kStatusDone; Loading @@ -156,6 +157,9 @@ public: virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level, bool caching, int multipliedAlpha) = 0; virtual void onDrawOpDeferred(OpenGLRenderer& renderer) { } // returns true if bounds exist virtual bool getLocalBounds(Rect& localBounds) { return false; } Loading Loading @@ -1081,6 +1085,12 @@ public: OP_LOG("Draw some text, %d bytes", mBytesCount); } virtual void onDrawOpDeferred(OpenGLRenderer& renderer) { SkPaint* paint = getPaint(renderer); FontRenderer& fontRenderer = renderer.getCaches().fontRenderer->getFontRenderer(paint); fontRenderer.precache(paint, mText, mCount, mat4::identity()); } virtual DeferredDisplayList::OpBatchId getBatchId() { return mPaint->getColor() == 0xff000000 ? DeferredDisplayList::kOpBatch_Text : Loading Loading @@ -1156,6 +1166,19 @@ public: mLocalBounds.set(x, mY + metrics.fTop, x + length, mY + metrics.fBottom); } /* * When this method is invoked the state field is initialized to have the * final rendering state. We can thus use it to process data as it will be * used at draw time. */ virtual void onDrawOpDeferred(OpenGLRenderer& renderer) { SkPaint* paint = getPaint(renderer); FontRenderer& fontRenderer = renderer.getCaches().fontRenderer->getFontRenderer(paint); const bool pureTranslate = state.mMatrix.isPureTranslate(); fontRenderer.precache(paint, mText, mCount, pureTranslate ? mat4::identity() : state.mMatrix); } virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level, bool caching, int multipliedAlpha) { return renderer.drawText(mText, mBytesCount, mCount, mX, mY, Loading
libs/hwui/DisplayListRenderer.cpp +5 −21 Original line number Diff line number Diff line Loading @@ -403,11 +403,7 @@ status_t DisplayListRenderer::drawTextOnPath(const char* text, int bytesCount, i DrawOp* op = new (alloc()) DrawTextOnPathOp(text, bytesCount, count, path, hOffset, vOffset, paint); if (addDrawOp(op)) { // precache if draw operation is visible FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(paint); fontRenderer.precache(paint, text, count, mat4::identity()); } addDrawOp(op); return DrawGlInfo::kStatusDone; } Loading @@ -420,11 +416,7 @@ status_t DisplayListRenderer::drawPosText(const char* text, int bytesCount, int paint = refPaint(paint); DrawOp* op = new (alloc()) DrawPosTextOp(text, bytesCount, count, positions, paint); if (addDrawOp(op)) { // precache if draw operation is visible FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(paint); fontRenderer.precache(paint, text, count, mat4::identity()); } addDrawOp(op); return DrawGlInfo::kStatusDone; } Loading @@ -439,13 +431,7 @@ status_t DisplayListRenderer::drawText(const char* text, int bytesCount, int cou paint = refPaint(paint); DrawOp* op = new (alloc()) DrawTextOp(text, bytesCount, count, x, y, positions, paint, length); if (addDrawOp(op)) { // precache if draw operation is visible FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(paint); const bool pureTranslate = mSnapshot->transform->isPureTranslate(); fontRenderer.precache(paint, text, count, pureTranslate ? mat4::identity() : *mSnapshot->transform); } addDrawOp(op); return DrawGlInfo::kStatusDone; } Loading Loading @@ -515,17 +501,15 @@ void DisplayListRenderer::addStateOp(StateOp* op) { addOpInternal(op); } bool DisplayListRenderer::addDrawOp(DrawOp* op) { bool rejected = false; void DisplayListRenderer::addDrawOp(DrawOp* op) { Rect localBounds; if (op->getLocalBounds(localBounds)) { rejected = quickRejectNoScissor(localBounds.left, localBounds.top, bool rejected = quickRejectNoScissor(localBounds.left, localBounds.top, localBounds.right, localBounds.bottom); op->setQuickRejected(rejected); } mHasDrawOps = true; addOpInternal(op); return !rejected; } }; // namespace uirenderer Loading