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