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

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

Issue 940323003: Revert of Make SkPixelRef::isLocked() debug-only, remove related dead code. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 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/SkBitmapProcState.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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 SkColorTable* fColorTable; 79 SkColorTable* fColorTable;
80 size_t fRowBytes; 80 size_t fRowBytes;
81 81
82 void zero() { sk_bzero(this, sizeof(*this)); } 82 void zero() { sk_bzero(this, sizeof(*this)); }
83 83
84 bool isZero() const { 84 bool isZero() const {
85 return NULL == fPixels && NULL == fColorTable && 0 == fRowBytes; 85 return NULL == fPixels && NULL == fColorTable && 0 == fRowBytes;
86 } 86 }
87 }; 87 };
88 88
89 SkDEBUGCODE(bool isLocked() const { return fLockCount > 0; }) 89 /**
90 * Returns true if the lockcount > 0
91 */
92 bool isLocked() const { return fLockCount > 0; }
93
90 SkDEBUGCODE(int getLockCount() const { return fLockCount; }) 94 SkDEBUGCODE(int getLockCount() const { return fLockCount; })
91 95
92 /** 96 /**
93 * Call to access the pixel memory. Return true on success. Balance this 97 * Call to access the pixel memory. Return true on success. Balance this
94 * with a call to unlockPixels(). 98 * with a call to unlockPixels().
95 */ 99 */
96 bool lockPixels(); 100 bool lockPixels();
97 101
98 /** 102 /**
99 * Call to access the pixel memory. On success, return true and fill out 103 * Call to access the pixel memory. On success, return true and fill out
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 * return a ref to its data. If the pixelRef 190 * return a ref to its data. If the pixelRef
187 * is uncompressed or otherwise does not have this form, return NULL. 191 * is uncompressed or otherwise does not have this form, return NULL.
188 * 192 *
189 * If non-null is returned, the caller is responsible for calling unref() 193 * If non-null is returned, the caller is responsible for calling unref()
190 * on the data when it is finished. 194 * on the data when it is finished.
191 */ 195 */
192 SkData* refEncodedData() { 196 SkData* refEncodedData() {
193 return this->onRefEncodedData(); 197 return this->onRefEncodedData();
194 } 198 }
195 199
200 /**
201 * Experimental -- tells the caller if it is worth it to call decodeInto().
202 * Just an optimization at this point, to avoid checking the cache first.
203 * We may remove/change this call in the future.
204 */
205 bool implementsDecodeInto() {
206 return this->onImplementsDecodeInto();
207 }
208
209 /**
210 * Return a decoded instance of this pixelRef in bitmap. If this cannot be
211 * done, return false and the bitmap parameter is ignored/unchanged.
212 *
213 * pow2 is the requeste power-of-two downscale that the caller needs. This
214 * can be ignored, and the "original" size can be returned, but if the
215 * underlying codec can efficiently return a smaller size, that should be
216 * done. Some examples:
217 *
218 * To request the "base" version (original scale), pass 0 for pow2
219 * To request 1/2 scale version (1/2 width, 1/2 height), pass 1 for pow2
220 * To request 1/4 scale version (1/4 width, 1/4 height), pass 2 for pow2
221 * ...
222 *
223 * If this returns true, then bitmap must be "locked" such that
224 * bitmap->getPixels() will return the correct address.
225 */
226 bool decodeInto(int pow2, SkBitmap* bitmap) {
227 SkASSERT(pow2 >= 0);
228 return this->onDecodeInto(pow2, bitmap);
229 }
230
196 /** Are we really wrapping a texture instead of a bitmap? 231 /** Are we really wrapping a texture instead of a bitmap?
197 */ 232 */
198 virtual GrTexture* getTexture() { return NULL; } 233 virtual GrTexture* getTexture() { return NULL; }
199 234
200 /** 235 /**
201 * If any planes or rowBytes is NULL, this should output the sizes and retu rn true 236 * If any planes or rowBytes is NULL, this should output the sizes and retu rn true
202 * if it can efficiently return YUV planar data. If it cannot, it should re turn false. 237 * if it can efficiently return YUV planar data. If it cannot, it should re turn false.
203 * 238 *
204 * If all planes and rowBytes are not NULL, then it should copy the associa ted Y,U,V data 239 * If all planes and rowBytes are not NULL, then it should copy the associa ted Y,U,V data
205 * into those planes of memory supplied by the caller. It should validate t hat the sizes 240 * into those planes of memory supplied by the caller. It should validate t hat the sizes
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 * move or discard that memory. 296 * move or discard that memory.
262 * 297 *
263 * The caller will have already acquired a mutex for thread safety, so this 298 * The caller will have already acquired a mutex for thread safety, so this
264 * method need not do that. 299 * method need not do that.
265 */ 300 */
266 virtual void onUnlockPixels() = 0; 301 virtual void onUnlockPixels() = 0;
267 302
268 /** Default impl returns true */ 303 /** Default impl returns true */
269 virtual bool onLockPixelsAreWritable() const; 304 virtual bool onLockPixelsAreWritable() const;
270 305
306 // returns false;
307 virtual bool onImplementsDecodeInto();
308 // returns false;
309 virtual bool onDecodeInto(int pow2, SkBitmap* bitmap);
310
271 /** 311 /**
272 * For pixelrefs that don't have access to their raw pixels, they may be 312 * For pixelrefs that don't have access to their raw pixels, they may be
273 * able to make a copy of them (e.g. if the pixels are on the GPU). 313 * able to make a copy of them (e.g. if the pixels are on the GPU).
274 * 314 *
275 * The base class implementation returns false; 315 * The base class implementation returns false;
276 */ 316 */
277 virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subsetOrNull); 317 virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subsetOrNull);
278 318
279 // default impl returns NULL. 319 // default impl returns NULL.
280 virtual SkData* onRefEncodedData(); 320 virtual SkData* onRefEncodedData();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 /** 386 /**
347 * Allocate a new pixelref matching the specified ImageInfo, allocating 387 * Allocate a new pixelref matching the specified ImageInfo, allocating
348 * the memory for the pixels. If the ImageInfo requires a ColorTable, 388 * the memory for the pixels. If the ImageInfo requires a ColorTable,
349 * the pixelref will ref() the colortable. 389 * the pixelref will ref() the colortable.
350 * On failure return NULL. 390 * On failure return NULL.
351 */ 391 */
352 virtual SkPixelRef* create(const SkImageInfo&, size_t rowBytes, SkColorTable *) = 0; 392 virtual SkPixelRef* create(const SkImageInfo&, size_t rowBytes, SkColorTable *) = 0;
353 }; 393 };
354 394
355 #endif 395 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkBitmapProcState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698