summaryrefslogtreecommitdiff
path: root/libs/hwui/renderthread/CanvasContext.cpp
diff options
context:
space:
mode:
authorChris Craik <ccraik@google.com>2015-10-05 13:00:52 -0700
committerChris Craik <ccraik@google.com>2015-10-14 16:10:40 -0700
commitb565df13a9e5c7b1d7d93bdfa4a793752d66d3cc (patch)
tree4a2dadd3b2c95663c23a626eff75962a0b8d4ce2 /libs/hwui/renderthread/CanvasContext.cpp
parentb08949151f8dfc7a72ea6696f2e6067c2b1643bb (diff)
Initial commit of new Canvas operation recording / replay
Done: - drawRect, drawBitmap, drawColor, drawPaint, drawRenderNode, drawRegion - Recording with new DisplayList format - batching & reordering - Stateless op reorder - Stateless op rendering - Frame lifecycle (clear, geterror, cleanup) Not done: - SaveLayer (clipped and unclipped) - HW layers - Complex clipping - Ripple projection - Z reordering - Z shadows - onDefer prefetching (text + task kickoff) - round rect clip - linear allocation for std collections - AssetAtlas support Change-Id: Iaf98c1a3aeab5fa47cc8f9c6d964420abc0e7691
Diffstat (limited to 'libs/hwui/renderthread/CanvasContext.cpp')
-rw-r--r--libs/hwui/renderthread/CanvasContext.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp
index 38f6e539693e..e1d8abdd7034 100644
--- a/libs/hwui/renderthread/CanvasContext.cpp
+++ b/libs/hwui/renderthread/CanvasContext.cpp
@@ -28,6 +28,11 @@
#include "renderstate/Stencil.h"
#include "protos/hwui.pb.h"
+#if HWUI_NEW_OPS
+#include "BakedOpRenderer.h"
+#include "OpReorderer.h"
+#endif
+
#include <cutils/properties.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <private/hwui/DrawGlInfo.h>
@@ -121,9 +126,11 @@ void CanvasContext::setSwapBehavior(SwapBehavior swapBehavior) {
bool CanvasContext::initialize(ANativeWindow* window) {
setSurface(window);
+#if !HWUI_NEW_OPS
if (mCanvas) return false;
mCanvas = new OpenGLRenderer(mRenderThread.renderState());
mCanvas->initProperties();
+#endif
return true;
}
@@ -162,11 +169,13 @@ void CanvasContext::makeCurrent() {
}
void CanvasContext::processLayerUpdate(DeferredLayerUpdater* layerUpdater) {
+#if !HWUI_NEW_OPS
bool success = layerUpdater->apply();
LOG_ALWAYS_FATAL_IF(!success, "Failed to update layer!");
if (layerUpdater->backingLayer()->deferredUpdateScheduled) {
mCanvas->pushLayerUpdate(layerUpdater->backingLayer());
}
+#endif
}
static bool wasSkipped(FrameInfo* info) {
@@ -239,8 +248,10 @@ void CanvasContext::notifyFramePending() {
}
void CanvasContext::draw() {
+#if !HWUI_NEW_OPS
LOG_ALWAYS_FATAL_IF(!mCanvas || mEglSurface == EGL_NO_SURFACE,
"drawRenderNode called on a context with no canvas or surface!");
+#endif
SkRect dirty;
mDamageAccumulator.finish(&dirty);
@@ -254,6 +265,8 @@ void CanvasContext::draw() {
mCurrentFrameInfo->markIssueDrawCommandsStart();
Frame frame = mEglManager.beginFrame(mEglSurface);
+
+#if !HWUI_NEW_OPS
if (frame.width() != mCanvas->getViewportWidth()
|| frame.height() != mCanvas->getViewportHeight()) {
// can't rely on prior content of window if viewport size changes
@@ -417,6 +430,16 @@ void CanvasContext::draw() {
// Even if we decided to cancel the frame, from the perspective of jank
// metrics the frame was swapped at this point
mCurrentFrameInfo->markSwapBuffers();
+#else
+ OpReorderer reorderer;
+ reorderer.defer(frame.width(), frame.height(), mRenderNodes);
+ BakedOpRenderer::Info info(Caches::getInstance(), mRenderThread.renderState(),
+ frame.width(), frame.height(), mOpaque);
+ reorderer.replayBakedOps<BakedOpRenderer>(&info);
+
+ bool drew = info.didDraw;
+ SkRect screenDirty = SkRect::MakeWH(frame.width(), frame.height());
+#endif
if (drew) {
if (CC_UNLIKELY(!mEglManager.swapBuffers(frame, screenDirty))) {