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__) | 11 #if defined(__linux__) || defined(__FreeBSD__) |
12 typedef struct _cairo cairo_t; | 12 typedef struct _cairo cairo_t; |
13 #endif | 13 #endif |
14 | 14 |
15 namespace skia { | 15 namespace skia { |
16 | 16 |
17 // 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 |
18 // 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 |
19 // using both Skia operations and platform-specific operations. It *doesn't* | 19 // using both Skia operations and platform-specific operations. It *doesn't* |
20 // 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. |
21 class VectorCanvas : public PlatformCanvas { | 21 class VectorCanvas : public PlatformCanvas { |
22 public: | 22 public: |
23 VectorCanvas(); | 23 VectorCanvas(); |
24 #if defined(WIN32) | 24 #if defined(WIN32) |
25 VectorCanvas(HDC dc, int width, int height); | 25 VectorCanvas(HDC dc, int width, int height); |
26 #elif defined(__linux__) | 26 #elif defined(__linux__) || defined(__FreeBSD__) |
27 // Caller owns |context|. Ownership is not transferred. | 27 // Caller owns |context|. Ownership is not transferred. |
28 VectorCanvas(cairo_t* context, int width, int height); | 28 VectorCanvas(cairo_t* context, int width, int height); |
29 #endif | 29 #endif |
30 virtual ~VectorCanvas(); | 30 virtual ~VectorCanvas(); |
31 | 31 |
32 // 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 |
33 #if defined(WIN32) | 33 #if defined(WIN32) |
34 bool initialize(HDC context, int width, int height); | 34 bool initialize(HDC context, int width, int height); |
35 #elif defined(__linux__) | 35 #elif defined(__linux__) || defined(__FreeBSD__) |
36 // Ownership of |context| is not transferred. | 36 // Ownership of |context| is not transferred. |
37 bool initialize(cairo_t* context, int width, int height); | 37 bool initialize(cairo_t* context, int width, int height); |
38 #endif | 38 #endif |
39 | 39 |
40 virtual SkBounder* setBounder(SkBounder* bounder); | 40 virtual SkBounder* setBounder(SkBounder* bounder); |
41 #if defined(WIN32) || defined(__linux__) | 41 #if defined(WIN32) || defined(__linux__) || defined(__FreeBSD__) |
42 virtual SkDevice* createDevice(SkBitmap::Config config, | 42 virtual SkDevice* createDevice(SkBitmap::Config config, |
43 int width, int height, | 43 int width, int height, |
44 bool is_opaque, bool isForLayer); | 44 bool is_opaque, bool isForLayer); |
45 #endif | 45 #endif |
46 virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter); | 46 virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter); |
47 | 47 |
48 private: | 48 private: |
49 #if defined(WIN32) | 49 #if defined(WIN32) |
50 // |shared_section| is in fact the HDC used for output. |is_opaque| is unused. | 50 // |shared_section| is in fact the HDC used for output. |is_opaque| is unused. |
51 virtual SkDevice* createPlatformDevice(int width, int height, bool is_opaque, | 51 virtual SkDevice* createPlatformDevice(int width, int height, bool is_opaque, |
52 HANDLE shared_section); | 52 HANDLE shared_section); |
53 #elif defined(__linux__) | 53 #elif defined(__linux__) || defined(__FreeBSD__) |
54 // Ownership of |context| is not transferred. |is_opaque| is unused. | 54 // Ownership of |context| is not transferred. |is_opaque| is unused. |
55 virtual SkDevice* createPlatformDevice(cairo_t* context, | 55 virtual SkDevice* createPlatformDevice(cairo_t* context, |
56 int width, int height, | 56 int width, int height, |
57 bool is_opaque); | 57 bool is_opaque); |
58 #endif | 58 #endif |
59 | 59 |
60 // 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. |
61 bool IsTopDeviceVectorial() const; | 61 bool IsTopDeviceVectorial() const; |
62 | 62 |
63 // Copy & assign are not supported. | 63 // Copy & assign are not supported. |
64 VectorCanvas(const VectorCanvas&); | 64 VectorCanvas(const VectorCanvas&); |
65 const VectorCanvas& operator=(const VectorCanvas&); | 65 const VectorCanvas& operator=(const VectorCanvas&); |
66 }; | 66 }; |
67 | 67 |
68 } // namespace skia | 68 } // namespace skia |
69 | 69 |
70 #endif // SKIA_EXT_VECTOR_CANVAS_H_ | 70 #endif // SKIA_EXT_VECTOR_CANVAS_H_ |
71 | 71 |
OLD | NEW |