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

Side by Side Diff: include/core/SkPixelRef.h

Issue 1151573009: Revert of add asserts around results from requestLock (patchset #3 id:40001 of https://codereview.chromium.or… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « no previous file | src/core/SkPixelRef.cpp » ('j') | 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 * Copyright 2008 The Android Open Source Project 2 * Copyright 2008 The Android Open Source Project
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 #ifndef SkPixelRef_DEFINED 8 #ifndef SkPixelRef_DEFINED
9 #define SkPixelRef_DEFINED 9 #define SkPixelRef_DEFINED
10 10
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 */ 68 */
69 SkColorTable* colorTable() const { return fRec.fColorTable; } 69 SkColorTable* colorTable() const { return fRec.fColorTable; }
70 70
71 size_t rowBytes() const { return fRec.fRowBytes; } 71 size_t rowBytes() const { return fRec.fRowBytes; }
72 72
73 /** 73 /**
74 * To access the actual pixels of a pixelref, it must be "locked". 74 * To access the actual pixels of a pixelref, it must be "locked".
75 * Calling lockPixels returns a LockRec struct (on success). 75 * Calling lockPixels returns a LockRec struct (on success).
76 */ 76 */
77 struct LockRec { 77 struct LockRec {
78 LockRec() : fPixels(NULL), fColorTable(NULL) {}
79
80 void* fPixels; 78 void* fPixels;
81 SkColorTable* fColorTable; 79 SkColorTable* fColorTable;
82 size_t fRowBytes; 80 size_t fRowBytes;
83 81
84 void zero() { sk_bzero(this, sizeof(*this)); } 82 void zero() { sk_bzero(this, sizeof(*this)); }
85 83
86 bool isZero() const { 84 bool isZero() const {
87 return NULL == fPixels && NULL == fColorTable && 0 == fRowBytes; 85 return NULL == fPixels && NULL == fColorTable && 0 == fRowBytes;
88 } 86 }
89 }; 87 };
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 SkData* refEncodedData() { 192 SkData* refEncodedData() {
195 return this->onRefEncodedData(); 193 return this->onRefEncodedData();
196 } 194 }
197 195
198 struct LockRequest { 196 struct LockRequest {
199 SkISize fSize; 197 SkISize fSize;
200 SkFilterQuality fQuality; 198 SkFilterQuality fQuality;
201 }; 199 };
202 200
203 struct LockResult { 201 struct LockResult {
204 LockResult() : fPixels(NULL), fCTable(NULL) {}
205
206 void (*fUnlockProc)(void* ctx); 202 void (*fUnlockProc)(void* ctx);
207 void* fUnlockContext; 203 void* fUnlockContext;
208 204
205 SkColorTable* fCTable; // should be NULL unless colortype is kIndex8
209 const void* fPixels; 206 const void* fPixels;
210 SkColorTable* fCTable; // should be NULL unless colortype is kIndex8
211 size_t fRowBytes; 207 size_t fRowBytes;
212 SkISize fSize; 208 SkISize fSize;
213 209
214 void unlock() { 210 void unlock() {
215 if (fUnlockProc) { 211 if (fUnlockProc) {
216 fUnlockProc(fUnlockContext); 212 fUnlockProc(fUnlockContext);
217 fUnlockProc = NULL; // can't unlock twice! 213 fUnlockProc = NULL; // can't unlock twice!
218 } 214 }
219 } 215 }
220 }; 216 };
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 private: 338 private:
343 SkBaseMutex* fMutex; // must remain in scope for the life of this object 339 SkBaseMutex* fMutex; // must remain in scope for the life of this object
344 340
345 // mostly const. fInfo.fAlpahType can be changed at runtime. 341 // mostly const. fInfo.fAlpahType can be changed at runtime.
346 const SkImageInfo fInfo; 342 const SkImageInfo fInfo;
347 343
348 // LockRec is only valid if we're in a locked state (isLocked()) 344 // LockRec is only valid if we're in a locked state (isLocked())
349 LockRec fRec; 345 LockRec fRec;
350 int fLockCount; 346 int fLockCount;
351 347
352 bool lockPixelsInsideMutex(); 348 bool lockPixelsInsideMutex(LockRec* rec);
353 349
354 // Bottom bit indicates the Gen ID is unique. 350 // Bottom bit indicates the Gen ID is unique.
355 bool genIDIsUnique() const { return SkToBool(fTaggedGenID.load() & 1); } 351 bool genIDIsUnique() const { return SkToBool(fTaggedGenID.load() & 1); }
356 mutable SkAtomic<uint32_t> fTaggedGenID; 352 mutable SkAtomic<uint32_t> fTaggedGenID;
357 353
358 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK 354 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
359 const uint32_t fStableID; 355 const uint32_t fStableID;
360 #endif 356 #endif
361 357
362 SkTDArray<GenIDChangeListener*> fGenIDChangeListeners; // pointers are owne d 358 SkTDArray<GenIDChangeListener*> fGenIDChangeListeners; // pointers are owne d
(...skipping 25 matching lines...) Expand all
388 /** 384 /**
389 * Allocate a new pixelref matching the specified ImageInfo, allocating 385 * Allocate a new pixelref matching the specified ImageInfo, allocating
390 * the memory for the pixels. If the ImageInfo requires a ColorTable, 386 * the memory for the pixels. If the ImageInfo requires a ColorTable,
391 * the pixelref will ref() the colortable. 387 * the pixelref will ref() the colortable.
392 * On failure return NULL. 388 * On failure return NULL.
393 */ 389 */
394 virtual SkPixelRef* create(const SkImageInfo&, size_t rowBytes, SkColorTable *) = 0; 390 virtual SkPixelRef* create(const SkImageInfo&, size_t rowBytes, SkColorTable *) = 0;
395 }; 391 };
396 392
397 #endif 393 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkPixelRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698