| 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 26 matching lines...) Expand all Loading... |
| 37 * Construct a new device. | 37 * Construct a new device. |
| 38 */ | 38 */ |
| 39 SkBaseDevice(const SkDeviceProperties& deviceProperties); | 39 SkBaseDevice(const SkDeviceProperties& deviceProperties); |
| 40 | 40 |
| 41 virtual ~SkBaseDevice(); | 41 virtual ~SkBaseDevice(); |
| 42 | 42 |
| 43 SkBaseDevice* createCompatibleDevice(const SkImageInfo&); | 43 SkBaseDevice* createCompatibleDevice(const SkImageInfo&); |
| 44 | 44 |
| 45 SkMetaData& getMetaData(); | 45 SkMetaData& getMetaData(); |
| 46 | 46 |
| 47 /** Return the width of the device (in pixels). | |
| 48 */ | |
| 49 virtual int width() const = 0; | |
| 50 /** Return the height of the device (in pixels). | |
| 51 */ | |
| 52 virtual int height() const = 0; | |
| 53 | |
| 54 /** Return the image properties of the device. */ | 47 /** Return the image properties of the device. */ |
| 55 virtual const SkDeviceProperties& getDeviceProperties() const { | 48 virtual const SkDeviceProperties& getDeviceProperties() const { |
| 56 //Currently, all the properties are leaky. | 49 //Currently, all the properties are leaky. |
| 57 return fLeakyProperties; | 50 return fLeakyProperties; |
| 58 } | 51 } |
| 59 | 52 |
| 60 /** | 53 /** |
| 61 * Return ImageInfo for this device. If the canvas is not backed by pixels | 54 * Return ImageInfo for this device. If the canvas is not backed by pixels |
| 62 * (cpu or gpu), then the info's ColorType will be kUnknown_SkColorType. | 55 * (cpu or gpu), then the info's ColorType will be kUnknown_SkColorType. |
| 63 */ | 56 */ |
| 64 virtual SkImageInfo imageInfo() const; | 57 virtual SkImageInfo imageInfo() const; |
| 65 | 58 |
| 66 /** | 59 /** |
| 67 * Return the bounds of the device in the coordinate space of the root | 60 * Return the bounds of the device in the coordinate space of the root |
| 68 * canvas. The root device will have its top-left at 0,0, but other devices | 61 * canvas. The root device will have its top-left at 0,0, but other devices |
| 69 * such as those associated with saveLayer may have a non-zero origin. | 62 * such as those associated with saveLayer may have a non-zero origin. |
| 70 */ | 63 */ |
| 71 void getGlobalBounds(SkIRect* bounds) const { | 64 void getGlobalBounds(SkIRect* bounds) const { |
| 72 SkASSERT(bounds); | 65 SkASSERT(bounds); |
| 73 const SkIPoint& origin = this->getOrigin(); | 66 const SkIPoint& origin = this->getOrigin(); |
| 74 bounds->setXYWH(origin.x(), origin.y(), this->width(), this->height()); | 67 bounds->setXYWH(origin.x(), origin.y(), this->width(), this->height()); |
| 75 } | 68 } |
| 76 | 69 |
| 77 /** Returns true if the device's bitmap's config treats every pixel as | 70 #ifdef SK_SUPPORT_LEGACY_DEVICE_VIRTUAL_ISOPAQUE |
| 78 implicitly opaque. | 71 virtual int width() const { |
| 79 */ | 72 return this->imageInfo().width(); |
| 80 virtual bool isOpaque() const = 0; | 73 } |
| 74 virtual int height() const { |
| 75 return this->imageInfo().height(); |
| 76 } |
| 77 virtual bool isOpaque() const { |
| 78 return this->imageInfo().isOpaque(); |
| 79 } |
| 80 #else |
| 81 int width() const { |
| 82 return this->imageInfo().width(); |
| 83 } |
| 84 int height() const { |
| 85 return this->imageInfo().height(); |
| 86 } |
| 87 bool isOpaque() const { |
| 88 return this->imageInfo().isOpaque(); |
| 89 } |
| 90 #endif |
| 81 | 91 |
| 82 /** Return the bitmap associated with this device. Call this each time you n
eed | 92 /** Return the bitmap associated with this device. Call this each time you n
eed |
| 83 to access the bitmap, as it notifies the subclass to perform any flushin
g | 93 to access the bitmap, as it notifies the subclass to perform any flushin
g |
| 84 etc. before you examine the pixels. | 94 etc. before you examine the pixels. |
| 85 @param changePixels set to true if the caller plans to change the pixels | 95 @param changePixels set to true if the caller plans to change the pixels |
| 86 @return the device's bitmap | 96 @return the device's bitmap |
| 87 */ | 97 */ |
| 88 const SkBitmap& accessBitmap(bool changePixels); | 98 const SkBitmap& accessBitmap(bool changePixels); |
| 89 | 99 |
| 90 bool writePixels(const SkImageInfo&, const void*, size_t rowBytes, int x, in
t y); | 100 bool writePixels(const SkImageInfo&, const void*, size_t rowBytes, int x, in
t y); |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 SkMetaData* fMetaData; | 399 SkMetaData* fMetaData; |
| 390 | 400 |
| 391 #ifdef SK_DEBUG | 401 #ifdef SK_DEBUG |
| 392 bool fAttachedToCanvas; | 402 bool fAttachedToCanvas; |
| 393 #endif | 403 #endif |
| 394 | 404 |
| 395 typedef SkRefCnt INHERITED; | 405 typedef SkRefCnt INHERITED; |
| 396 }; | 406 }; |
| 397 | 407 |
| 398 #endif | 408 #endif |
| OLD | NEW |