OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_LINUX_H_ | 5 #ifndef SKIA_EXT_VECTOR_PLATFORM_DEVICE_LINUX_H_ |
6 #define SKIA_EXT_VECTOR_PLATFORM_DEVICE_LINUX_H_ | 6 #define SKIA_EXT_VECTOR_PLATFORM_DEVICE_LINUX_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "skia/ext/platform_device.h" | 9 #include "skia/ext/platform_device.h" |
10 #include "third_party/skia/include/core/SkMatrix.h" | 10 #include "third_party/skia/include/core/SkMatrix.h" |
11 #include "third_party/skia/include/core/SkRegion.h" | 11 #include "third_party/skia/include/core/SkRegion.h" |
12 | 12 |
13 namespace skia { | 13 namespace skia { |
14 | 14 |
| 15 class SkVectorPlatformDeviceFactory : public SkRasterDeviceFactory { |
| 16 public: |
| 17 virtual SkDevice* newDevice(SkBitmap::Config config, int width, int height, |
| 18 bool isOpaque, bool isForLayer); |
| 19 |
| 20 static SkDevice* CreateDevice(cairo_t* context, int width, int height, |
| 21 bool isOpaque); |
| 22 }; |
| 23 |
15 // This device is basically a wrapper that provides a surface for SkCanvas | 24 // This device is basically a wrapper that provides a surface for SkCanvas |
16 // to draw into. It is basically an adaptor which converts skia APIs into | 25 // to draw into. It is basically an adaptor which converts skia APIs into |
17 // cooresponding Cairo APIs and outputs to a Cairo surface. Please NOTE that | 26 // cooresponding Cairo APIs and outputs to a Cairo surface. Please NOTE that |
18 // since it is completely vectorial, the bitmap content in it is thus | 27 // since it is completely vectorial, the bitmap content in it is thus |
19 // meaningless. | 28 // meaningless. |
20 class VectorPlatformDevice : public PlatformDevice { | 29 class VectorPlatformDevice : public PlatformDevice { |
21 public: | 30 public: |
22 // Factory function. Ownership of |context| is not transferred. | 31 // Factory function. Ownership of |context| is not transferred. |
23 static VectorPlatformDevice* create(PlatformSurface context, | 32 static VectorPlatformDevice* create(PlatformSurface context, |
24 int width, int height); | 33 int width, int height); |
25 virtual ~VectorPlatformDevice(); | 34 virtual ~VectorPlatformDevice(); |
26 | 35 |
| 36 virtual SkDeviceFactory* getDeviceFactory() { |
| 37 return SkNEW(SkVectorPlatformDeviceFactory); |
| 38 } |
| 39 |
27 virtual bool IsVectorial() { return true; } | 40 virtual bool IsVectorial() { return true; } |
28 virtual PlatformSurface beginPlatformPaint() { return context_; } | 41 virtual PlatformSurface beginPlatformPaint() { return context_; } |
29 | 42 |
30 // We translate following skia APIs into corresponding Cairo APIs. | 43 // We translate following skia APIs into corresponding Cairo APIs. |
31 virtual void drawBitmap(const SkDraw& draw, const SkBitmap& bitmap, | 44 virtual void drawBitmap(const SkDraw& draw, const SkBitmap& bitmap, |
32 const SkMatrix& matrix, const SkPaint& paint); | 45 const SkMatrix& matrix, const SkPaint& paint); |
33 virtual void drawDevice(const SkDraw& draw, SkDevice*, int x, int y, | 46 virtual void drawDevice(const SkDraw& draw, SkDevice*, int x, int y, |
34 const SkPaint&); | 47 const SkPaint&); |
35 virtual void drawPaint(const SkDraw& draw, const SkPaint& paint); | 48 virtual void drawPaint(const SkDraw& draw, const SkPaint& paint); |
36 virtual void drawPath(const SkDraw& draw, const SkPath& path, | 49 virtual void drawPath(const SkDraw& draw, const SkPath& path, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 PlatformSurface context_; | 122 PlatformSurface context_; |
110 | 123 |
111 // Copy & assign are not supported. | 124 // Copy & assign are not supported. |
112 VectorPlatformDevice(const VectorPlatformDevice&); | 125 VectorPlatformDevice(const VectorPlatformDevice&); |
113 const VectorPlatformDevice& operator=(const VectorPlatformDevice&); | 126 const VectorPlatformDevice& operator=(const VectorPlatformDevice&); |
114 }; | 127 }; |
115 | 128 |
116 } // namespace skia | 129 } // namespace skia |
117 | 130 |
118 #endif // SKIA_EXT_VECTOR_PLATFORM_DEVICE_LINUX_H_ | 131 #endif // SKIA_EXT_VECTOR_PLATFORM_DEVICE_LINUX_H_ |
OLD | NEW |