Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(930)

Side by Side Diff: cc/test/test_compositor_frame_sink.cc

Issue 2392113003: Reland of cc: Remove frame queuing from the scheduler. (Closed)
Patch Set: rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/test/test_compositor_frame_sink.h ('k') | cc/trees/proxy_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 18 matching lines...) Expand all
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 frame_sink_id_(kCompositorFrameSinkId), 33 frame_sink_id_(kCompositorFrameSinkId),
34 surface_manager_(new SurfaceManager), 34 surface_manager_(new SurfaceManager),
35 surface_id_allocator_(new SurfaceIdAllocator()), 35 surface_id_allocator_(new SurfaceIdAllocator()),
36 surface_factory_( 36 surface_factory_(
37 new SurfaceFactory(frame_sink_id_, surface_manager_.get(), this)), 37 new SurfaceFactory(frame_sink_id_, surface_manager_.get(), this)),
38 display_context_shared_with_compositor_( 38 display_context_shared_with_compositor_(
39 display_output_surface->context_provider() == context_provider()), 39 display_output_surface->context_provider() == context_provider()) {
40 weak_ptrs_(this) {
41 std::unique_ptr<SyntheticBeginFrameSource> begin_frame_source; 40 std::unique_ptr<SyntheticBeginFrameSource> begin_frame_source;
42 std::unique_ptr<DisplayScheduler> scheduler; 41 std::unique_ptr<DisplayScheduler> scheduler;
43 if (!synchronous_composite) { 42 if (!synchronous_composite) {
44 if (renderer_settings.disable_display_vsync) { 43 if (renderer_settings.disable_display_vsync) {
45 begin_frame_source.reset(new BackToBackBeginFrameSource( 44 begin_frame_source.reset(new BackToBackBeginFrameSource(
46 base::MakeUnique<DelayBasedTimeSource>(task_runner))); 45 base::MakeUnique<DelayBasedTimeSource>(task_runner)));
47 } else { 46 } else {
48 begin_frame_source.reset(new DelayBasedBeginFrameSource( 47 begin_frame_source.reset(new DelayBasedBeginFrameSource(
49 base::MakeUnique<DelayBasedTimeSource>(task_runner))); 48 base::MakeUnique<DelayBasedTimeSource>(task_runner)));
50 begin_frame_source->SetAuthoritativeVSyncInterval( 49 begin_frame_source->SetAuthoritativeVSyncInterval(
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 if (!delegated_local_frame_id_.is_null()) 105 if (!delegated_local_frame_id_.is_null())
107 surface_factory_->Destroy(delegated_local_frame_id_); 106 surface_factory_->Destroy(delegated_local_frame_id_);
108 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_); 107 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_);
109 surface_manager_->InvalidateFrameSinkId(frame_sink_id_); 108 surface_manager_->InvalidateFrameSinkId(frame_sink_id_);
110 bound_ = false; 109 bound_ = false;
111 } 110 }
112 display_ = nullptr; 111 display_ = nullptr;
113 surface_factory_ = nullptr; 112 surface_factory_ = nullptr;
114 surface_id_allocator_ = nullptr; 113 surface_id_allocator_ = nullptr;
115 surface_manager_ = nullptr; 114 surface_manager_ = nullptr;
116 weak_ptrs_.InvalidateWeakPtrs();
117 CompositorFrameSink::DetachFromClient(); 115 CompositorFrameSink::DetachFromClient();
118 } 116 }
119 117
120 void TestCompositorFrameSink::SwapBuffers(CompositorFrame frame) { 118 void TestCompositorFrameSink::SwapBuffers(CompositorFrame frame) {
121 if (test_client_) 119 if (test_client_)
122 test_client_->DisplayReceivedCompositorFrame(frame); 120 test_client_->DisplayReceivedCompositorFrame(frame);
123 121
124 if (delegated_local_frame_id_.is_null()) { 122 if (delegated_local_frame_id_.is_null()) {
125 delegated_local_frame_id_ = surface_id_allocator_->GenerateId(); 123 delegated_local_frame_id_ = surface_id_allocator_->GenerateId();
126 surface_factory_->Create(delegated_local_frame_id_); 124 surface_factory_->Create(delegated_local_frame_id_);
127 } 125 }
128 display_->SetSurfaceId(SurfaceId(frame_sink_id_, delegated_local_frame_id_), 126 display_->SetSurfaceId(SurfaceId(frame_sink_id_, delegated_local_frame_id_),
129 frame.metadata.device_scale_factor); 127 frame.metadata.device_scale_factor);
130 128
131 gfx::Size frame_size = 129 gfx::Size frame_size =
132 frame.delegated_frame_data->render_pass_list.back()->output_rect.size(); 130 frame.delegated_frame_data->render_pass_list.back()->output_rect.size();
133 display_->Resize(frame_size); 131 display_->Resize(frame_size);
134 132
135 bool synchronous = !display_->has_scheduler(); 133 bool synchronous = !display_->has_scheduler();
136 134
137 surface_factory_->SubmitCompositorFrame( 135 surface_factory_->SubmitCompositorFrame(
138 delegated_local_frame_id_, std::move(frame), 136 delegated_local_frame_id_, std::move(frame),
139 base::Bind(&TestCompositorFrameSink::DidDrawCallback, 137 base::Bind(&TestCompositorFrameSink::DidDrawCallback,
140 weak_ptrs_.GetWeakPtr(), synchronous)); 138 base::Unretained(this)));
141 139
142 for (std::unique_ptr<CopyOutputRequest>& copy_request : copy_requests_) { 140 for (std::unique_ptr<CopyOutputRequest>& copy_request : copy_requests_) {
143 surface_factory_->RequestCopyOfSurface(delegated_local_frame_id_, 141 surface_factory_->RequestCopyOfSurface(delegated_local_frame_id_,
144 std::move(copy_request)); 142 std::move(copy_request));
145 } 143 }
146 copy_requests_.clear(); 144 copy_requests_.clear();
147 145
148 if (synchronous) 146 if (synchronous)
149 display_->DrawAndSwap(); 147 display_->DrawAndSwap();
150 } 148 }
151 149
152 void TestCompositorFrameSink::DidDrawCallback(bool synchronous) { 150 void TestCompositorFrameSink::DidDrawCallback() {
153 // This is the frame ack to unthrottle the next frame, not actually a notice 151 // This is the frame ack to unthrottle the next frame, not actually a notice
154 // that drawing is done. 152 // that drawing is done.
155 if (synchronous) { 153 CompositorFrameSink::PostSwapBuffersComplete();
156 // For synchronous draws, this must be posted to a new stack because we are
157 // still the original call to SwapBuffers, and we want to leave that before
158 // saying that it is done.
159 CompositorFrameSink::PostSwapBuffersComplete();
160 } else {
161 client_->DidSwapBuffersComplete();
162 }
163 } 154 }
164 155
165 void TestCompositorFrameSink::ForceReclaimResources() { 156 void TestCompositorFrameSink::ForceReclaimResources() {
166 if (capabilities_.can_force_reclaim_resources && 157 if (capabilities_.can_force_reclaim_resources &&
167 !delegated_local_frame_id_.is_null()) { 158 !delegated_local_frame_id_.is_null()) {
168 surface_factory_->SubmitCompositorFrame(delegated_local_frame_id_, 159 surface_factory_->SubmitCompositorFrame(delegated_local_frame_id_,
169 CompositorFrame(), 160 CompositorFrame(),
170 SurfaceFactory::DrawCallback()); 161 SurfaceFactory::DrawCallback());
171 } 162 }
172 } 163 }
(...skipping 18 matching lines...) Expand all
191 if (test_client_) 182 if (test_client_)
192 test_client_->DisplayWillDrawAndSwap(will_draw_and_swap, render_passes); 183 test_client_->DisplayWillDrawAndSwap(will_draw_and_swap, render_passes);
193 } 184 }
194 185
195 void TestCompositorFrameSink::DisplayDidDrawAndSwap() { 186 void TestCompositorFrameSink::DisplayDidDrawAndSwap() {
196 if (test_client_) 187 if (test_client_)
197 test_client_->DisplayDidDrawAndSwap(); 188 test_client_->DisplayDidDrawAndSwap();
198 } 189 }
199 190
200 } // namespace cc 191 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/test_compositor_frame_sink.h ('k') | cc/trees/proxy_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698