| 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/dri/gbm_surfaceless.h" | 5 #include "ui/ozone/platform/dri/gbm_surfaceless.h" |
| 6 | 6 |
| 7 #include "ui/ozone/platform/dri/dri_vsync_provider.h" | 7 #include "ui/ozone/platform/dri/dri_vsync_provider.h" |
| 8 #include "ui/ozone/platform/dri/dri_window_delegate.h" | 8 #include "ui/ozone/platform/dri/dri_window_delegate.h" |
| 9 #include "ui/ozone/platform/dri/gbm_buffer.h" | 9 #include "ui/ozone/platform/dri/gbm_buffer.h" |
| 10 #include "ui/ozone/platform/dri/hardware_display_controller.h" | 10 #include "ui/ozone/platform/dri/hardware_display_controller.h" |
| 11 #include "ui/ozone/platform/dri/page_flip_event_handler.h" |
| 11 | 12 |
| 12 namespace ui { | 13 namespace ui { |
| 13 | 14 |
| 14 GbmSurfaceless::GbmSurfaceless(DriWindowDelegate* window_delegate) | 15 GbmSurfaceless::GbmSurfaceless(DriWindowDelegate* window_delegate, |
| 15 : window_delegate_(window_delegate) { | 16 PageFlipEventHandler* handler) |
| 17 : window_delegate_(window_delegate), flip_handler_(handler) { |
| 16 } | 18 } |
| 17 | 19 |
| 18 GbmSurfaceless::~GbmSurfaceless() {} | 20 GbmSurfaceless::~GbmSurfaceless() {} |
| 19 | 21 |
| 20 intptr_t GbmSurfaceless::GetNativeWindow() { | 22 intptr_t GbmSurfaceless::GetNativeWindow() { |
| 21 NOTREACHED(); | 23 NOTREACHED(); |
| 22 return 0; | 24 return 0; |
| 23 } | 25 } |
| 24 | 26 |
| 25 bool GbmSurfaceless::ResizeNativeWindow(const gfx::Size& viewport_size) { | 27 bool GbmSurfaceless::ResizeNativeWindow(const gfx::Size& viewport_size) { |
| 26 NOTIMPLEMENTED(); | 28 NOTIMPLEMENTED(); |
| 27 return false; | 29 return false; |
| 28 } | 30 } |
| 29 | 31 |
| 30 bool GbmSurfaceless::OnSwapBuffers() { | 32 bool GbmSurfaceless::OnSwapBuffers() { |
| 31 HardwareDisplayController* controller = window_delegate_->GetController(); | 33 HardwareDisplayController* controller = window_delegate_->GetController(); |
| 32 if (!controller) | 34 if (!controller) |
| 33 return true; | 35 return true; |
| 34 | 36 |
| 35 bool success = controller->SchedulePageFlip(); | 37 bool success = controller->SchedulePageFlip(); |
| 36 controller->WaitForPageFlipEvent(); | 38 |
| 39 if (flip_handler_) |
| 40 flip_handler_->GetPageFlipCompleted(controller, callback_); |
| 41 else |
| 42 controller->WaitForPageFlipEvent(); |
| 37 | 43 |
| 38 return success; | 44 return success; |
| 39 } | 45 } |
| 40 | 46 |
| 41 scoped_ptr<gfx::VSyncProvider> GbmSurfaceless::CreateVSyncProvider() { | 47 scoped_ptr<gfx::VSyncProvider> GbmSurfaceless::CreateVSyncProvider() { |
| 42 return scoped_ptr<gfx::VSyncProvider>(new DriVSyncProvider(window_delegate_)); | 48 return scoped_ptr<gfx::VSyncProvider>(new DriVSyncProvider(window_delegate_)); |
| 43 } | 49 } |
| 44 | 50 |
| 51 void GbmSurfaceless::SetPageFlipCompletionCallback( |
| 52 const PageFlipCompletionCallback& callback) { |
| 53 callback_ = callback; |
| 54 } |
| 55 |
| 45 } // namespace ui | 56 } // namespace ui |
| OLD | NEW |