OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_BITMAP_PLATFORM_DEVICE_WIN_H_ | 5 #ifndef SKIA_BITMAP_PLATFORM_DEVICE_WIN_H_ |
6 #define SKIA_BITMAP_PLATFORM_DEVICE_WIN_H_ | 6 #define SKIA_BITMAP_PLATFORM_DEVICE_WIN_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "skia/ext/platform_device_win.h" | 9 #include "skia/ext/platform_device_win.h" |
10 | 10 |
11 namespace skia { | 11 namespace skia { |
12 | 12 |
| 13 class SkBitmapPlatformDeviceFactory : public SkRasterDeviceFactory { |
| 14 public: |
| 15 virtual SkDevice* newDevice(SkBitmap::Config config, int width, int height, |
| 16 bool isOpaque, bool isForLayer); |
| 17 }; |
| 18 |
13 // A device is basically a wrapper around SkBitmap that provides a surface for | 19 // A device is basically a wrapper around SkBitmap that provides a surface for |
14 // SkCanvas to draw into. Our device provides a surface Windows can also write | 20 // SkCanvas to draw into. Our device provides a surface Windows can also write |
15 // to. BitmapPlatformDevice creates a bitmap using CreateDIBSection() in a | 21 // to. BitmapPlatformDevice creates a bitmap using CreateDIBSection() in a |
16 // format that Skia supports and can then use this to draw ClearType into, etc. | 22 // format that Skia supports and can then use this to draw ClearType into, etc. |
17 // This pixel data is provided to the bitmap that the device contains so that it | 23 // This pixel data is provided to the bitmap that the device contains so that it |
18 // can be shared. | 24 // can be shared. |
19 // | 25 // |
20 // The device owns the pixel data, when the device goes away, the pixel data | 26 // The device owns the pixel data, when the device goes away, the pixel data |
21 // also becomes invalid. THIS IS DIFFERENT THAN NORMAL SKIA which uses | 27 // also becomes invalid. THIS IS DIFFERENT THAN NORMAL SKIA which uses |
22 // reference counting for the pixel data. In normal Skia, you could assign | 28 // reference counting for the pixel data. In normal Skia, you could assign |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 // the resulting GDI clip rect will be random. | 61 // the resulting GDI clip rect will be random. |
56 // | 62 // |
57 // Copy constucting and "=" is designed for saving the device or passing it | 63 // Copy constucting and "=" is designed for saving the device or passing it |
58 // around to another routine willing to deal with the bitmap data directly. | 64 // around to another routine willing to deal with the bitmap data directly. |
59 BitmapPlatformDevice(const BitmapPlatformDevice& other); | 65 BitmapPlatformDevice(const BitmapPlatformDevice& other); |
60 virtual ~BitmapPlatformDevice(); | 66 virtual ~BitmapPlatformDevice(); |
61 | 67 |
62 // See warning for copy constructor above. | 68 // See warning for copy constructor above. |
63 BitmapPlatformDevice& operator=(const BitmapPlatformDevice& other); | 69 BitmapPlatformDevice& operator=(const BitmapPlatformDevice& other); |
64 | 70 |
| 71 virtual SkDeviceFactory* getDeviceFactory() { |
| 72 return SkNEW(SkBitmapPlatformDeviceFactory); |
| 73 } |
| 74 |
65 // Retrieves the bitmap DC, which is the memory DC for our bitmap data. The | 75 // Retrieves the bitmap DC, which is the memory DC for our bitmap data. The |
66 // bitmap DC is lazy created. | 76 // bitmap DC is lazy created. |
67 virtual HDC getBitmapDC(); | 77 virtual HDC getBitmapDC(); |
68 | 78 |
69 // Loads the given transform and clipping region into the HDC. This is | 79 // Loads the given transform and clipping region into the HDC. This is |
70 // overridden from SkDevice. | 80 // overridden from SkDevice. |
71 virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region); | 81 virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region); |
72 | 82 |
73 virtual void drawToHDC(HDC dc, int x, int y, const RECT* src_rect); | 83 virtual void drawToHDC(HDC dc, int x, int y, const RECT* src_rect); |
74 virtual void makeOpaque(int x, int y, int width, int height); | 84 virtual void makeOpaque(int x, int y, int width, int height); |
(...skipping 21 matching lines...) Expand all Loading... |
96 | 106 |
97 // Data associated with this device, guaranteed non-null. We hold a reference | 107 // Data associated with this device, guaranteed non-null. We hold a reference |
98 // to this object. | 108 // to this object. |
99 BitmapPlatformDeviceData* data_; | 109 BitmapPlatformDeviceData* data_; |
100 }; | 110 }; |
101 | 111 |
102 } // namespace skia | 112 } // namespace skia |
103 | 113 |
104 #endif // SKIA_BITMAP_PLATFORM_DEVICE_WIN_H_ | 114 #endif // SKIA_BITMAP_PLATFORM_DEVICE_WIN_H_ |
105 | 115 |
OLD | NEW |