| 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 11 matching lines...) Expand all Loading... |
| 22 scoped_refptr<ContextProvider> compositor_context_provider, | 22 scoped_refptr<ContextProvider> compositor_context_provider, |
| 23 scoped_refptr<ContextProvider> worker_context_provider, | 23 scoped_refptr<ContextProvider> worker_context_provider, |
| 24 std::unique_ptr<OutputSurface> display_output_surface, | 24 std::unique_ptr<OutputSurface> display_output_surface, |
| 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 base::SingleThreadTaskRunner* task_runner, | 28 base::SingleThreadTaskRunner* task_runner, |
| 29 bool synchronous_composite, | 29 bool synchronous_composite, |
| 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 nullptr), | |
| 34 surface_manager_(new SurfaceManager), | 33 surface_manager_(new SurfaceManager), |
| 35 surface_id_allocator_(new SurfaceIdAllocator(kCompositorClientId)), | 34 surface_id_allocator_(new SurfaceIdAllocator(kCompositorClientId)), |
| 36 surface_factory_(new SurfaceFactory(surface_manager_.get(), this)), | 35 surface_factory_(new SurfaceFactory(surface_manager_.get(), this)), |
| 37 weak_ptrs_(this) { | 36 weak_ptrs_(this) { |
| 38 std::unique_ptr<SyntheticBeginFrameSource> begin_frame_source; | 37 std::unique_ptr<SyntheticBeginFrameSource> begin_frame_source; |
| 39 std::unique_ptr<DisplayScheduler> scheduler; | 38 std::unique_ptr<DisplayScheduler> scheduler; |
| 40 if (!synchronous_composite) { | 39 if (!synchronous_composite) { |
| 41 if (renderer_settings.disable_display_vsync) { | 40 if (renderer_settings.disable_display_vsync) { |
| 42 begin_frame_source.reset(new BackToBackBeginFrameSource( | 41 begin_frame_source.reset(new BackToBackBeginFrameSource( |
| 43 base::MakeUnique<DelayBasedTimeSource>(task_runner))); | 42 base::MakeUnique<DelayBasedTimeSource>(task_runner))); |
| 44 } else { | 43 } else { |
| 45 begin_frame_source.reset(new DelayBasedBeginFrameSource( | 44 begin_frame_source.reset(new DelayBasedBeginFrameSource( |
| 46 base::MakeUnique<DelayBasedTimeSource>(task_runner))); | 45 base::MakeUnique<DelayBasedTimeSource>(task_runner))); |
| 47 begin_frame_source->SetAuthoritativeVSyncInterval( | 46 begin_frame_source->SetAuthoritativeVSyncInterval( |
| 48 base::TimeDelta::FromMilliseconds(1000.f / | 47 base::TimeDelta::FromMilliseconds(1000.f / |
| 49 renderer_settings.refresh_rate)); | 48 renderer_settings.refresh_rate)); |
| 50 } | 49 } |
| 51 scheduler.reset(new DisplayScheduler( | 50 scheduler.reset(new DisplayScheduler( |
| 52 begin_frame_source.get(), task_runner, | 51 begin_frame_source.get(), task_runner, |
| 53 display_output_surface->capabilities().max_frames_pending)); | 52 display_output_surface->capabilities().max_frames_pending)); |
| 54 } | 53 } |
| 55 const bool context_shared_with_compositor = | 54 const bool context_shared_with_compositor = |
| 56 display_output_surface->context_provider() == context_provider(); | 55 display_output_surface->context_provider() == context_provider(); |
| 57 display_.reset( | 56 display_.reset( |
| 58 new Display(shared_bitmap_manager, gpu_memory_buffer_manager, | 57 new Display(shared_bitmap_manager, gpu_memory_buffer_manager, |
| 59 renderer_settings, std::move(begin_frame_source), | 58 renderer_settings, std::move(begin_frame_source), |
| 60 std::move(display_output_surface), std::move(scheduler), | 59 std::move(display_output_surface), std::move(scheduler), |
| 61 base::MakeUnique<TextureMailboxDeleter>(task_runner))); | 60 base::MakeUnique<TextureMailboxDeleter>(task_runner))); |
| 62 | 61 |
| 63 capabilities_.delegated_rendering = true; | |
| 64 // Since this CompositorFrameSink and the Display are tightly coupled and in | 62 // Since this CompositorFrameSink and the Display are tightly coupled and in |
| 65 // the same process/thread, the LayerTreeHostImpl can reclaim resources from | 63 // the same process/thread, the LayerTreeHostImpl can reclaim resources from |
| 66 // the Display. But we allow tests to disable this to mimic an out-of-process | 64 // the Display. But we allow tests to disable this to mimic an out-of-process |
| 67 // Display. | 65 // Display. |
| 68 capabilities_.can_force_reclaim_resources = !force_disable_reclaim_resources; | 66 capabilities_.can_force_reclaim_resources = !force_disable_reclaim_resources; |
| 69 capabilities_.delegated_sync_points_required = | 67 capabilities_.delegated_sync_points_required = |
| 70 !context_shared_with_compositor; | 68 !context_shared_with_compositor; |
| 69 // TODO(enne): Remove this, it's only here to make some tests pass. |
| 70 capabilities_.adjust_deadline_for_parent = true; |
| 71 } | 71 } |
| 72 | 72 |
| 73 TestCompositorFrameSink::~TestCompositorFrameSink() { | 73 TestCompositorFrameSink::~TestCompositorFrameSink() { |
| 74 DCHECK(copy_requests_.empty()); | 74 DCHECK(copy_requests_.empty()); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void TestCompositorFrameSink::RequestCopyOfOutput( | 77 void TestCompositorFrameSink::RequestCopyOfOutput( |
| 78 std::unique_ptr<CopyOutputRequest> request) { | 78 std::unique_ptr<CopyOutputRequest> request) { |
| 79 copy_requests_.push_back(std::move(request)); | 79 copy_requests_.push_back(std::move(request)); |
| 80 } | 80 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 | 167 |
| 168 void TestCompositorFrameSink::ForceReclaimResources() { | 168 void TestCompositorFrameSink::ForceReclaimResources() { |
| 169 if (capabilities_.can_force_reclaim_resources && | 169 if (capabilities_.can_force_reclaim_resources && |
| 170 !delegated_surface_id_.is_null()) { | 170 !delegated_surface_id_.is_null()) { |
| 171 surface_factory_->SubmitCompositorFrame(delegated_surface_id_, | 171 surface_factory_->SubmitCompositorFrame(delegated_surface_id_, |
| 172 CompositorFrame(), | 172 CompositorFrame(), |
| 173 SurfaceFactory::DrawCallback()); | 173 SurfaceFactory::DrawCallback()); |
| 174 } | 174 } |
| 175 } | 175 } |
| 176 | 176 |
| 177 void TestCompositorFrameSink::BindFramebuffer() { | |
| 178 // This is a delegating output surface, no framebuffer/direct drawing support. | |
| 179 NOTREACHED(); | |
| 180 } | |
| 181 | |
| 182 uint32_t TestCompositorFrameSink::GetFramebufferCopyTextureFormat() { | |
| 183 // This is a delegating output surface, no framebuffer/direct drawing support. | |
| 184 NOTREACHED(); | |
| 185 return 0; | |
| 186 } | |
| 187 | |
| 188 void TestCompositorFrameSink::ReturnResources( | 177 void TestCompositorFrameSink::ReturnResources( |
| 189 const ReturnedResourceArray& resources) { | 178 const ReturnedResourceArray& resources) { |
| 190 client_->ReclaimResources(resources); | 179 client_->ReclaimResources(resources); |
| 191 } | 180 } |
| 192 | 181 |
| 193 void TestCompositorFrameSink::SetBeginFrameSource( | 182 void TestCompositorFrameSink::SetBeginFrameSource( |
| 194 BeginFrameSource* begin_frame_source) { | 183 BeginFrameSource* begin_frame_source) { |
| 195 client_->SetBeginFrameSource(begin_frame_source); | 184 client_->SetBeginFrameSource(begin_frame_source); |
| 196 } | 185 } |
| 197 | 186 |
| 198 void TestCompositorFrameSink::DisplayOutputSurfaceLost() { | 187 void TestCompositorFrameSink::DisplayOutputSurfaceLost() { |
| 199 client_->DidLoseCompositorFrameSink(); | 188 client_->DidLoseCompositorFrameSink(); |
| 200 } | 189 } |
| 201 | 190 |
| 202 void TestCompositorFrameSink::DisplayWillDrawAndSwap( | 191 void TestCompositorFrameSink::DisplayWillDrawAndSwap( |
| 203 bool will_draw_and_swap, | 192 bool will_draw_and_swap, |
| 204 const RenderPassList& render_passes) { | 193 const RenderPassList& render_passes) { |
| 205 if (test_client_) | 194 if (test_client_) |
| 206 test_client_->DisplayWillDrawAndSwap(will_draw_and_swap, render_passes); | 195 test_client_->DisplayWillDrawAndSwap(will_draw_and_swap, render_passes); |
| 207 } | 196 } |
| 208 | 197 |
| 209 void TestCompositorFrameSink::DisplayDidDrawAndSwap() { | 198 void TestCompositorFrameSink::DisplayDidDrawAndSwap() { |
| 210 if (test_client_) | 199 if (test_client_) |
| 211 test_client_->DisplayDidDrawAndSwap(); | 200 test_client_->DisplayDidDrawAndSwap(); |
| 212 } | 201 } |
| 213 | 202 |
| 214 } // namespace cc | 203 } // namespace cc |
| OLD | NEW |