OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_PLATFORM_CANVAS_LINUX_H_ | 5 #ifndef SKIA_EXT_PLATFORM_CANVAS_LINUX_H_ |
6 #define SKIA_EXT_PLATFORM_CANVAS_LINUX_H_ | 6 #define SKIA_EXT_PLATFORM_CANVAS_LINUX_H_ |
7 | 7 |
8 #include <unistd.h> | 8 #include <unistd.h> |
9 | 9 |
10 #include "skia/ext/platform_device_linux.h" | 10 #include "skia/ext/platform_device_linux.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 PlatformCanvasLinux(int width, int height, bool is_opaque); | 25 PlatformCanvasLinux(int width, int height, bool is_opaque); |
26 // Construct a canvas from the given memory region. The memory is not cleared | 26 // Construct a canvas from the given memory region. The memory is not cleared |
27 // first. @data must be, at least, @height * StrideForWidth(@width) bytes. | 27 // first. @data must be, at least, @height * StrideForWidth(@width) bytes. |
28 PlatformCanvasLinux(int width, int height, bool is_opaque, uint8_t* data); | 28 PlatformCanvasLinux(int width, int height, bool is_opaque, uint8_t* data); |
29 virtual ~PlatformCanvasLinux(); | 29 virtual ~PlatformCanvasLinux(); |
30 | 30 |
31 // For two-part init, call if you use the no-argument constructor above | 31 // For two-part init, call if you use the no-argument constructor above |
32 bool initialize(int width, int height, bool is_opaque); | 32 bool initialize(int width, int height, bool is_opaque); |
33 bool initialize(int width, int height, bool is_opaque, uint8_t* data); | 33 bool initialize(int width, int height, bool is_opaque, uint8_t* data); |
34 | 34 |
| 35 // These calls should surround calls to platform-specific drawing routines. |
| 36 // The cairo_surface_t* returned by beginPlatformPaint represents the |
| 37 // memory that can be used to draw into. |
| 38 // endPlatformPaint is a no-op; it is used for symmetry with Windows. |
| 39 cairo_surface_t* beginPlatformPaint(); |
| 40 void endPlatformPaint() {} |
| 41 |
35 // Returns the platform device pointer of the topmost rect with a non-empty | 42 // Returns the platform device pointer of the topmost rect with a non-empty |
36 // clip. Both the windows and mac versions have an equivalent of this method; | 43 // clip. Both the windows and mac versions have an equivalent of this method; |
37 // a Linux version is added for compatibility. | 44 // a Linux version is added for compatibility. |
38 PlatformDeviceLinux& getTopPlatformDevice() const; | 45 PlatformDeviceLinux& getTopPlatformDevice() const; |
39 | 46 |
40 // Return the stride (length of a line in bytes) for the given width. Because | 47 // Return the stride (length of a line in bytes) for the given width. Because |
41 // we use 32-bits per pixel, this will be roughly 4*width. However, for | 48 // we use 32-bits per pixel, this will be roughly 4*width. However, for |
42 // alignment reasons we may wish to increase that. | 49 // alignment reasons we may wish to increase that. |
43 static size_t StrideForWidth(unsigned width); | 50 static size_t StrideForWidth(unsigned width); |
44 | 51 |
45 protected: | 52 protected: |
46 // Creates a device store for use by the canvas. We override this so that | 53 // Creates a device store for use by the canvas. We override this so that |
47 // the device is always our own so we know that we can use GDI operations | 54 // the device is always our own so we know that we can use GDI operations |
48 // on it. Simply calls into createPlatformDevice(). | 55 // on it. Simply calls into createPlatformDevice(). |
49 virtual SkDevice* createDevice(SkBitmap::Config, int width, int height, | 56 virtual SkDevice* createDevice(SkBitmap::Config, int width, int height, |
50 bool is_opaque, bool isForLayer); | 57 bool is_opaque, bool isForLayer); |
51 | 58 |
52 // Creates a device store for use by the canvas. By default, it creates a | 59 // Creates a device store for use by the canvas. By default, it creates a |
53 // BitmapPlatformDevice object. Can be overridden to change the object type. | 60 // BitmapPlatformDevice object. Can be overridden to change the object type. |
54 virtual SkDevice* createPlatformDevice(int width, int height, bool is_opaque); | 61 virtual SkDevice* createPlatformDevice(int width, int height, bool is_opaque); |
55 | 62 |
56 // Disallow copy and assign. | 63 // Disallow copy and assign. |
57 PlatformCanvasLinux(const PlatformCanvasLinux&); | 64 PlatformCanvasLinux(const PlatformCanvasLinux&); |
58 PlatformCanvasLinux& operator=(const PlatformCanvasLinux&); | 65 PlatformCanvasLinux& operator=(const PlatformCanvasLinux&); |
59 }; | 66 }; |
60 | 67 |
61 } // namespace skia | 68 } // namespace skia |
62 | 69 |
63 #endif // SKIA_EXT_PLATFORM_CANVAS_LINUX_H_ | 70 #endif // SKIA_EXT_PLATFORM_CANVAS_LINUX_H_ |
OLD | NEW |