Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Side by Side Diff: ui/ozone/platform/drm/gpu/gbm_surface_factory.cc

Issue 1311043016: Switch DRM platform to using a separate thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mv-drm-calls-on-thread2
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_surface.h" 17 #include "ui/ozone/platform/drm/gpu/gbm_surface.h"
17 #include "ui/ozone/platform/drm/gpu/gbm_surfaceless.h" 18 #include "ui/ozone/platform/drm/gpu/gbm_surfaceless.h"
18 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h" 19 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h"
20 #include "ui/ozone/platform/drm/gpu/proxy_helpers.h"
19 #include "ui/ozone/platform/drm/gpu/screen_manager.h" 21 #include "ui/ozone/platform/drm/gpu/screen_manager.h"
20 #include "ui/ozone/public/native_pixmap.h" 22 #include "ui/ozone/public/native_pixmap.h"
21 #include "ui/ozone/public/surface_ozone_canvas.h" 23 #include "ui/ozone/public/surface_ozone_canvas.h"
22 #include "ui/ozone/public/surface_ozone_egl.h" 24 #include "ui/ozone/public/surface_ozone_egl.h"
23 25
24 namespace ui { 26 namespace ui {
25 27
26 GbmSurfaceFactory::GbmSurfaceFactory(bool allow_surfaceless) 28 GbmSurfaceFactory::GbmSurfaceFactory(bool allow_surfaceless,
27 : DrmSurfaceFactory(nullptr), 29 DrmThread* drm_thread)
28 allow_surfaceless_(allow_surfaceless), 30 : DrmSurfaceFactory(drm_thread), allow_surfaceless_(allow_surfaceless) {}
29 drm_device_manager_(nullptr) {}
30 31
31 GbmSurfaceFactory::~GbmSurfaceFactory() { 32 GbmSurfaceFactory::~GbmSurfaceFactory() {
32 DCHECK(thread_checker_.CalledOnValidThread()); 33 DCHECK(thread_checker_.CalledOnValidThread());
33 } 34 }
34 35
35 void GbmSurfaceFactory::InitializeGpu(DrmDeviceManager* drm_device_manager,
36 ScreenManager* screen_manager) {
37 drm_device_manager_ = drm_device_manager;
38 screen_manager_ = screen_manager;
39 }
40
41 intptr_t GbmSurfaceFactory::GetNativeDisplay() { 36 intptr_t GbmSurfaceFactory::GetNativeDisplay() {
42 DCHECK(thread_checker_.CalledOnValidThread()); 37 DCHECK(thread_checker_.CalledOnValidThread());
43 return EGL_DEFAULT_DISPLAY; 38 return EGL_DEFAULT_DISPLAY;
44 } 39 }
45 40
46 const int32* GbmSurfaceFactory::GetEGLSurfaceProperties( 41 const int32* GbmSurfaceFactory::GetEGLSurfaceProperties(
47 const int32* desired_list) { 42 const int32* desired_list) {
48 DCHECK(thread_checker_.CalledOnValidThread()); 43 DCHECK(thread_checker_.CalledOnValidThread());
49 static const int32 kConfigAttribs[] = {EGL_BUFFER_SIZE, 44 static const int32 kConfigAttribs[] = {EGL_BUFFER_SIZE,
50 32, 45 32,
(...skipping 28 matching lines...) Expand all
79 return nullptr; 74 return nullptr;
80 } 75 }
81 76
82 scoped_ptr<SurfaceOzoneEGL> GbmSurfaceFactory::CreateEGLSurfaceForWidget( 77 scoped_ptr<SurfaceOzoneEGL> GbmSurfaceFactory::CreateEGLSurfaceForWidget(
83 gfx::AcceleratedWidget widget) { 78 gfx::AcceleratedWidget widget) {
84 DCHECK(thread_checker_.CalledOnValidThread()); 79 DCHECK(thread_checker_.CalledOnValidThread());
85 scoped_refptr<GbmDevice> gbm = GetGbmDevice(widget); 80 scoped_refptr<GbmDevice> gbm = GetGbmDevice(widget);
86 DCHECK(gbm); 81 DCHECK(gbm);
87 82
88 scoped_ptr<GbmSurface> surface( 83 scoped_ptr<GbmSurface> surface(
89 new GbmSurface(screen_manager_->GetWindow(widget), gbm)); 84 new GbmSurface(drm_thread_->CreateWindowProxy(widget), gbm));
90 if (!surface->Initialize()) 85 if (!surface->Initialize())
91 return nullptr; 86 return nullptr;
92 87
93 return surface.Pass(); 88 return surface.Pass();
94 } 89 }
95 90
96 scoped_ptr<SurfaceOzoneEGL> 91 scoped_ptr<SurfaceOzoneEGL>
97 GbmSurfaceFactory::CreateSurfacelessEGLSurfaceForWidget( 92 GbmSurfaceFactory::CreateSurfacelessEGLSurfaceForWidget(
98 gfx::AcceleratedWidget widget) { 93 gfx::AcceleratedWidget widget) {
99 DCHECK(thread_checker_.CalledOnValidThread()); 94 DCHECK(thread_checker_.CalledOnValidThread());
100 if (!allow_surfaceless_) 95 if (!allow_surfaceless_)
101 return nullptr; 96 return nullptr;
102 97
103 return make_scoped_ptr(new GbmSurfaceless(screen_manager_->GetWindow(widget), 98 return make_scoped_ptr(
104 drm_device_manager_)); 99 new GbmSurfaceless(drm_thread_->CreateWindowProxy(widget)));
105 } 100 }
106 101
107 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( 102 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap(
108 gfx::AcceleratedWidget widget, 103 gfx::AcceleratedWidget widget,
109 gfx::Size size, 104 gfx::Size size,
110 gfx::BufferFormat format, 105 gfx::BufferFormat format,
111 gfx::BufferUsage usage) { 106 gfx::BufferUsage usage) {
112 #if !defined(OS_CHROMEOS) 107 #if !defined(OS_CHROMEOS)
113 // Support for memory mapping accelerated buffers requires some 108 // Support for memory mapping accelerated buffers requires some
114 // CrOS-specific patches (using vgem). 109 // CrOS-specific patches (using vgem).
115 DCHECK_EQ(gfx::BufferUsage::SCANOUT, usage); 110 DCHECK_EQ(gfx::BufferUsage::SCANOUT, usage);
116 #endif 111 #endif
117 112
118 scoped_refptr<GbmDevice> gbm = GetGbmDevice(widget); 113 scoped_refptr<GbmDevice> gbm = GetGbmDevice(widget);
119 DCHECK(gbm); 114 DCHECK(gbm);
120 115
121 scoped_refptr<GbmBuffer> buffer = 116 scoped_refptr<GbmBuffer> buffer =
122 GbmBuffer::CreateBuffer(gbm, format, size, usage); 117 GbmBuffer::CreateBuffer(gbm, format, size, usage);
123 if (!buffer.get()) 118 if (!buffer.get())
124 return nullptr; 119 return nullptr;
125 120
126 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(buffer, screen_manager_)); 121 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(buffer, drm_thread_));
127 if (!pixmap->Initialize()) 122 if (!pixmap->Initialize())
128 return nullptr; 123 return nullptr;
129 124
130 return pixmap; 125 return pixmap;
131 } 126 }
132 127
133 bool GbmSurfaceFactory::CanShowPrimaryPlaneAsOverlay() { 128 bool GbmSurfaceFactory::CanShowPrimaryPlaneAsOverlay() {
134 DCHECK(thread_checker_.CalledOnValidThread()); 129 DCHECK(thread_checker_.CalledOnValidThread());
135 return allow_surfaceless_; 130 return allow_surfaceless_;
136 } 131 }
137 132
138 scoped_refptr<GbmDevice> GbmSurfaceFactory::GetGbmDevice( 133 scoped_refptr<GbmDevice> GbmSurfaceFactory::GetGbmDevice(
139 gfx::AcceleratedWidget widget) { 134 gfx::AcceleratedWidget widget) {
140 return static_cast<GbmDevice*>( 135 return static_cast<GbmDevice*>(
141 drm_device_manager_->GetDrmDevice(widget).get()); 136 drm_thread_->device_manager()->GetDrmDevice(widget).get());
142 } 137 }
143 138
144 } // namespace ui 139 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698