Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Unified Diff: src/core/SkBitmap.cpp

Issue 22235002: Fix race condition when locking/unlocking pixels. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBitmap.cpp
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 2635e130666885e1b98ad35e99ac5ba85922d080..9a116dfc2ed511a90f35bb63f35377fdb824fd7b 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -340,7 +340,7 @@ SkPixelRef* SkBitmap::setPixelRef(SkPixelRef* pr, size_t offset) {
}
void SkBitmap::lockPixels() const {
- if (NULL != fPixelRef && 1 == ++fPixelLockCount) {
+ if (NULL != fPixelRef && 0 == sk_atomic_inc(&fPixelLockCount)) {
fPixelRef->lockPixels();
this->updatePixelsFromRef();
}
@@ -350,7 +350,7 @@ void SkBitmap::lockPixels() const {
void SkBitmap::unlockPixels() const {
SkASSERT(NULL == fPixelRef || fPixelLockCount > 0);
- if (NULL != fPixelRef && 0 == --fPixelLockCount) {
+ if (NULL != fPixelRef && 1 == sk_atomic_dec(&fPixelLockCount)) {
fPixelRef->unlockPixels();
this->updatePixelsFromRef();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698