| 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> |
| 9 |
| 8 #include "skia/ext/platform_device_linux.h" | 10 #include "skia/ext/platform_device_linux.h" |
| 9 | 11 |
| 10 namespace skia { | 12 namespace skia { |
| 11 | 13 |
| 12 // This class is a specialization of the regular SkCanvas that is designed to | 14 // This class is a specialization of the regular SkCanvas that is designed to |
| 13 // work with a gfx::PlatformDevice to manage platform-specific drawing. It | 15 // work with a gfx::PlatformDevice to manage platform-specific drawing. It |
| 14 // allows using both Skia operations and platform-specific operations. | 16 // allows using both Skia operations and platform-specific operations. |
| 15 class PlatformCanvasLinux : public SkCanvas { | 17 class PlatformCanvasLinux : public SkCanvas { |
| 16 public: | 18 public: |
| 17 // Set is_opaque if you are going to erase the bitmap and not use | 19 // Set is_opaque if you are going to erase the bitmap and not use |
| 18 // tranparency: this will enable some optimizations. The shared_section | 20 // tranparency: this will enable some optimizations. The shared_section |
| 19 // parameter is passed to gfx::PlatformDevice::create. See it for details. | 21 // parameter is passed to gfx::PlatformDevice::create. See it for details. |
| 20 // | 22 // |
| 21 // If you use the version with no arguments, you MUST call initialize() | 23 // If you use the version with no arguments, you MUST call initialize() |
| 22 PlatformCanvasLinux(); | 24 PlatformCanvasLinux(); |
| 23 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 |
| 27 // first. @data must be, at least, @height * StrideForWidth(@width) bytes. |
| 28 PlatformCanvasLinux(int width, int height, bool is_opaque, uint8_t* data); |
| 24 virtual ~PlatformCanvasLinux(); | 29 virtual ~PlatformCanvasLinux(); |
| 25 | 30 |
| 26 // 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 |
| 27 bool initialize(int width, int height, bool is_opaque); | 32 bool initialize(int width, int height, bool is_opaque); |
| 28 | 33 |
| 29 // Returns the platform device pointer of the topmost rect with a non-empty | 34 // Returns the platform device pointer of the topmost rect with a non-empty |
| 30 // clip. Both the windows and mac versions have an equivalent of this method; | 35 // clip. Both the windows and mac versions have an equivalent of this method; |
| 31 // a Linux version is added for compatibility. | 36 // a Linux version is added for compatibility. |
| 32 PlatformDeviceLinux& getTopPlatformDevice() const; | 37 PlatformDeviceLinux& getTopPlatformDevice() const; |
| 33 | 38 |
| 39 // Return the stride (length of a line in bytes) for the given width. Because |
| 40 // we use 32-bits per pixel, this will be roughly 4*width. However, for |
| 41 // alignment reasons we may wish to increase that. |
| 42 static size_t StrideForWidth(unsigned width); |
| 43 |
| 34 protected: | 44 protected: |
| 35 // Creates a device store for use by the canvas. We override this so that | 45 // Creates a device store for use by the canvas. We override this so that |
| 36 // the device is always our own so we know that we can use GDI operations | 46 // the device is always our own so we know that we can use GDI operations |
| 37 // on it. Simply calls into createPlatformDevice(). | 47 // on it. Simply calls into createPlatformDevice(). |
| 38 virtual SkDevice* createDevice(SkBitmap::Config, int width, int height, | 48 virtual SkDevice* createDevice(SkBitmap::Config, int width, int height, |
| 39 bool is_opaque, bool isForLayer); | 49 bool is_opaque, bool isForLayer); |
| 40 | 50 |
| 41 // Creates a device store for use by the canvas. By default, it creates a | 51 // Creates a device store for use by the canvas. By default, it creates a |
| 42 // BitmapPlatformDevice object. Can be overridden to change the object type. | 52 // BitmapPlatformDevice object. Can be overridden to change the object type. |
| 43 virtual SkDevice* createPlatformDevice(int width, int height, bool is_opaque); | 53 virtual SkDevice* createPlatformDevice(int width, int height, bool is_opaque); |
| 44 | 54 |
| 45 // Disallow copy and assign. | 55 // Disallow copy and assign. |
| 46 PlatformCanvasLinux(const PlatformCanvasLinux&); | 56 PlatformCanvasLinux(const PlatformCanvasLinux&); |
| 47 PlatformCanvasLinux& operator=(const PlatformCanvasLinux&); | 57 PlatformCanvasLinux& operator=(const PlatformCanvasLinux&); |
| 48 }; | 58 }; |
| 49 | 59 |
| 50 } // namespace skia | 60 } // namespace skia |
| 51 | 61 |
| 52 #endif // SKIA_EXT_PLATFORM_CANVAS_LINUX_H_ | 62 #endif // SKIA_EXT_PLATFORM_CANVAS_LINUX_H_ |
| OLD | NEW |