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/drm/gpu/gbm_surface_factory.h" | 5 #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h" |
6 | 6 |
7 #include <gbm.h> | 7 #include <gbm.h> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "third_party/khronos/EGL/egl.h" | 10 #include "third_party/khronos/EGL/egl.h" |
11 #include "ui/ozone/common/egl_util.h" | 11 #include "ui/ozone/common/egl_util.h" |
12 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h" | 12 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h" |
13 #include "ui/ozone/platform/drm/gpu/drm_window.h" | 13 #include "ui/ozone/platform/drm/gpu/drm_thread.h" |
| 14 #include "ui/ozone/platform/drm/gpu/drm_window_proxy.h" |
14 #include "ui/ozone/platform/drm/gpu/gbm_buffer.h" | 15 #include "ui/ozone/platform/drm/gpu/gbm_buffer.h" |
15 #include "ui/ozone/platform/drm/gpu/gbm_device.h" | 16 #include "ui/ozone/platform/drm/gpu/gbm_device.h" |
16 #include "ui/ozone/platform/drm/gpu/gbm_surfaceless.h" | 17 #include "ui/ozone/platform/drm/gpu/gbm_surfaceless.h" |
17 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h" | |
18 #include "ui/ozone/platform/drm/gpu/screen_manager.h" | 18 #include "ui/ozone/platform/drm/gpu/screen_manager.h" |
19 #include "ui/ozone/public/native_pixmap.h" | 19 #include "ui/ozone/public/native_pixmap.h" |
20 #include "ui/ozone/public/surface_ozone_canvas.h" | 20 #include "ui/ozone/public/surface_ozone_canvas.h" |
21 #include "ui/ozone/public/surface_ozone_egl.h" | 21 #include "ui/ozone/public/surface_ozone_egl.h" |
22 | 22 |
23 namespace ui { | 23 namespace ui { |
24 | 24 |
25 GbmSurfaceFactory::GbmSurfaceFactory() | 25 GbmSurfaceFactory::GbmSurfaceFactory(DrmThread* drm_thread) |
26 : drm_device_manager_(nullptr), screen_manager_(nullptr) {} | 26 : drm_thread_(drm_thread) {} |
27 | 27 |
28 GbmSurfaceFactory::~GbmSurfaceFactory() { | 28 GbmSurfaceFactory::~GbmSurfaceFactory() { |
29 DCHECK(thread_checker_.CalledOnValidThread()); | 29 DCHECK(thread_checker_.CalledOnValidThread()); |
30 } | 30 } |
31 | 31 |
32 void GbmSurfaceFactory::InitializeGpu(DrmDeviceManager* drm_device_manager, | |
33 ScreenManager* screen_manager) { | |
34 drm_device_manager_ = drm_device_manager; | |
35 screen_manager_ = screen_manager; | |
36 } | |
37 | |
38 void GbmSurfaceFactory::RegisterSurface(gfx::AcceleratedWidget widget, | 32 void GbmSurfaceFactory::RegisterSurface(gfx::AcceleratedWidget widget, |
39 GbmSurfaceless* surface) { | 33 GbmSurfaceless* surface) { |
40 widget_to_surface_map_.insert(std::make_pair(widget, surface)); | 34 widget_to_surface_map_.insert(std::make_pair(widget, surface)); |
41 } | 35 } |
42 | 36 |
43 void GbmSurfaceFactory::UnregisterSurface(gfx::AcceleratedWidget widget) { | 37 void GbmSurfaceFactory::UnregisterSurface(gfx::AcceleratedWidget widget) { |
44 widget_to_surface_map_.erase(widget); | 38 widget_to_surface_map_.erase(widget); |
45 } | 39 } |
46 | 40 |
47 GbmSurfaceless* GbmSurfaceFactory::GetSurface( | 41 GbmSurfaceless* GbmSurfaceFactory::GetSurface( |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 scoped_ptr<SurfaceOzoneEGL> GbmSurfaceFactory::CreateEGLSurfaceForWidget( | 89 scoped_ptr<SurfaceOzoneEGL> GbmSurfaceFactory::CreateEGLSurfaceForWidget( |
96 gfx::AcceleratedWidget widget) { | 90 gfx::AcceleratedWidget widget) { |
97 NOTREACHED(); | 91 NOTREACHED(); |
98 return nullptr; | 92 return nullptr; |
99 } | 93 } |
100 | 94 |
101 scoped_ptr<SurfaceOzoneEGL> | 95 scoped_ptr<SurfaceOzoneEGL> |
102 GbmSurfaceFactory::CreateSurfacelessEGLSurfaceForWidget( | 96 GbmSurfaceFactory::CreateSurfacelessEGLSurfaceForWidget( |
103 gfx::AcceleratedWidget widget) { | 97 gfx::AcceleratedWidget widget) { |
104 DCHECK(thread_checker_.CalledOnValidThread()); | 98 DCHECK(thread_checker_.CalledOnValidThread()); |
105 return make_scoped_ptr(new GbmSurfaceless(screen_manager_->GetWindow(widget), | 99 scoped_ptr<DrmWindowProxy> window(drm_thread_->CreateWindowProxy(widget)); |
106 drm_device_manager_, this)); | 100 if (!window) |
| 101 return nullptr; |
| 102 |
| 103 return make_scoped_ptr( |
| 104 new GbmSurfaceless(window.Pass(), this, drm_thread_->device_manager())); |
107 } | 105 } |
108 | 106 |
109 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( | 107 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( |
110 gfx::AcceleratedWidget widget, | 108 gfx::AcceleratedWidget widget, |
111 gfx::Size size, | 109 gfx::Size size, |
112 gfx::BufferFormat format, | 110 gfx::BufferFormat format, |
113 gfx::BufferUsage usage) { | 111 gfx::BufferUsage usage) { |
114 #if !defined(OS_CHROMEOS) | 112 #if !defined(OS_CHROMEOS) |
115 // Support for memory mapping accelerated buffers requires some | 113 // Support for memory mapping accelerated buffers requires some |
116 // CrOS-specific patches (using vgem). | 114 // CrOS-specific patches (using vgem). |
(...skipping 11 matching lines...) Expand all Loading... |
128 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(buffer, this)); | 126 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(buffer, this)); |
129 if (!pixmap->Initialize()) | 127 if (!pixmap->Initialize()) |
130 return nullptr; | 128 return nullptr; |
131 | 129 |
132 return pixmap; | 130 return pixmap; |
133 } | 131 } |
134 | 132 |
135 scoped_refptr<GbmDevice> GbmSurfaceFactory::GetGbmDevice( | 133 scoped_refptr<GbmDevice> GbmSurfaceFactory::GetGbmDevice( |
136 gfx::AcceleratedWidget widget) { | 134 gfx::AcceleratedWidget widget) { |
137 return static_cast<GbmDevice*>( | 135 return static_cast<GbmDevice*>( |
138 drm_device_manager_->GetDrmDevice(widget).get()); | 136 drm_thread_->device_manager()->GetDrmDevice(widget).get()); |
139 } | 137 } |
140 | 138 |
141 } // namespace ui | 139 } // namespace ui |
OLD | NEW |