OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_H_ | 5 #ifndef SKIA_EXT_PLATFORM_DEVICE_H_ |
6 #define SKIA_EXT_PLATFORM_DEVICE_H_ | 6 #define SKIA_EXT_PLATFORM_DEVICE_H_ |
7 | 7 |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 | 9 |
10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
11 #include <windows.h> | 11 #include <windows.h> |
12 #include <vector> | 12 #include <vector> |
13 #endif | 13 #endif |
14 | 14 |
15 #include "third_party/skia/include/core/SkColor.h" | 15 #include "third_party/skia/include/core/SkColor.h" |
16 #include "third_party/skia/include/core/SkDevice.h" | 16 #include "third_party/skia/include/core/SkBitmapDevice.h" |
17 #include "third_party/skia/include/core/SkPreConfig.h" | 17 #include "third_party/skia/include/core/SkPreConfig.h" |
18 | 18 |
19 class SkMatrix; | 19 class SkMatrix; |
20 class SkMetaData; | 20 class SkMetaData; |
21 class SkPath; | 21 class SkPath; |
22 class SkRegion; | 22 class SkRegion; |
23 | 23 |
24 #if defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_FREEBSD) \ | 24 #if defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_FREEBSD) \ |
25 || defined(OS_SOLARIS) | 25 || defined(OS_SOLARIS) |
26 typedef struct _cairo cairo_t; | 26 typedef struct _cairo cairo_t; |
(...skipping 15 matching lines...) Expand all Loading... | |
42 typedef SkIRect* PlatformRect; | 42 typedef SkIRect* PlatformRect; |
43 #elif defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_FREEBSD) \ | 43 #elif defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_FREEBSD) \ |
44 || defined(OS_SOLARIS) | 44 || defined(OS_SOLARIS) |
45 typedef cairo_t* PlatformSurface; | 45 typedef cairo_t* PlatformSurface; |
46 typedef cairo_rectangle_t PlatformRect; | 46 typedef cairo_rectangle_t PlatformRect; |
47 #elif defined(OS_MACOSX) | 47 #elif defined(OS_MACOSX) |
48 typedef CGContextRef PlatformSurface; | 48 typedef CGContextRef PlatformSurface; |
49 typedef CGRect PlatformRect; | 49 typedef CGRect PlatformRect; |
50 #endif | 50 #endif |
51 | 51 |
52 // The following routines provide accessor points for the functionality | 52 // The following routines provide accessor points for the functionality |
vandebo (ex-Chrome)
2013/08/22 20:41:58
The comments in this file needs some closer attent
robertphillips
2013/08/23 14:01:03
I have removed the bits that are obviously wrong (
| |
53 // exported by the various PlatformDevice ports. The PlatformDevice, and | 53 // exported by the various PlatformDevice ports. The PlatformDevice, and |
54 // BitmapPlatformDevice classes inherit directly from SkDevice, which is no | 54 // BitmapPlatformDevice classes inherit directly from SkBitmapDevice, which is n o |
55 // longer a supported usage-pattern for skia. In preparation of the removal of | 55 // longer a supported usage-pattern for skia. In preparation of the removal of |
56 // these classes, all calls to PlatformDevice::* should be routed through these | 56 // these classes, all calls to PlatformDevice::* should be routed through these |
57 // helper functions. | 57 // helper functions. |
58 | 58 |
59 // Bind a PlatformDevice instance, |platform_device| to |device|. Subsequent | 59 // Bind a PlatformDevice instance, |platform_device| to |device|. Subsequent |
60 // calls to the functions exported below will forward the request to the | 60 // calls to the functions exported below will forward the request to the |
61 // corresponding method on the bound PlatformDevice instance. If no | 61 // corresponding method on the bound PlatformDevice instance. If no |
62 // PlatformDevice has been bound to the SkDevice passed, then the routines are | 62 // PlatformDevice has been bound to the SkBaseDevice passed, then the routines a re |
63 // NOPS. | 63 // NOPS. |
64 SK_API void SetPlatformDevice(SkDevice* device, | 64 SK_API void SetPlatformDevice(SkBaseDevice* device, |
65 PlatformDevice* platform_device); | 65 PlatformDevice* platform_device); |
66 SK_API PlatformDevice* GetPlatformDevice(SkDevice* device); | 66 SK_API PlatformDevice* GetPlatformDevice(SkBaseDevice* device); |
67 | 67 |
68 | 68 |
69 #if defined(OS_WIN) | 69 #if defined(OS_WIN) |
70 // Initializes the default settings and colors in a device context. | 70 // Initializes the default settings and colors in a device context. |
71 SK_API void InitializeDC(HDC context); | 71 SK_API void InitializeDC(HDC context); |
72 #elif defined(OS_MACOSX) | 72 #elif defined(OS_MACOSX) |
73 // Returns the CGContext that backing the SkDevice. Forwards to the bound | 73 // Returns the CGContext that backing the SkBaseDevice. Forwards to the bound |
74 // PlatformDevice. Returns NULL if no PlatformDevice is bound. | 74 // PlatformDevice. Returns NULL if no PlatformDevice is bound. |
75 SK_API CGContextRef GetBitmapContext(SkDevice* device); | 75 SK_API CGContextRef GetBitmapContext(SkBaseDevice* device); |
76 #endif | 76 #endif |
77 | 77 |
78 // Following routines are used in print preview workflow to mark the draft mode | 78 // Following routines are used in print preview workflow to mark the draft mode |
79 // metafile and preview metafile. | 79 // metafile and preview metafile. |
80 SK_API SkMetaData& getMetaData(const SkCanvas& canvas); | 80 SK_API SkMetaData& getMetaData(const SkCanvas& canvas); |
81 SK_API void SetIsDraftMode(const SkCanvas& canvas, bool draft_mode); | 81 SK_API void SetIsDraftMode(const SkCanvas& canvas, bool draft_mode); |
82 SK_API bool IsDraftMode(const SkCanvas& canvas); | 82 SK_API bool IsDraftMode(const SkCanvas& canvas); |
83 | 83 |
84 #if defined(OS_MACOSX) || defined(OS_WIN) | 84 #if defined(OS_MACOSX) || defined(OS_WIN) |
85 SK_API void SetIsPreviewMetafile(const SkCanvas& canvas, bool is_preview); | 85 SK_API void SetIsPreviewMetafile(const SkCanvas& canvas, bool is_preview); |
86 SK_API bool IsPreviewMetafile(const SkCanvas& canvas); | 86 SK_API bool IsPreviewMetafile(const SkCanvas& canvas); |
87 #endif | 87 #endif |
88 | 88 |
89 // A SkDevice is basically a wrapper around SkBitmap that provides a surface for | 89 // A SkBitmapDevice is basically a wrapper around SkBitmap that provides a surfa ce for |
90 // SkCanvas to draw into. PlatformDevice provides a surface Windows can also | 90 // SkCanvas to draw into. PlatformDevice provides a surface Windows can also |
91 // write to. It also provides functionality to play well with GDI drawing | 91 // write to. It also provides functionality to play well with GDI drawing |
92 // functions. This class is abstract and must be subclassed. It provides the | 92 // functions. This class is abstract and must be subclassed. It provides the |
93 // basic interface to implement it either with or without a bitmap backend. | 93 // basic interface to implement it either with or without a bitmap backend. |
94 // | 94 // |
95 // PlatformDevice provides an interface which sub-classes of SkDevice can also | 95 // PlatformDevice provides an interface which sub-classes of SkBaseDevice can al so |
96 // provide to allow for drawing by the native platform into the device. | 96 // provide to allow for drawing by the native platform into the device. |
97 class SK_API PlatformDevice { | 97 class SK_API PlatformDevice { |
vandebo (ex-Chrome)
2013/08/22 20:41:58
Not part of this CL, but with SkBitmapDevice separ
robertphillips
2013/08/23 14:01:03
I think that would make sense but I'm not too fami
vandebo (ex-Chrome)
2013/08/23 17:10:04
Can you add a TODO here to figure it out...
Platf
robertphillips
2013/08/26 13:11:48
Done.
| |
98 public: | 98 public: |
99 virtual ~PlatformDevice() {} | 99 virtual ~PlatformDevice() {} |
100 | 100 |
101 #if defined(OS_MACOSX) | 101 #if defined(OS_MACOSX) |
102 // The CGContext that corresponds to the bitmap, used for CoreGraphics | 102 // The CGContext that corresponds to the bitmap, used for CoreGraphics |
103 // operations drawing into the bitmap. This is possibly heavyweight, so it | 103 // operations drawing into the bitmap. This is possibly heavyweight, so it |
104 // should exist only during one pass of rendering. | 104 // should exist only during one pass of rendering. |
105 virtual CGContextRef GetBitmapContext() = 0; | 105 virtual CGContextRef GetBitmapContext() = 0; |
106 #endif | 106 #endif |
107 | 107 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 #elif defined(OS_MACOSX) | 164 #elif defined(OS_MACOSX) |
165 // Loads the specified Skia transform into the device context | 165 // Loads the specified Skia transform into the device context |
166 static void LoadTransformToCGContext(CGContextRef context, | 166 static void LoadTransformToCGContext(CGContextRef context, |
167 const SkMatrix& matrix); | 167 const SkMatrix& matrix); |
168 #endif | 168 #endif |
169 }; | 169 }; |
170 | 170 |
171 } // namespace skia | 171 } // namespace skia |
172 | 172 |
173 #endif // SKIA_EXT_PLATFORM_DEVICE_H_ | 173 #endif // SKIA_EXT_PLATFORM_DEVICE_H_ |
OLD | NEW |