Loading core/java/android/view/ThreadedRenderer.java +3 −0 Original line number Diff line number Diff line Loading @@ -255,6 +255,9 @@ public class ThreadedRenderer extends HardwareRenderer { mProfilingEnabled = wantProfiling; changed = true; } if (changed) { invalidateRoot(); } return changed; } Loading libs/hwui/DeferredDisplayList.cpp +5 −6 Original line number Diff line number Diff line Loading @@ -525,7 +525,7 @@ void DeferredDisplayList::addDrawOp(OpenGLRenderer& renderer, DrawOp* op) { deferInfo.mergeable &= !recordingComplexClip(); deferInfo.opaqueOverBounds &= !recordingComplexClip() && mSaveStack.isEmpty(); if (CC_LIKELY(mAvoidOverdraw) && mBatches.size() && if (mBatches.size() && state->mClipSideFlags != kClipSide_ConservativeFull && deferInfo.opaqueOverBounds && state->mBounds.contains(mBounds)) { // avoid overdraw by resetting drawing state + discarding drawing ops Loading Loading @@ -677,13 +677,12 @@ status_t DeferredDisplayList::flush(OpenGLRenderer& renderer, Rect& dirty) { DrawModifiers restoreDrawModifiers = renderer.getDrawModifiers(); renderer.save(SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag); if (CC_LIKELY(mAvoidOverdraw)) { for (unsigned int i = 1; i < mBatches.size(); i++) { if (mBatches[i] && mBatches[i]->coversBounds(mBounds)) { discardDrawingBatches(i - 1); } } } // NOTE: depth of the save stack at this point, before playback, should be reflected in // FLUSH_SAVE_STACK_DEPTH, so that save/restores match up correctly status |= replayBatchList(mBatches, renderer, dirty); Loading libs/hwui/DeferredDisplayList.h +2 −3 Original line number Diff line number Diff line Loading @@ -81,8 +81,8 @@ public: class DeferredDisplayList { friend class DeferStateStruct; // used to give access to allocator public: DeferredDisplayList(const Rect& bounds, bool avoidOverdraw = true) : mBounds(bounds), mAvoidOverdraw(avoidOverdraw) { DeferredDisplayList(const Rect& bounds) : mBounds(bounds) { clear(); } ~DeferredDisplayList() { clear(); } Loading Loading @@ -150,7 +150,6 @@ private: // layer space bounds of rendering Rect mBounds; const bool mAvoidOverdraw; /** * At defer time, stores the *defer time* savecount of save/saveLayer ops that were deferred, so Loading libs/hwui/DrawProfiler.cpp +35 −15 Original line number Diff line number Diff line Loading @@ -22,7 +22,8 @@ #define DEFAULT_MAX_FRAMES 128 #define RETURN_IF_DISABLED() if (CC_LIKELY(mType == kNone)) return #define RETURN_IF_PROFILING_DISABLED() if (CC_LIKELY(mType == kNone)) return #define RETURN_IF_DISABLED() if (CC_LIKELY(mType == kNone && !mShowDirtyRegions)) return #define NANOS_TO_MILLIS_FLOAT(nanos) ((nanos) * 0.000001f) Loading Loading @@ -64,7 +65,9 @@ DrawProfiler::DrawProfiler() , mPreviousTime(0) , mVerticalUnit(0) , mHorizontalUnit(0) , mThresholdStroke(0) { , mThresholdStroke(0) , mShowDirtyRegions(false) , mFlashToggle(false) { setDensity(1); } Loading @@ -82,27 +85,27 @@ void DrawProfiler::setDensity(float density) { } void DrawProfiler::startFrame(nsecs_t recordDurationNanos) { RETURN_IF_DISABLED(); RETURN_IF_PROFILING_DISABLED(); mData[mCurrentFrame].record = NANOS_TO_MILLIS_FLOAT(recordDurationNanos); mPreviousTime = systemTime(CLOCK_MONOTONIC); } void DrawProfiler::markPlaybackStart() { RETURN_IF_DISABLED(); RETURN_IF_PROFILING_DISABLED(); nsecs_t now = systemTime(CLOCK_MONOTONIC); mData[mCurrentFrame].prepare = NANOS_TO_MILLIS_FLOAT(now - mPreviousTime); mPreviousTime = now; } void DrawProfiler::markPlaybackEnd() { RETURN_IF_DISABLED(); RETURN_IF_PROFILING_DISABLED(); nsecs_t now = systemTime(CLOCK_MONOTONIC); mData[mCurrentFrame].playback = NANOS_TO_MILLIS_FLOAT(now - mPreviousTime); mPreviousTime = now; } void DrawProfiler::finishFrame() { RETURN_IF_DISABLED(); RETURN_IF_PROFILING_DISABLED(); nsecs_t now = systemTime(CLOCK_MONOTONIC); mData[mCurrentFrame].swapBuffers = NANOS_TO_MILLIS_FLOAT(now - mPreviousTime); mPreviousTime = now; Loading @@ -114,20 +117,31 @@ void DrawProfiler::unionDirty(SkRect* dirty) { // Not worth worrying about minimizing the dirty region for debugging, so just // dirty the entire viewport. if (dirty) { mDirtyRegion = *dirty; dirty->setEmpty(); } } void DrawProfiler::draw(OpenGLRenderer* canvas) { if (CC_LIKELY(mType != kBars)) { return; RETURN_IF_DISABLED(); if (mShowDirtyRegions) { mFlashToggle = !mFlashToggle; if (mFlashToggle) { SkPaint paint; paint.setColor(0x7fff0000); canvas->drawRect(mDirtyRegion.fLeft, mDirtyRegion.fTop, mDirtyRegion.fRight, mDirtyRegion.fBottom, &paint); } } if (mType == kBars) { prepareShapes(canvas->getViewportHeight()); drawGraph(canvas); drawCurrentFrame(canvas); drawThreshold(canvas); } } void DrawProfiler::createData() { if (mData) return; Loading Loading @@ -217,6 +231,7 @@ DrawProfiler::ProfileType DrawProfiler::loadRequestedProfileType() { } bool DrawProfiler::loadSystemProperties() { bool changed = false; ProfileType newType = loadRequestedProfileType(); if (newType != mType) { mType = newType; Loading @@ -225,13 +240,18 @@ bool DrawProfiler::loadSystemProperties() { } else { createData(); } return true; changed = true; } return false; bool showDirty = property_get_bool(PROPERTY_DEBUG_SHOW_DIRTY_REGIONS, false); if (showDirty != mShowDirtyRegions) { mShowDirtyRegions = showDirty; changed = true; } return changed; } void DrawProfiler::dumpData(int fd) { RETURN_IF_DISABLED(); RETURN_IF_PROFILING_DISABLED(); // This method logs the last N frames (where N is <= mDataSize) since the // last call to dumpData(). In other words if there's a dumpData(), draw frame, Loading libs/hwui/DrawProfiler.h +4 −0 Original line number Diff line number Diff line Loading @@ -88,6 +88,10 @@ private: * information. */ float** mRects; bool mShowDirtyRegions; SkRect mDirtyRegion; bool mFlashToggle; }; } /* namespace uirenderer */ Loading Loading
core/java/android/view/ThreadedRenderer.java +3 −0 Original line number Diff line number Diff line Loading @@ -255,6 +255,9 @@ public class ThreadedRenderer extends HardwareRenderer { mProfilingEnabled = wantProfiling; changed = true; } if (changed) { invalidateRoot(); } return changed; } Loading
libs/hwui/DeferredDisplayList.cpp +5 −6 Original line number Diff line number Diff line Loading @@ -525,7 +525,7 @@ void DeferredDisplayList::addDrawOp(OpenGLRenderer& renderer, DrawOp* op) { deferInfo.mergeable &= !recordingComplexClip(); deferInfo.opaqueOverBounds &= !recordingComplexClip() && mSaveStack.isEmpty(); if (CC_LIKELY(mAvoidOverdraw) && mBatches.size() && if (mBatches.size() && state->mClipSideFlags != kClipSide_ConservativeFull && deferInfo.opaqueOverBounds && state->mBounds.contains(mBounds)) { // avoid overdraw by resetting drawing state + discarding drawing ops Loading Loading @@ -677,13 +677,12 @@ status_t DeferredDisplayList::flush(OpenGLRenderer& renderer, Rect& dirty) { DrawModifiers restoreDrawModifiers = renderer.getDrawModifiers(); renderer.save(SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag); if (CC_LIKELY(mAvoidOverdraw)) { for (unsigned int i = 1; i < mBatches.size(); i++) { if (mBatches[i] && mBatches[i]->coversBounds(mBounds)) { discardDrawingBatches(i - 1); } } } // NOTE: depth of the save stack at this point, before playback, should be reflected in // FLUSH_SAVE_STACK_DEPTH, so that save/restores match up correctly status |= replayBatchList(mBatches, renderer, dirty); Loading
libs/hwui/DeferredDisplayList.h +2 −3 Original line number Diff line number Diff line Loading @@ -81,8 +81,8 @@ public: class DeferredDisplayList { friend class DeferStateStruct; // used to give access to allocator public: DeferredDisplayList(const Rect& bounds, bool avoidOverdraw = true) : mBounds(bounds), mAvoidOverdraw(avoidOverdraw) { DeferredDisplayList(const Rect& bounds) : mBounds(bounds) { clear(); } ~DeferredDisplayList() { clear(); } Loading Loading @@ -150,7 +150,6 @@ private: // layer space bounds of rendering Rect mBounds; const bool mAvoidOverdraw; /** * At defer time, stores the *defer time* savecount of save/saveLayer ops that were deferred, so Loading
libs/hwui/DrawProfiler.cpp +35 −15 Original line number Diff line number Diff line Loading @@ -22,7 +22,8 @@ #define DEFAULT_MAX_FRAMES 128 #define RETURN_IF_DISABLED() if (CC_LIKELY(mType == kNone)) return #define RETURN_IF_PROFILING_DISABLED() if (CC_LIKELY(mType == kNone)) return #define RETURN_IF_DISABLED() if (CC_LIKELY(mType == kNone && !mShowDirtyRegions)) return #define NANOS_TO_MILLIS_FLOAT(nanos) ((nanos) * 0.000001f) Loading Loading @@ -64,7 +65,9 @@ DrawProfiler::DrawProfiler() , mPreviousTime(0) , mVerticalUnit(0) , mHorizontalUnit(0) , mThresholdStroke(0) { , mThresholdStroke(0) , mShowDirtyRegions(false) , mFlashToggle(false) { setDensity(1); } Loading @@ -82,27 +85,27 @@ void DrawProfiler::setDensity(float density) { } void DrawProfiler::startFrame(nsecs_t recordDurationNanos) { RETURN_IF_DISABLED(); RETURN_IF_PROFILING_DISABLED(); mData[mCurrentFrame].record = NANOS_TO_MILLIS_FLOAT(recordDurationNanos); mPreviousTime = systemTime(CLOCK_MONOTONIC); } void DrawProfiler::markPlaybackStart() { RETURN_IF_DISABLED(); RETURN_IF_PROFILING_DISABLED(); nsecs_t now = systemTime(CLOCK_MONOTONIC); mData[mCurrentFrame].prepare = NANOS_TO_MILLIS_FLOAT(now - mPreviousTime); mPreviousTime = now; } void DrawProfiler::markPlaybackEnd() { RETURN_IF_DISABLED(); RETURN_IF_PROFILING_DISABLED(); nsecs_t now = systemTime(CLOCK_MONOTONIC); mData[mCurrentFrame].playback = NANOS_TO_MILLIS_FLOAT(now - mPreviousTime); mPreviousTime = now; } void DrawProfiler::finishFrame() { RETURN_IF_DISABLED(); RETURN_IF_PROFILING_DISABLED(); nsecs_t now = systemTime(CLOCK_MONOTONIC); mData[mCurrentFrame].swapBuffers = NANOS_TO_MILLIS_FLOAT(now - mPreviousTime); mPreviousTime = now; Loading @@ -114,20 +117,31 @@ void DrawProfiler::unionDirty(SkRect* dirty) { // Not worth worrying about minimizing the dirty region for debugging, so just // dirty the entire viewport. if (dirty) { mDirtyRegion = *dirty; dirty->setEmpty(); } } void DrawProfiler::draw(OpenGLRenderer* canvas) { if (CC_LIKELY(mType != kBars)) { return; RETURN_IF_DISABLED(); if (mShowDirtyRegions) { mFlashToggle = !mFlashToggle; if (mFlashToggle) { SkPaint paint; paint.setColor(0x7fff0000); canvas->drawRect(mDirtyRegion.fLeft, mDirtyRegion.fTop, mDirtyRegion.fRight, mDirtyRegion.fBottom, &paint); } } if (mType == kBars) { prepareShapes(canvas->getViewportHeight()); drawGraph(canvas); drawCurrentFrame(canvas); drawThreshold(canvas); } } void DrawProfiler::createData() { if (mData) return; Loading Loading @@ -217,6 +231,7 @@ DrawProfiler::ProfileType DrawProfiler::loadRequestedProfileType() { } bool DrawProfiler::loadSystemProperties() { bool changed = false; ProfileType newType = loadRequestedProfileType(); if (newType != mType) { mType = newType; Loading @@ -225,13 +240,18 @@ bool DrawProfiler::loadSystemProperties() { } else { createData(); } return true; changed = true; } return false; bool showDirty = property_get_bool(PROPERTY_DEBUG_SHOW_DIRTY_REGIONS, false); if (showDirty != mShowDirtyRegions) { mShowDirtyRegions = showDirty; changed = true; } return changed; } void DrawProfiler::dumpData(int fd) { RETURN_IF_DISABLED(); RETURN_IF_PROFILING_DISABLED(); // This method logs the last N frames (where N is <= mDataSize) since the // last call to dumpData(). In other words if there's a dumpData(), draw frame, Loading
libs/hwui/DrawProfiler.h +4 −0 Original line number Diff line number Diff line Loading @@ -88,6 +88,10 @@ private: * information. */ float** mRects; bool mShowDirtyRegions; SkRect mDirtyRegion; bool mFlashToggle; }; } /* namespace uirenderer */ Loading