OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 // to store the backing buffer. This buffer is BGRA in memory (on little-endian | 49 // to store the backing buffer. This buffer is BGRA in memory (on little-endian |
50 // machines). | 50 // machines). |
51 // | 51 // |
52 // For now we are also using Cairo to paint to the Drawables so we provide an | 52 // For now we are also using Cairo to paint to the Drawables so we provide an |
53 // accessor for getting the surface. | 53 // accessor for getting the surface. |
54 // | 54 // |
55 // This is all quite ok for test_shell. In the future we will want to use | 55 // This is all quite ok for test_shell. In the future we will want to use |
56 // shared memory between the renderer and the main process at least. In this | 56 // shared memory between the renderer and the main process at least. In this |
57 // case we'll probably create the buffer from a precreated region of memory. | 57 // case we'll probably create the buffer from a precreated region of memory. |
58 // ----------------------------------------------------------------------------- | 58 // ----------------------------------------------------------------------------- |
59 class BitmapPlatformDevice : public SkDevice, public PlatformDevice { | 59 class BitmapPlatformDevice : public SkBitmapDevice, public PlatformDevice { |
60 // A reference counted cairo surface | 60 // A reference counted cairo surface |
61 class BitmapPlatformDeviceData; | 61 class BitmapPlatformDeviceData; |
62 | 62 |
63 public: | 63 public: |
64 // Create a BitmapPlatformDeviceLinux from an already constructed bitmap; | 64 // Create a BitmapPlatformDeviceLinux from an already constructed bitmap; |
65 // you should probably be using Create(). This may become private later if | 65 // you should probably be using Create(). This may become private later if |
66 // we ever have to share state between some native drawing UI and Skia, like | 66 // we ever have to share state between some native drawing UI and Skia, like |
67 // the Windows and Mac versions of this class do. | 67 // the Windows and Mac versions of this class do. |
68 // | 68 // |
69 // This object takes ownership of @data. | 69 // This object takes ownership of @data. |
70 BitmapPlatformDevice(const SkBitmap& other, BitmapPlatformDeviceData* data); | 70 BitmapPlatformDevice(const SkBitmap& other, BitmapPlatformDeviceData* data); |
71 virtual ~BitmapPlatformDevice(); | 71 virtual ~BitmapPlatformDevice(); |
72 | 72 |
73 // Constructs a device with size |width| * |height| with contents initialized | 73 // Constructs a device with size |width| * |height| with contents initialized |
74 // to zero. |is_opaque| should be set if the caller knows the bitmap will be | 74 // to zero. |is_opaque| should be set if the caller knows the bitmap will be |
75 // completely opaque and allows some optimizations. | 75 // completely opaque and allows some optimizations. |
76 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque); | 76 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque); |
77 | 77 |
78 // Performs the same construction as Create. | 78 // Performs the same construction as Create. |
79 // Other ports require a separate construction routine because Create does not | 79 // Other ports require a separate construction routine because Create does not |
80 // initialize the bitmap to 0. | 80 // initialize the bitmap to 0. |
81 static BitmapPlatformDevice* CreateAndClear(int width, int height, | 81 static BitmapPlatformDevice* CreateAndClear(int width, int height, |
82 bool is_opaque); | 82 bool is_opaque); |
83 | 83 |
84 // This doesn't take ownership of |data|. If |data| is NULL, the contents | 84 // This doesn't take ownership of |data|. If |data| is NULL, the contents |
85 // of the device are initialized to 0. | 85 // of the device are initialized to 0. |
86 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque, | 86 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque, |
87 uint8_t* data); | 87 uint8_t* data); |
88 | 88 |
89 // Overridden from SkDevice: | 89 // Overridden from SkBaseDevice: |
90 virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region, | 90 virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region, |
91 const SkClipStack&) OVERRIDE; | 91 const SkClipStack&) OVERRIDE; |
92 | 92 |
93 // Overridden from PlatformDevice: | 93 // Overridden from PlatformDevice: |
94 virtual cairo_t* BeginPlatformPaint() OVERRIDE; | 94 virtual cairo_t* BeginPlatformPaint() OVERRIDE; |
95 virtual void DrawToNativeContext(PlatformSurface surface, int x, int y, | 95 virtual void DrawToNativeContext(PlatformSurface surface, int x, int y, |
96 const PlatformRect* src_rect) OVERRIDE; | 96 const PlatformRect* src_rect) OVERRIDE; |
97 | 97 |
98 protected: | 98 protected: |
99 virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config, int width, | 99 virtual SkBaseDevice* onCreateCompatibleDevice(SkBitmap::Config, int width, |
100 int height, bool isOpaque, | 100 int height, bool isOpaque, |
101 Usage usage) OVERRIDE; | 101 Usage usage) OVERRIDE; |
102 | 102 |
103 private: | 103 private: |
104 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque, | 104 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque, |
105 cairo_surface_t* surface); | 105 cairo_surface_t* surface); |
106 | 106 |
107 scoped_refptr<BitmapPlatformDeviceData> data_; | 107 scoped_refptr<BitmapPlatformDeviceData> data_; |
108 | 108 |
109 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice); | 109 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice); |
110 }; | 110 }; |
111 | 111 |
112 } // namespace skia | 112 } // namespace skia |
113 | 113 |
114 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_LINUX_H_ | 114 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_LINUX_H_ |
OLD | NEW |