diff options
author | John Reck <jreck@google.com> | 2015-04-29 20:10:25 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-04-29 20:10:26 +0000 |
commit | b2cec86a44f3fe937079b26827bdc031f5aec731 (patch) | |
tree | 47f60cfe1d3eda88a42e58f843a082cacd00863b /libs/hwui | |
parent | 05a56db39d26e1e6ee160e82b79df39c15d1804c (diff) | |
parent | 240ff6246a29602539fd0295274e1c769e743a2e (diff) | |
download | frameworks_base-b2cec86a44f3fe937079b26827bdc031f5aec731.zip frameworks_base-b2cec86a44f3fe937079b26827bdc031f5aec731.tar.gz frameworks_base-b2cec86a44f3fe937079b26827bdc031f5aec731.tar.bz2 |
Merge "Skip frames with no damage" into mnc-dev
Diffstat (limited to 'libs/hwui')
-rw-r--r-- | libs/hwui/FrameInfo.h | 5 | ||||
-rw-r--r-- | libs/hwui/renderthread/CanvasContext.cpp | 29 |
2 files changed, 31 insertions, 3 deletions
diff --git a/libs/hwui/FrameInfo.h b/libs/hwui/FrameInfo.h index 65daf03..c8189b8 100644 --- a/libs/hwui/FrameInfo.h +++ b/libs/hwui/FrameInfo.h @@ -53,6 +53,7 @@ enum class FrameInfoFlags { kWindowLayoutChanged = 1 << 0, kRTAnimation = 1 << 1, kSurfaceCanvas = 1 << 2, + kSkippedFrame = 1 << 3, }; MAKE_FLAGS_ENUM(FrameInfoFlags) @@ -101,6 +102,10 @@ public: set(FrameInfoIndex::kFrameCompleted) = systemTime(CLOCK_MONOTONIC); } + void addFlag(FrameInfoFlags flag) { + set(FrameInfoIndex::kFlags) |= static_cast<uint64_t>(flag); + } + int64_t operator[](FrameInfoIndex index) const { if (index == FrameInfoIndex::kNumIndexes) return 0; return mFrameInfo[static_cast<int>(index)]; diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp index 9237151..3de3086 100644 --- a/libs/hwui/renderthread/CanvasContext.cpp +++ b/libs/hwui/renderthread/CanvasContext.cpp @@ -27,12 +27,25 @@ #include "../OpenGLRenderer.h" #include <algorithm> +#include <cutils/properties.h> #include <private/hwui/DrawGlInfo.h> #include <strings.h> #define TRIM_MEMORY_COMPLETE 80 #define TRIM_MEMORY_UI_HIDDEN 20 +#define PROPERTY_SKIP_EMPTY_DAMAGE "debug.hwui.skip_empty_damage" + +static bool sInitialized = false; +static bool sSkipEmptyDamage = true; + +static void initGlobals() { + if (sInitialized) return; + sInitialized = true; + sSkipEmptyDamage = property_get_bool(PROPERTY_SKIP_EMPTY_DAMAGE, + sSkipEmptyDamage); +} + namespace android { namespace uirenderer { namespace renderthread { @@ -45,6 +58,9 @@ CanvasContext::CanvasContext(RenderThread& thread, bool translucent, , mAnimationContext(contextFactory->createAnimationContext(mRenderThread.timeLord())) , mRootRenderNode(rootRenderNode) , mJankTracker(thread.timeLord().frameIntervalNanos()) { + // Done lazily at first draw instead of at library load to avoid + // running pre-zygote fork + initGlobals(); mRenderThread.renderState().registerCanvasContext(this); mProfiler.setDensity(mRenderThread.mainDisplayInfo().density); } @@ -203,12 +219,17 @@ void CanvasContext::draw() { LOG_ALWAYS_FATAL_IF(!mCanvas || mEglSurface == EGL_NO_SURFACE, "drawRenderNode called on a context with no canvas or surface!"); - profiler().markPlaybackStart(); - mCurrentFrameInfo->markIssueDrawCommandsStart(); - SkRect dirty; mDamageAccumulator.finish(&dirty); + if (dirty.isEmpty() && sSkipEmptyDamage) { + mCurrentFrameInfo->addFlag(FrameInfoFlags::kSkippedFrame); + return; + } + + profiler().markPlaybackStart(); + mCurrentFrameInfo->markIssueDrawCommandsStart(); + EGLint width, height; mEglManager.beginFrame(mEglSurface, &width, &height); if (width != mCanvas->getViewportWidth() || height != mCanvas->getViewportHeight()) { @@ -277,6 +298,8 @@ void CanvasContext::doFrame() { prepareTree(info, frameInfo); if (info.out.canDrawThisFrame) { draw(); + } else { + mCurrentFrameInfo->addFlag(FrameInfoFlags::kSkippedFrame); } } |