OLD | NEW |
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 } | 70 } |
71 | 71 |
72 int height() const { | 72 int height() const { |
73 return this->imageInfo().height(); | 73 return this->imageInfo().height(); |
74 } | 74 } |
75 | 75 |
76 bool isOpaque() const { | 76 bool isOpaque() const { |
77 return this->imageInfo().isOpaque(); | 77 return this->imageInfo().isOpaque(); |
78 } | 78 } |
79 | 79 |
| 80 #ifdef SK_SUPPORT_LEGACY_ACCESSBITMAP |
80 /** Return the bitmap associated with this device. Call this each time you n
eed | 81 /** Return the bitmap associated with this device. Call this each time you n
eed |
81 to access the bitmap, as it notifies the subclass to perform any flushin
g | 82 to access the bitmap, as it notifies the subclass to perform any flushin
g |
82 etc. before you examine the pixels. | 83 etc. before you examine the pixels. |
83 @param changePixels set to true if the caller plans to change the pixels | 84 @param changePixels set to true if the caller plans to change the pixels |
84 @return the device's bitmap | 85 @return the device's bitmap |
85 */ | 86 */ |
86 const SkBitmap& accessBitmap(bool changePixels); | 87 const SkBitmap& accessBitmap(bool changePixels); |
| 88 #endif |
87 | 89 |
88 bool writePixels(const SkImageInfo&, const void*, size_t rowBytes, int x, in
t y); | 90 bool writePixels(const SkImageInfo&, const void*, size_t rowBytes, int x, in
t y); |
89 | 91 |
90 /** | 92 /** |
91 * Try to get write-access to the pixels behind the device. If successful,
this returns true | 93 * Try to get write-access to the pixels behind the device. If successful,
this returns true |
92 * and fills-out the pixmap parameter. On success it also bumps the genID o
f the underlying | 94 * and fills-out the pixmap parameter. On success it also bumps the genID o
f the underlying |
93 * bitmap. | 95 * bitmap. |
94 * | 96 * |
95 * On failure, returns false and ignores the pixmap parameter. | 97 * On failure, returns false and ignores the pixmap parameter. |
96 */ | 98 */ |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 | 271 |
270 virtual void drawSpecial(const SkDraw&, SkSpecialImage*, int x, int y, const
SkPaint&); | 272 virtual void drawSpecial(const SkDraw&, SkSpecialImage*, int x, int y, const
SkPaint&); |
271 virtual sk_sp<SkSpecialImage> makeSpecial(const SkBitmap&); | 273 virtual sk_sp<SkSpecialImage> makeSpecial(const SkBitmap&); |
272 virtual sk_sp<SkSpecialImage> makeSpecial(const SkImage*); | 274 virtual sk_sp<SkSpecialImage> makeSpecial(const SkImage*); |
273 virtual sk_sp<SkSpecialImage> snapSpecial(); | 275 virtual sk_sp<SkSpecialImage> snapSpecial(); |
274 | 276 |
275 bool readPixels(const SkImageInfo&, void* dst, size_t rowBytes, int x, int y
); | 277 bool readPixels(const SkImageInfo&, void* dst, size_t rowBytes, int x, int y
); |
276 | 278 |
277 /////////////////////////////////////////////////////////////////////////// | 279 /////////////////////////////////////////////////////////////////////////// |
278 | 280 |
| 281 #ifdef SK_SUPPORT_LEGACY_ACCESSBITMAP |
279 /** Update as needed the pixel value in the bitmap, so that the caller can | 282 /** Update as needed the pixel value in the bitmap, so that the caller can |
280 access the pixels directly. | 283 access the pixels directly. |
281 @return The device contents as a bitmap | 284 @return The device contents as a bitmap |
282 */ | 285 */ |
283 virtual const SkBitmap& onAccessBitmap() = 0; | 286 virtual const SkBitmap& onAccessBitmap() { |
| 287 SkASSERT(0); |
| 288 return fLegacyBitmap; |
| 289 } |
| 290 #endif |
284 | 291 |
285 virtual GrContext* context() const { return nullptr; } | 292 virtual GrContext* context() const { return nullptr; } |
286 | 293 |
287 protected: | 294 protected: |
288 virtual sk_sp<SkSurface> makeSurface(const SkImageInfo&, const SkSurfaceProp
s&); | 295 virtual sk_sp<SkSurface> makeSurface(const SkImageInfo&, const SkSurfaceProp
s&); |
289 virtual bool onPeekPixels(SkPixmap*) { return false; } | 296 virtual bool onPeekPixels(SkPixmap*) { return false; } |
290 | 297 |
291 /** | 298 /** |
292 * The caller is responsible for "pre-clipping" the dst. The impl can assum
e that the dst | 299 * The caller is responsible for "pre-clipping" the dst. The impl can assum
e that the dst |
293 * image at the specified x,y offset will fit within the device's bounds. | 300 * image at the specified x,y offset will fit within the device's bounds. |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 /** Causes any deferred drawing to the device to be completed. | 387 /** Causes any deferred drawing to the device to be completed. |
381 */ | 388 */ |
382 virtual void flush() {} | 389 virtual void flush() {} |
383 | 390 |
384 virtual SkImageFilterCache* getImageFilterCache() { return NULL; } | 391 virtual SkImageFilterCache* getImageFilterCache() { return NULL; } |
385 | 392 |
386 SkIPoint fOrigin; | 393 SkIPoint fOrigin; |
387 SkMetaData* fMetaData; | 394 SkMetaData* fMetaData; |
388 SkSurfaceProps fSurfaceProps; | 395 SkSurfaceProps fSurfaceProps; |
389 | 396 |
| 397 #ifdef SK_SUPPORT_LEGACY_ACCESSBITMAP |
| 398 SkBitmap fLegacyBitmap; |
| 399 #endif |
| 400 |
390 #ifdef SK_DEBUG | 401 #ifdef SK_DEBUG |
391 bool fAttachedToCanvas; | 402 bool fAttachedToCanvas; |
392 #endif | 403 #endif |
393 | 404 |
394 typedef SkRefCnt INHERITED; | 405 typedef SkRefCnt INHERITED; |
395 }; | 406 }; |
396 | 407 |
397 #endif | 408 #endif |
OLD | NEW |