OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_GFX_OZONE_DRI_DRI_SURFACE_H_ | 5 #ifndef UI_GFX_OZONE_DRI_DRI_SURFACE_H_ |
6 #define UI_GFX_OZONE_DRI_DRI_SURFACE_H_ | 6 #define UI_GFX_OZONE_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/gfx_export.h" | 10 #include "ui/gfx/gfx_export.h" |
| 11 #include "ui/gfx/ozone/dri/scanout_surface.h" |
11 #include "ui/gfx/skia_util.h" | 12 #include "ui/gfx/skia_util.h" |
12 | 13 |
13 class SkBitmapDevice; | 14 class SkBitmapDevice; |
14 class SkCanvas; | 15 class SkCanvas; |
15 | 16 |
16 namespace gfx { | 17 namespace gfx { |
17 | 18 |
18 class DriSkBitmap; | 19 class DriSkBitmap; |
19 class HardwareDisplayController; | 20 class HardwareDisplayController; |
20 | 21 |
21 // DriSurface is used to represent a surface that can be scanned out | |
22 // 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 // operations to initialize and update the drawing surface. | |
25 // | |
26 // The implementation uses dumb buffers, which is used for software rendering. | 22 // The implementation uses dumb buffers, which is used for software rendering. |
27 // The intent is to have one DriSurface implementation for a | 23 // The intent is to have one DriSurface implementation for a |
28 // HardwareDisplayController. | 24 // HardwareDisplayController. |
29 // | 25 // |
30 // DoubleBufferedSurface is intended to be the software analog to | 26 // SkCanvas backed by DriSkBitmap is intended to be the software analog to |
31 // EGLNativeSurface while DriSurface is intended to provide the glue | 27 // EGLNativeSurface while DriSurface is intended to provide the glue |
32 // necessary to initialize and display the surface to the screen. | 28 // necessary to initialize and display the surface to the screen. |
33 // | 29 // |
34 // The typical usage pattern is: | 30 // The typical usage pattern is: |
35 // ----------------------------------------------------------------------------- | 31 // ----------------------------------------------------------------------------- |
36 // HardwareDisplayController controller; | 32 // HardwareDisplayController controller; |
37 // // Initialize controller | 33 // // Initialize controller |
38 // | 34 // |
39 // DriSurface* surface = new DriSurface(controller); | 35 // DriSurface* surface = new DriSurface(controller); |
40 // surface.Initialize(); | 36 // surface.Initialize(); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // | d | | d | | 106 // | d | | d | |
111 // | | | | | 107 // | | | | |
112 // | | | | | 108 // | | | | |
113 // ------- ------- | 109 // ------- ------- |
114 // b[0] b[1]* | 110 // b[0] b[1]* |
115 // | 111 // |
116 // The synchronization consists of copying the damaged area from the frontbuffer | 112 // The synchronization consists of copying the damaged area from the frontbuffer |
117 // to the backbuffer. | 113 // to the backbuffer. |
118 // | 114 // |
119 // At this point we're back to step 1 and can start a new draw iteration. | 115 // At this point we're back to step 1 and can start a new draw iteration. |
120 class GFX_EXPORT DriSurface { | 116 class GFX_EXPORT DriSurface : public ScanoutSurface { |
121 public: | 117 public: |
122 DriSurface(HardwareDisplayController* controller); | 118 DriSurface(HardwareDisplayController* controller); |
123 | 119 |
124 virtual ~DriSurface(); | 120 virtual ~DriSurface(); |
125 | 121 |
126 // Used to allocate all necessary buffers for this surface. If the | 122 // Used to allocate all necessary buffers for this surface. If the |
127 // initialization succeeds, the device is ready to be used for drawing | 123 // initialization succeeds, the device is ready to be used for drawing |
128 // operations. | 124 // operations. |
129 // Returns true if the initialization is successful, false otherwise. | 125 // Returns true if the initialization is successful, false otherwise. |
130 bool Initialize(); | 126 virtual bool Initialize() OVERRIDE; |
131 | 127 |
132 // Returns the ID of the current backbuffer. | 128 // Returns the ID of the current backbuffer. |
133 uint32_t GetFramebufferId() const; | 129 virtual uint32_t GetFramebufferId() const OVERRIDE; |
134 | 130 |
135 // Synchronizes and swaps the back buffer with the front buffer. | 131 // Synchronizes and swaps the back buffer with the front buffer. |
136 void SwapBuffers(); | 132 virtual void SwapBuffers() OVERRIDE; |
137 | 133 |
138 // Get a Skia canvas for a backbuffer. | 134 // Get a Skia canvas for a backbuffer. |
139 SkCanvas* GetDrawableForWidget(); | 135 SkCanvas* GetDrawableForWidget(); |
140 | 136 |
141 private: | 137 private: |
142 friend class HardwareDisplayController; | 138 friend class HardwareDisplayController; |
143 | 139 |
144 // Used to create the backing buffers. | 140 // Used to create the backing buffers. |
145 virtual DriSkBitmap* CreateBuffer(); | 141 virtual DriSkBitmap* CreateBuffer(); |
146 | 142 |
147 // Stores DRM information for this output device (connector, encoder, last | 143 // Stores DRM information for this output device (connector, encoder, last |
148 // CRTC state). | 144 // CRTC state). |
149 HardwareDisplayController* controller_; | 145 HardwareDisplayController* controller_; |
150 | 146 |
151 // The actual buffers used for painting. | 147 // The actual buffers used for painting. |
152 scoped_ptr<DriSkBitmap> bitmaps_[2]; | 148 scoped_ptr<DriSkBitmap> bitmaps_[2]; |
153 | 149 |
154 // BitmapDevice for the current backbuffer. | 150 // BitmapDevice for the current backbuffer. |
155 skia::RefPtr<SkBitmapDevice> skia_device_; | 151 skia::RefPtr<SkBitmapDevice> skia_device_; |
156 | 152 |
157 // Canvas for the current backbuffer. | 153 // Canvas for the current backbuffer. |
158 skia::RefPtr<SkCanvas> skia_canvas_; | 154 skia::RefPtr<SkCanvas> skia_canvas_; |
159 | 155 |
160 // Keeps track of which bitmap is |buffers_| is the frontbuffer. | 156 // Keeps track of which bitmap is |bitmaps_| is the frontbuffer. |
161 int front_buffer_; | 157 int front_buffer_; |
162 | 158 |
163 DISALLOW_COPY_AND_ASSIGN(DriSurface); | 159 DISALLOW_COPY_AND_ASSIGN(DriSurface); |
164 }; | 160 }; |
165 | 161 |
166 } // namespace gfx | 162 } // namespace gfx |
167 | 163 |
168 #endif // UI_GFX_OZONE_DRI_DRI_SURFACE_H_ | 164 #endif // UI_GFX_OZONE_DRI_DRI_SURFACE_H_ |
OLD | NEW |