| 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 |
| 11 #include "SkRefCnt.h" | 11 #include "SkRefCnt.h" |
| 12 #include "SkBitmap.h" | 12 #include "SkBitmap.h" |
| 13 #include "SkCanvas.h" | 13 #include "SkCanvas.h" |
| 14 #include "SkColor.h" | 14 #include "SkColor.h" |
| 15 #include "SkDeviceProperties.h" | |
| 16 #include "SkImageFilter.h" | 15 #include "SkImageFilter.h" |
| 17 | 16 |
| 18 class SkClipStack; | 17 class SkClipStack; |
| 19 class SkDraw; | 18 class SkDraw; |
| 20 struct SkIRect; | 19 struct SkIRect; |
| 21 class SkMatrix; | 20 class SkMatrix; |
| 22 class SkMetaData; | 21 class SkMetaData; |
| 23 class SkRegion; | 22 class SkRegion; |
| 24 | 23 struct SkDeviceProperties; |
| 25 class GrRenderTarget; | 24 class GrRenderTarget; |
| 26 | 25 |
| 27 class SK_API SkBaseDevice : public SkRefCnt { | 26 class SK_API SkBaseDevice : public SkRefCnt { |
| 28 public: | 27 public: |
| 29 SK_DECLARE_INST_COUNT(SkBaseDevice) | 28 SK_DECLARE_INST_COUNT(SkBaseDevice) |
| 30 | 29 |
| 31 /** | 30 /** |
| 32 * Construct a new device. | 31 * Construct a new device. |
| 33 */ | 32 */ |
| 34 SkBaseDevice(); | 33 SkBaseDevice(); |
| 35 | |
| 36 /** | |
| 37 * Construct a new device. | |
| 38 */ | |
| 39 SkBaseDevice(const SkDeviceProperties& deviceProperties); | |
| 40 | |
| 41 virtual ~SkBaseDevice(); | 34 virtual ~SkBaseDevice(); |
| 42 | 35 |
| 43 SkBaseDevice* createCompatibleDevice(const SkImageInfo&); | 36 SkBaseDevice* createCompatibleDevice(const SkImageInfo&); |
| 44 | 37 |
| 45 SkMetaData& getMetaData(); | 38 SkMetaData& getMetaData(); |
| 46 | 39 |
| 47 /** Return the image properties of the device. */ | |
| 48 virtual const SkDeviceProperties& getDeviceProperties() const { | |
| 49 //Currently, all the properties are leaky. | |
| 50 return fLeakyProperties; | |
| 51 } | |
| 52 | |
| 53 /** | 40 /** |
| 54 * Return ImageInfo for this device. If the canvas is not backed by pixels | 41 * Return ImageInfo for this device. If the canvas is not backed by pixels |
| 55 * (cpu or gpu), then the info's ColorType will be kUnknown_SkColorType. | 42 * (cpu or gpu), then the info's ColorType will be kUnknown_SkColorType. |
| 56 */ | 43 */ |
| 57 virtual SkImageInfo imageInfo() const; | 44 virtual SkImageInfo imageInfo() const; |
| 58 | 45 |
| 59 /** | 46 /** |
| 60 * Return the bounds of the device in the coordinate space of the root | 47 * Return the bounds of the device in the coordinate space of the root |
| 61 * canvas. The root device will have its top-left at 0,0, but other devices | 48 * canvas. The root device will have its top-left at 0,0, but other devices |
| 62 * such as those associated with saveLayer may have a non-zero origin. | 49 * such as those associated with saveLayer may have a non-zero origin. |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 * Default impl returns NULL. | 313 * Default impl returns NULL. |
| 327 */ | 314 */ |
| 328 virtual void* onAccessPixels(SkImageInfo* info, size_t* rowBytes); | 315 virtual void* onAccessPixels(SkImageInfo* info, size_t* rowBytes); |
| 329 | 316 |
| 330 /** | 317 /** |
| 331 * Leaky properties are those which the device should be applying but it is
n't. | 318 * Leaky properties are those which the device should be applying but it is
n't. |
| 332 * These properties will be applied by the draw, when and as it can. | 319 * These properties will be applied by the draw, when and as it can. |
| 333 * If the device does handle a property, that property should be set to the
identity value | 320 * If the device does handle a property, that property should be set to the
identity value |
| 334 * for that property, effectively making it non-leaky. | 321 * for that property, effectively making it non-leaky. |
| 335 */ | 322 */ |
| 336 SkDeviceProperties fLeakyProperties; | 323 const SkDeviceProperties& getLeakyProperties() const { |
| 324 return *fLeakyProperties; |
| 325 } |
| 337 | 326 |
| 338 /** | 327 /** |
| 339 * PRIVATE / EXPERIMENTAL -- do not call | 328 * PRIVATE / EXPERIMENTAL -- do not call |
| 340 * Construct an acceleration object and attach it to 'picture' | 329 * Construct an acceleration object and attach it to 'picture' |
| 341 */ | 330 */ |
| 342 virtual void EXPERIMENTAL_optimize(const SkPicture* picture); | 331 virtual void EXPERIMENTAL_optimize(const SkPicture* picture); |
| 343 | 332 |
| 344 /** | 333 /** |
| 345 * PRIVATE / EXPERIMENTAL -- do not call | 334 * PRIVATE / EXPERIMENTAL -- do not call |
| 346 * This entry point gives the backend an opportunity to take over the rende
ring | 335 * This entry point gives the backend an opportunity to take over the rende
ring |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 } | 372 } |
| 384 | 373 |
| 385 /** Causes any deferred drawing to the device to be completed. | 374 /** Causes any deferred drawing to the device to be completed. |
| 386 */ | 375 */ |
| 387 virtual void flush() {} | 376 virtual void flush() {} |
| 388 | 377 |
| 389 virtual SkImageFilter::Cache* getImageFilterCache() { return NULL; } | 378 virtual SkImageFilter::Cache* getImageFilterCache() { return NULL; } |
| 390 | 379 |
| 391 SkIPoint fOrigin; | 380 SkIPoint fOrigin; |
| 392 SkMetaData* fMetaData; | 381 SkMetaData* fMetaData; |
| 382 SkDeviceProperties* fLeakyProperties; // will always exist. |
| 393 | 383 |
| 394 #ifdef SK_DEBUG | 384 #ifdef SK_DEBUG |
| 395 bool fAttachedToCanvas; | 385 bool fAttachedToCanvas; |
| 396 #endif | 386 #endif |
| 397 | 387 |
| 398 typedef SkRefCnt INHERITED; | 388 typedef SkRefCnt INHERITED; |
| 399 }; | 389 }; |
| 400 | 390 |
| 401 #endif | 391 #endif |
| OLD | NEW |