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

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

Issue 1155443004: change internals over to SkPixmap and stop using accessBitmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright 2010 The Android Open Source Project 2 * Copyright 2010 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 SkDevice_DEFINED 8 #ifndef SkDevice_DEFINED
9 #define SkDevice_DEFINED 9 #define SkDevice_DEFINED
10 10
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 /** Return the bitmap associated with this device. Call this each time you n eed 75 /** Return the bitmap associated with this device. Call this each time you n eed
76 to access the bitmap, as it notifies the subclass to perform any flushin g 76 to access the bitmap, as it notifies the subclass to perform any flushin g
77 etc. before you examine the pixels. 77 etc. before you examine the pixels.
78 @param changePixels set to true if the caller plans to change the pixels 78 @param changePixels set to true if the caller plans to change the pixels
79 @return the device's bitmap 79 @return the device's bitmap
80 */ 80 */
81 const SkBitmap& accessBitmap(bool changePixels); 81 const SkBitmap& accessBitmap(bool changePixels);
82 82
83 bool writePixels(const SkImageInfo&, const void*, size_t rowBytes, int x, in t y); 83 bool writePixels(const SkImageInfo&, const void*, size_t rowBytes, int x, in t y);
84 84
85 void* accessPixels(SkImageInfo* info, size_t* rowBytes); 85 bool accessPixels(SkPixmap* pmap);
86 86
87 /** 87 /**
88 * Return the device's associated gpu render target, or NULL. 88 * Return the device's associated gpu render target, or NULL.
89 */ 89 */
90 virtual GrRenderTarget* accessRenderTarget() { return NULL; } 90 virtual GrRenderTarget* accessRenderTarget() { return NULL; }
91 91
92 92
93 /** 93 /**
94 * Return the device's origin: its offset in device coordinates from 94 * Return the device's origin: its offset in device coordinates from
95 * the default origin in its canvas' matrix/clip 95 * the default origin in its canvas' matrix/clip
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 virtual void drawPatch(const SkDraw&, const SkPoint cubics[12], const SkColo r colors[4], 232 virtual void drawPatch(const SkDraw&, const SkPoint cubics[12], const SkColo r colors[4],
233 const SkPoint texCoords[4], SkXfermode* xmode, const SkPaint& paint); 233 const SkPoint texCoords[4], SkXfermode* xmode, const SkPaint& paint);
234 /** The SkDevice passed will be an SkDevice which was returned by a call to 234 /** The SkDevice passed will be an SkDevice which was returned by a call to
235 onCreateDevice on this device with kNeverTile_TileExpectation. 235 onCreateDevice on this device with kNeverTile_TileExpectation.
236 */ 236 */
237 virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, 237 virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y,
238 const SkPaint&) = 0; 238 const SkPaint&) = 0;
239 239
240 virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len, con st SkPath&, 240 virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len, con st SkPath&,
241 const SkMatrix*, const SkPaint&); 241 const SkMatrix*, const SkPaint&);
242
242 bool readPixels(const SkImageInfo&, void* dst, size_t rowBytes, int x, int y ); 243 bool readPixels(const SkImageInfo&, void* dst, size_t rowBytes, int x, int y );
244 bool peekPixels(SkPixmap*);
243 245
244 /////////////////////////////////////////////////////////////////////////// 246 ///////////////////////////////////////////////////////////////////////////
245 247
246 /** Update as needed the pixel value in the bitmap, so that the caller can 248 /** Update as needed the pixel value in the bitmap, so that the caller can
247 access the pixels directly. 249 access the pixels directly.
248 @return The device contents as a bitmap 250 @return The device contents as a bitmap
249 */ 251 */
250 virtual const SkBitmap& onAccessBitmap() = 0; 252 virtual const SkBitmap& onAccessBitmap() = 0;
251 253
252 /** 254 /**
(...skipping 12 matching lines...) Expand all
265 * If the device does not recognize or support this filter, 267 * If the device does not recognize or support this filter,
266 * it just returns false and leaves result and offset unchanged. 268 * it just returns false and leaves result and offset unchanged.
267 */ 269 */
268 virtual bool filterImage(const SkImageFilter*, const SkBitmap&, 270 virtual bool filterImage(const SkImageFilter*, const SkBitmap&,
269 const SkImageFilter::Context&, 271 const SkImageFilter::Context&,
270 SkBitmap* /*result*/, SkIPoint* /*offset*/) { 272 SkBitmap* /*result*/, SkIPoint* /*offset*/) {
271 return false; 273 return false;
272 } 274 }
273 275
274 protected: 276 protected:
275 // default impl returns NULL 277 virtual SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) { r eturn NULL; }
276 virtual SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&); 278 virtual bool onPeekPixels(SkPixmap*) { return false; }
277
278 // default impl returns NULL
279 virtual const void* peekPixels(SkImageInfo*, size_t* rowBytes);
280 279
281 /** 280 /**
282 * The caller is responsible for "pre-clipping" the dst. The impl can assum e that the dst 281 * The caller is responsible for "pre-clipping" the dst. The impl can assum e that the dst
283 * image at the specified x,y offset will fit within the device's bounds. 282 * image at the specified x,y offset will fit within the device's bounds.
284 * 283 *
285 * This is explicitly asserted in readPixels(), the public way to call this . 284 * This is explicitly asserted in readPixels(), the public way to call this .
286 */ 285 */
287 virtual bool onReadPixels(const SkImageInfo&, void*, size_t, int x, int y); 286 virtual bool onReadPixels(const SkImageInfo&, void*, size_t, int x, int y);
288 287
289 /** 288 /**
290 * The caller is responsible for "pre-clipping" the src. The impl can assum e that the src 289 * The caller is responsible for "pre-clipping" the src. The impl can assum e that the src
291 * image at the specified x,y offset will fit within the device's bounds. 290 * image at the specified x,y offset will fit within the device's bounds.
292 * 291 *
293 * This is explicitly asserted in writePixelsDirect(), the public way to ca ll this. 292 * This is explicitly asserted in writePixelsDirect(), the public way to ca ll this.
294 */ 293 */
295 virtual bool onWritePixels(const SkImageInfo&, const void*, size_t, int x, i nt y); 294 virtual bool onWritePixels(const SkImageInfo&, const void*, size_t, int x, i nt y);
296 295
297 /** 296 virtual bool onAccessPixels(SkPixmap*) { return false; }
298 * Default impl returns NULL.
299 */
300 virtual void* onAccessPixels(SkImageInfo* info, size_t* rowBytes);
301 297
302 /** 298 /**
303 * Leaky properties are those which the device should be applying but it is n't. 299 * Leaky properties are those which the device should be applying but it is n't.
304 * These properties will be applied by the draw, when and as it can. 300 * These properties will be applied by the draw, when and as it can.
305 * If the device does handle a property, that property should be set to the identity value 301 * If the device does handle a property, that property should be set to the identity value
306 * for that property, effectively making it non-leaky. 302 * for that property, effectively making it non-leaky.
307 */ 303 */
308 const SkDeviceProperties& getLeakyProperties() const { 304 const SkDeviceProperties& getLeakyProperties() const {
309 return *fLeakyProperties; 305 return *fLeakyProperties;
310 } 306 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 SkDeviceProperties* fLeakyProperties; // will always exist. 388 SkDeviceProperties* fLeakyProperties; // will always exist.
393 389
394 #ifdef SK_DEBUG 390 #ifdef SK_DEBUG
395 bool fAttachedToCanvas; 391 bool fAttachedToCanvas;
396 #endif 392 #endif
397 393
398 typedef SkRefCnt INHERITED; 394 typedef SkRefCnt INHERITED;
399 }; 395 };
400 396
401 #endif 397 #endif
OLDNEW
« no previous file with comments | « include/core/SkCanvas.h ('k') | include/core/SkPixmap.h » ('j') | src/core/SkPixmap.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698