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_CAIRO_LINUX_H_ | 5 #ifndef SKIA_EXT_VECTOR_PLATFORM_DEVICE_CAIRO_LINUX_H_ |
6 #define SKIA_EXT_VECTOR_PLATFORM_DEVICE_CAIRO_LINUX_H_ | 6 #define SKIA_EXT_VECTOR_PLATFORM_DEVICE_CAIRO_LINUX_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 VectorPlatformDeviceCairoFactory : public SkDeviceFactory { | |
18 public: | |
19 static PlatformDevice* CreateDevice(cairo_t* context, int width, int height, | |
20 bool isOpaque); | |
21 | |
22 // Overridden from SkDeviceFactory: | |
23 virtual SkDevice* newDevice(SkCanvas* ignored, SkBitmap::Config config, | |
24 int width, int height, | |
25 bool isOpaque, bool isForLayer); | |
26 }; | |
27 | |
28 // This device is basically a wrapper that provides a surface for SkCanvas | 17 // This device is basically a wrapper that provides a surface for SkCanvas |
29 // to draw into. It is basically an adaptor which converts skia APIs into | 18 // to draw into. It is basically an adaptor which converts skia APIs into |
30 // cooresponding Cairo APIs and outputs to a Cairo surface. Please NOTE that | 19 // cooresponding Cairo APIs and outputs to a Cairo surface. Please NOTE that |
31 // since it is completely vectorial, the bitmap content in it is thus | 20 // since it is completely vectorial, the bitmap content in it is thus |
32 // meaningless. | 21 // meaningless. |
33 class SK_API VectorPlatformDeviceCairo : public PlatformDevice { | 22 class SK_API VectorPlatformDeviceCairo : public PlatformDevice { |
34 public: | 23 public: |
35 virtual ~VectorPlatformDeviceCairo(); | 24 virtual ~VectorPlatformDeviceCairo(); |
36 | 25 |
37 // Factory function. Ownership of |context| is not transferred. | 26 static PlatformDevice* CreateDevice(cairo_t* context, int width, int height, |
38 static VectorPlatformDeviceCairo* create(PlatformSurface context, | 27 bool isOpaque); |
39 int width, int height); | |
40 | 28 |
41 // Clean up cached fonts. It is an error to call this while some | 29 // Clean up cached fonts. It is an error to call this while some |
42 // VectorPlatformDeviceCairo callee is still using fonts created for it by | 30 // VectorPlatformDeviceCairo callee is still using fonts created for it by |
43 // this class. | 31 // this class. |
44 static void ClearFontCache(); | 32 static void ClearFontCache(); |
45 | 33 |
46 // Overridden from SkDevice | 34 // Overridden from SkDevice |
47 virtual uint32_t getDeviceCapabilities(); | 35 virtual uint32_t getDeviceCapabilities(); |
48 virtual void drawPaint(const SkDraw& draw, const SkPaint& paint) OVERRIDE; | 36 virtual void drawPaint(const SkDraw& draw, const SkPaint& paint) OVERRIDE; |
49 virtual void drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, | 37 virtual void drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region, | 69 virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region, |
82 const SkClipStack&); | 70 const SkClipStack&); |
83 | 71 |
84 // Overridden from PlatformDevice | 72 // Overridden from PlatformDevice |
85 virtual PlatformSurface BeginPlatformPaint(); | 73 virtual PlatformSurface BeginPlatformPaint(); |
86 | 74 |
87 protected: | 75 protected: |
88 explicit VectorPlatformDeviceCairo(PlatformSurface context, | 76 explicit VectorPlatformDeviceCairo(PlatformSurface context, |
89 const SkBitmap& bitmap); | 77 const SkBitmap& bitmap); |
90 | 78 |
91 // Override from SkDevice (through PlatformDevice). | 79 virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config, int width, |
92 virtual SkDeviceFactory* onNewDeviceFactory(); | 80 int height, bool isOpaque, |
| 81 Usage usage); |
93 | 82 |
94 private: | 83 private: |
95 // Apply paint's color in the context. | 84 // Apply paint's color in the context. |
96 void ApplyPaintColor(const SkPaint& paint); | 85 void ApplyPaintColor(const SkPaint& paint); |
97 | 86 |
98 // Apply path's fill style in the context. | 87 // Apply path's fill style in the context. |
99 void ApplyFillStyle(const SkPath& path); | 88 void ApplyFillStyle(const SkPath& path); |
100 | 89 |
101 // Apply paint's stroke style in the context. | 90 // Apply paint's stroke style in the context. |
102 void ApplyStrokeStyle(const SkPaint& paint); | 91 void ApplyStrokeStyle(const SkPaint& paint); |
(...skipping 28 matching lines...) Expand all Loading... |
131 | 120 |
132 // Device context. | 121 // Device context. |
133 PlatformSurface context_; | 122 PlatformSurface context_; |
134 | 123 |
135 DISALLOW_COPY_AND_ASSIGN(VectorPlatformDeviceCairo); | 124 DISALLOW_COPY_AND_ASSIGN(VectorPlatformDeviceCairo); |
136 }; | 125 }; |
137 | 126 |
138 } // namespace skia | 127 } // namespace skia |
139 | 128 |
140 #endif // SKIA_EXT_VECTOR_PLATFORM_DEVICE_CAIRO_LINUX_H_ | 129 #endif // SKIA_EXT_VECTOR_PLATFORM_DEVICE_CAIRO_LINUX_H_ |
OLD | NEW |