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

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

Issue 197873039: Hide SkMallocPixelRef class befind SkPixelRef factory functions. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: AnotherPatchSet Created 6 years, 8 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/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 * 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 This class is the smart container for pixel memory, and is used with 43 This class is the smart container for pixel memory, and is used with
44 SkBitmap. A pixelref is installed into a bitmap, and then the bitmap can 44 SkBitmap. A pixelref is installed into a bitmap, and then the bitmap can
45 access the actual pixel memory by calling lockPixels/unlockPixels. 45 access the actual pixel memory by calling lockPixels/unlockPixels.
46 46
47 This class can be shared/accessed between multiple threads. 47 This class can be shared/accessed between multiple threads.
48 */ 48 */
49 class SK_API SkPixelRef : public SkFlattenable { 49 class SK_API SkPixelRef : public SkFlattenable {
50 public: 50 public:
51 SK_DECLARE_INST_COUNT(SkPixelRef) 51 SK_DECLARE_INST_COUNT(SkPixelRef)
52 52
53 /**
54 * Return a new pre-locked SkPixelRef, automatically allocating
55 * storage for the pixels. If rowBytes are 0, an optimal value
56 * will be chosen automatically. If rowBytes is > 0, then it
57 * will be respected, or NULL will be returned if rowBytes is
58 * invalid for the specified info.
59 *
60 * This pixelref will ref() the specified colortable (if not NULL).
61 *
62 * Returns NULL on failure.
63 */
64 static SkPixelRef* NewPrelockedAllocate(
scroggo 2014/04/04 21:21:06 I know the goal is to hide SkMallocPixelRef, but I
65 const SkImageInfo& info,
66 size_t rowBytes,
67 SkColorTable* colorTable);
68
69 /**
70 * Return a new pre-locked immutable SkPixelRef that will use
71 * the provided SkData, rowBytes, and optional colortable as
72 * pixel storage. The SkData will be ref()ed, and on destruction
73 * of the PixelRef, the SkData will be unref()ed.
74 *
75 * @param offset (in bytes) into the provided SkData that the
76 * first pixel is located at.
77 *
78 * This pixelref will ref() the specified colortable (if not NULL).
79 *
80 * Returns NULL on failure.
81 */
82 static SkPixelRef* NewPrelockedWithData(
scroggo 2014/04/04 21:21:06 I thought Mike wanted to move people away from dea
83 const SkImageInfo& info,
84 size_t rowBytes,
85 SkColorTable* colorTable,
86 SkData* data,
87 size_t offset = 0);
scroggo 2014/04/04 21:21:06 This seems like an odd choice, given that we switc
hal.canary 2014/04/07 14:43:02 Look at our existing use of SkMallocPixelRef::NewW
mtklein 2014/04/07 14:51:01 Yep, exactly. x and y don't make sense until you'
88
89 /**
90 * Return a new pre-locked SkPixelRef with the provided pixel
91 * storage, rowBytes, and optional colortable. On destruction,
92 * ReleaseProc will be called. If this function fails,
93 * ReleaseProc will be called before returning NULL.
94 *
95 * This pixelref will ref() the specified colortable (if not NULL).
96 *
97 * Returns NULL on failure.
98 */
99 static SkPixelRef* NewPrelockedDirectWithProc(
100 const SkImageInfo& info,
101 size_t rowBytes,
102 SkColorTable* colorTable,
103 void* pixelAddress,
104 void (*releaseProcedure)(void* pixelAddress, void* context),
105 void* releaseProcedureContext);
106
107 /**
108 * Return a new pre-locked SkPixelRef with the provided pixel
109 * storage, rowBytes, and optional colortable. The caller is
110 * responsible for managing the lifetime of the pixel storage
111 * buffer, as this pixelref will not try to delete it.
112 *
113 * The pixelref will ref() the colortable (if not NULL).
114 *
115 * Returns NULL on failure.
116 */
117 static SkPixelRef* NewPrelockedDirect(
118 const SkImageInfo& info,
119 size_t rowBytes,
120 SkColorTable* colorTable,
121 void* pixelAddress) {
122 return SkPixelRef::NewPrelockedDirectWithProc(
123 info, rowBytes, colorTable, pixelAddress, NULL, NULL);
124 }
125
53 explicit SkPixelRef(const SkImageInfo&); 126 explicit SkPixelRef(const SkImageInfo&);
54 SkPixelRef(const SkImageInfo&, SkBaseMutex* mutex); 127 SkPixelRef(const SkImageInfo&, SkBaseMutex* mutex);
55 virtual ~SkPixelRef(); 128 virtual ~SkPixelRef();
56 129
57 const SkImageInfo& info() const { 130 const SkImageInfo& info() const {
58 return fInfo; 131 return fInfo;
59 } 132 }
60 133
61 /** Return the pixel memory returned from lockPixels, or null if the 134 /** Return the pixel memory returned from lockPixels, or null if the
62 lockCount is 0. 135 lockCount is 0.
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 /** 444 /**
372 * Allocate a new pixelref matching the specified ImageInfo, allocating 445 * Allocate a new pixelref matching the specified ImageInfo, allocating
373 * the memory for the pixels. If the ImageInfo requires a ColorTable, 446 * the memory for the pixels. If the ImageInfo requires a ColorTable,
374 * the pixelref will ref() the colortable. 447 * the pixelref will ref() the colortable.
375 * On failure return NULL. 448 * On failure return NULL.
376 */ 449 */
377 virtual SkPixelRef* create(const SkImageInfo&, SkColorTable*) = 0; 450 virtual SkPixelRef* create(const SkImageInfo&, SkColorTable*) = 0;
378 }; 451 };
379 452
380 #endif 453 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkMallocPixelRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698