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_GBM_SURFACE_H_ | 5 #ifndef UI_OZONE_PLATFORM_DRI_GBM_SURFACE_H_ |
6 #define UI_OZONE_PLATFORM_DRI_GBM_SURFACE_H_ | 6 #define UI_OZONE_PLATFORM_DRI_GBM_SURFACE_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "ui/gfx/geometry/size.h" | 10 #include "ui/gfx/geometry/size.h" |
11 #include "ui/ozone/platform/dri/scanout_surface.h" | 11 #include "ui/ozone/platform/dri/gbm_surfaceless.h" |
| 12 #include "ui/ozone/public/surface_ozone_egl.h" |
12 | 13 |
13 struct gbm_bo; | 14 struct gbm_bo; |
14 struct gbm_device; | 15 struct gbm_device; |
15 struct gbm_surface; | 16 struct gbm_surface; |
16 | 17 |
17 namespace ui { | 18 namespace ui { |
18 | 19 |
19 class DriBuffer; | 20 class DriBuffer; |
20 class DriWrapper; | 21 class DriWrapper; |
21 class GbmBufferBase; | |
22 | 22 |
23 // Implement the ScanoutSurface interface on top of GBM (Generic Buffer | 23 // Extends the GBM surfaceless functionality and adds an implicit surface for |
24 // Manager). GBM provides generic access to hardware accelerated surfaces which | 24 // the primary plane. Arbitrary buffers can still be allocated and displayed as |
25 // can be used in association with EGL to provide accelerated drawing. | 25 // overlay planes, however the primary plane is associated with the native |
26 class GbmSurface : public ScanoutSurface { | 26 // surface and is updated via an EGLSurface. |
| 27 class GbmSurface : public GbmSurfaceless { |
27 public: | 28 public: |
28 GbmSurface(gbm_device* device, DriWrapper* dri, const gfx::Size& size); | 29 GbmSurface(const base::WeakPtr<HardwareDisplayController>& controller, |
| 30 gbm_device* device, |
| 31 DriWrapper* dri); |
29 virtual ~GbmSurface(); | 32 virtual ~GbmSurface(); |
30 | 33 |
31 scoped_refptr<GbmBufferBase> backbuffer() const { | 34 bool Initialize(); |
32 return buffers_[front_buffer_ ^ 1]; | |
33 } | |
34 | 35 |
35 // ScanoutSurface: | 36 // GbmSurfaceless: |
36 virtual bool Initialize() OVERRIDE; | 37 virtual intptr_t GetNativeWindow() OVERRIDE; |
37 virtual uint32_t GetFramebufferId() const OVERRIDE; | 38 virtual bool OnSwapBuffers() OVERRIDE; |
38 virtual uint32_t GetHandle() const OVERRIDE; | |
39 virtual gfx::Size Size() const OVERRIDE; | |
40 virtual void PreSwapBuffers() OVERRIDE; | |
41 virtual void SwapBuffers() OVERRIDE; | |
42 | |
43 gbm_surface* native_surface() { return native_surface_; }; | |
44 | 39 |
45 private: | 40 private: |
46 gbm_device* gbm_device_; | 41 gbm_device* gbm_device_; |
47 | 42 |
48 DriWrapper* dri_; | 43 DriWrapper* dri_; |
49 | 44 |
50 gfx::Size size_; | |
51 | |
52 // The native GBM surface. In EGL this represents the EGLNativeWindowType. | 45 // The native GBM surface. In EGL this represents the EGLNativeWindowType. |
53 gbm_surface* native_surface_; | 46 gbm_surface* native_surface_; |
54 | 47 |
55 // Backing GBM buffers. One is the current front buffer. The other is the | 48 // Buffer currently used for scanout. |
56 // current backbuffer that is pending scan out. | 49 gbm_bo* current_buffer_; |
57 scoped_refptr<GbmBufferBase> buffers_[2]; | |
58 | |
59 // Index to the front buffer. | |
60 int front_buffer_; | |
61 | |
62 // We can't lock (and get) an accelerated buffer from the GBM surface until | |
63 // after something draws into it. But modesetting needs to happen earlier, | |
64 // before an actual window is created and draws. So, we create a dumb buffer | |
65 // for this purpose. | |
66 scoped_refptr<DriBuffer> dumb_buffer_; | |
67 | 50 |
68 DISALLOW_COPY_AND_ASSIGN(GbmSurface); | 51 DISALLOW_COPY_AND_ASSIGN(GbmSurface); |
69 }; | 52 }; |
70 | 53 |
71 } // namespace ui | 54 } // namespace ui |
72 | 55 |
73 #endif // UI_OZONE_PLATFORM_DRI_GBM_SURFACE_H_ | 56 #endif // UI_OZONE_PLATFORM_DRI_GBM_SURFACE_H_ |
OLD | NEW |