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 #include "ui/ozone/platform/dri/gbm_surface_factory.h" | 5 #include "ui/ozone/platform/dri/gbm_surface_factory.h" |
6 | 6 |
7 #include <gbm.h> | 7 #include <gbm.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "third_party/khronos/EGL/egl.h" | 11 #include "third_party/khronos/EGL/egl.h" |
12 #include "ui/ozone/common/egl_util.h" | 12 #include "ui/ozone/common/egl_util.h" |
13 #include "ui/ozone/platform/dri/dri_window_delegate_impl.h" | 13 #include "ui/ozone/platform/dri/dri_window_delegate_impl.h" |
14 #include "ui/ozone/platform/dri/dri_window_delegate_manager.h" | 14 #include "ui/ozone/platform/dri/dri_window_delegate_manager.h" |
15 #include "ui/ozone/platform/dri/gbm_buffer.h" | 15 #include "ui/ozone/platform/dri/gbm_buffer.h" |
16 #include "ui/ozone/platform/dri/gbm_surface.h" | 16 #include "ui/ozone/platform/dri/gbm_surface.h" |
17 #include "ui/ozone/platform/dri/gbm_surfaceless.h" | 17 #include "ui/ozone/platform/dri/gbm_surfaceless.h" |
18 #include "ui/ozone/platform/dri/gbm_wrapper.h" | 18 #include "ui/ozone/platform/dri/gbm_wrapper.h" |
19 #include "ui/ozone/platform/dri/screen_manager.h" | 19 #include "ui/ozone/platform/dri/hardware_display_controller.h" |
20 #include "ui/ozone/public/native_pixmap.h" | 20 #include "ui/ozone/public/native_pixmap.h" |
21 #include "ui/ozone/public/overlay_candidates_ozone.h" | 21 #include "ui/ozone/public/overlay_candidates_ozone.h" |
22 #include "ui/ozone/public/ozone_switches.h" | 22 #include "ui/ozone/public/ozone_switches.h" |
23 #include "ui/ozone/public/surface_ozone_egl.h" | 23 #include "ui/ozone/public/surface_ozone_egl.h" |
24 | 24 |
25 namespace ui { | 25 namespace ui { |
26 namespace { | 26 namespace { |
27 | 27 |
28 class SingleOverlay : public OverlayCandidatesOzone { | 28 class SingleOverlay : public OverlayCandidatesOzone { |
29 public: | 29 public: |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 69 |
70 GbmSurfaceFactory::GbmSurfaceFactory(bool allow_surfaceless) | 70 GbmSurfaceFactory::GbmSurfaceFactory(bool allow_surfaceless) |
71 : DriSurfaceFactory(NULL, NULL), | 71 : DriSurfaceFactory(NULL, NULL), |
72 allow_surfaceless_(allow_surfaceless) { | 72 allow_surfaceless_(allow_surfaceless) { |
73 } | 73 } |
74 | 74 |
75 GbmSurfaceFactory::~GbmSurfaceFactory() {} | 75 GbmSurfaceFactory::~GbmSurfaceFactory() {} |
76 | 76 |
77 void GbmSurfaceFactory::InitializeGpu( | 77 void GbmSurfaceFactory::InitializeGpu( |
78 GbmWrapper* gbm, | 78 GbmWrapper* gbm, |
79 ScreenManager* screen_manager, | |
80 DriWindowDelegateManager* window_manager) { | 79 DriWindowDelegateManager* window_manager) { |
81 gbm_ = gbm; | 80 gbm_ = gbm; |
82 screen_manager_ = screen_manager; | |
83 window_manager_ = window_manager; | 81 window_manager_ = window_manager; |
84 } | 82 } |
85 | 83 |
86 intptr_t GbmSurfaceFactory::GetNativeDisplay() { | 84 intptr_t GbmSurfaceFactory::GetNativeDisplay() { |
87 #if defined(USE_MESA_PLATFORM_NULL) | 85 #if defined(USE_MESA_PLATFORM_NULL) |
88 return EGL_DEFAULT_DISPLAY; | 86 return EGL_DEFAULT_DISPLAY; |
89 #else | 87 #else |
90 DCHECK(gbm_); | 88 DCHECK(gbm_); |
91 return reinterpret_cast<intptr_t>(gbm_->device()); | 89 return reinterpret_cast<intptr_t>(gbm_->device()); |
92 #endif | 90 #endif |
(...skipping 21 matching lines...) Expand all Loading... |
114 } | 112 } |
115 | 113 |
116 bool GbmSurfaceFactory::LoadEGLGLES2Bindings( | 114 bool GbmSurfaceFactory::LoadEGLGLES2Bindings( |
117 AddGLLibraryCallback add_gl_library, | 115 AddGLLibraryCallback add_gl_library, |
118 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { | 116 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { |
119 return LoadDefaultEGLGLES2Bindings(add_gl_library, set_gl_get_proc_address); | 117 return LoadDefaultEGLGLES2Bindings(add_gl_library, set_gl_get_proc_address); |
120 } | 118 } |
121 | 119 |
122 scoped_ptr<SurfaceOzoneEGL> GbmSurfaceFactory::CreateEGLSurfaceForWidget( | 120 scoped_ptr<SurfaceOzoneEGL> GbmSurfaceFactory::CreateEGLSurfaceForWidget( |
123 gfx::AcceleratedWidget widget) { | 121 gfx::AcceleratedWidget widget) { |
124 DriWindowDelegate* delegate = GetOrCreateWindowDelegate(widget); | 122 scoped_ptr<GbmSurface> surface( |
125 | 123 new GbmSurface(window_manager_->GetWindowDelegate(widget), gbm_)); |
126 scoped_ptr<GbmSurface> surface(new GbmSurface(delegate, gbm_)); | |
127 if (!surface->Initialize()) | 124 if (!surface->Initialize()) |
128 return nullptr; | 125 return nullptr; |
129 | 126 |
130 return surface.Pass(); | 127 return surface.Pass(); |
131 } | 128 } |
132 | 129 |
133 scoped_ptr<SurfaceOzoneEGL> | 130 scoped_ptr<SurfaceOzoneEGL> |
134 GbmSurfaceFactory::CreateSurfacelessEGLSurfaceForWidget( | 131 GbmSurfaceFactory::CreateSurfacelessEGLSurfaceForWidget( |
135 gfx::AcceleratedWidget widget) { | 132 gfx::AcceleratedWidget widget) { |
136 if (!allow_surfaceless_) | 133 if (!allow_surfaceless_) |
137 return nullptr; | 134 return nullptr; |
138 | 135 |
139 DriWindowDelegate* delegate = GetOrCreateWindowDelegate(widget); | 136 return scoped_ptr<SurfaceOzoneEGL>( |
140 return scoped_ptr<SurfaceOzoneEGL>(new GbmSurfaceless(delegate)); | 137 new GbmSurfaceless(window_manager_->GetWindowDelegate(widget))); |
141 } | 138 } |
142 | 139 |
143 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( | 140 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( |
144 gfx::AcceleratedWidget widget, | 141 gfx::AcceleratedWidget widget, |
145 gfx::Size size, | 142 gfx::Size size, |
146 BufferFormat format, | 143 BufferFormat format, |
147 BufferUsage usage) { | 144 BufferUsage usage) { |
148 if (usage == MAP) | 145 if (usage == MAP) |
149 return NULL; | 146 return NULL; |
150 | 147 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 switch (usage) { | 198 switch (usage) { |
202 case MAP: | 199 case MAP: |
203 return false; | 200 return false; |
204 case SCANOUT: | 201 case SCANOUT: |
205 return true; | 202 return true; |
206 } | 203 } |
207 NOTREACHED(); | 204 NOTREACHED(); |
208 return false; | 205 return false; |
209 } | 206 } |
210 | 207 |
211 DriWindowDelegate* GbmSurfaceFactory::GetOrCreateWindowDelegate( | |
212 gfx::AcceleratedWidget widget) { | |
213 if (!window_manager_->HasWindowDelegate(widget)) { | |
214 scoped_ptr<DriWindowDelegate> delegate(new DriWindowDelegateImpl( | |
215 widget, gbm_, window_manager_, screen_manager_)); | |
216 delegate->Initialize(); | |
217 window_manager_->AddWindowDelegate(widget, delegate.Pass()); | |
218 } | |
219 | |
220 return window_manager_->GetWindowDelegate(widget); | |
221 } | |
222 | |
223 } // namespace ui | 208 } // namespace ui |
OLD | NEW |