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 // Initializes the default settings and colors in a device context. | 21 // Initializes the default settings and colors in a device context. |
22 SK_API void InitializeDC(HDC context); | 22 SK_API void InitializeDC(HDC context); |
23 | 23 |
24 // A device is basically a wrapper around SkBitmap that provides a surface for | 24 // A device is basically a wrapper around SkBitmap that provides a surface for |
25 // SkCanvas to draw into. Our device provides a surface Windows can also write | 25 // SkCanvas to draw into. Our device provides a surface Windows can also write |
26 // to. It also provides functionality to play well with GDI drawing functions. | 26 // to. It also provides functionality to play well with GDI drawing functions. |
27 // This class is abstract and must be subclassed. It provides the basic | 27 // This class is abstract and must be subclassed. It provides the basic |
28 // interface to implement it either with or without a bitmap backend. | 28 // interface to implement it either with or without a bitmap backend. |
29 class SK_API PlatformDevice : public SkDevice { | 29 class SK_API PlatformDevice /*: public SkDevice */ { |
30 public: | 30 public: |
31 typedef HDC PlatformSurface; | 31 typedef HDC PlatformSurface; |
32 | 32 |
33 // The DC that corresponds to the bitmap, used for GDI operations drawing | 33 // The DC that corresponds to the bitmap, used for GDI operations drawing |
34 // into the bitmap. This is possibly heavyweight, so it should be existant | 34 // into the bitmap. This is possibly heavyweight, so it should be existant |
35 // only during one pass of rendering. | 35 // only during one pass of rendering. |
36 virtual PlatformSurface BeginPlatformPaint() = 0; | 36 virtual PlatformSurface BeginPlatformPaint() = 0; |
37 | 37 |
38 // Finish a previous call to beginPlatformPaint. | 38 // Finish a previous call to beginPlatformPaint. |
39 virtual void EndPlatformPaint(); | 39 virtual void EndPlatformPaint(); |
(...skipping 18 matching lines...) Expand all Loading... |
58 virtual bool AlphaBlendUsed() const { return false; } | 58 virtual bool AlphaBlendUsed() const { return false; } |
59 | 59 |
60 // Loads a SkPath into the GDI context. The path can there after be used for | 60 // Loads a SkPath into the GDI context. The path can there after be used for |
61 // clipping or as a stroke. Returns false if the path failed to be loaded. | 61 // clipping or as a stroke. Returns false if the path failed to be loaded. |
62 static bool LoadPathToDC(HDC context, const SkPath& path); | 62 static bool LoadPathToDC(HDC context, const SkPath& path); |
63 | 63 |
64 // Loads a SkRegion into the GDI context. | 64 // Loads a SkRegion into the GDI context. |
65 static void LoadClippingRegionToDC(HDC context, const SkRegion& region, | 65 static void LoadClippingRegionToDC(HDC context, const SkRegion& region, |
66 const SkMatrix& transformation); | 66 const SkMatrix& transformation); |
67 | 67 |
| 68 SkDevice* GetOwningDevice() { return device_; } |
| 69 |
68 protected: | 70 protected: |
69 // Arrays must be inside structures. | 71 // Arrays must be inside structures. |
70 struct CubicPoints { | 72 struct CubicPoints { |
71 SkPoint p[4]; | 73 SkPoint p[4]; |
72 }; | 74 }; |
73 typedef std::vector<CubicPoints> CubicPath; | 75 typedef std::vector<CubicPoints> CubicPath; |
74 typedef std::vector<CubicPath> CubicPaths; | 76 typedef std::vector<CubicPath> CubicPaths; |
75 | 77 |
76 // Forwards |bitmap| to SkDevice's constructor. | 78 // Forwards |bitmap| to SkDevice's constructor. |
77 PlatformDevice(const SkBitmap& bitmap); | 79 //PlatformDevice(const SkBitmap& bitmap); |
| 80 PlatformDevice(SkDevice* device); |
78 | 81 |
79 // Loads the specified Skia transform into the device context, excluding | 82 // Loads the specified Skia transform into the device context, excluding |
80 // perspective (which GDI doesn't support). | 83 // perspective (which GDI doesn't support). |
81 static void LoadTransformToDC(HDC dc, const SkMatrix& matrix); | 84 static void LoadTransformToDC(HDC dc, const SkMatrix& matrix); |
82 | 85 |
83 // Transforms SkPath's paths into a series of cubic path. | 86 // Transforms SkPath's paths into a series of cubic path. |
84 static bool SkPathToCubicPaths(CubicPaths* paths, const SkPath& skpath); | 87 static bool SkPathToCubicPaths(CubicPaths* paths, const SkPath& skpath); |
| 88 |
| 89 SkDevice* device_; |
85 }; | 90 }; |
86 | 91 |
87 } // namespace skia | 92 } // namespace skia |
88 | 93 |
89 #endif // SKIA_EXT_PLATFORM_DEVICE_WIN_H_ | 94 #endif // SKIA_EXT_PLATFORM_DEVICE_WIN_H_ |
90 | 95 |
OLD | NEW |