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_MAC_H_ | 5 #ifndef SKIA_EXT_PLATFORM_CANVAS_MAC_H_ |
6 #define SKIA_EXT_PLATFORM_CANVAS_MAC_H_ | 6 #define SKIA_EXT_PLATFORM_CANVAS_MAC_H_ |
7 | 7 |
8 #include "skia/ext/platform_device_mac.h" | 8 #include "skia/ext/platform_device_mac.h" |
9 | 9 |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 // bottommost device. | 50 // bottommost device. |
51 // | 51 // |
52 // Danger: the resulting device should not be saved. It will be invalidated | 52 // Danger: the resulting device should not be saved. It will be invalidated |
53 // by the next call to save() or restore(). | 53 // by the next call to save() or restore(). |
54 PlatformDeviceMac& getTopPlatformDevice() const; | 54 PlatformDeviceMac& getTopPlatformDevice() const; |
55 | 55 |
56 // Allow callers to see the non-virtual function even though we have an | 56 // Allow callers to see the non-virtual function even though we have an |
57 // override of a virtual one. | 57 // override of a virtual one. |
58 using SkCanvas::clipRect; | 58 using SkCanvas::clipRect; |
59 | 59 |
| 60 // Return the stride (length of a line in bytes) for the given width. Because |
| 61 // we use 32-bits per pixel, this will be roughly 4*width. However, for |
| 62 // alignment reasons we may wish to increase that. |
| 63 static size_t StrideForWidth(unsigned width); |
| 64 |
60 protected: | 65 protected: |
61 // Creates a device store for use by the canvas. We override this so that | 66 // Creates a device store for use by the canvas. We override this so that |
62 // the device is always our own so we know that we can use GDI operations | 67 // the device is always our own so we know that we can use GDI operations |
63 // on it. Simply calls into createPlatformDevice(). | 68 // on it. Simply calls into createPlatformDevice(). |
64 virtual SkDevice* createDevice(SkBitmap::Config, int width, int height, | 69 virtual SkDevice* createDevice(SkBitmap::Config, int width, int height, |
65 bool is_opaque, bool isForLayer); | 70 bool is_opaque, bool isForLayer); |
66 | 71 |
67 // Creates a device store for use by the canvas. By default, it creates a | 72 // Creates a device store for use by the canvas. By default, it creates a |
68 // BitmapPlatformDevice object. Can be overridden to change the object type. | 73 // BitmapPlatformDevice object. Can be overridden to change the object type. |
69 virtual SkDevice* createPlatformDevice(int width, int height, bool is_opaque, | 74 virtual SkDevice* createPlatformDevice(int width, int height, bool is_opaque, |
70 CGContextRef context); | 75 CGContextRef context); |
71 | 76 |
72 private: | 77 private: |
73 // Unimplemented. This is to try to prevent people from calling this function | 78 // Unimplemented. This is to try to prevent people from calling this function |
74 // on SkCanvas. SkCanvas' version is not virtual, so we can't prevent this | 79 // on SkCanvas. SkCanvas' version is not virtual, so we can't prevent this |
75 // 100%, but hopefully this will make people notice and not use the function. | 80 // 100%, but hopefully this will make people notice and not use the function. |
76 // Calling SkCanvas' version will create a new device which is not compatible | 81 // Calling SkCanvas' version will create a new device which is not compatible |
77 // with us and we will crash if somebody tries to draw into it with | 82 // with us and we will crash if somebody tries to draw into it with |
78 // CoreGraphics. | 83 // CoreGraphics. |
79 SkDevice* setBitmapDevice(const SkBitmap& bitmap); | 84 SkDevice* setBitmapDevice(const SkBitmap& bitmap); |
80 | 85 |
81 // Disallow copy and assign. | 86 // Disallow copy and assign. |
82 PlatformCanvasMac(const PlatformCanvasMac&); | 87 PlatformCanvasMac(const PlatformCanvasMac&); |
83 PlatformCanvasMac& operator=(const PlatformCanvasMac&); | 88 PlatformCanvasMac& operator=(const PlatformCanvasMac&); |
84 }; | 89 }; |
85 | 90 |
86 } // namespace skia | 91 } // namespace skia |
87 | 92 |
88 #endif // SKIA_EXT_PLATFORM_CANVAS_MAC_H_ | 93 #endif // SKIA_EXT_PLATFORM_CANVAS_MAC_H_ |
OLD | NEW |