| 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/bind_helpers.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" |
| 9 #include "ui/ozone/platform/drm/gpu/drm_thread.h" |
| 11 #include "ui/ozone/platform/drm/gpu/drm_vsync_provider.h" | 10 #include "ui/ozone/platform/drm/gpu/drm_vsync_provider.h" |
| 12 #include "ui/ozone/platform/drm/gpu/drm_window.h" | 11 #include "ui/ozone/platform/drm/gpu/drm_window.h" |
| 13 #include "ui/ozone/platform/drm/gpu/gbm_buffer.h" | 12 #include "ui/ozone/platform/drm/gpu/proxy_helpers.h" |
| 14 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h" | |
| 15 | 13 |
| 16 namespace ui { | 14 namespace ui { |
| 17 | 15 |
| 18 GbmSurfaceless::GbmSurfaceless(DrmWindow* window, | 16 GbmSurfaceless::GbmSurfaceless(gfx::AcceleratedWidget widget, |
| 19 DrmDeviceManager* drm_device_manager) | 17 DrmThread* drm_thread) |
| 20 : window_(window), drm_device_manager_(drm_device_manager) { | 18 : widget_(widget), |
| 21 } | 19 drm_thread_(drm_thread), |
| 20 window_(drm_thread->GetWindow(widget_)) {} |
| 22 | 21 |
| 23 GbmSurfaceless::~GbmSurfaceless() { | 22 GbmSurfaceless::~GbmSurfaceless() { |
| 24 } | 23 } |
| 25 | 24 |
| 26 intptr_t GbmSurfaceless::GetNativeWindow() { | 25 intptr_t GbmSurfaceless::GetNativeWindow() { |
| 27 NOTREACHED(); | 26 NOTREACHED(); |
| 28 return 0; | 27 return 0; |
| 29 } | 28 } |
| 30 | 29 |
| 31 bool GbmSurfaceless::ResizeNativeWindow(const gfx::Size& viewport_size) { | 30 bool GbmSurfaceless::ResizeNativeWindow(const gfx::Size& viewport_size) { |
| 32 return true; | 31 return true; |
| 33 } | 32 } |
| 34 | 33 |
| 35 bool GbmSurfaceless::OnSwapBuffers() { | 34 bool GbmSurfaceless::OnSwapBuffers() { |
| 36 NOTREACHED(); | 35 NOTREACHED(); |
| 37 return false; | 36 return false; |
| 38 } | 37 } |
| 39 | 38 |
| 40 bool GbmSurfaceless::OnSwapBuffersAsync( | 39 bool GbmSurfaceless::OnSwapBuffersAsync( |
| 41 const SwapCompletionCallback& callback) { | 40 const SwapCompletionCallback& callback) { |
| 42 return window_->SchedulePageFlip(callback); | 41 drm_thread_->task_runner()->PostTask( |
| 42 FROM_HERE, base::Bind(&DrmWindow::SchedulePageFlip, window_, |
| 43 CreateSafeCallback(callback))); |
| 44 return true; |
| 43 } | 45 } |
| 44 | 46 |
| 45 scoped_ptr<gfx::VSyncProvider> GbmSurfaceless::CreateVSyncProvider() { | 47 scoped_ptr<gfx::VSyncProvider> GbmSurfaceless::CreateVSyncProvider() { |
| 46 return make_scoped_ptr(new DrmVSyncProvider(window_)); | 48 return make_scoped_ptr( |
| 49 new DrmVSyncProvider(drm_thread_->task_runner(), window_)); |
| 47 } | 50 } |
| 48 | 51 |
| 49 bool GbmSurfaceless::IsUniversalDisplayLinkDevice() { | 52 bool GbmSurfaceless::IsUniversalDisplayLinkDevice() { |
| 50 if (!drm_device_manager_) | 53 DrmDeviceManager* device_manager = drm_thread_->device_manager(); |
| 54 scoped_refptr<DrmDevice> widget_device = |
| 55 device_manager->GetDrmDevice(widget_); |
| 56 if (!widget_device) |
| 51 return false; | 57 return false; |
| 52 scoped_refptr<DrmDevice> drm_primary = | |
| 53 drm_device_manager_->GetDrmDevice(gfx::kNullAcceleratedWidget); | |
| 54 DCHECK(drm_primary); | |
| 55 | 58 |
| 56 HardwareDisplayController* controller = window_->GetController(); | 59 return device_manager->GetDrmDevice(gfx::kNullAcceleratedWidget) != |
| 57 if (!controller) | 60 widget_device; |
| 58 return false; | |
| 59 scoped_refptr<DrmDevice> drm = controller->GetAllocationDrmDevice(); | |
| 60 DCHECK(drm); | |
| 61 | |
| 62 return drm_primary != drm; | |
| 63 } | 61 } |
| 64 | 62 |
| 65 } // namespace ui | 63 } // namespace ui |
| OLD | NEW |