| 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" |
| 11 #include "cc/output/begin_frame_args.h" | 11 #include "cc/output/begin_frame_args.h" |
| 12 #include "cc/output/compositor_frame_sink_client.h" | 12 #include "cc/output/compositor_frame_sink_client.h" |
| 13 #include "cc/output/copy_output_request.h" | 13 #include "cc/output/copy_output_request.h" |
| 14 #include "cc/output/direct_renderer.h" | 14 #include "cc/output/direct_renderer.h" |
| 15 #include "cc/output/output_surface.h" | 15 #include "cc/output/output_surface.h" |
| 16 #include "cc/output/texture_mailbox_deleter.h" | 16 #include "cc/output/texture_mailbox_deleter.h" |
| 17 | 17 |
| 18 namespace cc { | 18 namespace cc { |
| 19 | 19 |
| 20 static constexpr FrameSinkId kCompositorFrameSinkId(1, 1); | 20 static constexpr FrameSinkId kCompositorFrameSinkId(1, 1); |
| 21 | 21 |
| 22 TestCompositorFrameSink::TestCompositorFrameSink( | 22 TestCompositorFrameSink::TestCompositorFrameSink( |
| 23 scoped_refptr<ContextProvider> compositor_context_provider, | 23 scoped_refptr<ContextProvider> compositor_context_provider, |
| 24 scoped_refptr<ContextProvider> worker_context_provider, | 24 scoped_refptr<ContextProvider> worker_context_provider, |
| 25 SharedBitmapManager* shared_bitmap_manager, | 25 SharedBitmapManager* shared_bitmap_manager, |
| 26 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 26 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 27 const RendererSettings& renderer_settings, | 27 const RendererSettings& renderer_settings, |
| 28 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 28 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 29 bool synchronous_composite, | 29 bool synchronous_composite) |
| 30 bool force_disable_reclaim_resources) | |
| 31 : CompositorFrameSink(std::move(compositor_context_provider), | 30 : CompositorFrameSink(std::move(compositor_context_provider), |
| 32 std::move(worker_context_provider), | 31 std::move(worker_context_provider), |
| 33 gpu_memory_buffer_manager, | 32 gpu_memory_buffer_manager, |
| 34 shared_bitmap_manager), | 33 shared_bitmap_manager), |
| 35 synchronous_composite_(synchronous_composite), | 34 synchronous_composite_(synchronous_composite), |
| 36 renderer_settings_(renderer_settings), | 35 renderer_settings_(renderer_settings), |
| 37 task_runner_(std::move(task_runner)), | 36 task_runner_(std::move(task_runner)), |
| 38 frame_sink_id_(kCompositorFrameSinkId), | 37 frame_sink_id_(kCompositorFrameSinkId), |
| 39 surface_manager_(new SurfaceManager), | 38 surface_manager_(new SurfaceManager), |
| 40 surface_id_allocator_(new SurfaceIdAllocator()), | 39 surface_id_allocator_(new SurfaceIdAllocator()), |
| 41 surface_factory_( | 40 surface_factory_( |
| 42 new SurfaceFactory(frame_sink_id_, surface_manager_.get(), this)), | 41 new SurfaceFactory(frame_sink_id_, surface_manager_.get(), this)), |
| 43 weak_ptr_factory_(this) { | 42 weak_ptr_factory_(this) { |
| 44 // Since this CompositorFrameSink and the Display are tightly coupled and in | |
| 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 | |
| 47 // Display. | |
| 48 capabilities_.can_force_reclaim_resources = !force_disable_reclaim_resources; | |
| 49 // Always use sync tokens so that code paths in resource provider that deal | 43 // Always use sync tokens so that code paths in resource provider that deal |
| 50 // with sync tokens are tested. | 44 // with sync tokens are tested. |
| 51 capabilities_.delegated_sync_points_required = true; | 45 capabilities_.delegated_sync_points_required = true; |
| 52 } | 46 } |
| 53 | 47 |
| 54 TestCompositorFrameSink::~TestCompositorFrameSink() { | 48 TestCompositorFrameSink::~TestCompositorFrameSink() { |
| 55 DCHECK(copy_requests_.empty()); | 49 DCHECK(copy_requests_.empty()); |
| 56 } | 50 } |
| 57 | 51 |
| 58 void TestCompositorFrameSink::RequestCopyOfOutput( | 52 void TestCompositorFrameSink::RequestCopyOfOutput( |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 weak_ptr_factory_.GetWeakPtr())); | 159 weak_ptr_factory_.GetWeakPtr())); |
| 166 } | 160 } |
| 167 } | 161 } |
| 168 | 162 |
| 169 void TestCompositorFrameSink::DidDrawCallback() { | 163 void TestCompositorFrameSink::DidDrawCallback() { |
| 170 // This is to unthrottle the next frame, not actually a notice that drawing is | 164 // This is to unthrottle the next frame, not actually a notice that drawing is |
| 171 // done. | 165 // done. |
| 172 client_->DidReceiveCompositorFrameAck(); | 166 client_->DidReceiveCompositorFrameAck(); |
| 173 } | 167 } |
| 174 | 168 |
| 175 void TestCompositorFrameSink::ForceReclaimResources() { | |
| 176 if (capabilities_.can_force_reclaim_resources && | |
| 177 delegated_local_frame_id_.is_valid()) { | |
| 178 surface_factory_->ClearSurface(); | |
| 179 } | |
| 180 } | |
| 181 | |
| 182 void TestCompositorFrameSink::ReturnResources( | 169 void TestCompositorFrameSink::ReturnResources( |
| 183 const ReturnedResourceArray& resources) { | 170 const ReturnedResourceArray& resources) { |
| 184 client_->ReclaimResources(resources); | 171 client_->ReclaimResources(resources); |
| 185 } | 172 } |
| 186 | 173 |
| 187 void TestCompositorFrameSink::SetBeginFrameSource( | 174 void TestCompositorFrameSink::SetBeginFrameSource( |
| 188 BeginFrameSource* begin_frame_source) { | 175 BeginFrameSource* begin_frame_source) { |
| 189 client_->SetBeginFrameSource(begin_frame_source); | 176 client_->SetBeginFrameSource(begin_frame_source); |
| 190 } | 177 } |
| 191 | 178 |
| 192 void TestCompositorFrameSink::DisplayOutputSurfaceLost() { | 179 void TestCompositorFrameSink::DisplayOutputSurfaceLost() { |
| 193 client_->DidLoseCompositorFrameSink(); | 180 client_->DidLoseCompositorFrameSink(); |
| 194 } | 181 } |
| 195 | 182 |
| 196 void TestCompositorFrameSink::DisplayWillDrawAndSwap( | 183 void TestCompositorFrameSink::DisplayWillDrawAndSwap( |
| 197 bool will_draw_and_swap, | 184 bool will_draw_and_swap, |
| 198 const RenderPassList& render_passes) { | 185 const RenderPassList& render_passes) { |
| 199 test_client_->DisplayWillDrawAndSwap(will_draw_and_swap, render_passes); | 186 test_client_->DisplayWillDrawAndSwap(will_draw_and_swap, render_passes); |
| 200 } | 187 } |
| 201 | 188 |
| 202 void TestCompositorFrameSink::DisplayDidDrawAndSwap() { | 189 void TestCompositorFrameSink::DisplayDidDrawAndSwap() { |
| 203 test_client_->DisplayDidDrawAndSwap(); | 190 test_client_->DisplayDidDrawAndSwap(); |
| 204 } | 191 } |
| 205 | 192 |
| 206 } // namespace cc | 193 } // namespace cc |
| OLD | NEW |