| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_valid()) { | 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_->SetLocalFrameId(delegated_local_frame_id_, | 135 display_->SetLocalFrameId(delegated_local_frame_id_, |
| 136 frame.metadata.device_scale_factor); | 136 frame.metadata.device_scale_factor); |
| 137 | 137 |
| 138 gfx::Size frame_size = | 138 gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size(); |
| 139 frame.delegated_frame_data->render_pass_list.back()->output_rect.size(); | |
| 140 display_->Resize(frame_size); | 139 display_->Resize(frame_size); |
| 141 | 140 |
| 142 bool synchronous = !display_->has_scheduler(); | 141 bool synchronous = !display_->has_scheduler(); |
| 143 | 142 |
| 144 SurfaceFactory::DrawCallback draw_callback; | 143 SurfaceFactory::DrawCallback draw_callback; |
| 145 if (!synchronous) { | 144 if (!synchronous) { |
| 146 // For async draws, we use a callback tell when it is done, but for sync | 145 // For async draws, we use a callback tell when it is done, but for sync |
| 147 // draws we don't need one. Unretained is safe here because the callback | 146 // draws we don't need one. Unretained is safe here because the callback |
| 148 // will be run when |surface_factory_| is destroyed which is owned by this | 147 // will be run when |surface_factory_| is destroyed which is owned by this |
| 149 // class. | 148 // class. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 172 | 171 |
| 173 void TestCompositorFrameSink::DidDrawCallback() { | 172 void TestCompositorFrameSink::DidDrawCallback() { |
| 174 // 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 |
| 175 // done. | 174 // done. |
| 176 client_->DidReceiveCompositorFrameAck(); | 175 client_->DidReceiveCompositorFrameAck(); |
| 177 } | 176 } |
| 178 | 177 |
| 179 void TestCompositorFrameSink::ForceReclaimResources() { | 178 void TestCompositorFrameSink::ForceReclaimResources() { |
| 180 if (capabilities_.can_force_reclaim_resources && | 179 if (capabilities_.can_force_reclaim_resources && |
| 181 delegated_local_frame_id_.is_valid()) { | 180 delegated_local_frame_id_.is_valid()) { |
| 182 surface_factory_->SubmitCompositorFrame(delegated_local_frame_id_, | 181 surface_factory_->ClearSurface(delegated_local_frame_id_); |
| 183 CompositorFrame(), | |
| 184 SurfaceFactory::DrawCallback()); | |
| 185 } | 182 } |
| 186 } | 183 } |
| 187 | 184 |
| 188 void TestCompositorFrameSink::ReturnResources( | 185 void TestCompositorFrameSink::ReturnResources( |
| 189 const ReturnedResourceArray& resources) { | 186 const ReturnedResourceArray& resources) { |
| 190 client_->ReclaimResources(resources); | 187 client_->ReclaimResources(resources); |
| 191 } | 188 } |
| 192 | 189 |
| 193 void TestCompositorFrameSink::SetBeginFrameSource( | 190 void TestCompositorFrameSink::SetBeginFrameSource( |
| 194 BeginFrameSource* begin_frame_source) { | 191 BeginFrameSource* begin_frame_source) { |
| 195 client_->SetBeginFrameSource(begin_frame_source); | 192 client_->SetBeginFrameSource(begin_frame_source); |
| 196 } | 193 } |
| 197 | 194 |
| 198 void TestCompositorFrameSink::DisplayOutputSurfaceLost() { | 195 void TestCompositorFrameSink::DisplayOutputSurfaceLost() { |
| 199 client_->DidLoseCompositorFrameSink(); | 196 client_->DidLoseCompositorFrameSink(); |
| 200 } | 197 } |
| 201 | 198 |
| 202 void TestCompositorFrameSink::DisplayWillDrawAndSwap( | 199 void TestCompositorFrameSink::DisplayWillDrawAndSwap( |
| 203 bool will_draw_and_swap, | 200 bool will_draw_and_swap, |
| 204 const RenderPassList& render_passes) { | 201 const RenderPassList& render_passes) { |
| 205 test_client_->DisplayWillDrawAndSwap(will_draw_and_swap, render_passes); | 202 test_client_->DisplayWillDrawAndSwap(will_draw_and_swap, render_passes); |
| 206 } | 203 } |
| 207 | 204 |
| 208 void TestCompositorFrameSink::DisplayDidDrawAndSwap() { | 205 void TestCompositorFrameSink::DisplayDidDrawAndSwap() { |
| 209 test_client_->DisplayDidDrawAndSwap(); | 206 test_client_->DisplayDidDrawAndSwap(); |
| 210 } | 207 } |
| 211 | 208 |
| 212 } // namespace cc | 209 } // namespace cc |
| OLD | NEW |