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_BITMAP_PLATFORM_DEVICE_LINUX_H_ | 5 #ifndef SKIA_EXT_BITMAP_PLATFORM_DEVICE_LINUX_H_ |
6 #define SKIA_EXT_BITMAP_PLATFORM_DEVICE_LINUX_H_ | 6 #define SKIA_EXT_BITMAP_PLATFORM_DEVICE_LINUX_H_ |
7 | 7 |
8 #include "base/ref_counted.h" | 8 #include "base/ref_counted.h" |
9 #include "skia/ext/platform_device_linux.h" | 9 #include "skia/ext/platform_device_linux.h" |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... |
40 // something that we can't easily change. | 40 // something that we can't easily change. |
41 // ----------------------------------------------------------------------------- | 41 // ----------------------------------------------------------------------------- |
42 | 42 |
43 namespace skia { | 43 namespace skia { |
44 | 44 |
45 // ----------------------------------------------------------------------------- | 45 // ----------------------------------------------------------------------------- |
46 // This is the Linux bitmap backing for Skia. We create a Cairo image surface | 46 // This is the Linux bitmap backing for Skia. We create a Cairo image surface |
47 // to store the backing buffer. This buffer is BGRA in memory (on little-endian | 47 // to store the backing buffer. This buffer is BGRA in memory (on little-endian |
48 // machines). | 48 // machines). |
49 // | 49 // |
50 // For now we are also using Cairo to paint to the Drawables so we provide an | 50 // The caller may optionally provide a handle to a real X Drawable surface; |
51 // accessor for getting the surface. | 51 // this is only necessary for plugins. |
52 // | 52 // |
53 // This is all quite ok for test_shell. In the future we will want to use | 53 // For now we are also using Cairo to paint to the Drawables so we |
54 // shared memory between the renderer and the main process at least. In this | 54 // provide an accessor for getting the surface. |
55 // case we'll probably create the buffer from a precreated region of memory. | 55 // TODO(agl): document how the new BackingStore-based drawing code |
| 56 // path in the browser works in relation to this. |
56 // ----------------------------------------------------------------------------- | 57 // ----------------------------------------------------------------------------- |
57 class BitmapPlatformDeviceLinux : public PlatformDeviceLinux { | 58 class BitmapPlatformDeviceLinux : public PlatformDeviceLinux { |
58 // A reference counted cairo surface | 59 // A reference counted cairo surface |
59 class BitmapPlatformDeviceLinuxData; | 60 class BitmapPlatformDeviceLinuxData; |
60 | 61 |
61 public: | 62 public: |
62 static BitmapPlatformDeviceLinux* Create(int width, int height, | 63 static BitmapPlatformDeviceLinux* Create(int width, int height, |
63 bool is_opaque); | 64 bool is_opaque); |
64 // This doesn't take ownership of |data| | 65 // This doesn't take ownership of |data| |
65 static BitmapPlatformDeviceLinux* Create(int width, int height, | 66 static BitmapPlatformDeviceLinux* Create(int width, int height, |
66 bool is_opaque, uint8_t* data); | 67 bool is_opaque, uint8_t* data); |
67 static BitmapPlatformDeviceLinux* Create(int width, int height, | 68 static BitmapPlatformDeviceLinux* Create(int width, int height, |
68 bool is_opaque, | 69 bool is_opaque, |
69 cairo_surface_t* surface); | 70 cairo_surface_t* surface); |
70 | 71 |
71 // Create a BitmapPlatformDeviceLinux from an already constructed bitmap; | 72 // Create a BitmapPlatformDeviceLinux from an already constructed bitmap; |
72 // you should probably be using Create(). This may become private later if | 73 // you should probably be using Create(). This may become private later if |
73 // we ever have to share state between some native drawing UI and Skia, like | 74 // we ever have to share state between some native drawing UI and Skia, like |
74 // the Windows and Mac versions of this class do. | 75 // the Windows and Mac versions of this class do. |
75 // | 76 // |
76 // This object takes ownership of @data. | 77 // This object takes ownership of @data. |
77 BitmapPlatformDeviceLinux(const SkBitmap& other, | 78 BitmapPlatformDeviceLinux(const SkBitmap& other, |
78 BitmapPlatformDeviceLinuxData* data); | 79 BitmapPlatformDeviceLinuxData* data); |
79 virtual ~BitmapPlatformDeviceLinux(); | 80 virtual ~BitmapPlatformDeviceLinux(); |
80 BitmapPlatformDeviceLinux& operator=(const BitmapPlatformDeviceLinux& other); | 81 BitmapPlatformDeviceLinux& operator=(const BitmapPlatformDeviceLinux& other); |
81 | 82 |
| 83 // Bitmaps aren't vector graphics. |
| 84 virtual bool IsVectorial() { return false; } |
| 85 |
| 86 // See comment in platform_device_linux.h. |
| 87 virtual XDrawable GetXDrawable(); |
| 88 |
| 89 cairo_surface_t* surface() const; |
| 90 |
82 // A stub copy constructor. Needs to be properly implemented. | 91 // A stub copy constructor. Needs to be properly implemented. |
83 BitmapPlatformDeviceLinux(const BitmapPlatformDeviceLinux& other); | 92 BitmapPlatformDeviceLinux(const BitmapPlatformDeviceLinux& other); |
84 | 93 |
85 // Bitmaps aren't vector graphics. | 94 protected: |
86 virtual bool IsVectorial() { return false; } | 95 // Flushes the pixmap (if any) so that the pixel data can be accessed |
87 | 96 // directly by Skia. Overridden from SkDevice, this is called when Skia |
88 cairo_surface_t* surface() const; | 97 // starts accessing pixel data. |
| 98 virtual void onAccessBitmap(SkBitmap* bitmap); |
89 | 99 |
90 private: | 100 private: |
91 scoped_refptr<BitmapPlatformDeviceLinuxData> data_; | 101 scoped_refptr<BitmapPlatformDeviceLinuxData> data_; |
92 }; | 102 }; |
93 | 103 |
94 } // namespace skia | 104 } // namespace skia |
95 | 105 |
96 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_LINUX_H_ | 106 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_LINUX_H_ |
OLD | NEW |