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 // 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 |
18 // 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 |
19 // 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 |
20 // 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 |
21 // meaningless. | 21 // meaningless. |
22 class SK_API VectorPlatformDeviceCairo : public PlatformDevice { | 22 class SK_API VectorPlatformDeviceCairo : public PlatformDevice, |
| 23 public SkDevice { |
23 public: | 24 public: |
24 virtual ~VectorPlatformDeviceCairo(); | 25 virtual ~VectorPlatformDeviceCairo(); |
25 | 26 |
26 static PlatformDevice* CreateDevice(cairo_t* context, int width, int height, | 27 static SkDevice* CreateDevice(cairo_t* context, int width, int height, |
27 bool isOpaque); | 28 bool isOpaque); |
28 | 29 |
29 // Clean up cached fonts. It is an error to call this while some | 30 // Clean up cached fonts. It is an error to call this while some |
30 // VectorPlatformDeviceCairo callee is still using fonts created for it by | 31 // VectorPlatformDeviceCairo callee is still using fonts created for it by |
31 // this class. | 32 // this class. |
32 static void ClearFontCache(); | 33 static void ClearFontCache(); |
33 | 34 |
34 // Overridden from SkDevice | 35 // Overridden from SkDevice |
35 virtual uint32_t getDeviceCapabilities(); | 36 virtual uint32_t getDeviceCapabilities(); |
36 virtual void drawPaint(const SkDraw& draw, const SkPaint& paint) OVERRIDE; | 37 virtual void drawPaint(const SkDraw& draw, const SkPaint& paint) OVERRIDE; |
37 virtual void drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, | 38 virtual void drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, |
(...skipping 22 matching lines...) Expand all Loading... |
60 virtual void drawVertices(const SkDraw& draw, SkCanvas::VertexMode, | 61 virtual void drawVertices(const SkDraw& draw, SkCanvas::VertexMode, |
61 int vertexCount, | 62 int vertexCount, |
62 const SkPoint verts[], const SkPoint texs[], | 63 const SkPoint verts[], const SkPoint texs[], |
63 const SkColor colors[], SkXfermode* xmode, | 64 const SkColor colors[], SkXfermode* xmode, |
64 const uint16_t indices[], int indexCount, | 65 const uint16_t indices[], int indexCount, |
65 const SkPaint& paint) OVERRIDE; | 66 const SkPaint& paint) OVERRIDE; |
66 virtual void drawDevice(const SkDraw& draw, SkDevice*, int x, int y, | 67 virtual void drawDevice(const SkDraw& draw, SkDevice*, int x, int y, |
67 const SkPaint&) OVERRIDE; | 68 const SkPaint&) OVERRIDE; |
68 | 69 |
69 virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region, | 70 virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region, |
70 const SkClipStack&); | 71 const SkClipStack&) OVERRIDE; |
71 | 72 |
72 // Overridden from PlatformDevice | 73 // Overridden from PlatformDevice |
73 virtual PlatformSurface BeginPlatformPaint(); | 74 virtual PlatformSurface BeginPlatformPaint() OVERRIDE; |
| 75 virtual void DrawToNativeContext(PlatformSurface surface, int x, int y, |
| 76 const PlatformRect* src_rect) OVERRIDE; |
74 | 77 |
75 protected: | 78 protected: |
76 VectorPlatformDeviceCairo(PlatformSurface context, const SkBitmap& bitmap); | 79 VectorPlatformDeviceCairo(PlatformSurface context, const SkBitmap& bitmap); |
77 | 80 |
78 virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config, int width, | 81 virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config, int width, |
79 int height, bool isOpaque, | 82 int height, bool isOpaque, |
80 Usage usage); | 83 Usage usage) OVERRIDE; |
81 | 84 |
82 private: | 85 private: |
83 // Apply paint's color in the context. | 86 // Apply paint's color in the context. |
84 void ApplyPaintColor(const SkPaint& paint); | 87 void ApplyPaintColor(const SkPaint& paint); |
85 | 88 |
86 // Apply path's fill style in the context. | 89 // Apply path's fill style in the context. |
87 void ApplyFillStyle(const SkPath& path); | 90 void ApplyFillStyle(const SkPath& path); |
88 | 91 |
89 // Apply paint's stroke style in the context. | 92 // Apply paint's stroke style in the context. |
90 void ApplyStrokeStyle(const SkPaint& paint); | 93 void ApplyStrokeStyle(const SkPaint& paint); |
(...skipping 28 matching lines...) Expand all Loading... |
119 | 122 |
120 // Device context. | 123 // Device context. |
121 PlatformSurface context_; | 124 PlatformSurface context_; |
122 | 125 |
123 DISALLOW_COPY_AND_ASSIGN(VectorPlatformDeviceCairo); | 126 DISALLOW_COPY_AND_ASSIGN(VectorPlatformDeviceCairo); |
124 }; | 127 }; |
125 | 128 |
126 } // namespace skia | 129 } // namespace skia |
127 | 130 |
128 #endif // SKIA_EXT_VECTOR_PLATFORM_DEVICE_CAIRO_LINUX_H_ | 131 #endif // SKIA_EXT_VECTOR_PLATFORM_DEVICE_CAIRO_LINUX_H_ |
OLD | NEW |