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