| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2010 The Android Open Source Project | 3 * Copyright 2010 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #ifndef SkDevice_DEFINED | 10 #ifndef SkDevice_DEFINED |
| 11 #define SkDevice_DEFINED | 11 #define SkDevice_DEFINED |
| 12 | 12 |
| 13 #include "SkRefCnt.h" | 13 #include "SkRefCnt.h" |
| 14 #include "SkBitmap.h" | 14 #include "SkBitmap.h" |
| 15 #include "SkCanvas.h" | 15 #include "SkCanvas.h" |
| 16 #include "SkColor.h" | 16 #include "SkColor.h" |
| 17 #include "SkDeviceProperties.h" | 17 #include "SkDeviceProperties.h" |
| 18 #include "SkImageFilter.h" | 18 #include "SkImageFilter.h" |
| 19 | 19 |
| 20 // getDeviceCapabilities() is not called by skia, but this flag keeps it around | |
| 21 // for clients that have "override" annotations on their subclass. These overrid
es | |
| 22 // should be deleted. | |
| 23 //#define SK_SUPPORT_LEGACY_GETDEVICECAPABILITIES | |
| 24 | |
| 25 //#define SK_SUPPORT_LEGACY_COMPATIBLEDEVICE_CONFIG | |
| 26 | |
| 27 class SkClipStack; | 20 class SkClipStack; |
| 28 class SkDraw; | 21 class SkDraw; |
| 29 struct SkIRect; | 22 struct SkIRect; |
| 30 class SkMatrix; | 23 class SkMatrix; |
| 31 class SkMetaData; | 24 class SkMetaData; |
| 32 class SkRegion; | 25 class SkRegion; |
| 33 | 26 |
| 34 class GrRenderTarget; | 27 class GrRenderTarget; |
| 35 | 28 |
| 36 class SK_API SkBaseDevice : public SkRefCnt { | 29 class SK_API SkBaseDevice : public SkRefCnt { |
| 37 public: | 30 public: |
| 38 SK_DECLARE_INST_COUNT(SkBaseDevice) | 31 SK_DECLARE_INST_COUNT(SkBaseDevice) |
| 39 | 32 |
| 40 /** | 33 /** |
| 41 * Construct a new device. | 34 * Construct a new device. |
| 42 */ | 35 */ |
| 43 SkBaseDevice(); | 36 SkBaseDevice(); |
| 44 | 37 |
| 45 /** | 38 /** |
| 46 * Construct a new device. | 39 * Construct a new device. |
| 47 */ | 40 */ |
| 48 SkBaseDevice(const SkDeviceProperties& deviceProperties); | 41 SkBaseDevice(const SkDeviceProperties& deviceProperties); |
| 49 | 42 |
| 50 virtual ~SkBaseDevice(); | 43 virtual ~SkBaseDevice(); |
| 51 | 44 |
| 52 #ifdef SK_SUPPORT_LEGACY_COMPATIBLEDEVICE_CONFIG | |
| 53 /** | |
| 54 * Creates a device that is of the same type as this device (e.g. SW-raster
, | |
| 55 * GPU, or PDF). The backing store for this device is created automatically | |
| 56 * (e.g. offscreen pixels or FBO or whatever is appropriate). | |
| 57 * | |
| 58 * @param width width of the device to create | |
| 59 * @param height height of the device to create | |
| 60 * @param isOpaque performance hint, set to true if you know that you will | |
| 61 * draw into this device such that all of the pixels will | |
| 62 * be opaque. | |
| 63 */ | |
| 64 SkBaseDevice* createCompatibleDevice(SkBitmap::Config config, | |
| 65 int width, int height, | |
| 66 bool isOpaque); | |
| 67 #endif | |
| 68 SkBaseDevice* createCompatibleDevice(const SkImageInfo&); | 45 SkBaseDevice* createCompatibleDevice(const SkImageInfo&); |
| 69 | 46 |
| 70 SkMetaData& getMetaData(); | 47 SkMetaData& getMetaData(); |
| 71 | 48 |
| 72 #ifdef SK_SUPPORT_LEGACY_GETDEVICECAPABILITIES | |
| 73 enum Capabilities { | |
| 74 kVector_Capability = 0x1, | |
| 75 }; | |
| 76 virtual uint32_t getDeviceCapabilities() { return 0; } | |
| 77 #endif | |
| 78 | |
| 79 /** Return the width of the device (in pixels). | 49 /** Return the width of the device (in pixels). |
| 80 */ | 50 */ |
| 81 virtual int width() const = 0; | 51 virtual int width() const = 0; |
| 82 /** Return the height of the device (in pixels). | 52 /** Return the height of the device (in pixels). |
| 83 */ | 53 */ |
| 84 virtual int height() const = 0; | 54 virtual int height() const = 0; |
| 85 | 55 |
| 86 /** Return the image properties of the device. */ | 56 /** Return the image properties of the device. */ |
| 87 virtual const SkDeviceProperties& getDeviceProperties() const { | 57 virtual const SkDeviceProperties& getDeviceProperties() const { |
| 88 //Currently, all the properties are leaky. | 58 //Currently, all the properties are leaky. |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 // but cannot change the width/height, so there should be no change to | 370 // but cannot change the width/height, so there should be no change to |
| 401 // any clip information. | 371 // any clip information. |
| 402 // TODO: move to SkBitmapDevice | 372 // TODO: move to SkBitmapDevice |
| 403 virtual void replaceBitmapBackendForRasterSurface(const SkBitmap&) = 0; | 373 virtual void replaceBitmapBackendForRasterSurface(const SkBitmap&) = 0; |
| 404 | 374 |
| 405 // just called by SkCanvas when built as a layer | 375 // just called by SkCanvas when built as a layer |
| 406 void setOrigin(int x, int y) { fOrigin.set(x, y); } | 376 void setOrigin(int x, int y) { fOrigin.set(x, y); } |
| 407 // just called by SkCanvas for saveLayer | 377 // just called by SkCanvas for saveLayer |
| 408 SkBaseDevice* createCompatibleDeviceForSaveLayer(const SkImageInfo&); | 378 SkBaseDevice* createCompatibleDeviceForSaveLayer(const SkImageInfo&); |
| 409 | 379 |
| 410 #ifdef SK_SUPPORT_LEGACY_COMPATIBLEDEVICE_CONFIG | |
| 411 /** | |
| 412 * Justs exists during the period where clients still "override" this | |
| 413 * signature. They are supported by our base-impl calling this old | |
| 414 * signature from the new one (using ImageInfo). | |
| 415 */ | |
| 416 virtual SkBaseDevice* onCreateCompatibleDevice(SkBitmap::Config config, | |
| 417 int width, int height, | |
| 418 bool isOpaque, Usage) { | |
| 419 return NULL; | |
| 420 } | |
| 421 #endif | |
| 422 virtual SkBaseDevice* onCreateDevice(const SkImageInfo&, Usage) { | 380 virtual SkBaseDevice* onCreateDevice(const SkImageInfo&, Usage) { |
| 423 return NULL; | 381 return NULL; |
| 424 } | 382 } |
| 425 | 383 |
| 426 /** Causes any deferred drawing to the device to be completed. | 384 /** Causes any deferred drawing to the device to be completed. |
| 427 */ | 385 */ |
| 428 virtual void flush() = 0; | 386 virtual void flush() = 0; |
| 429 | 387 |
| 430 SkIPoint fOrigin; | 388 SkIPoint fOrigin; |
| 431 SkMetaData* fMetaData; | 389 SkMetaData* fMetaData; |
| 432 | 390 |
| 433 #ifdef SK_DEBUG | 391 #ifdef SK_DEBUG |
| 434 bool fAttachedToCanvas; | 392 bool fAttachedToCanvas; |
| 435 #endif | 393 #endif |
| 436 | 394 |
| 437 typedef SkRefCnt INHERITED; | 395 typedef SkRefCnt INHERITED; |
| 438 }; | 396 }; |
| 439 | 397 |
| 440 #endif | 398 #endif |
| OLD | NEW |