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 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "skia/ext/platform_device.h" | 10 #include "skia/ext/platform_device.h" |
11 #include "third_party/skia/include/core/SkMatrix.h" | 11 #include "third_party/skia/include/core/SkMatrix.h" |
12 #include "third_party/skia/include/core/SkRegion.h" | 12 #include "third_party/skia/include/core/SkRegion.h" |
13 | 13 |
14 namespace skia { | 14 namespace skia { |
15 | 15 |
16 // A device is basically a wrapper around SkBitmap that provides a surface for | 16 // A device is basically a wrapper around SkBitmap that provides a surface for |
17 // SkCanvas to draw into. This specific device is not not backed by a surface | 17 // SkCanvas to draw into. This specific device is not not backed by a surface |
18 // and is thus unreadable. This is because the backend is completely vectorial. | 18 // and is thus unreadable. This is because the backend is completely vectorial. |
19 // This device is a simple wrapper over a Windows device context (HDC) handle. | 19 // This device is a simple wrapper over a Windows device context (HDC) handle. |
20 class VectorPlatformDeviceEmf : public SkDevice, public PlatformDevice { | 20 // TODO(robertphillips): Once Skia's SkBaseDevice is refactored to remove |
| 21 // the bitmap-specific entry points, this class should derive from it. |
| 22 class VectorPlatformDeviceEmf : public SkBitmapDevice, public PlatformDevice { |
21 public: | 23 public: |
22 SK_API static SkDevice* CreateDevice(int width, int height, bool isOpaque, | 24 SK_API static SkBaseDevice* CreateDevice(int width, int height, bool isOpaque, |
23 HANDLE shared_section); | 25 HANDLE shared_section); |
24 | 26 |
25 // Factory function. The DC is kept as the output context. | 27 // Factory function. The DC is kept as the output context. |
26 static SkDevice* create(HDC dc, int width, int height); | 28 static SkBaseDevice* create(HDC dc, int width, int height); |
27 | 29 |
28 VectorPlatformDeviceEmf(HDC dc, const SkBitmap& bitmap); | 30 VectorPlatformDeviceEmf(HDC dc, const SkBitmap& bitmap); |
29 virtual ~VectorPlatformDeviceEmf(); | 31 virtual ~VectorPlatformDeviceEmf(); |
30 | 32 |
31 // PlatformDevice methods | 33 // PlatformDevice methods |
32 virtual PlatformSurface BeginPlatformPaint() OVERRIDE; | 34 virtual PlatformSurface BeginPlatformPaint() OVERRIDE; |
33 virtual void DrawToNativeContext(HDC dc, int x, int y, | 35 virtual void DrawToNativeContext(HDC dc, int x, int y, |
34 const RECT* src_rect) OVERRIDE; | 36 const RECT* src_rect) OVERRIDE; |
35 // SkDevice methods. | 37 // SkBaseDevice methods. |
36 virtual uint32_t getDeviceCapabilities(); | 38 virtual uint32_t getDeviceCapabilities(); |
37 virtual void drawPaint(const SkDraw& draw, const SkPaint& paint) OVERRIDE; | 39 virtual void drawPaint(const SkDraw& draw, const SkPaint& paint) OVERRIDE; |
38 virtual void drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, | 40 virtual void drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, |
39 size_t count, const SkPoint[], | 41 size_t count, const SkPoint[], |
40 const SkPaint& paint) OVERRIDE; | 42 const SkPaint& paint) OVERRIDE; |
41 virtual void drawRect(const SkDraw& draw, const SkRect& r, | 43 virtual void drawRect(const SkDraw& draw, const SkRect& r, |
42 const SkPaint& paint) OVERRIDE; | 44 const SkPaint& paint) OVERRIDE; |
43 virtual void drawPath(const SkDraw& draw, const SkPath& path, | 45 virtual void drawPath(const SkDraw& draw, const SkPath& path, |
44 const SkPaint& paint, | 46 const SkPaint& paint, |
45 const SkMatrix* prePathMatrix = NULL, | 47 const SkMatrix* prePathMatrix = NULL, |
(...skipping 14 matching lines...) Expand all Loading... |
60 int scalarsPerPos, const SkPaint& paint) OVERRIDE; | 62 int scalarsPerPos, const SkPaint& paint) OVERRIDE; |
61 virtual void drawTextOnPath(const SkDraw& draw, const void* text, size_t len, | 63 virtual void drawTextOnPath(const SkDraw& draw, const void* text, size_t len, |
62 const SkPath& path, const SkMatrix* matrix, | 64 const SkPath& path, const SkMatrix* matrix, |
63 const SkPaint& paint) OVERRIDE; | 65 const SkPaint& paint) OVERRIDE; |
64 virtual void drawVertices(const SkDraw& draw, SkCanvas::VertexMode, | 66 virtual void drawVertices(const SkDraw& draw, SkCanvas::VertexMode, |
65 int vertexCount, | 67 int vertexCount, |
66 const SkPoint verts[], const SkPoint texs[], | 68 const SkPoint verts[], const SkPoint texs[], |
67 const SkColor colors[], SkXfermode* xmode, | 69 const SkColor colors[], SkXfermode* xmode, |
68 const uint16_t indices[], int indexCount, | 70 const uint16_t indices[], int indexCount, |
69 const SkPaint& paint) OVERRIDE; | 71 const SkPaint& paint) OVERRIDE; |
70 virtual void drawDevice(const SkDraw& draw, SkDevice*, int x, int y, | 72 virtual void drawDevice(const SkDraw& draw, SkBaseDevice*, int x, int y, |
71 const SkPaint&) OVERRIDE; | 73 const SkPaint&) OVERRIDE; |
72 | 74 |
73 virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region, | 75 virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region, |
74 const SkClipStack&) OVERRIDE; | 76 const SkClipStack&) OVERRIDE; |
75 | 77 |
76 void LoadClipRegion(); | 78 void LoadClipRegion(); |
77 | 79 |
78 protected: | 80 protected: |
79 virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config, int width, | 81 virtual SkBaseDevice* onCreateCompatibleDevice(SkBitmap::Config, int width, |
80 int height, bool isOpaque, | 82 int height, bool isOpaque, |
81 Usage usage) OVERRIDE; | 83 Usage usage) OVERRIDE; |
82 | 84 |
83 private: | 85 private: |
84 // Applies the SkPaint's painting properties in the current GDI context, if | 86 // Applies the SkPaint's painting properties in the current GDI context, if |
85 // possible. If GDI can't support all paint's properties, returns false. It | 87 // possible. If GDI can't support all paint's properties, returns false. It |
86 // doesn't execute the "commands" in SkPaint. | 88 // doesn't execute the "commands" in SkPaint. |
87 bool ApplyPaint(const SkPaint& paint); | 89 bool ApplyPaint(const SkPaint& paint); |
88 | 90 |
89 // Selects a new object in the device context. It can be a pen, a brush, a | 91 // Selects a new object in the device context. It can be a pen, a brush, a |
90 // clipping region, a bitmap or a font. Returns the old selected object. | 92 // clipping region, a bitmap or a font. Returns the old selected object. |
91 HGDIOBJ SelectObject(HGDIOBJ object); | 93 HGDIOBJ SelectObject(HGDIOBJ object); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 134 |
133 typedef void (*SkiaEnsureTypefaceCharactersAccessible) | 135 typedef void (*SkiaEnsureTypefaceCharactersAccessible) |
134 (const LOGFONT& font, const wchar_t* text, unsigned int text_length); | 136 (const LOGFONT& font, const wchar_t* text, unsigned int text_length); |
135 | 137 |
136 SK_API void SetSkiaEnsureTypefaceCharactersAccessible( | 138 SK_API void SetSkiaEnsureTypefaceCharactersAccessible( |
137 SkiaEnsureTypefaceCharactersAccessible func); | 139 SkiaEnsureTypefaceCharactersAccessible func); |
138 | 140 |
139 } // namespace skia | 141 } // namespace skia |
140 | 142 |
141 #endif // SKIA_EXT_VECTOR_PLATFORM_DEVICE_EMF_WIN_H_ | 143 #endif // SKIA_EXT_VECTOR_PLATFORM_DEVICE_EMF_WIN_H_ |
OLD | NEW |