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/drm_device_manager.h" | 15 #include "ui/ozone/platform/dri/drm_device_manager.h" |
16 #include "ui/ozone/platform/dri/gbm_buffer.h" | 16 #include "ui/ozone/platform/dri/gbm_buffer.h" |
| 17 #include "ui/ozone/platform/dri/gbm_device.h" |
17 #include "ui/ozone/platform/dri/gbm_surface.h" | 18 #include "ui/ozone/platform/dri/gbm_surface.h" |
18 #include "ui/ozone/platform/dri/gbm_surfaceless.h" | 19 #include "ui/ozone/platform/dri/gbm_surfaceless.h" |
19 #include "ui/ozone/platform/dri/gbm_wrapper.h" | |
20 #include "ui/ozone/platform/dri/hardware_display_controller.h" | 20 #include "ui/ozone/platform/dri/hardware_display_controller.h" |
21 #include "ui/ozone/public/native_pixmap.h" | 21 #include "ui/ozone/public/native_pixmap.h" |
22 #include "ui/ozone/public/overlay_candidates_ozone.h" | 22 #include "ui/ozone/public/overlay_candidates_ozone.h" |
23 #include "ui/ozone/public/ozone_switches.h" | 23 #include "ui/ozone/public/ozone_switches.h" |
24 #include "ui/ozone/public/surface_ozone_canvas.h" | 24 #include "ui/ozone/public/surface_ozone_canvas.h" |
25 #include "ui/ozone/public/surface_ozone_egl.h" | 25 #include "ui/ozone/public/surface_ozone_egl.h" |
26 | 26 |
27 namespace ui { | 27 namespace ui { |
28 namespace { | 28 namespace { |
29 | 29 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 #if defined(USE_MESA_PLATFORM_NULL) | 86 #if defined(USE_MESA_PLATFORM_NULL) |
87 return EGL_DEFAULT_DISPLAY; | 87 return EGL_DEFAULT_DISPLAY; |
88 #else | 88 #else |
89 scoped_refptr<GbmWrapper> gbm = GetGbmDevice(gfx::kNullAcceleratedWidget); | 89 scoped_refptr<GbmWrapper> gbm = GetGbmDevice(gfx::kNullAcceleratedWidget); |
90 DCHECK(gbm); | 90 DCHECK(gbm); |
91 return reinterpret_cast<intptr_t>(gbm->device()); | 91 return reinterpret_cast<intptr_t>(gbm->device()); |
92 #endif | 92 #endif |
93 } | 93 } |
94 | 94 |
95 int GbmSurfaceFactory::GetDrmFd() { | 95 int GbmSurfaceFactory::GetDrmFd() { |
96 scoped_refptr<GbmWrapper> gbm = GetGbmDevice(gfx::kNullAcceleratedWidget); | 96 scoped_refptr<GbmDevice> gbm = GetGbmDevice(gfx::kNullAcceleratedWidget); |
97 DCHECK(gbm); | 97 DCHECK(gbm); |
98 return gbm->get_fd(); | 98 return gbm->get_fd(); |
99 } | 99 } |
100 | 100 |
101 const int32* GbmSurfaceFactory::GetEGLSurfaceProperties( | 101 const int32* GbmSurfaceFactory::GetEGLSurfaceProperties( |
102 const int32* desired_list) { | 102 const int32* desired_list) { |
103 static const int32 kConfigAttribs[] = { | 103 static const int32 kConfigAttribs[] = { |
104 EGL_BUFFER_SIZE, 32, | 104 EGL_BUFFER_SIZE, 32, |
105 EGL_ALPHA_SIZE, 8, | 105 EGL_ALPHA_SIZE, 8, |
106 EGL_BLUE_SIZE, 8, | 106 EGL_BLUE_SIZE, 8, |
(...skipping 14 matching lines...) Expand all Loading... |
121 } | 121 } |
122 | 122 |
123 scoped_ptr<SurfaceOzoneCanvas> GbmSurfaceFactory::CreateCanvasForWidget( | 123 scoped_ptr<SurfaceOzoneCanvas> GbmSurfaceFactory::CreateCanvasForWidget( |
124 gfx::AcceleratedWidget widget) { | 124 gfx::AcceleratedWidget widget) { |
125 LOG(FATAL) << "Software rendering mode is not supported with GBM platform"; | 125 LOG(FATAL) << "Software rendering mode is not supported with GBM platform"; |
126 return nullptr; | 126 return nullptr; |
127 } | 127 } |
128 | 128 |
129 scoped_ptr<SurfaceOzoneEGL> GbmSurfaceFactory::CreateEGLSurfaceForWidget( | 129 scoped_ptr<SurfaceOzoneEGL> GbmSurfaceFactory::CreateEGLSurfaceForWidget( |
130 gfx::AcceleratedWidget widget) { | 130 gfx::AcceleratedWidget widget) { |
131 scoped_refptr<GbmWrapper> gbm = GetGbmDevice(widget); | 131 scoped_refptr<GbmDevice> gbm = GetGbmDevice(widget); |
132 DCHECK(gbm); | 132 DCHECK(gbm); |
133 | 133 |
134 scoped_ptr<GbmSurface> surface( | 134 scoped_ptr<GbmSurface> surface( |
135 new GbmSurface(window_manager_->GetWindowDelegate(widget), gbm)); | 135 new GbmSurface(window_manager_->GetWindowDelegate(widget), gbm)); |
136 if (!surface->Initialize()) | 136 if (!surface->Initialize()) |
137 return nullptr; | 137 return nullptr; |
138 | 138 |
139 return surface.Pass(); | 139 return surface.Pass(); |
140 } | 140 } |
141 | 141 |
142 scoped_ptr<SurfaceOzoneEGL> | 142 scoped_ptr<SurfaceOzoneEGL> |
143 GbmSurfaceFactory::CreateSurfacelessEGLSurfaceForWidget( | 143 GbmSurfaceFactory::CreateSurfacelessEGLSurfaceForWidget( |
144 gfx::AcceleratedWidget widget) { | 144 gfx::AcceleratedWidget widget) { |
145 if (!allow_surfaceless_) | 145 if (!allow_surfaceless_) |
146 return nullptr; | 146 return nullptr; |
147 | 147 |
148 return make_scoped_ptr(new GbmSurfaceless( | 148 return make_scoped_ptr(new GbmSurfaceless( |
149 window_manager_->GetWindowDelegate(widget), drm_device_manager_)); | 149 window_manager_->GetWindowDelegate(widget), drm_device_manager_)); |
150 } | 150 } |
151 | 151 |
152 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( | 152 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( |
153 gfx::AcceleratedWidget widget, | 153 gfx::AcceleratedWidget widget, |
154 gfx::Size size, | 154 gfx::Size size, |
155 BufferFormat format, | 155 BufferFormat format, |
156 BufferUsage usage) { | 156 BufferUsage usage) { |
157 if (usage == MAP) | 157 if (usage == MAP) |
158 return nullptr; | 158 return nullptr; |
159 | 159 |
160 scoped_refptr<GbmWrapper> gbm = GetGbmDevice(widget); | 160 scoped_refptr<GbmDevice> gbm = GetGbmDevice(widget); |
161 DCHECK(gbm); | 161 DCHECK(gbm); |
162 | 162 |
163 scoped_refptr<GbmBuffer> buffer = | 163 scoped_refptr<GbmBuffer> buffer = |
164 GbmBuffer::CreateBuffer(gbm, format, size, true); | 164 GbmBuffer::CreateBuffer(gbm, format, size, true); |
165 if (!buffer.get()) | 165 if (!buffer.get()) |
166 return nullptr; | 166 return nullptr; |
167 | 167 |
168 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(buffer)); | 168 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(buffer)); |
169 if (!pixmap->Initialize()) | 169 if (!pixmap->Initialize()) |
170 return nullptr; | 170 return nullptr; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 switch (usage) { | 213 switch (usage) { |
214 case MAP: | 214 case MAP: |
215 return false; | 215 return false; |
216 case SCANOUT: | 216 case SCANOUT: |
217 return true; | 217 return true; |
218 } | 218 } |
219 NOTREACHED(); | 219 NOTREACHED(); |
220 return false; | 220 return false; |
221 } | 221 } |
222 | 222 |
223 scoped_refptr<GbmWrapper> GbmSurfaceFactory::GetGbmDevice( | 223 scoped_refptr<GbmDevice> GbmSurfaceFactory::GetGbmDevice( |
224 gfx::AcceleratedWidget widget) { | 224 gfx::AcceleratedWidget widget) { |
225 return static_cast<GbmWrapper*>( | 225 return static_cast<GbmDevice*>( |
226 drm_device_manager_->GetDrmDevice(widget).get()); | 226 drm_device_manager_->GetDrmDevice(widget).get()); |
227 } | 227 } |
228 | 228 |
229 } // namespace ui | 229 } // namespace ui |
OLD | NEW |