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/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "ui/gfx/geometry/size.h" | 10 #include "ui/gfx/geometry/size.h" |
11 #include "ui/ozone/platform/dri/gbm_surfaceless.h" | 11 #include "ui/ozone/platform/dri/gbm_surfaceless.h" |
12 #include "ui/ozone/public/surface_ozone_egl.h" | 12 #include "ui/ozone/public/surface_ozone_egl.h" |
13 | 13 |
14 struct gbm_bo; | 14 struct gbm_bo; |
15 struct gbm_device; | |
16 struct gbm_surface; | 15 struct gbm_surface; |
17 | 16 |
18 namespace ui { | 17 namespace ui { |
19 | 18 |
20 class DriBuffer; | 19 class DriBuffer; |
21 class DriWrapper; | |
22 class DriWindowDelegate; | 20 class DriWindowDelegate; |
| 21 class GbmWrapper; |
23 | 22 |
24 // Extends the GBM surfaceless functionality and adds an implicit surface for | 23 // Extends the GBM surfaceless functionality and adds an implicit surface for |
25 // the primary plane. Arbitrary buffers can still be allocated and displayed as | 24 // the primary plane. Arbitrary buffers can still be allocated and displayed as |
26 // overlay planes, however the primary plane is associated with the native | 25 // overlay planes, however the primary plane is associated with the native |
27 // surface and is updated via an EGLSurface. | 26 // surface and is updated via an EGLSurface. |
28 class GbmSurface : public GbmSurfaceless { | 27 class GbmSurface : public GbmSurfaceless { |
29 public: | 28 public: |
30 GbmSurface(DriWindowDelegate* window_delegate, | 29 GbmSurface(DriWindowDelegate* window_delegate, GbmWrapper* gbm); |
31 gbm_device* device, | |
32 DriWrapper* dri); | |
33 ~GbmSurface() override; | 30 ~GbmSurface() override; |
34 | 31 |
35 bool Initialize(); | 32 bool Initialize(); |
36 | 33 |
37 // GbmSurfaceless: | 34 // GbmSurfaceless: |
38 intptr_t GetNativeWindow() override; | 35 intptr_t GetNativeWindow() override; |
39 bool ResizeNativeWindow(const gfx::Size& viewport_size) override; | 36 bool ResizeNativeWindow(const gfx::Size& viewport_size) override; |
40 bool OnSwapBuffers() override; | 37 bool OnSwapBuffers() override; |
41 bool OnSwapBuffersAsync(const SwapCompletionCallback& callback) override; | 38 bool OnSwapBuffersAsync(const SwapCompletionCallback& callback) override; |
42 | 39 |
43 private: | 40 private: |
44 void OnSwapBuffersCallback(const SwapCompletionCallback& callback, | 41 void OnSwapBuffersCallback(const SwapCompletionCallback& callback, |
45 gbm_bo* pending_buffer); | 42 gbm_bo* pending_buffer); |
46 | 43 |
47 gbm_device* gbm_device_; | 44 GbmWrapper* gbm_; // Not owned. |
48 | |
49 DriWrapper* dri_; | |
50 | 45 |
51 // The native GBM surface. In EGL this represents the EGLNativeWindowType. | 46 // The native GBM surface. In EGL this represents the EGLNativeWindowType. |
52 gbm_surface* native_surface_; | 47 gbm_surface* native_surface_; |
53 | 48 |
54 // Buffer currently used for scanout. | 49 // Buffer currently used for scanout. |
55 gbm_bo* current_buffer_; | 50 gbm_bo* current_buffer_; |
56 | 51 |
57 gfx::Size size_; | 52 gfx::Size size_; |
58 | 53 |
59 base::WeakPtrFactory<GbmSurface> weak_factory_; | 54 base::WeakPtrFactory<GbmSurface> weak_factory_; |
60 | 55 |
61 DISALLOW_COPY_AND_ASSIGN(GbmSurface); | 56 DISALLOW_COPY_AND_ASSIGN(GbmSurface); |
62 }; | 57 }; |
63 | 58 |
64 } // namespace ui | 59 } // namespace ui |
65 | 60 |
66 #endif // UI_OZONE_PLATFORM_DRI_GBM_SURFACE_H_ | 61 #endif // UI_OZONE_PLATFORM_DRI_GBM_SURFACE_H_ |
OLD | NEW |