summaryrefslogtreecommitdiffstats
path: root/libs/hwui
diff options
context:
space:
mode:
authorTom Hudson <tomhudson@google.com>2015-06-24 09:13:50 -0400
committerTom Hudson <tomhudson@google.com>2015-06-24 10:43:16 -0400
commit90fb1f6732a610ad5ff6acdb3bd9ae392c8eac82 (patch)
tree6de48ca292004cd9e3e0d06b9daf2da4d78a3829 /libs/hwui
parent82e595fd6e3a9438b090106c226bb2f8bb2a6254 (diff)
downloadframeworks_base-90fb1f6732a610ad5ff6acdb3bd9ae392c8eac82.zip
frameworks_base-90fb1f6732a610ad5ff6acdb3bd9ae392c8eac82.tar.gz
frameworks_base-90fb1f6732a610ad5ff6acdb3bd9ae392c8eac82.tar.bz2
Sync canvas proxy CTM (b/21945972)
SkiaCanvasProxy was being created with an identity transform, ignoring any transform that may have been applied in Java (or C++) to the android graphics Canvas it was proxy for. This CL makes sure the DisplayListCanvas transform is propagated to the Proxy every time asSkCanvas() is called. We could instead move the code to the SkiaCanvasProxy constructor if we got rid of the cached proxy on DisplayListCanvas; nobody's using the proxy heavily enough that that should be a performance hit at this time. BUG:21945972 R=djsollen@google.com Change-Id: I99ed1563802a2449bb9939cb67976cd60dd8611c
Diffstat (limited to 'libs/hwui')
-rw-r--r--libs/hwui/Canvas.h4
-rw-r--r--libs/hwui/DisplayListCanvas.cpp8
2 files changed, 12 insertions, 0 deletions
diff --git a/libs/hwui/Canvas.h b/libs/hwui/Canvas.h
index aa24673..562bb80 100644
--- a/libs/hwui/Canvas.h
+++ b/libs/hwui/Canvas.h
@@ -47,6 +47,10 @@ public:
* It is useful for testing and clients (e.g. Picture/Movie) that expect to
* draw their contents into an SkCanvas.
*
+ * The SkCanvas returned is *only* valid until another Canvas call is made
+ * that would change state (e.g. matrix or clip). Clients of asSkCanvas()
+ * are responsible for *not* persisting this pointer.
+ *
* Further, the returned SkCanvas should NOT be unref'd and is valid until
* this canvas is destroyed or a new bitmap is set.
*/
diff --git a/libs/hwui/DisplayListCanvas.cpp b/libs/hwui/DisplayListCanvas.cpp
index 843c412..1988f5e 100644
--- a/libs/hwui/DisplayListCanvas.cpp
+++ b/libs/hwui/DisplayListCanvas.cpp
@@ -99,6 +99,14 @@ SkCanvas* DisplayListCanvas::asSkCanvas() {
if (!mSkiaCanvasProxy) {
mSkiaCanvasProxy.reset(new SkiaCanvasProxy(this));
}
+
+ // SkCanvas instances default to identity transform, but should inherit
+ // the state of this Canvas; if this code was in the SkiaCanvasProxy
+ // constructor, we couldn't cache mSkiaCanvasProxy.
+ SkMatrix parentTransform;
+ getMatrix(&parentTransform);
+ mSkiaCanvasProxy.get()->setMatrix(parentTransform);
+
return mSkiaCanvasProxy.get();
}