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_VECTOR_PLATFORM_DEVICE_EMF_WIN_H_ | 5 #ifndef SKIA_EXT_VECTOR_PLATFORM_DEVICE_EMF_WIN_H_ |
6 #define SKIA_EXT_VECTOR_PLATFORM_DEVICE_EMF_WIN_H_ | 6 #define SKIA_EXT_VECTOR_PLATFORM_DEVICE_EMF_WIN_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "skia/ext/platform_device.h" | 11 #include "skia/ext/platform_device.h" |
12 #include "third_party/skia/include/core/SkMatrix.h" | 12 #include "third_party/skia/include/core/SkMatrix.h" |
13 #include "third_party/skia/include/core/SkRegion.h" | 13 #include "third_party/skia/include/core/SkRegion.h" |
14 | 14 |
15 namespace skia { | 15 namespace skia { |
16 | 16 |
17 class SK_API VectorPlatformDeviceEmfFactory : public SkDeviceFactory { | |
18 public: | |
19 virtual SkDevice* newDevice(SkCanvas* ignored, SkBitmap::Config config, | |
20 int width, int height, | |
21 bool isOpaque, bool isForLayer) OVERRIDE; | |
22 static PlatformDevice* CreateDevice(int width, int height, bool isOpaque, | |
23 HANDLE shared_section); | |
24 }; | |
25 | |
26 // A device is basically a wrapper around SkBitmap that provides a surface for | 17 // A device is basically a wrapper around SkBitmap that provides a surface for |
27 // SkCanvas to draw into. This specific device is not not backed by a surface | 18 // SkCanvas to draw into. This specific device is not not backed by a surface |
28 // and is thus unreadable. This is because the backend is completely vectorial. | 19 // and is thus unreadable. This is because the backend is completely vectorial. |
29 // This device is a simple wrapper over a Windows device context (HDC) handle. | 20 // This device is a simple wrapper over a Windows device context (HDC) handle. |
30 class VectorPlatformDeviceEmf : public PlatformDevice { | 21 class VectorPlatformDeviceEmf : public PlatformDevice { |
31 public: | 22 public: |
| 23 static PlatformDevice* CreateDevice(int width, int height, bool isOpaque, |
| 24 HANDLE shared_section); |
| 25 |
32 // Factory function. The DC is kept as the output context. | 26 // Factory function. The DC is kept as the output context. |
33 static VectorPlatformDeviceEmf* create(HDC dc, int width, int height); | 27 static VectorPlatformDeviceEmf* create(HDC dc, int width, int height); |
34 | 28 |
35 VectorPlatformDeviceEmf(HDC dc, const SkBitmap& bitmap); | 29 VectorPlatformDeviceEmf(HDC dc, const SkBitmap& bitmap); |
36 virtual ~VectorPlatformDeviceEmf(); | 30 virtual ~VectorPlatformDeviceEmf(); |
37 | 31 |
38 // PlatformDevice methods | 32 // PlatformDevice methods |
39 virtual PlatformSurface BeginPlatformPaint(); | 33 virtual PlatformSurface BeginPlatformPaint(); |
40 virtual void DrawToNativeContext(HDC dc, int x, int y, const RECT* src_rect); | 34 virtual void DrawToNativeContext(HDC dc, int x, int y, const RECT* src_rect); |
41 | 35 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 virtual void drawDevice(const SkDraw& draw, SkDevice*, int x, int y, | 68 virtual void drawDevice(const SkDraw& draw, SkDevice*, int x, int y, |
75 const SkPaint&) OVERRIDE; | 69 const SkPaint&) OVERRIDE; |
76 | 70 |
77 virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region, | 71 virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region, |
78 const SkClipStack&); | 72 const SkClipStack&); |
79 | 73 |
80 void LoadClipRegion(); | 74 void LoadClipRegion(); |
81 bool alpha_blend_used() const { return alpha_blend_used_; } | 75 bool alpha_blend_used() const { return alpha_blend_used_; } |
82 | 76 |
83 protected: | 77 protected: |
84 // Override from SkDevice (through PlatformDevice). | 78 virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config, int width, |
85 virtual SkDeviceFactory* onNewDeviceFactory(); | 79 int height, bool isOpaque, |
| 80 Usage usage); |
86 | 81 |
87 private: | 82 private: |
88 // Applies the SkPaint's painting properties in the current GDI context, if | 83 // Applies the SkPaint's painting properties in the current GDI context, if |
89 // possible. If GDI can't support all paint's properties, returns false. It | 84 // possible. If GDI can't support all paint's properties, returns false. It |
90 // doesn't execute the "commands" in SkPaint. | 85 // doesn't execute the "commands" in SkPaint. |
91 bool ApplyPaint(const SkPaint& paint); | 86 bool ApplyPaint(const SkPaint& paint); |
92 | 87 |
93 // Selects a new object in the device context. It can be a pen, a brush, a | 88 // Selects a new object in the device context. It can be a pen, a brush, a |
94 // clipping region, a bitmap or a font. Returns the old selected object. | 89 // clipping region, a bitmap or a font. Returns the old selected object. |
95 HGDIOBJ SelectObject(HGDIOBJ object); | 90 HGDIOBJ SelectObject(HGDIOBJ object); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 // True if AlphaBlend() was called during this print. | 129 // True if AlphaBlend() was called during this print. |
135 bool alpha_blend_used_; | 130 bool alpha_blend_used_; |
136 | 131 |
137 DISALLOW_COPY_AND_ASSIGN(VectorPlatformDeviceEmf); | 132 DISALLOW_COPY_AND_ASSIGN(VectorPlatformDeviceEmf); |
138 }; | 133 }; |
139 | 134 |
140 } // namespace skia | 135 } // namespace skia |
141 | 136 |
142 #endif // SKIA_EXT_VECTOR_PLATFORM_DEVICE_EMF_WIN_H_ | 137 #endif // SKIA_EXT_VECTOR_PLATFORM_DEVICE_EMF_WIN_H_ |
143 | 138 |
OLD | NEW |