| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef SKIA_EXT_BITMAP_PLATFORM_DEVICE_DATA_H_ | 5 #ifndef SKIA_EXT_BITMAP_PLATFORM_DEVICE_DATA_H_ |
| 6 #define SKIA_EXT_BITMAP_PLATFORM_DEVICE_DATA_H_ | 6 #define SKIA_EXT_BITMAP_PLATFORM_DEVICE_DATA_H_ |
| 7 | 7 |
| 8 #include "skia/ext/bitmap_platform_device.h" | 8 #include "skia/ext/bitmap_platform_device.h" |
| 9 | 9 |
| 10 namespace skia { | 10 namespace skia { |
| 11 | 11 |
| 12 class BitmapPlatformDevice::BitmapPlatformDeviceData : | 12 class BitmapPlatformDevice::BitmapPlatformDeviceData : |
| 13 #if defined(WIN32) || defined(__APPLE__) | 13 #if defined(WIN32) || defined(__APPLE__) |
| 14 public SkRefCnt { | 14 public SkRefCnt { |
| 15 #elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) | 15 #elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defi
ned(__sun) |
| 16 // These objects are reference counted and own a Cairo surface. The surface | 16 // These objects are reference counted and own a Cairo surface. The surface |
| 17 // is the backing store for a Skia bitmap and we reference count it so that | 17 // is the backing store for a Skia bitmap and we reference count it so that |
| 18 // we can copy BitmapPlatformDevice objects without having to copy all the | 18 // we can copy BitmapPlatformDevice objects without having to copy all the |
| 19 // image data. | 19 // image data. |
| 20 public base::RefCounted<BitmapPlatformDeviceData> { | 20 public base::RefCounted<BitmapPlatformDeviceData> { |
| 21 #endif | 21 #endif |
| 22 | 22 |
| 23 public: | 23 public: |
| 24 #if defined(WIN32) | 24 #if defined(WIN32) |
| 25 typedef HBITMAP PlatformContext; | 25 typedef HBITMAP PlatformContext; |
| 26 #elif defined(__APPLE__) | 26 #elif defined(__APPLE__) |
| 27 typedef CGContextRef PlatformContext; | 27 typedef CGContextRef PlatformContext; |
| 28 #elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) | 28 #elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defi
ned(__sun) |
| 29 typedef cairo_t* PlatformContext; | 29 typedef cairo_t* PlatformContext; |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 #if defined(WIN32) || defined(__APPLE__) | 32 #if defined(WIN32) || defined(__APPLE__) |
| 33 explicit BitmapPlatformDeviceData(PlatformContext bitmap); | 33 explicit BitmapPlatformDeviceData(PlatformContext bitmap); |
| 34 #elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) | 34 #elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defi
ned(__sun) |
| 35 explicit BitmapPlatformDeviceData(cairo_surface_t* surface); | 35 explicit BitmapPlatformDeviceData(cairo_surface_t* surface); |
| 36 #endif | 36 #endif |
| 37 | 37 |
| 38 #if defined(WIN32) | 38 #if defined(WIN32) |
| 39 // Create/destroy hdc_, which is the memory DC for our bitmap data. | 39 // Create/destroy hdc_, which is the memory DC for our bitmap data. |
| 40 HDC GetBitmapDC(); | 40 HDC GetBitmapDC(); |
| 41 void ReleaseBitmapDC(); | 41 void ReleaseBitmapDC(); |
| 42 bool IsBitmapDCCreated() const; | 42 bool IsBitmapDCCreated() const; |
| 43 #endif | 43 #endif |
| 44 | 44 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 57 | 57 |
| 58 const SkMatrix& transform() const { | 58 const SkMatrix& transform() const { |
| 59 return transform_; | 59 return transform_; |
| 60 } | 60 } |
| 61 | 61 |
| 62 PlatformContext bitmap_context() { | 62 PlatformContext bitmap_context() { |
| 63 return bitmap_context_; | 63 return bitmap_context_; |
| 64 } | 64 } |
| 65 | 65 |
| 66 private: | 66 private: |
| 67 #if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) | 67 #if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || define
d(__sun) |
| 68 friend class base::RefCounted<BitmapPlatformDeviceData>; | 68 friend class base::RefCounted<BitmapPlatformDeviceData>; |
| 69 #endif | 69 #endif |
| 70 virtual ~BitmapPlatformDeviceData(); | 70 virtual ~BitmapPlatformDeviceData(); |
| 71 | 71 |
| 72 // Lazily-created graphics context used to draw into the bitmap. | 72 // Lazily-created graphics context used to draw into the bitmap. |
| 73 PlatformContext bitmap_context_; | 73 PlatformContext bitmap_context_; |
| 74 | 74 |
| 75 #if defined(WIN32) | 75 #if defined(WIN32) |
| 76 // Lazily-created DC used to draw into the bitmap, see GetBitmapDC(). | 76 // Lazily-created DC used to draw into the bitmap, see GetBitmapDC(). |
| 77 HDC hdc_; | 77 HDC hdc_; |
| 78 #elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) | 78 #elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defi
ned(__sun) |
| 79 cairo_surface_t *const surface_; | 79 cairo_surface_t *const surface_; |
| 80 #endif | 80 #endif |
| 81 | 81 |
| 82 // True when there is a transform or clip that has not been set to the | 82 // True when there is a transform or clip that has not been set to the |
| 83 // context. The context is retrieved for every text operation, and the | 83 // context. The context is retrieved for every text operation, and the |
| 84 // transform and clip do not change as much. We can save time by not loading | 84 // transform and clip do not change as much. We can save time by not loading |
| 85 // the clip and transform for every one. | 85 // the clip and transform for every one. |
| 86 bool config_dirty_; | 86 bool config_dirty_; |
| 87 | 87 |
| 88 // Translation assigned to the context: we need to keep track of this | 88 // Translation assigned to the context: we need to keep track of this |
| 89 // separately so it can be updated even if the context isn't created yet. | 89 // separately so it can be updated even if the context isn't created yet. |
| 90 SkMatrix transform_; | 90 SkMatrix transform_; |
| 91 | 91 |
| 92 // The current clipping | 92 // The current clipping |
| 93 SkRegion clip_region_; | 93 SkRegion clip_region_; |
| 94 | 94 |
| 95 // Disallow copy & assign. | 95 // Disallow copy & assign. |
| 96 BitmapPlatformDeviceData(const BitmapPlatformDeviceData&); | 96 BitmapPlatformDeviceData(const BitmapPlatformDeviceData&); |
| 97 BitmapPlatformDeviceData& operator=(const BitmapPlatformDeviceData&); | 97 BitmapPlatformDeviceData& operator=(const BitmapPlatformDeviceData&); |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 } // namespace skia | 100 } // namespace skia |
| 101 | 101 |
| 102 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_DATA_H_ | 102 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_DATA_H_ |
| OLD | NEW |