summaryrefslogtreecommitdiffstats
path: root/cc/resources/ui_resource_bitmap.cc
diff options
context:
space:
mode:
authorccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-26 10:05:03 +0000
committerccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-26 10:05:03 +0000
commitf6668c890b01c37a5b90433c4cf2f43f85c3050a (patch)
tree5445baacd6a82eadeab6f44104ab1bfa64721b12 /cc/resources/ui_resource_bitmap.cc
parent286dd793164b6cccccf6ff44c0500a71cc7dc0ea (diff)
downloadchromium_src-f6668c890b01c37a5b90433c4cf2f43f85c3050a.zip
chromium_src-f6668c890b01c37a5b90433c4cf2f43f85c3050a.tar.gz
chromium_src-f6668c890b01c37a5b90433c4cf2f43f85c3050a.tar.bz2
[cc] Don't access pixels without a lock
Fix a bug where we don't lock a nine patch layer's pixels before accessing them. BUG=296830 Review URL: https://codereview.chromium.org/24490002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225433 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/resources/ui_resource_bitmap.cc')
-rw-r--r--cc/resources/ui_resource_bitmap.cc19
1 files changed, 13 insertions, 6 deletions
diff --git a/cc/resources/ui_resource_bitmap.cc b/cc/resources/ui_resource_bitmap.cc
index 2acbd95..86acfa5 100644
--- a/cc/resources/ui_resource_bitmap.cc
+++ b/cc/resources/ui_resource_bitmap.cc
@@ -10,12 +10,6 @@
namespace cc {
-uint8_t* UIResourceBitmap::GetPixels() const {
- if (!pixel_ref_)
- return NULL;
- return static_cast<uint8_t*>(pixel_ref_->pixels());
-}
-
void UIResourceBitmap::Create(const skia::RefPtr<SkPixelRef>& pixel_ref,
UIResourceFormat format,
UIResourceWrapMode wrap_mode,
@@ -45,4 +39,17 @@ UIResourceBitmap::UIResourceBitmap(const SkBitmap& skbitmap,
UIResourceBitmap::~UIResourceBitmap() {}
+AutoLockUIResourceBitmap::AutoLockUIResourceBitmap(
+ const UIResourceBitmap& bitmap) : bitmap_(bitmap) {
+ bitmap_.pixel_ref_->lockPixels();
+}
+
+AutoLockUIResourceBitmap::~AutoLockUIResourceBitmap() {
+ bitmap_.pixel_ref_->unlockPixels();
+}
+
+const uint8_t* AutoLockUIResourceBitmap::GetPixels() const {
+ return static_cast<const uint8_t*>(bitmap_.pixel_ref_->pixels());
+}
+
} // namespace cc