OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_WIN_H_ | 5 #ifndef SKIA_EXT_BITMAP_PLATFORM_DEVICE_WIN_H_ |
6 #define SKIA_EXT_BITMAP_PLATFORM_DEVICE_WIN_H_ | 6 #define SKIA_EXT_BITMAP_PLATFORM_DEVICE_WIN_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "skia/ext/platform_device_win.h" | 10 #include "skia/ext/platform_device_win.h" |
11 | 11 |
12 namespace skia { | 12 namespace skia { |
13 | 13 |
| 14 class BitmapPlatformDeviceFactory : public SkDeviceFactory { |
| 15 public: |
| 16 virtual SkDevice* newDevice(SkCanvas* ignored, SkBitmap::Config config, |
| 17 int width, int height, |
| 18 bool isOpaque, bool isForLayer); |
| 19 }; |
| 20 |
14 // A device is basically a wrapper around SkBitmap that provides a surface for | 21 // A device is basically a wrapper around SkBitmap that provides a surface for |
15 // SkCanvas to draw into. Our device provides a surface Windows can also write | 22 // SkCanvas to draw into. Our device provides a surface Windows can also write |
16 // to. BitmapPlatformDevice creates a bitmap using CreateDIBSection() in a | 23 // to. BitmapPlatformDevice creates a bitmap using CreateDIBSection() in a |
17 // format that Skia supports and can then use this to draw ClearType into, etc. | 24 // format that Skia supports and can then use this to draw ClearType into, etc. |
18 // This pixel data is provided to the bitmap that the device contains so that it | 25 // This pixel data is provided to the bitmap that the device contains so that it |
19 // can be shared. | 26 // can be shared. |
20 // | 27 // |
21 // The device owns the pixel data, when the device goes away, the pixel data | 28 // The device owns the pixel data, when the device goes away, the pixel data |
22 // also becomes invalid. THIS IS DIFFERENT THAN NORMAL SKIA which uses | 29 // also becomes invalid. THIS IS DIFFERENT THAN NORMAL SKIA which uses |
23 // reference counting for the pixel data. In normal Skia, you could assign | 30 // reference counting for the pixel data. In normal Skia, you could assign |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 // overridden from SkDevice. | 68 // overridden from SkDevice. |
62 virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region, | 69 virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region, |
63 const SkClipStack&); | 70 const SkClipStack&); |
64 | 71 |
65 protected: | 72 protected: |
66 // Flushes the Windows device context so that the pixel data can be accessed | 73 // Flushes the Windows device context so that the pixel data can be accessed |
67 // directly by Skia. Overridden from SkDevice, this is called when Skia | 74 // directly by Skia. Overridden from SkDevice, this is called when Skia |
68 // starts accessing pixel data. | 75 // starts accessing pixel data. |
69 virtual void onAccessBitmap(SkBitmap* bitmap); | 76 virtual void onAccessBitmap(SkBitmap* bitmap); |
70 | 77 |
71 virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config, int width, | 78 // Override SkDevice. |
72 int height, bool isOpaque, | 79 virtual SkDeviceFactory* onNewDeviceFactory(); |
73 Usage usage); | |
74 | 80 |
75 private: | 81 private: |
76 // Reference counted data that can be shared between multiple devices. This | 82 // Reference counted data that can be shared between multiple devices. This |
77 // allows copy constructors and operator= for devices to work properly. The | 83 // allows copy constructors and operator= for devices to work properly. The |
78 // bitmaps used by the base device class are already refcounted and copyable. | 84 // bitmaps used by the base device class are already refcounted and copyable. |
79 class BitmapPlatformDeviceData; | 85 class BitmapPlatformDeviceData; |
80 | 86 |
81 // Private constructor. The data should already be ref'ed for us. | 87 // Private constructor. The data should already be ref'ed for us. |
82 BitmapPlatformDevice(BitmapPlatformDeviceData* data, | 88 BitmapPlatformDevice(BitmapPlatformDeviceData* data, |
83 const SkBitmap& bitmap); | 89 const SkBitmap& bitmap); |
84 | 90 |
85 // Data associated with this device, guaranteed non-null. We hold a reference | 91 // Data associated with this device, guaranteed non-null. We hold a reference |
86 // to this object. | 92 // to this object. |
87 BitmapPlatformDeviceData* data_; | 93 BitmapPlatformDeviceData* data_; |
88 | 94 |
89 #ifdef SK_DEBUG | 95 #ifdef SK_DEBUG |
90 int begin_paint_count_; | 96 int begin_paint_count_; |
91 #endif | 97 #endif |
92 | 98 |
93 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice); | 99 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice); |
94 }; | 100 }; |
95 | 101 |
96 } // namespace skia | 102 } // namespace skia |
97 | 103 |
98 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_WIN_H_ | 104 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_WIN_H_ |
99 | 105 |
OLD | NEW |