OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/ref_counted.h" | 9 #include "base/ref_counted.h" |
10 #include "skia/ext/platform_device_linux.h" | 10 #include "skia/ext/platform_device_linux.h" |
11 | 11 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // | 59 // |
60 // This is all quite ok for test_shell. In the future we will want to use | 60 // This is all quite ok for test_shell. In the future we will want to use |
61 // shared memory between the renderer and the main process at least. In this | 61 // shared memory between the renderer and the main process at least. In this |
62 // case we'll probably create the buffer from a precreated region of memory. | 62 // case we'll probably create the buffer from a precreated region of memory. |
63 // ----------------------------------------------------------------------------- | 63 // ----------------------------------------------------------------------------- |
64 class BitmapPlatformDevice : public PlatformDevice { | 64 class BitmapPlatformDevice : public PlatformDevice { |
65 // A reference counted cairo surface | 65 // A reference counted cairo surface |
66 class BitmapPlatformDeviceData; | 66 class BitmapPlatformDeviceData; |
67 | 67 |
68 public: | 68 public: |
69 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque); | |
70 | |
71 // This doesn't take ownership of |data| | |
72 static BitmapPlatformDevice* Create(int width, int height, | |
73 bool is_opaque, uint8_t* data); | |
74 | |
75 // Create a BitmapPlatformDeviceLinux from an already constructed bitmap; | 69 // Create a BitmapPlatformDeviceLinux from an already constructed bitmap; |
76 // you should probably be using Create(). This may become private later if | 70 // you should probably be using Create(). This may become private later if |
77 // we ever have to share state between some native drawing UI and Skia, like | 71 // we ever have to share state between some native drawing UI and Skia, like |
78 // the Windows and Mac versions of this class do. | 72 // the Windows and Mac versions of this class do. |
79 // | 73 // |
80 // This object takes ownership of @data. | 74 // This object takes ownership of @data. |
81 BitmapPlatformDevice(const SkBitmap& other, BitmapPlatformDeviceData* data); | 75 BitmapPlatformDevice(const SkBitmap& other, BitmapPlatformDeviceData* data); |
82 virtual ~BitmapPlatformDevice(); | |
83 BitmapPlatformDevice& operator=(const BitmapPlatformDevice& other); | |
84 | 76 |
85 // A stub copy constructor. Needs to be properly implemented. | 77 // A stub copy constructor. Needs to be properly implemented. |
86 BitmapPlatformDevice(const BitmapPlatformDevice& other); | 78 BitmapPlatformDevice(const BitmapPlatformDevice& other); |
87 | 79 |
88 virtual SkDeviceFactory* getDeviceFactory(); | 80 virtual ~BitmapPlatformDevice(); |
| 81 |
| 82 BitmapPlatformDevice& operator=(const BitmapPlatformDevice& other); |
| 83 |
| 84 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque); |
| 85 |
| 86 // This doesn't take ownership of |data| |
| 87 static BitmapPlatformDevice* Create(int width, int height, |
| 88 bool is_opaque, uint8_t* data); |
89 | 89 |
90 virtual void makeOpaque(int x, int y, int width, int height); | 90 virtual void makeOpaque(int x, int y, int width, int height); |
91 | 91 |
92 // Bitmaps aren't vector graphics. | 92 // Overridden from SkDevice: |
| 93 virtual SkDeviceFactory* getDeviceFactory(); |
| 94 virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region); |
| 95 |
| 96 // Overridden from PlatformDevice: |
93 virtual bool IsVectorial(); | 97 virtual bool IsVectorial(); |
94 | |
95 // If someone wants to paint on a Cairo surface version of our | |
96 // buffer, then give them the surface we're already using. | |
97 virtual cairo_t* beginPlatformPaint(); | 98 virtual cairo_t* beginPlatformPaint(); |
98 | 99 |
99 // Loads the given transform and clipping region into the HDC. This is | |
100 // overridden from SkDevice. | |
101 virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region); | |
102 | |
103 private: | 100 private: |
104 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque, | 101 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque, |
105 cairo_surface_t* surface); | 102 cairo_surface_t* surface); |
106 | 103 |
107 scoped_refptr<BitmapPlatformDeviceData> data_; | 104 scoped_refptr<BitmapPlatformDeviceData> data_; |
108 }; | 105 }; |
109 | 106 |
110 } // namespace skia | 107 } // namespace skia |
111 | 108 |
112 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_LINUX_H_ | 109 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_LINUX_H_ |
OLD | NEW |