| 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 "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 bool force_disable_reclaim_resources) | 30 bool force_disable_reclaim_resources) |
| 31 : CompositorFrameSink(std::move(compositor_context_provider), | 31 : CompositorFrameSink(std::move(compositor_context_provider), |
| 32 std::move(worker_context_provider), | 32 std::move(worker_context_provider), |
| 33 gpu_memory_buffer_manager, | 33 gpu_memory_buffer_manager, |
| 34 shared_bitmap_manager), | 34 shared_bitmap_manager), |
| 35 synchronous_composite_(synchronous_composite), | 35 synchronous_composite_(synchronous_composite), |
| 36 renderer_settings_(renderer_settings), | 36 renderer_settings_(renderer_settings), |
| 37 task_runner_(std::move(task_runner)), | 37 task_runner_(std::move(task_runner)), |
| 38 frame_sink_id_(kCompositorFrameSinkId), | 38 frame_sink_id_(kCompositorFrameSinkId), |
| 39 surface_manager_(new SurfaceManager), | 39 surface_manager_(new SurfaceManager), |
| 40 surface_id_allocator_(new SurfaceIdAllocator()), | 40 local_surface_id_allocator_(new LocalSurfaceIdAllocator()), |
| 41 surface_factory_( | 41 surface_factory_( |
| 42 new SurfaceFactory(frame_sink_id_, surface_manager_.get(), this)), | 42 new SurfaceFactory(frame_sink_id_, surface_manager_.get(), this)), |
| 43 weak_ptr_factory_(this) { | 43 weak_ptr_factory_(this) { |
| 44 // Since this CompositorFrameSink and the Display are tightly coupled and in | 44 // Since this CompositorFrameSink and the Display are tightly coupled and in |
| 45 // the same process/thread, the LayerTreeHostImpl can reclaim resources from | 45 // the same process/thread, the LayerTreeHostImpl can reclaim resources from |
| 46 // the Display. But we allow tests to disable this to mimic an out-of-process | 46 // the Display. But we allow tests to disable this to mimic an out-of-process |
| 47 // Display. | 47 // Display. |
| 48 capabilities_.can_force_reclaim_resources = !force_disable_reclaim_resources; | 48 capabilities_.can_force_reclaim_resources = !force_disable_reclaim_resources; |
| 49 // Always use sync tokens so that code paths in resource provider that deal | 49 // Always use sync tokens so that code paths in resource provider that deal |
| 50 // with sync tokens are tested. | 50 // with sync tokens are tested. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 surface_factory_->EvictSurface(); | 114 surface_factory_->EvictSurface(); |
| 115 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_); | 115 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_); |
| 116 surface_manager_->InvalidateFrameSinkId(frame_sink_id_); | 116 surface_manager_->InvalidateFrameSinkId(frame_sink_id_); |
| 117 display_ = nullptr; | 117 display_ = nullptr; |
| 118 bound_ = false; | 118 bound_ = false; |
| 119 } | 119 } |
| 120 surface_factory_ = nullptr; | 120 surface_factory_ = nullptr; |
| 121 surface_id_allocator_ = nullptr; | 121 local_surface_id_allocator_ = nullptr; |
| 122 surface_manager_ = nullptr; | 122 surface_manager_ = nullptr; |
| 123 test_client_ = nullptr; | 123 test_client_ = nullptr; |
| 124 CompositorFrameSink::DetachFromClient(); | 124 CompositorFrameSink::DetachFromClient(); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void TestCompositorFrameSink::SubmitCompositorFrame(CompositorFrame frame) { | 127 void TestCompositorFrameSink::SubmitCompositorFrame(CompositorFrame frame) { |
| 128 test_client_->DisplayReceivedCompositorFrame(frame); | 128 test_client_->DisplayReceivedCompositorFrame(frame); |
| 129 | 129 |
| 130 if (!delegated_local_surface_id_.is_valid()) { | 130 if (!delegated_local_surface_id_.is_valid()) { |
| 131 delegated_local_surface_id_ = surface_id_allocator_->GenerateId(); | 131 delegated_local_surface_id_ = local_surface_id_allocator_->GenerateId(); |
| 132 } | 132 } |
| 133 display_->SetLocalSurfaceId(delegated_local_surface_id_, | 133 display_->SetLocalSurfaceId(delegated_local_surface_id_, |
| 134 frame.metadata.device_scale_factor); | 134 frame.metadata.device_scale_factor); |
| 135 | 135 |
| 136 gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size(); | 136 gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size(); |
| 137 display_->Resize(frame_size); | 137 display_->Resize(frame_size); |
| 138 | 138 |
| 139 bool synchronous = !display_->has_scheduler(); | 139 bool synchronous = !display_->has_scheduler(); |
| 140 | 140 |
| 141 SurfaceFactory::DrawCallback draw_callback; | 141 SurfaceFactory::DrawCallback draw_callback; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 bool will_draw_and_swap, | 197 bool will_draw_and_swap, |
| 198 const RenderPassList& render_passes) { | 198 const RenderPassList& render_passes) { |
| 199 test_client_->DisplayWillDrawAndSwap(will_draw_and_swap, render_passes); | 199 test_client_->DisplayWillDrawAndSwap(will_draw_and_swap, render_passes); |
| 200 } | 200 } |
| 201 | 201 |
| 202 void TestCompositorFrameSink::DisplayDidDrawAndSwap() { | 202 void TestCompositorFrameSink::DisplayDidDrawAndSwap() { |
| 203 test_client_->DisplayDidDrawAndSwap(); | 203 test_client_->DisplayDidDrawAndSwap(); |
| 204 } | 204 } |
| 205 | 205 |
| 206 } // namespace cc | 206 } // namespace cc |
| OLD | NEW |