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_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_vsync_provider.h" | 8 #include "ui/ozone/platform/drm/gpu/drm_vsync_provider.h" |
11 #include "ui/ozone/platform/drm/gpu/drm_window.h" | 9 #include "ui/ozone/platform/drm/gpu/drm_window_proxy.h" |
12 #include "ui/ozone/platform/drm/gpu/gbm_buffer.h" | |
13 #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h" | 10 #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h" |
14 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h" | 11 #include "ui/ozone/platform/drm/gpu/scanout_buffer.h" |
15 | 12 |
16 namespace ui { | 13 namespace ui { |
17 | 14 |
18 namespace { | 15 GbmSurfaceless::GbmSurfaceless(scoped_ptr<DrmWindowProxy> window, |
19 | |
20 void PostedSwapResult(const SwapCompletionCallback& callback, | |
21 gfx::SwapResult result) { | |
22 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | |
23 base::Bind(callback, result)); | |
24 } | |
25 | |
26 } // namespace | |
27 | |
28 GbmSurfaceless::GbmSurfaceless(DrmWindow* window, | |
29 GbmSurfaceFactory* surface_manager) | 16 GbmSurfaceFactory* surface_manager) |
30 : window_(window), | 17 : window_(window.Pass()), surface_manager_(surface_manager) { |
31 surface_manager_(surface_manager) { | 18 surface_manager_->RegisterSurface(window_->widget(), this); |
32 surface_manager_->RegisterSurface(window_->GetAcceleratedWidget(), this); | |
33 } | 19 } |
34 | 20 |
35 GbmSurfaceless::~GbmSurfaceless() { | 21 GbmSurfaceless::~GbmSurfaceless() { |
36 surface_manager_->UnregisterSurface(window_->GetAcceleratedWidget()); | 22 surface_manager_->UnregisterSurface(window_->widget()); |
37 } | 23 } |
38 | 24 |
39 void GbmSurfaceless::QueueOverlayPlane(const OverlayPlane& plane) { | 25 void GbmSurfaceless::QueueOverlayPlane(const OverlayPlane& plane) { |
40 planes_.push_back(plane); | 26 planes_.push_back(plane); |
41 } | 27 } |
42 | 28 |
43 intptr_t GbmSurfaceless::GetNativeWindow() { | 29 intptr_t GbmSurfaceless::GetNativeWindow() { |
44 NOTREACHED(); | 30 NOTREACHED(); |
45 return 0; | 31 return 0; |
46 } | 32 } |
47 | 33 |
48 bool GbmSurfaceless::ResizeNativeWindow(const gfx::Size& viewport_size) { | 34 bool GbmSurfaceless::ResizeNativeWindow(const gfx::Size& viewport_size) { |
49 return true; | 35 return true; |
50 } | 36 } |
51 | 37 |
52 bool GbmSurfaceless::OnSwapBuffers() { | 38 bool GbmSurfaceless::OnSwapBuffers() { |
53 NOTREACHED(); | 39 NOTREACHED(); |
54 return false; | 40 return false; |
55 } | 41 } |
56 | 42 |
57 bool GbmSurfaceless::OnSwapBuffersAsync( | 43 bool GbmSurfaceless::OnSwapBuffersAsync( |
58 const SwapCompletionCallback& callback) { | 44 const SwapCompletionCallback& callback) { |
59 // Wrap the callback and post the result such that everything using the | 45 window_->SchedulePageFlip(planes_, callback); |
60 // callback doesn't need to worry about re-entrancy. | |
61 window_->SchedulePageFlip(planes_, base::Bind(&PostedSwapResult, callback)); | |
62 planes_.clear(); | 46 planes_.clear(); |
63 return true; | 47 return true; |
64 } | 48 } |
65 | 49 |
66 scoped_ptr<gfx::VSyncProvider> GbmSurfaceless::CreateVSyncProvider() { | 50 scoped_ptr<gfx::VSyncProvider> GbmSurfaceless::CreateVSyncProvider() { |
67 return make_scoped_ptr(new DrmVSyncProvider(window_)); | 51 return make_scoped_ptr(new DrmVSyncProvider(window_.get())); |
68 } | 52 } |
69 | 53 |
70 bool GbmSurfaceless::IsUniversalDisplayLinkDevice() { | 54 bool GbmSurfaceless::IsUniversalDisplayLinkDevice() { |
71 return planes_.empty() ? false : planes_[0].buffer->RequiresGlFinish(); | 55 return planes_.empty() ? false : planes_[0].buffer->RequiresGlFinish(); |
72 } | 56 } |
73 | 57 |
74 } // namespace ui | 58 } // namespace ui |
OLD | NEW |