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

Side by Side Diff: include/core/SkMallocPixelRef.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
« no previous file with comments | « no previous file | include/core/SkPixelRef.h » ('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 /* 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 SkMallocPixelRef_DEFINED 10 #ifndef SkMallocPixelRef_DEFINED
11 #define SkMallocPixelRef_DEFINED 11 #define SkMallocPixelRef_DEFINED
12 12
13 #include "SkPixelRef.h" 13 #include "SkPixelRef.h"
14 14
15 /** We explicitly use the same allocator for our pixels that SkMask does, 15 /** We explicitly use the same allocator for our pixels that SkMask does,
16 so that we can freely assign memory allocated by one class to the other. 16 so that we can freely assign memory allocated by one class to the other.
17 */ 17 */
18 class SkMallocPixelRef : public SkPixelRef { 18 class SkMallocPixelRef : public SkPixelRef {
19 public: 19 public:
20 /** Allocate the specified buffer for pixels. The memory is freed when the 20 /** Allocate the specified buffer for pixels. The memory is freed when the
21 last owner of this pixelref is gone. If addr is NULL, sk_malloc_throw() 21 last owner of this pixelref is gone. If addr is NULL, sk_malloc_throw()
22 is called to allocate it. 22 is called to allocate it.
23 */ 23 */
24 SkMallocPixelRef(void* addr, size_t size, SkColorTable* ctable, bool ownPixe ls = true); 24 SkMallocPixelRef(void* addr, size_t size, SkColorTable* ctable, bool ownPixe ls = true);
25 virtual ~SkMallocPixelRef(); 25 virtual ~SkMallocPixelRef();
26 26
27 //! Return the allocation size for the pixels
28 size_t getSize() const { return fSize; }
29 void* getAddr() const { return fStorage; } 27 void* getAddr() const { return fStorage; }
30 28
31 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMallocPixelRef) 29 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMallocPixelRef)
32 30
33 protected: 31 protected:
34 // overrides from SkPixelRef 32 // overrides from SkPixelRef
35 virtual void* onLockPixels(SkColorTable**); 33 virtual void* onLockPixels(SkColorTable**);
36 virtual void onUnlockPixels(); 34 virtual void onUnlockPixels();
37 35
38 SkMallocPixelRef(SkFlattenableReadBuffer& buffer); 36 SkMallocPixelRef(SkFlattenableReadBuffer& buffer);
39 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; 37 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
40 38
39 // Returns the allocation size for the pixels
40 virtual size_t getAllocatedSizeInBytes() const SK_OVERRIDE { return fSize; }
sugoi 2013/12/04 16:20:31 I moved and renamed this function and it's still c
41
41 private: 42 private:
42 void* fStorage; 43 void* fStorage;
43 size_t fSize; 44 size_t fSize;
44 SkColorTable* fCTable; 45 SkColorTable* fCTable;
45 bool fOwnPixels; 46 bool fOwnPixels;
46 47
47 typedef SkPixelRef INHERITED; 48 typedef SkPixelRef INHERITED;
48 }; 49 };
49 50
50 51
51 #endif 52 #endif
OLDNEW
« no previous file with comments | « no previous file | include/core/SkPixelRef.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698