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

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

Issue 92793002: Fixed bad bitmap size crashes (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Changed getSize name to getAllocatedSizeInBytes Created 7 years 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
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 #ifndef SkPixelRef_DEFINED 10 #ifndef SkPixelRef_DEFINED
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 * For pixelrefs that don't have access to their raw pixels, they may be 250 * For pixelrefs that don't have access to their raw pixels, they may be
251 * able to make a copy of them (e.g. if the pixels are on the GPU). 251 * able to make a copy of them (e.g. if the pixels are on the GPU).
252 * 252 *
253 * The base class implementation returns false; 253 * The base class implementation returns false;
254 */ 254 */
255 virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subsetOrNull); 255 virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subsetOrNull);
256 256
257 // default impl returns NULL. 257 // default impl returns NULL.
258 virtual SkData* onRefEncodedData(); 258 virtual SkData* onRefEncodedData();
259 259
260 /**
261 * Returns the size (in bytes) of the internally allocated memory.
262 * This should be implemented in all serializable SkPixelRef derived classe s.
263 * SkBitmap::fPixelRefOffset + SkBitmap::getSafeSize() should never overflo w this value,
264 * otherwise the rendering code may attempt to read memory out of bounds.
265 *
266 * @return default impl returns 0.
267 */
268 virtual size_t getAllocatedSizeInBytes() const;
269
260 /** Return the mutex associated with this pixelref. This value is assigned 270 /** Return the mutex associated with this pixelref. This value is assigned
261 in the constructor, and cannot change during the lifetime of the object. 271 in the constructor, and cannot change during the lifetime of the object.
262 */ 272 */
263 SkBaseMutex* mutex() const { return fMutex; } 273 SkBaseMutex* mutex() const { return fMutex; }
264 274
265 // serialization 275 // serialization
266 SkPixelRef(SkFlattenableReadBuffer&, SkBaseMutex*); 276 SkPixelRef(SkFlattenableReadBuffer&, SkBaseMutex*);
267 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; 277 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
268 278
269 // only call from constructor. Flags this to always be locked, removing 279 // only call from constructor. Flags this to always be locked, removing
(...skipping 26 matching lines...) Expand all
296 306
297 // When copying a bitmap to another with the same shape and config, we can s afely 307 // When copying a bitmap to another with the same shape and config, we can s afely
298 // clone the pixelref generation ID too, which makes them equivalent under c aching. 308 // clone the pixelref generation ID too, which makes them equivalent under c aching.
299 friend class SkBitmap; // only for cloneGenID 309 friend class SkBitmap; // only for cloneGenID
300 void cloneGenID(const SkPixelRef&); 310 void cloneGenID(const SkPixelRef&);
301 311
302 typedef SkFlattenable INHERITED; 312 typedef SkFlattenable INHERITED;
303 }; 313 };
304 314
305 #endif 315 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698