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

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

Issue 106883006: Add a release procedure to SkMallocPixelRef; remove SkDataPixelRef (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « gyp/tests.gyp ('k') | src/core/SkMallocPixelRef.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 /* 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
(...skipping 27 matching lines...) Expand all
38 * If rowBytes is > 0, then it will be used, unless it is invald for the 38 * If rowBytes is > 0, then it will be used, unless it is invald for the
39 * specified info, in which case NULL will be returned (failure). 39 * specified info, in which case NULL will be returned (failure).
40 * 40 *
41 * This pixelref will ref() the specified colortable (if not NULL). 41 * This pixelref will ref() the specified colortable (if not NULL).
42 * 42 *
43 * Returns NULL on failure. 43 * Returns NULL on failure.
44 */ 44 */
45 static SkMallocPixelRef* NewAllocate(const SkImageInfo& info, 45 static SkMallocPixelRef* NewAllocate(const SkImageInfo& info,
46 size_t rowBytes, SkColorTable*); 46 size_t rowBytes, SkColorTable*);
47 47
48 /**
49 * Return a new SkMallocPixelRef with the provided pixel storage,
50 * rowBytes, and optional colortable. On destruction, ReleaseProc
51 * will be called.
52 *
53 * This pixelref will ref() the specified colortable (if not NULL).
54 *
55 * Returns NULL on failure.
56 */
57 typedef void (*ReleaseProc)(void* addr, void* context);
58 static SkMallocPixelRef* NewWithProc(const SkImageInfo& info,
59 size_t rowBytes, SkColorTable*,
60 void* addr, ReleaseProc proc,
61 void* context);
62
63 /**
64 * Return a new SkMallocPixelRef that will use the provided
65 * SkData, rowBytes, and optional colortable as pixel storage.
66 * The SkData will be ref()ed and on destruction of the PielRef,
67 * the SkData will be unref()ed.
68 *
69 * @param offset (in bytes) into the provided SkData that the
70 * first pixel is located at.
71 *
72 * This pixelref will ref() the specified colortable (if not NULL).
73 *
74 * Returns NULL on failure.
75 */
76 static SkMallocPixelRef* NewWithData(const SkImageInfo& info,
77 size_t rowBytes,
78 SkColorTable* ctable,
79 SkData* data,
80 size_t offset = 0);
81
48 void* getAddr() const { return fStorage; } 82 void* getAddr() const { return fStorage; }
49 83
50 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMallocPixelRef) 84 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMallocPixelRef)
51 85
52 protected: 86 protected:
87 // The ownPixels version of this constructor is deprecated.
53 SkMallocPixelRef(const SkImageInfo&, void* addr, size_t rb, SkColorTable*, 88 SkMallocPixelRef(const SkImageInfo&, void* addr, size_t rb, SkColorTable*,
54 bool ownPixels); 89 bool ownPixels);
55 SkMallocPixelRef(SkFlattenableReadBuffer& buffer); 90 SkMallocPixelRef(SkFlattenableReadBuffer& buffer);
56 virtual ~SkMallocPixelRef(); 91 virtual ~SkMallocPixelRef();
57 92
58 virtual void* onLockPixels(SkColorTable**) SK_OVERRIDE; 93 virtual void* onLockPixels(SkColorTable**) SK_OVERRIDE;
59 virtual void onUnlockPixels() SK_OVERRIDE; 94 virtual void onUnlockPixels() SK_OVERRIDE;
60 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; 95 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
61 virtual size_t getAllocatedSizeInBytes() const SK_OVERRIDE; 96 virtual size_t getAllocatedSizeInBytes() const SK_OVERRIDE;
62 97
63 private: 98 private:
64 void* fStorage; 99 void* fStorage;
65 SkColorTable* fCTable; 100 SkColorTable* fCTable;
66 size_t fRB; 101 size_t fRB;
67 const bool fOwnPixels; 102 ReleaseProc fReleaseProc;
103 void* fReleaseProcContext;
104
105 SkMallocPixelRef(const SkImageInfo&, void* addr, size_t rb, SkColorTable*,
106 ReleaseProc proc, void* context);
68 107
69 typedef SkPixelRef INHERITED; 108 typedef SkPixelRef INHERITED;
70 }; 109 };
71 110
72 111
73 #endif 112 #endif
OLDNEW
« no previous file with comments | « gyp/tests.gyp ('k') | src/core/SkMallocPixelRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698