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

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/gbm_buffer.h" 14 #include "ui/ozone/platform/drm/gpu/gbm_buffer.h"
15 #include "ui/ozone/platform/drm/gpu/gbm_device.h" 15 #include "ui/ozone/platform/drm/gpu/gbm_device.h"
16 #include "ui/ozone/platform/drm/gpu/gbm_surfaceless.h" 16 #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" 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(DrmThread* 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 intptr_t GbmSurfaceFactory::GetNativeDisplay() { 31 intptr_t GbmSurfaceFactory::GetNativeDisplay() {
39 DCHECK(thread_checker_.CalledOnValidThread()); 32 DCHECK(thread_checker_.CalledOnValidThread());
40 return EGL_DEFAULT_DISPLAY; 33 return EGL_DEFAULT_DISPLAY;
41 } 34 }
42 35
43 const int32* GbmSurfaceFactory::GetEGLSurfaceProperties( 36 const int32* GbmSurfaceFactory::GetEGLSurfaceProperties(
44 const int32* desired_list) { 37 const int32* desired_list) {
45 DCHECK(thread_checker_.CalledOnValidThread()); 38 DCHECK(thread_checker_.CalledOnValidThread());
46 static const int32 kConfigAttribs[] = {EGL_BUFFER_SIZE, 39 static const int32 kConfigAttribs[] = {EGL_BUFFER_SIZE,
47 32, 40 32,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 scoped_ptr<SurfaceOzoneEGL> GbmSurfaceFactory::CreateEGLSurfaceForWidget( 72 scoped_ptr<SurfaceOzoneEGL> GbmSurfaceFactory::CreateEGLSurfaceForWidget(
80 gfx::AcceleratedWidget widget) { 73 gfx::AcceleratedWidget widget) {
81 NOTREACHED(); 74 NOTREACHED();
82 return nullptr; 75 return nullptr;
83 } 76 }
84 77
85 scoped_ptr<SurfaceOzoneEGL> 78 scoped_ptr<SurfaceOzoneEGL>
86 GbmSurfaceFactory::CreateSurfacelessEGLSurfaceForWidget( 79 GbmSurfaceFactory::CreateSurfacelessEGLSurfaceForWidget(
87 gfx::AcceleratedWidget widget) { 80 gfx::AcceleratedWidget widget) {
88 DCHECK(thread_checker_.CalledOnValidThread()); 81 DCHECK(thread_checker_.CalledOnValidThread());
89 return make_scoped_ptr(new GbmSurfaceless(screen_manager_->GetWindow(widget), 82 return make_scoped_ptr(new GbmSurfaceless(widget, drm_thread_));
90 drm_device_manager_));
91 } 83 }
92 84
93 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap( 85 scoped_refptr<ui::NativePixmap> GbmSurfaceFactory::CreateNativePixmap(
94 gfx::AcceleratedWidget widget, 86 gfx::AcceleratedWidget widget,
95 gfx::Size size, 87 gfx::Size size,
96 gfx::BufferFormat format, 88 gfx::BufferFormat format,
97 gfx::BufferUsage usage) { 89 gfx::BufferUsage usage) {
98 #if !defined(OS_CHROMEOS) 90 #if !defined(OS_CHROMEOS)
99 // Support for memory mapping accelerated buffers requires some 91 // Support for memory mapping accelerated buffers requires some
100 // CrOS-specific patches (using vgem). 92 // CrOS-specific patches (using vgem).
101 DCHECK(gfx::BufferUsage::SCANOUT == usage); 93 DCHECK(gfx::BufferUsage::SCANOUT == usage);
102 #endif 94 #endif
103 95
104 scoped_refptr<GbmDevice> gbm = GetGbmDevice(widget); 96 scoped_refptr<GbmDevice> gbm = GetGbmDevice(widget);
105 DCHECK(gbm); 97 DCHECK(gbm);
106 98
107 scoped_refptr<GbmBuffer> buffer = 99 scoped_refptr<GbmBuffer> buffer =
108 GbmBuffer::CreateBuffer(gbm, format, size, usage); 100 GbmBuffer::CreateBuffer(gbm, format, size, usage);
109 if (!buffer.get()) 101 if (!buffer.get())
110 return nullptr; 102 return nullptr;
111 103
112 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(buffer, screen_manager_)); 104 scoped_refptr<GbmPixmap> pixmap(new GbmPixmap(buffer, drm_thread_));
113 if (!pixmap->Initialize()) 105 if (!pixmap->Initialize())
114 return nullptr; 106 return nullptr;
115 107
116 return pixmap; 108 return pixmap;
117 } 109 }
118 110
119 scoped_refptr<GbmDevice> GbmSurfaceFactory::GetGbmDevice( 111 scoped_refptr<GbmDevice> GbmSurfaceFactory::GetGbmDevice(
120 gfx::AcceleratedWidget widget) { 112 gfx::AcceleratedWidget widget) {
121 return static_cast<GbmDevice*>( 113 return static_cast<GbmDevice*>(
122 drm_device_manager_->GetDrmDevice(widget).get()); 114 drm_thread_->device_manager()->GetDrmDevice(widget).get());
123 } 115 }
124 116
125 } // namespace ui 117 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698