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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2008 The Android Open Source Project 3 * Copyright 2008 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 } 333 }
334 fPixelRefOffset = offset; 334 fPixelRefOffset = offset;
335 this->updatePixelsFromRef(); 335 this->updatePixelsFromRef();
336 } 336 }
337 337
338 SkDEBUGCODE(this->validate();) 338 SkDEBUGCODE(this->validate();)
339 return pr; 339 return pr;
340 } 340 }
341 341
342 void SkBitmap::lockPixels() const { 342 void SkBitmap::lockPixels() const {
343 if (NULL != fPixelRef && 1 == ++fPixelLockCount) { 343 if (NULL != fPixelRef && 0 == sk_atomic_inc(&fPixelLockCount)) {
344 fPixelRef->lockPixels(); 344 fPixelRef->lockPixels();
345 this->updatePixelsFromRef(); 345 this->updatePixelsFromRef();
346 } 346 }
347 SkDEBUGCODE(this->validate();) 347 SkDEBUGCODE(this->validate();)
348 } 348 }
349 349
350 void SkBitmap::unlockPixels() const { 350 void SkBitmap::unlockPixels() const {
351 SkASSERT(NULL == fPixelRef || fPixelLockCount > 0); 351 SkASSERT(NULL == fPixelRef || fPixelLockCount > 0);
352 352
353 if (NULL != fPixelRef && 0 == --fPixelLockCount) { 353 if (NULL != fPixelRef && 1 == sk_atomic_dec(&fPixelLockCount)) {
354 fPixelRef->unlockPixels(); 354 fPixelRef->unlockPixels();
355 this->updatePixelsFromRef(); 355 this->updatePixelsFromRef();
356 } 356 }
357 SkDEBUGCODE(this->validate();) 357 SkDEBUGCODE(this->validate();)
358 } 358 }
359 359
360 bool SkBitmap::lockPixelsAreWritable() const { 360 bool SkBitmap::lockPixelsAreWritable() const {
361 return (fPixelRef) ? fPixelRef->lockPixelsAreWritable() : false; 361 return (fPixelRef) ? fPixelRef->lockPixelsAreWritable() : false;
362 } 362 }
363 363
(...skipping 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1686 if (NULL != uri) { 1686 if (NULL != uri) {
1687 str->appendf(" uri:\"%s\"", uri); 1687 str->appendf(" uri:\"%s\"", uri);
1688 } else { 1688 } else {
1689 str->appendf(" pixelref:%p", pr); 1689 str->appendf(" pixelref:%p", pr);
1690 } 1690 }
1691 } 1691 }
1692 1692
1693 str->append(")"); 1693 str->append(")");
1694 } 1694 }
1695 #endif 1695 #endif
OLDNEW
« 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