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_PLATFORM_DEVICE_WIN_H_ | 5 #ifndef SKIA_EXT_PLATFORM_DEVICE_WIN_H_ |
6 #define SKIA_EXT_PLATFORM_DEVICE_WIN_H_ | 6 #define SKIA_EXT_PLATFORM_DEVICE_WIN_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <windows.h> | 9 #include <windows.h> |
10 | 10 |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "third_party/skia/include/core/SkDevice.h" | 13 #include "third_party/skia/include/core/SkDevice.h" |
14 | 14 |
15 class SkMatrix; | 15 class SkMatrix; |
16 class SkPath; | 16 class SkPath; |
17 class SkRegion; | 17 class SkRegion; |
18 | 18 |
19 namespace skia { | 19 namespace skia { |
20 | 20 |
| 21 // Sets the opacity of each pixel in the specified region to be opaque. |
| 22 SK_API void MakeOpaque(SkDevice* device, int x, int y, int width, int height); |
| 23 |
| 24 // Initializes the default settings and colors in a device context. |
| 25 SK_API void InitializeDC(HDC context); |
| 26 |
21 // A device is basically a wrapper around SkBitmap that provides a surface for | 27 // 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 | 28 // SkCanvas to draw into. Our device provides a surface Windows can also write |
23 // to. It also provides functionality to play well with GDI drawing functions. | 29 // to. It also provides functionality to play well with GDI drawing functions. |
24 // This class is abstract and must be subclassed. It provides the basic | 30 // This class is abstract and must be subclassed. It provides the basic |
25 // interface to implement it either with or without a bitmap backend. | 31 // interface to implement it either with or without a bitmap backend. |
26 class SK_API PlatformDevice : public SkDevice { | 32 class SK_API PlatformDevice : public SkDevice { |
27 public: | 33 public: |
28 typedef HDC PlatformSurface; | 34 typedef HDC PlatformSurface; |
29 | 35 |
30 // The DC that corresponds to the bitmap, used for GDI operations drawing | 36 // The DC that corresponds to the bitmap, used for GDI operations drawing |
31 // into the bitmap. This is possibly heavyweight, so it should be existant | 37 // into the bitmap. This is possibly heavyweight, so it should be existant |
32 // only during one pass of rendering. | 38 // only during one pass of rendering. |
33 virtual PlatformSurface BeginPlatformPaint() = 0; | 39 virtual PlatformSurface BeginPlatformPaint() = 0; |
34 | 40 |
35 // Finish a previous call to beginPlatformPaint. | 41 // Finish a previous call to beginPlatformPaint. |
36 virtual void EndPlatformPaint(); | 42 virtual void EndPlatformPaint(); |
37 | 43 |
38 // Draws to the given screen DC, if the bitmap DC doesn't exist, this will | 44 // Draws to the given screen DC, if the bitmap DC doesn't exist, this will |
39 // temporarily create it. However, if you have created the bitmap DC, it will | 45 // temporarily create it. However, if you have created the bitmap DC, it will |
40 // be more efficient if you don't free it until after this call so it doesn't | 46 // be more efficient if you don't free it until after this call so it doesn't |
41 // have to be created twice. If src_rect is null, then the entirety of the | 47 // have to be created twice. If src_rect is null, then the entirety of the |
42 // source device will be copied. | 48 // source device will be copied. |
43 virtual void drawToHDC(HDC dc, int x, int y, const RECT* src_rect) = 0; | 49 virtual void DrawToNativeContext(HDC dc, int x, int y, |
| 50 const RECT* src_rect) = 0; |
44 | 51 |
45 // Sets the opacity of each pixel in the specified region to be opaque. | 52 // Sets the opacity of each pixel in the specified region to be opaque. |
46 virtual void makeOpaque(int x, int y, int width, int height) { } | 53 virtual void MakeOpaque(int x, int y, int width, int height) { } |
47 | 54 |
48 // Returns if the preferred rendering engine is vectorial or bitmap based. | 55 // Returns if the preferred rendering engine is vectorial or bitmap based. |
49 virtual bool IsVectorial() = 0; | 56 virtual bool IsVectorial() = 0; |
50 | 57 |
51 // Returns if GDI is allowed to render text to this device. | 58 // Returns if GDI is allowed to render text to this device. |
52 virtual bool IsNativeFontRenderingAllowed() { return true; } | 59 virtual bool IsNativeFontRenderingAllowed() { return true; } |
53 | 60 |
54 // Initializes the default settings and colors in a device context. | |
55 static void InitializeDC(HDC context); | |
56 | |
57 // Loads a SkPath into the GDI context. The path can there after be used for | 61 // Loads a SkPath into the GDI context. The path can there after be used for |
58 // clipping or as a stroke. | 62 // clipping or as a stroke. |
59 static void LoadPathToDC(HDC context, const SkPath& path); | 63 static void LoadPathToDC(HDC context, const SkPath& path); |
60 | 64 |
61 // Loads a SkRegion into the GDI context. | 65 // Loads a SkRegion into the GDI context. |
62 static void LoadClippingRegionToDC(HDC context, const SkRegion& region, | 66 static void LoadClippingRegionToDC(HDC context, const SkRegion& region, |
63 const SkMatrix& transformation); | 67 const SkMatrix& transformation); |
64 | 68 |
65 protected: | 69 protected: |
66 // Arrays must be inside structures. | 70 // Arrays must be inside structures. |
(...skipping 11 matching lines...) Expand all Loading... |
78 static void LoadTransformToDC(HDC dc, const SkMatrix& matrix); | 82 static void LoadTransformToDC(HDC dc, const SkMatrix& matrix); |
79 | 83 |
80 // Transforms SkPath's paths into a series of cubic path. | 84 // Transforms SkPath's paths into a series of cubic path. |
81 static bool SkPathToCubicPaths(CubicPaths* paths, const SkPath& skpath); | 85 static bool SkPathToCubicPaths(CubicPaths* paths, const SkPath& skpath); |
82 }; | 86 }; |
83 | 87 |
84 } // namespace skia | 88 } // namespace skia |
85 | 89 |
86 #endif // SKIA_EXT_PLATFORM_DEVICE_WIN_H_ | 90 #endif // SKIA_EXT_PLATFORM_DEVICE_WIN_H_ |
87 | 91 |
OLD | NEW |