| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 base::MakeUnique<DelayBasedTimeSource>(task_runner_.get()))); | 79 base::MakeUnique<DelayBasedTimeSource>(task_runner_.get()))); |
| 80 begin_frame_source->SetAuthoritativeVSyncInterval( | 80 begin_frame_source->SetAuthoritativeVSyncInterval( |
| 81 base::TimeDelta::FromMilliseconds(1000.f / | 81 base::TimeDelta::FromMilliseconds(1000.f / |
| 82 renderer_settings_.refresh_rate)); | 82 renderer_settings_.refresh_rate)); |
| 83 } | 83 } |
| 84 scheduler.reset(new DisplayScheduler( | 84 scheduler.reset(new DisplayScheduler( |
| 85 begin_frame_source.get(), task_runner_.get(), | 85 begin_frame_source.get(), task_runner_.get(), |
| 86 display_output_surface->capabilities().max_frames_pending)); | 86 display_output_surface->capabilities().max_frames_pending)); |
| 87 } | 87 } |
| 88 | 88 |
| 89 display_.reset( | 89 display_.reset(new Display( |
| 90 new Display(shared_bitmap_manager(), gpu_memory_buffer_manager(), | 90 shared_bitmap_manager(), gpu_memory_buffer_manager(), renderer_settings_, |
| 91 renderer_settings_, std::move(begin_frame_source), | 91 frame_sink_id_, std::move(begin_frame_source), |
| 92 std::move(display_output_surface), std::move(scheduler), | 92 std::move(display_output_surface), std::move(scheduler), |
| 93 base::MakeUnique<TextureMailboxDeleter>(task_runner_.get()))); | 93 base::MakeUnique<TextureMailboxDeleter>(task_runner_.get()))); |
| 94 | 94 |
| 95 // We want the Display's OutputSurface to hear about lost context, and when | 95 // We want the Display's OutputSurface to hear about lost context, and when |
| 96 // this shares a context with it we should not be listening for lost context | 96 // this shares a context with it we should not be listening for lost context |
| 97 // callbacks on the context here. | 97 // callbacks on the context here. |
| 98 if (display_context_shared_with_compositor && context_provider()) | 98 if (display_context_shared_with_compositor && context_provider()) |
| 99 context_provider()->SetLostContextCallback(base::Closure()); | 99 context_provider()->SetLostContextCallback(base::Closure()); |
| 100 | 100 |
| 101 surface_manager_->RegisterFrameSinkId(frame_sink_id_); | 101 surface_manager_->RegisterFrameSinkId(frame_sink_id_); |
| 102 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this); | 102 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this); |
| 103 display_->Initialize(this, surface_manager_.get(), frame_sink_id_); | 103 display_->Initialize(this, surface_manager_.get()); |
| 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_) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 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_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_->SetSurfaceId(SurfaceId(frame_sink_id_, 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 = 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(); |
| 142 | 142 |
| 143 SurfaceFactory::DrawCallback draw_callback; | 143 SurfaceFactory::DrawCallback draw_callback; |
| 144 if (!synchronous) { | 144 if (!synchronous) { |
| 145 // 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 |
| 146 // 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 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |