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" |
(...skipping 14 matching lines...) Expand all Loading... |
25 bool GbmSurfaceless::ResizeNativeWindow(const gfx::Size& viewport_size) { | 25 bool GbmSurfaceless::ResizeNativeWindow(const gfx::Size& viewport_size) { |
26 NOTIMPLEMENTED(); | 26 NOTIMPLEMENTED(); |
27 return false; | 27 return false; |
28 } | 28 } |
29 | 29 |
30 bool GbmSurfaceless::OnSwapBuffers() { | 30 bool GbmSurfaceless::OnSwapBuffers() { |
31 HardwareDisplayController* controller = window_delegate_->GetController(); | 31 HardwareDisplayController* controller = window_delegate_->GetController(); |
32 if (!controller) | 32 if (!controller) |
33 return true; | 33 return true; |
34 | 34 |
| 35 // Ensure any previous PageFlip events are handled. Doing this here also makes |
| 36 // sure we don't throttle GPU in case it's still handling previous PageFlip |
| 37 // request. This also makes sure we have at most two frames "in flight". Let's |
| 38 // say we submitted all the commands for render buffer A to GPU and then |
| 39 // requested the driver to display it. GPU might still be rendering buffer A, |
| 40 // so the flip is still pending. However, we might already be busy at work |
| 41 // submitting commands for render buffer B. Once done submitting commands for |
| 42 // buffer B, we queue B for page flip, and continue render for frame C. If we |
| 43 // try page flipping B without handling the events, the driver might return |
| 44 // EBusy(in case it's still handling previous flip) here, and also we don't |
| 45 // want to use any more than triple buffering. Thus, we sleep waiting for A |
| 46 // to show up on the screen, before issuing a flip request for B. |
| 47 controller->WaitForPageFlipEvent(); |
35 bool success = controller->SchedulePageFlip(); | 48 bool success = controller->SchedulePageFlip(); |
36 controller->WaitForPageFlipEvent(); | |
37 | 49 |
38 return success; | 50 return success; |
39 } | 51 } |
40 | 52 |
41 scoped_ptr<gfx::VSyncProvider> GbmSurfaceless::CreateVSyncProvider() { | 53 scoped_ptr<gfx::VSyncProvider> GbmSurfaceless::CreateVSyncProvider() { |
42 return scoped_ptr<gfx::VSyncProvider>(new DriVSyncProvider(window_delegate_)); | 54 return scoped_ptr<gfx::VSyncProvider>(new DriVSyncProvider(window_delegate_)); |
43 } | 55 } |
44 | 56 |
45 } // namespace ui | 57 } // namespace ui |
OLD | NEW |