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

Side by Side Diff: src/core/SkPixelRef.cpp

Issue 1266143003: lock pixels in image when bitmap is immutable and not-lazy (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBitmapCache.h" 8 #include "SkBitmapCache.h"
9 #include "SkMutex.h" 9 #include "SkMutex.h"
10 #include "SkPixelRef.h" 10 #include "SkPixelRef.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 return; // can't require ctable if the dimensions are empty 166 return; // can't require ctable if the dimensions are empty
167 } 167 }
168 if (kIndex_8_SkColorType == info.colorType()) { 168 if (kIndex_8_SkColorType == info.colorType()) {
169 SkASSERT(ctable); 169 SkASSERT(ctable);
170 } else { 170 } else {
171 SkASSERT(NULL == ctable); 171 SkASSERT(NULL == ctable);
172 } 172 }
173 } 173 }
174 174
175 void SkPixelRef::setPreLocked(void* pixels, size_t rowBytes, SkColorTable* ctabl e) { 175 void SkPixelRef::setPreLocked(void* pixels, size_t rowBytes, SkColorTable* ctabl e) {
176 #ifndef SK_IGNORE_PIXELREF_SETPRELOCKED
177 SkASSERT(pixels); 176 SkASSERT(pixels);
178 validate_pixels_ctable(fInfo, ctable); 177 validate_pixels_ctable(fInfo, ctable);
179 // only call me in your constructor, otherwise fLockCount tracking can get 178 // only call me in your constructor, otherwise fLockCount tracking can get
180 // out of sync. 179 // out of sync.
181 fRec.fPixels = pixels; 180 fRec.fPixels = pixels;
182 fRec.fColorTable = ctable; 181 fRec.fColorTable = ctable;
183 fRec.fRowBytes = rowBytes; 182 fRec.fRowBytes = rowBytes;
184 fLockCount = SKPIXELREF_PRELOCKED_LOCKCOUNT; 183 fLockCount = SKPIXELREF_PRELOCKED_LOCKCOUNT;
185 fPreLocked = true; 184 fPreLocked = true;
186 #endif
187 } 185 }
188 186
189 // Increments fLockCount only on success 187 // Increments fLockCount only on success
190 bool SkPixelRef::lockPixelsInsideMutex() { 188 bool SkPixelRef::lockPixelsInsideMutex() {
191 fMutex->assertHeld(); 189 fMutex->assertHeld();
192 190
193 if (1 == ++fLockCount) { 191 if (1 == ++fLockCount) {
194 SkASSERT(fRec.isZero()); 192 SkASSERT(fRec.isZero());
195 if (!this->onNewLockPixels(&fRec)) { 193 if (!this->onNewLockPixels(&fRec)) {
196 fRec.zero(); 194 fRec.zero();
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 } 403 }
406 404
407 result->fUnlockProc = unlock_legacy_result; 405 result->fUnlockProc = unlock_legacy_result;
408 result->fUnlockContext = SkRef(this); // this is balanced in our fUnlockPr oc 406 result->fUnlockContext = SkRef(this); // this is balanced in our fUnlockPr oc
409 result->fCTable = fRec.fColorTable; 407 result->fCTable = fRec.fColorTable;
410 result->fPixels = fRec.fPixels; 408 result->fPixels = fRec.fPixels;
411 result->fRowBytes = fRec.fRowBytes; 409 result->fRowBytes = fRec.fRowBytes;
412 result->fSize.set(fInfo.width(), fInfo.height()); 410 result->fSize.set(fInfo.width(), fInfo.height());
413 return true; 411 return true;
414 } 412 }
OLDNEW
« no previous file with comments | « include/core/SkPixelRef.h ('k') | src/image/SkImage.cpp » ('j') | tests/DeferredCanvasTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698