OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-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_CANVAS_H_ | 5 #ifndef SKIA_EXT_VECTOR_CANVAS_H_ |
6 #define SKIA_EXT_VECTOR_CANVAS_H_ | 6 #define SKIA_EXT_VECTOR_CANVAS_H_ |
7 | 7 |
8 #include "skia/ext/platform_canvas.h" | 8 #include "skia/ext/platform_canvas.h" |
9 #include "skia/ext/vector_platform_device.h" | 9 #include "skia/ext/vector_platform_device.h" |
10 | 10 |
| 11 #if defined(__linux__) |
| 12 typedef struct _cairo cairo_t; |
| 13 #endif |
| 14 |
11 namespace skia { | 15 namespace skia { |
12 | 16 |
13 // This class is a specialization of the regular PlatformCanvas. It is designed | 17 // This class is a specialization of the regular PlatformCanvas. It is designed |
14 // to work with a VectorDevice to manage platform-specific drawing. It allows | 18 // to work with a VectorDevice to manage platform-specific drawing. It allows |
15 // using both Skia operations and platform-specific operations. It *doesn't* | 19 // using both Skia operations and platform-specific operations. It *doesn't* |
16 // support reading back from the bitmap backstore since it is not used. | 20 // support reading back from the bitmap backstore since it is not used. |
17 class VectorCanvas : public PlatformCanvas { | 21 class VectorCanvas : public PlatformCanvas { |
18 public: | 22 public: |
19 VectorCanvas(); | 23 VectorCanvas(); |
20 #if defined(WIN32) | 24 #if defined(WIN32) |
21 VectorCanvas(HDC dc, int width, int height); | 25 VectorCanvas(HDC dc, int width, int height); |
22 #elif defined(__linux__) | 26 #elif defined(__linux__) |
23 VectorCanvas(int width, int height); | 27 // Caller owns |context|. Ownership is not transferred. |
| 28 VectorCanvas(cairo_t* context, int width, int height); |
24 #endif | 29 #endif |
25 virtual ~VectorCanvas(); | 30 virtual ~VectorCanvas(); |
26 | 31 |
27 // For two-part init, call if you use the no-argument constructor above | 32 // For two-part init, call if you use the no-argument constructor above |
28 #if defined(WIN32) | 33 #if defined(WIN32) |
29 bool initialize(HDC context, int width, int height); | 34 bool initialize(HDC context, int width, int height); |
30 #elif defined(__linux__) | 35 #elif defined(__linux__) |
31 bool initialize(int width, int height); | 36 // Ownership of |context| is not transferred. |
| 37 bool initialize(cairo_t* context, int width, int height); |
32 #endif | 38 #endif |
33 | 39 |
34 virtual SkBounder* setBounder(SkBounder*); | 40 virtual SkBounder* setBounder(SkBounder* bounder); |
35 #if defined(WIN32) || defined(__linux__) | 41 #if defined(WIN32) || defined(__linux__) |
36 virtual SkDevice* createDevice(SkBitmap::Config config, | 42 virtual SkDevice* createDevice(SkBitmap::Config config, |
37 int width, int height, | 43 int width, int height, |
38 bool is_opaque, bool isForLayer); | 44 bool is_opaque, bool isForLayer); |
39 #endif | 45 #endif |
40 virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter); | 46 virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter); |
41 | 47 |
42 private: | 48 private: |
43 // |is_opaque| is unused. |shared_section| is in fact the HDC used for output. | |
44 #if defined(WIN32) | 49 #if defined(WIN32) |
| 50 // |shared_section| is in fact the HDC used for output. |is_opaque| is unused. |
45 virtual SkDevice* createPlatformDevice(int width, int height, bool is_opaque, | 51 virtual SkDevice* createPlatformDevice(int width, int height, bool is_opaque, |
46 HANDLE shared_section); | 52 HANDLE shared_section); |
47 #elif defined(__linux__) | 53 #elif defined(__linux__) |
48 virtual SkDevice* createPlatformDevice(int width, int height, bool is_opaque); | 54 // Ownership of |context| is not transferred. |is_opaque| is unused. |
| 55 virtual SkDevice* createPlatformDevice(cairo_t* context, |
| 56 int width, int height, |
| 57 bool is_opaque); |
49 #endif | 58 #endif |
50 | 59 |
51 // Returns true if the top device is vector based and not bitmap based. | 60 // Returns true if the top device is vector based and not bitmap based. |
52 bool IsTopDeviceVectorial() const; | 61 bool IsTopDeviceVectorial() const; |
53 | 62 |
54 // Copy & assign are not supported. | 63 // Copy & assign are not supported. |
55 VectorCanvas(const VectorCanvas&); | 64 VectorCanvas(const VectorCanvas&); |
56 const VectorCanvas& operator=(const VectorCanvas&); | 65 const VectorCanvas& operator=(const VectorCanvas&); |
57 }; | 66 }; |
58 | 67 |
59 } // namespace skia | 68 } // namespace skia |
60 | 69 |
61 #endif // SKIA_EXT_VECTOR_CANVAS_H_ | 70 #endif // SKIA_EXT_VECTOR_CANVAS_H_ |
62 | 71 |
OLD | NEW |