diff options
author | Derek Sollenberger <djsollen@google.com> | 2013-02-28 11:18:50 -0500 |
---|---|---|
committer | Derek Sollenberger <djsollen@google.com> | 2013-02-28 11:18:50 -0500 |
commit | 5b6591c1d058a2c8008ba6f77ee0e978a84b78e9 (patch) | |
tree | dd9c52c32e6f37217d78b9df3d93a945c61d2bed /core/jni/android | |
parent | c732976e6b40be5a23eee2df2bff23101abc1f91 (diff) | |
download | frameworks_base-5b6591c1d058a2c8008ba6f77ee0e978a84b78e9.zip frameworks_base-5b6591c1d058a2c8008ba6f77ee0e978a84b78e9.tar.gz frameworks_base-5b6591c1d058a2c8008ba6f77ee0e978a84b78e9.tar.bz2 |
fix issue when replacement bitmap is larger than original.
getTotalClip() returns the canvas bounds even if no explicit clip
was set. This CL fixes that issue by only transfering clips that
were explicitly set to the new canvas.
bug: 8255582
Change-Id: I0144d430e7718151ad93d988fcf20b412f74b256
Diffstat (limited to 'core/jni/android')
-rw-r--r-- | core/jni/android/graphics/Canvas.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/core/jni/android/graphics/Canvas.cpp b/core/jni/android/graphics/Canvas.cpp index 6410bc3..6640555 100644 --- a/core/jni/android/graphics/Canvas.cpp +++ b/core/jni/android/graphics/Canvas.cpp @@ -54,6 +54,21 @@ static uint32_t get_thread_msec() { namespace android { +class ClipCopier : public SkCanvas::ClipVisitor { +public: + ClipCopier(SkCanvas* dstCanvas) : m_dstCanvas(dstCanvas) {} + + virtual void clipRect(const SkRect& rect, SkRegion::Op op, bool antialias) { + m_dstCanvas->clipRect(rect, op, antialias); + } + virtual void clipPath(const SkPath& path, SkRegion::Op op, bool antialias) { + m_dstCanvas->clipPath(path, op, antialias); + } + +private: + SkCanvas* m_dstCanvas; +}; + class SkCanvasGlue { public: @@ -68,13 +83,15 @@ public: static void copyCanvasState(JNIEnv* env, jobject clazz, SkCanvas* srcCanvas, SkCanvas* dstCanvas) { if (srcCanvas && dstCanvas) { + dstCanvas->setMatrix(srcCanvas->getTotalMatrix()); if (NULL != srcCanvas->getDevice() && NULL != dstCanvas->getDevice()) { - dstCanvas->clipRegion(srcCanvas->getTotalClip()); + ClipCopier copier(dstCanvas); + srcCanvas->replayClips(&copier); } - dstCanvas->setMatrix(srcCanvas->getTotalMatrix()); } } + static void freeCaches(JNIEnv* env, jobject) { // these are called in no particular order SkImageRef_GlobalPool::SetRAMUsed(0); |