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

Side by Side Diff: ui/ozone/platform/drm/gpu/gbm_surfaceless.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: added drm_thread_proxy 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_surfaceless.h" 5 #include "ui/ozone/platform/drm/gpu/gbm_surfaceless.h"
6 6
7 #include "base/bind.h"
8 #include "base/thread_task_runner_handle.h"
9 #include "ui/ozone/platform/drm/gpu/drm_device.h" 7 #include "ui/ozone/platform/drm/gpu/drm_device.h"
10 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h" 8 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h"
11 #include "ui/ozone/platform/drm/gpu/drm_vsync_provider.h" 9 #include "ui/ozone/platform/drm/gpu/drm_vsync_provider.h"
12 #include "ui/ozone/platform/drm/gpu/drm_window.h" 10 #include "ui/ozone/platform/drm/gpu/drm_window_proxy.h"
13 #include "ui/ozone/platform/drm/gpu/gbm_buffer.h"
14 #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h" 11 #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h"
15 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h" 12 #include "ui/ozone/platform/drm/gpu/scanout_buffer.h"
16 13
17 namespace ui { 14 namespace ui {
18 15
19 namespace { 16 GbmSurfaceless::GbmSurfaceless(scoped_ptr<DrmWindowProxy> window,
20 17 GbmSurfaceFactory* surface_manager,
21 void PostedSwapResult(const SwapCompletionCallback& callback, 18 DrmDeviceManager* device_manager)
22 gfx::SwapResult result) { 19 : window_(window.Pass()),
23 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, 20 surface_manager_(surface_manager),
24 base::Bind(callback, result)); 21 device_manager_(device_manager) {
25 } 22 surface_manager_->RegisterSurface(window_->widget(), this);
26
27 } // namespace
28
29 GbmSurfaceless::GbmSurfaceless(DrmWindow* window,
30 DrmDeviceManager* drm_device_manager,
31 GbmSurfaceFactory* surface_manager)
32 : window_(window),
33 drm_device_manager_(drm_device_manager),
34 surface_manager_(surface_manager) {
35 surface_manager_->RegisterSurface(window_->GetAcceleratedWidget(), this);
36 } 23 }
37 24
38 GbmSurfaceless::~GbmSurfaceless() { 25 GbmSurfaceless::~GbmSurfaceless() {
39 surface_manager_->UnregisterSurface(window_->GetAcceleratedWidget()); 26 surface_manager_->UnregisterSurface(window_->widget());
40 } 27 }
41 28
42 void GbmSurfaceless::QueueOverlayPlane(const OverlayPlane& plane) { 29 void GbmSurfaceless::QueueOverlayPlane(const OverlayPlane& plane) {
43 planes_.push_back(plane); 30 planes_.push_back(plane);
44 } 31 }
45 32
46 intptr_t GbmSurfaceless::GetNativeWindow() { 33 intptr_t GbmSurfaceless::GetNativeWindow() {
47 NOTREACHED(); 34 NOTREACHED();
48 return 0; 35 return 0;
49 } 36 }
50 37
51 bool GbmSurfaceless::ResizeNativeWindow(const gfx::Size& viewport_size) { 38 bool GbmSurfaceless::ResizeNativeWindow(const gfx::Size& viewport_size) {
52 return true; 39 return true;
53 } 40 }
54 41
55 bool GbmSurfaceless::OnSwapBuffers() { 42 bool GbmSurfaceless::OnSwapBuffers() {
56 NOTREACHED(); 43 NOTREACHED();
57 return false; 44 return false;
58 } 45 }
59 46
60 bool GbmSurfaceless::OnSwapBuffersAsync( 47 bool GbmSurfaceless::OnSwapBuffersAsync(
61 const SwapCompletionCallback& callback) { 48 const SwapCompletionCallback& callback) {
62 // Wrap the callback and post the result such that everything using the 49 window_->SchedulePageFlip(planes_, callback);
63 // callback doesn't need to worry about re-entrancy.
64 window_->SchedulePageFlip(planes_, base::Bind(&PostedSwapResult, callback));
65 planes_.clear(); 50 planes_.clear();
66 return true; 51 return true;
67 } 52 }
68 53
69 scoped_ptr<gfx::VSyncProvider> GbmSurfaceless::CreateVSyncProvider() { 54 scoped_ptr<gfx::VSyncProvider> GbmSurfaceless::CreateVSyncProvider() {
70 return make_scoped_ptr(new DrmVSyncProvider(window_)); 55 return make_scoped_ptr(new DrmVSyncProvider(window_.get()));
71 } 56 }
72 57
73 bool GbmSurfaceless::IsUniversalDisplayLinkDevice() { 58 bool GbmSurfaceless::IsUniversalDisplayLinkDevice() {
74 if (!drm_device_manager_) 59 scoped_refptr<DrmDevice> widget_device =
60 device_manager_->GetDrmDevice(window_->widget());
spang 2015/09/30 19:24:43 For this part, let's add a bool GbmBuffer::Should
dnicoara 2015/10/01 14:36:15 I don't have a strong opinion on naming.
61 if (!widget_device)
75 return false; 62 return false;
76 scoped_refptr<DrmDevice> drm_primary =
77 drm_device_manager_->GetDrmDevice(gfx::kNullAcceleratedWidget);
78 DCHECK(drm_primary);
79 63
80 HardwareDisplayController* controller = window_->GetController(); 64 return device_manager_->GetDrmDevice(gfx::kNullAcceleratedWidget) !=
81 if (!controller) 65 widget_device;
82 return false;
83 scoped_refptr<DrmDevice> drm = controller->GetAllocationDrmDevice();
84 DCHECK(drm);
85
86 return drm_primary != drm;
87 } 66 }
88 67
89 } // namespace ui 68 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698