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

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

Issue 1256993002: Make peekPixels() usable with raster surface snapshots (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: review comments Created 5 years, 4 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/image/SkImage.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 2015 Google Inc. 2 * Copyright 2015 Google Inc.
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 SkPixmap_DEFINED 8 #ifndef SkPixmap_DEFINED
9 #define SkPixmap_DEFINED 9 #define SkPixmap_DEFINED
10 10
11 #include "SkColor.h" 11 #include "SkColor.h"
12 #include "SkImageInfo.h" 12 #include "SkImageInfo.h"
13 13
14 class SkColorTable; 14 class SkColorTable;
15 struct SkMask; 15 struct SkMask;
16 16
17 /** 17 /**
18 * Pairs SkImageInfo with actual pixels and rowbytes. This class does not try t o manage the 18 * Pairs SkImageInfo with actual pixels and rowbytes. This class does not try t o manage the
19 * lifetime of the pixel memory (nor the colortable if provided). 19 * lifetime of the pixel memory (nor the colortable if provided).
20 */ 20 */
21 class SkPixmap { 21 class SK_API SkPixmap {
22 public: 22 public:
23 SkPixmap() 23 SkPixmap()
24 : fPixels(NULL), fCTable(NULL), fRowBytes(0), fInfo(SkImageInfo::MakeUnk nown(0, 0)) 24 : fPixels(NULL), fCTable(NULL), fRowBytes(0), fInfo(SkImageInfo::MakeUnk nown(0, 0))
25 {} 25 {}
26 26
27 SkPixmap(const SkImageInfo& info, const void* addr, size_t rowBytes, 27 SkPixmap(const SkImageInfo& info, const void* addr, size_t rowBytes,
28 SkColorTable* ctable = NULL) 28 SkColorTable* ctable = NULL)
29 : fPixels(addr), fCTable(ctable), fRowBytes(rowBytes), fInfo(info) 29 : fPixels(addr), fCTable(ctable), fRowBytes(rowBytes), fInfo(info)
30 { 30 {
31 if (kIndex_8_SkColorType == info.colorType()) { 31 if (kIndex_8_SkColorType == info.colorType()) {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 144
145 private: 145 private:
146 const void* fPixels; 146 const void* fPixels;
147 SkColorTable* fCTable; 147 SkColorTable* fCTable;
148 size_t fRowBytes; 148 size_t fRowBytes;
149 SkImageInfo fInfo; 149 SkImageInfo fInfo;
150 }; 150 };
151 151
152 //////////////////////////////////////////////////////////////////////////////// ///////////// 152 //////////////////////////////////////////////////////////////////////////////// /////////////
153 153
154 class SkAutoPixmapStorage : public SkPixmap { 154 class SK_API SkAutoPixmapStorage : public SkPixmap {
155 public: 155 public:
156 SkAutoPixmapStorage(); 156 SkAutoPixmapStorage();
157 ~SkAutoPixmapStorage(); 157 ~SkAutoPixmapStorage();
158 158
159 /** 159 /**
160 * Try to allocate memory for the pixels needed to match the specified Info . On success 160 * Try to allocate memory for the pixels needed to match the specified Info . On success
161 * return true and fill out the pixmap to point to that memory. The storage will be freed 161 * return true and fill out the pixmap to point to that memory. The storage will be freed
162 * when this object is destroyed, or if another call to tryAlloc() or alloc () is made. 162 * when this object is destroyed, or if another call to tryAlloc() or alloc () is made.
163 * 163 *
164 * On failure, return false and reset() the pixmap to empty. 164 * On failure, return false and reset() the pixmap to empty.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 void freeStorage() { 199 void freeStorage() {
200 sk_free(fStorage); 200 sk_free(fStorage);
201 fStorage = NULL; 201 fStorage = NULL;
202 } 202 }
203 203
204 typedef SkPixmap INHERITED; 204 typedef SkPixmap INHERITED;
205 }; 205 };
206 206
207 //////////////////////////////////////////////////////////////////////////////// ///////////// 207 //////////////////////////////////////////////////////////////////////////////// /////////////
208 208
209 class SkAutoPixmapUnlock : ::SkNoncopyable { 209 class SK_API SkAutoPixmapUnlock : ::SkNoncopyable {
210 public: 210 public:
211 SkAutoPixmapUnlock() : fUnlockProc(NULL), fIsLocked(false) {} 211 SkAutoPixmapUnlock() : fUnlockProc(NULL), fIsLocked(false) {}
212 SkAutoPixmapUnlock(const SkPixmap& pm, void (*unlock)(void*), void* ctx) 212 SkAutoPixmapUnlock(const SkPixmap& pm, void (*unlock)(void*), void* ctx)
213 : fUnlockProc(unlock), fUnlockContext(ctx), fPixmap(pm), fIsLocked(true) 213 : fUnlockProc(unlock), fUnlockContext(ctx), fPixmap(pm), fIsLocked(true)
214 {} 214 {}
215 ~SkAutoPixmapUnlock() { this->unlock(); } 215 ~SkAutoPixmapUnlock() { this->unlock(); }
216 216
217 /** 217 /**
218 * Return the currently locked pixmap. Undefined if it has been unlocked. 218 * Return the currently locked pixmap. Undefined if it has been unlocked.
219 */ 219 */
(...skipping 26 matching lines...) Expand all
246 private: 246 private:
247 void (*fUnlockProc)(void*); 247 void (*fUnlockProc)(void*);
248 void* fUnlockContext; 248 void* fUnlockContext;
249 SkPixmap fPixmap; 249 SkPixmap fPixmap;
250 bool fIsLocked; 250 bool fIsLocked;
251 251
252 friend class SkBitmap; 252 friend class SkBitmap;
253 }; 253 };
254 254
255 #endif 255 #endif
OLDNEW
« no previous file with comments | « no previous file | src/image/SkImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698