From 6a9368d41154890b6c316fdae704bf56ca4c70cc Mon Sep 17 00:00:00 2001 From: "scroggo@google.com" Date: Wed, 22 Aug 2012 16:19:52 +0000 Subject: [PATCH] SkBitmap::scrollRect changes pixels, but only if not immutable. scrollRect will now return false if the bitmap is immutable, and call notifyPixelsChanged when changing the pixels. This will give the bitmap a new generation ID. Review URL: https://codereview.appspot.com/6480046 git-svn-id: http://skia.googlecode.com/svn/trunk@5230 2bbb7eff-a529-9590-31e7-b0007b416f81 --- include/core/SkBitmap.h | 3 ++- src/core/SkBitmap_scroll.cpp | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h index eba3e0b..c2ef7b5 100644 --- a/include/core/SkBitmap.h +++ b/include/core/SkBitmap.h @@ -395,7 +395,8 @@ public: /** Scroll (a subset of) the contents of this bitmap by dx/dy. If there are no pixels allocated (i.e. getPixels() returns null) the method will - still update the inval region (if present). + still update the inval region (if present). If the bitmap is immutable, + do nothing and return false. @param subset The subset of the bitmap to scroll/move. To scroll the entire contents, specify [0, 0, width, height] or just diff --git a/src/core/SkBitmap_scroll.cpp b/src/core/SkBitmap_scroll.cpp index 54110e8..de4725b 100644 --- a/src/core/SkBitmap_scroll.cpp +++ b/src/core/SkBitmap_scroll.cpp @@ -11,6 +11,10 @@ bool SkBitmap::scrollRect(const SkIRect* subset, int dx, int dy, SkRegion* inval) const { + if (this->isImmutable()) { + return false; + } + if (NULL != subset) { SkBitmap tmp; @@ -113,5 +117,7 @@ bool SkBitmap::scrollRect(const SkIRect* subset, int dx, int dy, dst += rowBytes; src += rowBytes; } + + this->notifyPixelsChanged(); return true; } -- 2.7.4