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

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: update & fix clang Created 5 years, 2 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_thread_proxy.h"
13 #include "ui/ozone/platform/drm/gpu/drm_window.h" 13 #include "ui/ozone/platform/drm/gpu/drm_window_proxy.h"
14 #include "ui/ozone/platform/drm/gpu/gbm_buffer.h" 14 #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_surfaceless.h" 15 #include "ui/ozone/platform/drm/gpu/gbm_surfaceless.h"
17 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h" 16 #include "ui/ozone/platform/drm/gpu/proxy_helpers.h"
18 #include "ui/ozone/platform/drm/gpu/screen_manager.h" 17 #include "ui/ozone/platform/drm/gpu/screen_manager.h"
19 #include "ui/ozone/public/native_pixmap.h" 18 #include "ui/ozone/public/native_pixmap.h"
20 #include "ui/ozone/public/surface_ozone_canvas.h" 19 #include "ui/ozone/public/surface_ozone_canvas.h"
21 #include "ui/ozone/public/surface_ozone_egl.h" 20 #include "ui/ozone/public/surface_ozone_egl.h"
22 21
23 namespace ui { 22 namespace ui {
24 23
25 GbmSurfaceFactory::GbmSurfaceFactory() 24 GbmSurfaceFactory::GbmSurfaceFactory(DrmThreadProxy* drm_thread)
26 : drm_device_manager_(nullptr), screen_manager_(nullptr) {} 25 : drm_thread_(drm_thread) {}
27 26
28 GbmSurfaceFactory::~GbmSurfaceFactory() { 27 GbmSurfaceFactory::~GbmSurfaceFactory() {
29 DCHECK(thread_checker_.CalledOnValidThread()); 28 DCHECK(thread_checker_.CalledOnValidThread());
30 } 29 }
31 30
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, 31 void GbmSurfaceFactory::RegisterSurface(gfx::AcceleratedWidget widget,
39 GbmSurfaceless* surface) { 32 GbmSurfaceless* surface) {
40 DCHECK(thread_checker_.CalledOnValidThread()); 33 DCHECK(thread_checker_.CalledOnValidThread());
41 widget_to_surface_map_.insert(std::make_pair(widget, surface)); 34 widget_to_surface_map_.insert(std::make_pair(widget, surface));
42 } 35 }
43 36
44 void GbmSurfaceFactory::UnregisterSurface(gfx::AcceleratedWidget widget) { 37 void GbmSurfaceFactory::UnregisterSurface(gfx::AcceleratedWidget widget) {
45 DCHECK(thread_checker_.CalledOnValidThread()); 38 DCHECK(thread_checker_.CalledOnValidThread());
46 widget_to_surface_map_.erase(widget); 39 widget_to_surface_map_.erase(widget);
47 } 40 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 gfx::AcceleratedWidget widget) { 92 gfx::AcceleratedWidget widget) {
100 NOTREACHED(); 93 NOTREACHED();
101 return nullptr; 94 return nullptr;
102 } 95 }
103 96
104 scoped_ptr<SurfaceOzoneEGL> 97 scoped_ptr<SurfaceOzoneEGL>
105 GbmSurfaceFactory::CreateSurfacelessEGLSurfaceForWidget( 98 GbmSurfaceFactory::CreateSurfacelessEGLSurfaceForWidget(
106 gfx::AcceleratedWidget widget) { 99 gfx::AcceleratedWidget widget) {
107 DCHECK(thread_checker_.CalledOnValidThread()); 100 DCHECK(thread_checker_.CalledOnValidThread());
108 return make_scoped_ptr( 101 return make_scoped_ptr(
109 new GbmSurfaceless(screen_manager_->GetWindow(widget), this)); 102 new GbmSurfaceless(drm_thread_->CreateDrmWindowProxy(widget), this));
110 } 103 }
111 104
112 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( 105 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap(
113 gfx::AcceleratedWidget widget, 106 gfx::AcceleratedWidget widget,
114 gfx::Size size, 107 gfx::Size size,
115 gfx::BufferFormat format, 108 gfx::BufferFormat format,
116 gfx::BufferUsage usage) { 109 gfx::BufferUsage usage) {
117 #if !defined(OS_CHROMEOS) 110 #if !defined(OS_CHROMEOS)
118 // Support for memory mapping accelerated buffers requires some 111 // Support for memory mapping accelerated buffers requires some
119 // CrOS-specific patches (using vgem). 112 // CrOS-specific patches (using vgem).
120 DCHECK(gfx::BufferUsage::SCANOUT == usage); 113 DCHECK(gfx::BufferUsage::SCANOUT == usage);
121 #endif 114 #endif
122 115
123 scoped_refptr<GbmDevice> gbm = GetGbmDevice(widget);
124 DCHECK(gbm);
125
126 scoped_refptr<GbmBuffer> buffer = 116 scoped_refptr<GbmBuffer> buffer =
127 GbmBuffer::CreateBuffer(gbm, format, size, usage); 117 drm_thread_->CreateBuffer(widget, size, format, usage);
128 if (!buffer.get()) 118 if (!buffer.get())
129 return nullptr; 119 return nullptr;
130 120
131 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(buffer, this)); 121 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(buffer, this));
132 if (!pixmap->Initialize()) 122 if (!pixmap->Initialize())
133 return nullptr; 123 return nullptr;
134 124
135 return pixmap; 125 return pixmap;
136 } 126 }
137 127
138 scoped_refptr<GbmDevice> GbmSurfaceFactory::GetGbmDevice(
139 gfx::AcceleratedWidget widget) {
140 return static_cast<GbmDevice*>(
141 drm_device_manager_->GetDrmDevice(widget).get());
142 }
143
144 } // namespace ui 128 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/gpu/gbm_surface_factory.h ('k') | ui/ozone/platform/drm/gpu/gbm_surfaceless.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698