summaryrefslogtreecommitdiffstats
path: root/libs/hwui/renderthread
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2015-04-28 13:50:00 -0700
committerJohn Reck <jreck@google.com>2015-04-28 13:50:00 -0700
commit240ff6246a29602539fd0295274e1c769e743a2e (patch)
treed40e9aaf5e0871ba6270b31ccfbae9468a09a1ab /libs/hwui/renderthread
parentba474807b3e46c1e6127d461214deafc22f53766 (diff)
downloadframeworks_base-240ff6246a29602539fd0295274e1c769e743a2e.zip
frameworks_base-240ff6246a29602539fd0295274e1c769e743a2e.tar.gz
frameworks_base-240ff6246a29602539fd0295274e1c769e743a2e.tar.bz2
Skip frames with no damage
Bug: 20464038 Change-Id: Iae3aa9baf1d03c3aa443a39373e2bbd4a3910fad
Diffstat (limited to 'libs/hwui/renderthread')
-rw-r--r--libs/hwui/renderthread/CanvasContext.cpp29
1 files changed, 26 insertions, 3 deletions
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);
}
}