| 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_compositor_frame_sink.h" | 5 #include "cc/test/test_compositor_frame_sink.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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 display_->renderer_for_testing()->SetEnlargePassTextureAmountForTesting( | 104 display_->renderer_for_testing()->SetEnlargePassTextureAmountForTesting( |
| 105 enlarge_pass_texture_amount_); | 105 enlarge_pass_texture_amount_); |
| 106 display_->SetVisible(true); | 106 display_->SetVisible(true); |
| 107 bound_ = true; | 107 bound_ = true; |
| 108 return true; | 108 return true; |
| 109 } | 109 } |
| 110 | 110 |
| 111 void TestCompositorFrameSink::DetachFromClient() { | 111 void TestCompositorFrameSink::DetachFromClient() { |
| 112 // Some tests make BindToClient fail on purpose. ^__^ | 112 // Some tests make BindToClient fail on purpose. ^__^ |
| 113 if (bound_) { | 113 if (bound_) { |
| 114 if (!delegated_local_frame_id_.is_null()) | 114 if (delegated_local_frame_id_.is_valid()) |
| 115 surface_factory_->Destroy(delegated_local_frame_id_); | 115 surface_factory_->Destroy(delegated_local_frame_id_); |
| 116 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_); | 116 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_); |
| 117 surface_manager_->InvalidateFrameSinkId(frame_sink_id_); | 117 surface_manager_->InvalidateFrameSinkId(frame_sink_id_); |
| 118 display_ = nullptr; | 118 display_ = nullptr; |
| 119 bound_ = false; | 119 bound_ = false; |
| 120 } | 120 } |
| 121 surface_factory_ = nullptr; | 121 surface_factory_ = nullptr; |
| 122 surface_id_allocator_ = nullptr; | 122 surface_id_allocator_ = nullptr; |
| 123 surface_manager_ = nullptr; | 123 surface_manager_ = nullptr; |
| 124 test_client_ = nullptr; | 124 test_client_ = nullptr; |
| 125 CompositorFrameSink::DetachFromClient(); | 125 CompositorFrameSink::DetachFromClient(); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void TestCompositorFrameSink::SubmitCompositorFrame(CompositorFrame frame) { | 128 void TestCompositorFrameSink::SubmitCompositorFrame(CompositorFrame frame) { |
| 129 test_client_->DisplayReceivedCompositorFrame(frame); | 129 test_client_->DisplayReceivedCompositorFrame(frame); |
| 130 | 130 |
| 131 if (delegated_local_frame_id_.is_null()) { | 131 if (!delegated_local_frame_id_.is_valid()) { |
| 132 delegated_local_frame_id_ = surface_id_allocator_->GenerateId(); | 132 delegated_local_frame_id_ = surface_id_allocator_->GenerateId(); |
| 133 surface_factory_->Create(delegated_local_frame_id_); | 133 surface_factory_->Create(delegated_local_frame_id_); |
| 134 } | 134 } |
| 135 display_->SetSurfaceId(SurfaceId(frame_sink_id_, delegated_local_frame_id_), | 135 display_->SetSurfaceId(SurfaceId(frame_sink_id_, delegated_local_frame_id_), |
| 136 frame.metadata.device_scale_factor); | 136 frame.metadata.device_scale_factor); |
| 137 | 137 |
| 138 gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size(); | 138 gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size(); |
| 139 display_->Resize(frame_size); | 139 display_->Resize(frame_size); |
| 140 | 140 |
| 141 bool synchronous = !display_->has_scheduler(); | 141 bool synchronous = !display_->has_scheduler(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 170 } | 170 } |
| 171 | 171 |
| 172 void TestCompositorFrameSink::DidDrawCallback() { | 172 void TestCompositorFrameSink::DidDrawCallback() { |
| 173 // This is to unthrottle the next frame, not actually a notice that drawing is | 173 // This is to unthrottle the next frame, not actually a notice that drawing is |
| 174 // done. | 174 // done. |
| 175 client_->DidReceiveCompositorFrameAck(); | 175 client_->DidReceiveCompositorFrameAck(); |
| 176 } | 176 } |
| 177 | 177 |
| 178 void TestCompositorFrameSink::ForceReclaimResources() { | 178 void TestCompositorFrameSink::ForceReclaimResources() { |
| 179 if (capabilities_.can_force_reclaim_resources && | 179 if (capabilities_.can_force_reclaim_resources && |
| 180 !delegated_local_frame_id_.is_null()) { | 180 delegated_local_frame_id_.is_valid()) { |
| 181 surface_factory_->SubmitCompositorFrame(delegated_local_frame_id_, | 181 surface_factory_->SubmitCompositorFrame(delegated_local_frame_id_, |
| 182 CompositorFrame(), | 182 CompositorFrame(), |
| 183 SurfaceFactory::DrawCallback()); | 183 SurfaceFactory::DrawCallback()); |
| 184 } | 184 } |
| 185 } | 185 } |
| 186 | 186 |
| 187 void TestCompositorFrameSink::ReturnResources( | 187 void TestCompositorFrameSink::ReturnResources( |
| 188 const ReturnedResourceArray& resources) { | 188 const ReturnedResourceArray& resources) { |
| 189 client_->ReclaimResources(resources); | 189 client_->ReclaimResources(resources); |
| 190 } | 190 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 202 bool will_draw_and_swap, | 202 bool will_draw_and_swap, |
| 203 const RenderPassList& render_passes) { | 203 const RenderPassList& render_passes) { |
| 204 test_client_->DisplayWillDrawAndSwap(will_draw_and_swap, render_passes); | 204 test_client_->DisplayWillDrawAndSwap(will_draw_and_swap, render_passes); |
| 205 } | 205 } |
| 206 | 206 |
| 207 void TestCompositorFrameSink::DisplayDidDrawAndSwap() { | 207 void TestCompositorFrameSink::DisplayDidDrawAndSwap() { |
| 208 test_client_->DisplayDidDrawAndSwap(); | 208 test_client_->DisplayDidDrawAndSwap(); |
| 209 } | 209 } |
| 210 | 210 |
| 211 } // namespace cc | 211 } // namespace cc |
| OLD | NEW |