OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 UI_OZONE_PLATFORM_DRI_DRI_SURFACE_H_ | 5 #ifndef UI_OZONE_PLATFORM_DRI_DRI_SURFACE_H_ |
6 #define UI_OZONE_PLATFORM_DRI_DRI_SURFACE_H_ | 6 #define UI_OZONE_PLATFORM_DRI_DRI_SURFACE_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "ui/gfx/geometry/size.h" | 10 #include "ui/gfx/geometry/size.h" |
11 #include "ui/gfx/skia_util.h" | 11 #include "ui/gfx/skia_util.h" |
12 #include "ui/ozone/ozone_export.h" | 12 #include "ui/ozone/ozone_export.h" |
13 #include "ui/ozone/platform/dri/scanout_surface.h" | |
13 | 14 |
14 class SkCanvas; | 15 class SkCanvas; |
15 | 16 |
16 namespace ui { | 17 namespace ui { |
17 | 18 |
18 class DriBuffer; | 19 class DriBuffer; |
19 class DriWrapper; | 20 class DriWrapper; |
20 | 21 |
21 // DriSurface is used to represent a surface that can be scanned out | 22 // DriSurface is used to represent a surface that can be scanned out |
rjkroege
2014/05/27 15:33:42
This comment needs to be updated a bit to reflect
dnicoara
2014/05/27 17:20:52
Done.
I've moved the comments and updated them to
| |
22 // to a monitor. It will store the internal state associated with the drawing | 23 // to a monitor. It will store the internal state associated with the drawing |
23 // surface associated with it. DriSurface also performs all the needed | 24 // surface associated with it. DriSurface also performs all the needed |
24 // operations to initialize and update the drawing surface. | 25 // operations to initialize and update the drawing surface. |
25 // | 26 // |
26 // The implementation uses dumb buffers, which is used for software rendering. | 27 // The implementation uses dumb buffers, which is used for software rendering. |
27 // The intent is to have one DriSurface implementation for a | 28 // The intent is to have one DriSurface implementation for a |
28 // HardwareDisplayController. | 29 // HardwareDisplayController. |
29 // | 30 // |
30 // DoubleBufferedSurface is intended to be the software analog to | 31 // DoubleBufferedSurface is intended to be the software analog to |
31 // EGLNativeSurface while DriSurface is intended to provide the glue | 32 // EGLNativeSurface while DriSurface is intended to provide the glue |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 // | d | | d | | 111 // | d | | d | |
111 // | | | | | 112 // | | | | |
112 // | | | | | 113 // | | | | |
113 // ------- ------- | 114 // ------- ------- |
114 // b[0] b[1]* | 115 // b[0] b[1]* |
115 // | 116 // |
116 // The synchronization consists of copying the damaged area from the frontbuffer | 117 // The synchronization consists of copying the damaged area from the frontbuffer |
117 // to the backbuffer. | 118 // to the backbuffer. |
118 // | 119 // |
119 // At this point we're back to step 1 and can start a new draw iteration. | 120 // At this point we're back to step 1 and can start a new draw iteration. |
120 class OZONE_EXPORT DriSurface { | 121 class OZONE_EXPORT DriSurface : public ScanoutSurface { |
121 public: | 122 public: |
122 DriSurface(DriWrapper* dri, const gfx::Size& size); | 123 DriSurface(DriWrapper* dri, const gfx::Size& size); |
123 virtual ~DriSurface(); | 124 virtual ~DriSurface(); |
124 | 125 |
125 // Used to allocate all necessary buffers for this surface. If the | |
126 // initialization succeeds, the device is ready to be used for drawing | |
127 // operations. | |
128 // Returns true if the initialization is successful, false otherwise. | |
129 bool Initialize(); | |
130 | |
131 // Returns the ID of the current backbuffer. | |
132 uint32_t GetFramebufferId() const; | |
133 | |
134 // Returns the handle for the current backbuffer. | |
135 uint32_t GetHandle() const; | |
136 | |
137 // Synchronizes and swaps the back buffer with the front buffer. | |
138 void SwapBuffers(); | |
139 | |
140 // Get a Skia canvas for a backbuffer. | 126 // Get a Skia canvas for a backbuffer. |
141 SkCanvas* GetDrawableForWidget(); | 127 SkCanvas* GetDrawableForWidget(); |
142 | 128 |
143 const gfx::Size& size() const { return size_; } | 129 // ScanoutSurface: |
130 virtual bool Initialize() OVERRIDE; | |
131 virtual uint32_t GetFramebufferId() const OVERRIDE; | |
132 virtual uint32_t GetHandle() const OVERRIDE; | |
133 virtual void SwapBuffers() OVERRIDE; | |
134 virtual gfx::Size Size() const OVERRIDE; | |
144 | 135 |
145 private: | 136 private: |
146 DriBuffer* frontbuffer() const { return bitmaps_[front_buffer_].get(); } | 137 DriBuffer* frontbuffer() const { return bitmaps_[front_buffer_].get(); } |
147 DriBuffer* backbuffer() const { return bitmaps_[front_buffer_ ^ 1].get(); } | 138 DriBuffer* backbuffer() const { return bitmaps_[front_buffer_ ^ 1].get(); } |
148 | 139 |
149 // Used to create the backing buffers. | 140 // Used to create the backing buffers. |
150 virtual DriBuffer* CreateBuffer(); | 141 virtual DriBuffer* CreateBuffer(); |
151 | 142 |
152 // Stores the connection to the graphics card. Pointer not owned by this | 143 // Stores the connection to the graphics card. Pointer not owned by this |
153 // class. | 144 // class. |
154 DriWrapper* dri_; | 145 DriWrapper* dri_; |
155 | 146 |
156 // The actual buffers used for painting. | 147 // The actual buffers used for painting. |
157 scoped_ptr<DriBuffer> bitmaps_[2]; | 148 scoped_ptr<DriBuffer> bitmaps_[2]; |
158 | 149 |
159 // Keeps track of which bitmap is |buffers_| is the frontbuffer. | 150 // Keeps track of which bitmap is |buffers_| is the frontbuffer. |
160 int front_buffer_; | 151 int front_buffer_; |
161 | 152 |
162 // Surface size. | 153 // Surface size. |
163 gfx::Size size_; | 154 gfx::Size size_; |
164 | 155 |
165 DISALLOW_COPY_AND_ASSIGN(DriSurface); | 156 DISALLOW_COPY_AND_ASSIGN(DriSurface); |
166 }; | 157 }; |
167 | 158 |
168 } // namespace ui | 159 } // namespace ui |
169 | 160 |
170 #endif // UI_OZONE_PLATFORM_DRI_DRI_SURFACE_H_ | 161 #endif // UI_OZONE_PLATFORM_DRI_DRI_SURFACE_H_ |
OLD | NEW |