| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "cc/test/test_delegating_output_surface.h" | 5 #include "cc/test/test_delegating_output_surface.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "cc/output/begin_frame_args.h" | 10 #include "cc/output/begin_frame_args.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 delegated_surface_id_ = surface_id_allocator_->GenerateId(); | 103 delegated_surface_id_ = surface_id_allocator_->GenerateId(); |
| 104 surface_factory_->Create(delegated_surface_id_); | 104 surface_factory_->Create(delegated_surface_id_); |
| 105 } | 105 } |
| 106 display_->SetSurfaceId(delegated_surface_id_, | 106 display_->SetSurfaceId(delegated_surface_id_, |
| 107 frame.metadata.device_scale_factor); | 107 frame.metadata.device_scale_factor); |
| 108 | 108 |
| 109 gfx::Size frame_size = | 109 gfx::Size frame_size = |
| 110 frame.delegated_frame_data->render_pass_list.back()->output_rect.size(); | 110 frame.delegated_frame_data->render_pass_list.back()->output_rect.size(); |
| 111 display_->Resize(frame_size); | 111 display_->Resize(frame_size); |
| 112 | 112 |
| 113 bool synchronous = !display_->has_scheduler(); |
| 114 |
| 113 surface_factory_->SubmitCompositorFrame( | 115 surface_factory_->SubmitCompositorFrame( |
| 114 delegated_surface_id_, std::move(frame), | 116 delegated_surface_id_, std::move(frame), |
| 115 base::Bind(&TestDelegatingOutputSurface::DrawCallback, | 117 base::Bind(&TestDelegatingOutputSurface::DrawCallback, |
| 116 weak_ptrs_.GetWeakPtr())); | 118 weak_ptrs_.GetWeakPtr(), synchronous)); |
| 117 | 119 |
| 118 if (!display_->has_scheduler()) | 120 if (!display_->has_scheduler()) |
| 119 display_->DrawAndSwap(); | 121 display_->DrawAndSwap(); |
| 120 } | 122 } |
| 121 | 123 |
| 122 void TestDelegatingOutputSurface::DrawCallback() { | 124 void TestDelegatingOutputSurface::DrawCallback(bool synchronous) { |
| 123 client_->DidSwapBuffersComplete(); | 125 // This is the frame ack to unthrottle the next frame, not actually a notice |
| 126 // that drawing is done. |
| 127 if (synchronous) { |
| 128 // For synchronous draws, this must be posted to a new stack because we are |
| 129 // still the original call to SwapBuffers, and we want to leave that before |
| 130 // saying that it is done. |
| 131 OutputSurface::PostSwapBuffersComplete(); |
| 132 } else { |
| 133 client_->DidSwapBuffersComplete(); |
| 134 } |
| 124 } | 135 } |
| 125 | 136 |
| 126 void TestDelegatingOutputSurface::ForceReclaimResources() { | 137 void TestDelegatingOutputSurface::ForceReclaimResources() { |
| 127 if (capabilities_.can_force_reclaim_resources && | 138 if (capabilities_.can_force_reclaim_resources && |
| 128 !delegated_surface_id_.is_null()) { | 139 !delegated_surface_id_.is_null()) { |
| 129 surface_factory_->SubmitCompositorFrame(delegated_surface_id_, | 140 surface_factory_->SubmitCompositorFrame(delegated_surface_id_, |
| 130 CompositorFrame(), | 141 CompositorFrame(), |
| 131 SurfaceFactory::DrawCallback()); | 142 SurfaceFactory::DrawCallback()); |
| 132 } | 143 } |
| 133 } | 144 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 156 void TestDelegatingOutputSurface::DisplayOutputSurfaceLost() { | 167 void TestDelegatingOutputSurface::DisplayOutputSurfaceLost() { |
| 157 DidLoseOutputSurface(); | 168 DidLoseOutputSurface(); |
| 158 } | 169 } |
| 159 | 170 |
| 160 void TestDelegatingOutputSurface::DisplaySetMemoryPolicy( | 171 void TestDelegatingOutputSurface::DisplaySetMemoryPolicy( |
| 161 const ManagedMemoryPolicy& policy) { | 172 const ManagedMemoryPolicy& policy) { |
| 162 SetMemoryPolicy(policy); | 173 SetMemoryPolicy(policy); |
| 163 } | 174 } |
| 164 | 175 |
| 165 } // namespace cc | 176 } // namespace cc |
| OLD | NEW |