OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_DRM_GPU_GBM_SURFACELESS_H_ | 5 #ifndef UI_OZONE_PLATFORM_DRM_GPU_GBM_SURFACELESS_H_ |
6 #define UI_OZONE_PLATFORM_DRM_GPU_GBM_SURFACELESS_H_ | 6 #define UI_OZONE_PLATFORM_DRM_GPU_GBM_SURFACELESS_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <vector> | 9 #include <vector> |
9 | 10 |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/scoped_vector.h" |
| 13 #include "base/memory/weak_ptr.h" |
11 #include "ui/gfx/native_widget_types.h" | 14 #include "ui/gfx/native_widget_types.h" |
| 15 #include "ui/gl/gl_image.h" |
| 16 #include "ui/gl/gl_surface_egl.h" |
| 17 #include "ui/gl/gl_surface_overlay.h" |
| 18 #include "ui/gl/scoped_binders.h" |
12 #include "ui/ozone/platform/drm/gpu/overlay_plane.h" | 19 #include "ui/ozone/platform/drm/gpu/overlay_plane.h" |
13 #include "ui/ozone/public/surface_ozone_egl.h" | |
14 | |
15 namespace gfx { | |
16 class Size; | |
17 } | |
18 | 20 |
19 namespace ui { | 21 namespace ui { |
20 | 22 |
21 class DrmWindowProxy; | 23 class DrmWindowProxy; |
22 class GbmSurfaceFactory; | 24 class GbmSurfaceFactory; |
23 | 25 |
24 // In surfaceless mode drawing and displaying happens directly through | 26 // A GLSurface for GBM Ozone platform that uses surfaceless drawing. Drawing and |
25 // NativePixmap buffers. CC would call into SurfaceFactoryOzone to allocate the | 27 // displaying happens directly through NativePixmap buffers. CC would call into |
26 // buffers and then call ScheduleOverlayPlane(..) to schedule the buffer for | 28 // SurfaceFactoryOzone to allocate the buffers and then call |
27 // presentation. | 29 // ScheduleOverlayPlane(..) to schedule the buffer for presentation. |
28 class GbmSurfaceless : public SurfaceOzoneEGL { | 30 class GbmSurfaceless : public gl::SurfacelessEGL { |
29 public: | 31 public: |
30 GbmSurfaceless(std::unique_ptr<DrmWindowProxy> window, | 32 GbmSurfaceless(GbmSurfaceFactory* surface_factory, |
31 GbmSurfaceFactory* surface_manager); | 33 std::unique_ptr<DrmWindowProxy> window, |
32 ~GbmSurfaceless() override; | 34 gfx::AcceleratedWidget widget); |
33 | 35 |
34 void QueueOverlayPlane(const OverlayPlane& plane); | 36 void QueueOverlayPlane(const OverlayPlane& plane); |
35 | 37 |
36 // SurfaceOzoneEGL: | 38 // gl::GLSurface: |
37 intptr_t GetNativeWindow() override; | 39 bool Initialize(GLSurface::Format format) override; |
38 bool ResizeNativeWindow(const gfx::Size& viewport_size) override; | 40 gfx::SwapResult SwapBuffers() override; |
39 bool OnSwapBuffers() override; | 41 bool ScheduleOverlayPlane(int z_order, |
40 void OnSwapBuffersAsync(const SwapCompletionCallback& callback) override; | 42 gfx::OverlayTransform transform, |
41 std::unique_ptr<gfx::VSyncProvider> CreateVSyncProvider() override; | 43 gl::GLImage* image, |
42 bool IsUniversalDisplayLinkDevice() override; | 44 const gfx::Rect& bounds_rect, |
43 void* /* EGLConfig */ GetEGLSurfaceConfig( | 45 const gfx::RectF& crop_rect) override; |
44 const EglConfigCallbacks& egl) override; | 46 bool IsOffscreen() override; |
| 47 gfx::VSyncProvider* GetVSyncProvider() override; |
| 48 bool SupportsAsyncSwap() override; |
| 49 bool SupportsPostSubBuffer() override; |
| 50 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override; |
| 51 void SwapBuffersAsync(const SwapCompletionCallback& callback) override; |
| 52 void PostSubBufferAsync(int x, |
| 53 int y, |
| 54 int width, |
| 55 int height, |
| 56 const SwapCompletionCallback& callback) override; |
| 57 EGLConfig GetConfig() override; |
45 | 58 |
46 protected: | 59 protected: |
| 60 ~GbmSurfaceless() override; |
| 61 |
| 62 gfx::AcceleratedWidget widget() { return widget_; } |
| 63 GbmSurfaceFactory* surface_factory() { return surface_factory_; } |
| 64 |
| 65 private: |
| 66 struct PendingFrame { |
| 67 PendingFrame(); |
| 68 ~PendingFrame(); |
| 69 |
| 70 bool ScheduleOverlayPlanes(gfx::AcceleratedWidget widget); |
| 71 void Flush(); |
| 72 |
| 73 bool ready = false; |
| 74 std::vector<gl::GLSurfaceOverlay> overlays; |
| 75 SwapCompletionCallback callback; |
| 76 }; |
| 77 |
| 78 void SubmitFrame(); |
| 79 |
| 80 EGLSyncKHR InsertFence(bool implicit); |
| 81 void FenceRetired(EGLSyncKHR fence, PendingFrame* frame); |
| 82 |
| 83 void SwapCompleted(const SwapCompletionCallback& callback, |
| 84 gfx::SwapResult result); |
| 85 |
| 86 bool IsUniversalDisplayLinkDevice(); |
| 87 |
| 88 GbmSurfaceFactory* surface_factory_; |
47 std::unique_ptr<DrmWindowProxy> window_; | 89 std::unique_ptr<DrmWindowProxy> window_; |
48 | |
49 GbmSurfaceFactory* surface_manager_; | |
50 | |
51 std::vector<OverlayPlane> planes_; | 90 std::vector<OverlayPlane> planes_; |
52 | 91 |
53 private: | 92 // The native surface. Deleting this is allowed to free the EGLNativeWindow. |
| 93 gfx::AcceleratedWidget widget_; |
| 94 std::unique_ptr<gfx::VSyncProvider> vsync_provider_; |
| 95 ScopedVector<PendingFrame> unsubmitted_frames_; |
| 96 bool has_implicit_external_sync_; |
| 97 bool has_image_flush_external_; |
| 98 bool last_swap_buffers_result_ = true; |
| 99 bool swap_buffers_pending_ = false; |
| 100 |
| 101 base::WeakPtrFactory<GbmSurfaceless> weak_factory_; |
| 102 |
54 DISALLOW_COPY_AND_ASSIGN(GbmSurfaceless); | 103 DISALLOW_COPY_AND_ASSIGN(GbmSurfaceless); |
55 }; | 104 }; |
56 | 105 |
57 } // namespace ui | 106 } // namespace ui |
58 | 107 |
59 #endif // UI_OZONE_PLATFORM_DRM_GPU_GBM_SURFACELESS_H_ | 108 #endif // UI_OZONE_PLATFORM_DRM_GPU_GBM_SURFACELESS_H_ |
OLD | NEW |