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

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

Issue 2193293004: cc: Make LayerTreeTests use a DelegatingRenderer and Display. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: display-layertreetest: withperftestsfix Created 4 years, 4 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_delegating_output_surface.h ('k') | cc/test/test_hooks.h » ('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_delegating_output_surface.h" 5 #include "cc/test/test_delegating_output_surface.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"
11 #include "cc/output/copy_output_request.h" 11 #include "cc/output/copy_output_request.h"
12 #include "cc/output/texture_mailbox_deleter.h" 12 #include "cc/output/texture_mailbox_deleter.h"
13 #include "cc/test/begin_frame_args_test.h" 13 #include "cc/test/begin_frame_args_test.h"
14 14
15 static constexpr uint32_t kCompositorClientId = 1; 15 static constexpr uint32_t kCompositorClientId = 1;
16 16
17 namespace cc { 17 namespace cc {
18 18
19 TestDelegatingOutputSurface::TestDelegatingOutputSurface( 19 TestDelegatingOutputSurface::TestDelegatingOutputSurface(
20 scoped_refptr<ContextProvider> compositor_context_provider, 20 scoped_refptr<ContextProvider> compositor_context_provider,
21 scoped_refptr<ContextProvider> worker_context_provider, 21 scoped_refptr<ContextProvider> worker_context_provider,
22 std::unique_ptr<OutputSurface> display_output_surface, 22 std::unique_ptr<OutputSurface> display_output_surface,
23 SharedBitmapManager* shared_bitmap_manager, 23 SharedBitmapManager* shared_bitmap_manager,
24 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 24 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
25 const RendererSettings& renderer_settings, 25 const RendererSettings& renderer_settings,
26 base::SingleThreadTaskRunner* task_runner, 26 base::SingleThreadTaskRunner* task_runner,
27 bool synchronous_composite) 27 bool synchronous_composite,
28 bool force_disable_reclaim_resources)
28 : OutputSurface(std::move(compositor_context_provider), 29 : OutputSurface(std::move(compositor_context_provider),
29 std::move(worker_context_provider), 30 std::move(worker_context_provider),
30 nullptr), 31 nullptr),
31 surface_manager_(new SurfaceManager), 32 surface_manager_(new SurfaceManager),
32 surface_id_allocator_(new SurfaceIdAllocator(kCompositorClientId)), 33 surface_id_allocator_(new SurfaceIdAllocator(kCompositorClientId)),
33 surface_factory_(new SurfaceFactory(surface_manager_.get(), this)), 34 surface_factory_(new SurfaceFactory(surface_manager_.get(), this)),
34 weak_ptrs_(this) { 35 weak_ptrs_(this) {
35 std::unique_ptr<SyntheticBeginFrameSource> begin_frame_source; 36 std::unique_ptr<SyntheticBeginFrameSource> begin_frame_source;
36 std::unique_ptr<DisplayScheduler> scheduler; 37 std::unique_ptr<DisplayScheduler> scheduler;
37 if (!synchronous_composite) { 38 if (!synchronous_composite) {
38 begin_frame_source.reset(new DelayBasedBeginFrameSource( 39 if (renderer_settings.disable_display_vsync) {
39 base::MakeUnique<DelayBasedTimeSource>(task_runner))); 40 begin_frame_source.reset(new BackToBackBeginFrameSource(
41 base::MakeUnique<DelayBasedTimeSource>(task_runner)));
42 } else {
43 begin_frame_source.reset(new DelayBasedBeginFrameSource(
44 base::MakeUnique<DelayBasedTimeSource>(task_runner)));
45 begin_frame_source->SetAuthoritativeVSyncInterval(
46 base::TimeDelta::FromMilliseconds(1000.f /
47 renderer_settings.refresh_rate));
48 }
40 scheduler.reset(new DisplayScheduler( 49 scheduler.reset(new DisplayScheduler(
41 begin_frame_source.get(), task_runner, 50 begin_frame_source.get(), task_runner,
42 display_output_surface->capabilities().max_frames_pending)); 51 display_output_surface->capabilities().max_frames_pending));
43 } 52 }
44 const bool context_shared_with_compositor = 53 const bool context_shared_with_compositor =
45 display_output_surface->context_provider() == context_provider(); 54 display_output_surface->context_provider() == context_provider();
46 display_.reset( 55 display_.reset(
47 new Display(shared_bitmap_manager, gpu_memory_buffer_manager, 56 new Display(shared_bitmap_manager, gpu_memory_buffer_manager,
48 renderer_settings, std::move(begin_frame_source), 57 renderer_settings, std::move(begin_frame_source),
49 std::move(display_output_surface), std::move(scheduler), 58 std::move(display_output_surface), std::move(scheduler),
50 base::MakeUnique<TextureMailboxDeleter>(task_runner))); 59 base::MakeUnique<TextureMailboxDeleter>(task_runner)));
51 60
52 capabilities_.delegated_rendering = true; 61 capabilities_.delegated_rendering = true;
53 // Since this OutputSurface and the Display are tightly coupled and in the 62 // Since this OutputSurface and the Display are tightly coupled and in the
54 // same process/thread, the LayerTreeHostImpl can reclaim resources from 63 // same process/thread, the LayerTreeHostImpl can reclaim resources from
55 // the Display. 64 // the Display. But we allow tests to disable this to mimic an out-of-process
56 capabilities_.can_force_reclaim_resources = true; 65 // Display.
66 capabilities_.can_force_reclaim_resources = !force_disable_reclaim_resources;
57 capabilities_.delegated_sync_points_required = 67 capabilities_.delegated_sync_points_required =
58 !context_shared_with_compositor; 68 !context_shared_with_compositor;
59 } 69 }
60 70
61 TestDelegatingOutputSurface::~TestDelegatingOutputSurface() { 71 TestDelegatingOutputSurface::~TestDelegatingOutputSurface() {
62 DCHECK(copy_requests_.empty()); 72 DCHECK(copy_requests_.empty());
63 } 73 }
64 74
65 void TestDelegatingOutputSurface::RequestCopyOfOutput( 75 void TestDelegatingOutputSurface::RequestCopyOfOutput(
66 std::unique_ptr<CopyOutputRequest> request) { 76 std::unique_ptr<CopyOutputRequest> request) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } 110 }
101 display_ = nullptr; 111 display_ = nullptr;
102 surface_factory_ = nullptr; 112 surface_factory_ = nullptr;
103 surface_id_allocator_ = nullptr; 113 surface_id_allocator_ = nullptr;
104 surface_manager_ = nullptr; 114 surface_manager_ = nullptr;
105 weak_ptrs_.InvalidateWeakPtrs(); 115 weak_ptrs_.InvalidateWeakPtrs();
106 OutputSurface::DetachFromClient(); 116 OutputSurface::DetachFromClient();
107 } 117 }
108 118
109 void TestDelegatingOutputSurface::SwapBuffers(CompositorFrame frame) { 119 void TestDelegatingOutputSurface::SwapBuffers(CompositorFrame frame) {
120 if (test_client_)
121 test_client_->DisplayReceivedCompositorFrame(frame);
122
110 if (delegated_surface_id_.is_null()) { 123 if (delegated_surface_id_.is_null()) {
111 delegated_surface_id_ = surface_id_allocator_->GenerateId(); 124 delegated_surface_id_ = surface_id_allocator_->GenerateId();
112 surface_factory_->Create(delegated_surface_id_); 125 surface_factory_->Create(delegated_surface_id_);
113 } 126 }
114 display_->SetSurfaceId(delegated_surface_id_, 127 display_->SetSurfaceId(delegated_surface_id_,
115 frame.metadata.device_scale_factor); 128 frame.metadata.device_scale_factor);
116 129
117 gfx::Size frame_size = 130 gfx::Size frame_size =
118 frame.delegated_frame_data->render_pass_list.back()->output_rect.size(); 131 frame.delegated_frame_data->render_pass_list.back()->output_rect.size();
119 display_->Resize(frame_size); 132 display_->Resize(frame_size);
120 133
121 bool synchronous = !display_->has_scheduler(); 134 bool synchronous = !display_->has_scheduler();
122 135
123 surface_factory_->SubmitCompositorFrame( 136 surface_factory_->SubmitCompositorFrame(
124 delegated_surface_id_, std::move(frame), 137 delegated_surface_id_, std::move(frame),
125 base::Bind(&TestDelegatingOutputSurface::DrawCallback, 138 base::Bind(&TestDelegatingOutputSurface::DidDrawCallback,
126 weak_ptrs_.GetWeakPtr(), synchronous)); 139 weak_ptrs_.GetWeakPtr(), synchronous));
127 140
128 for (std::unique_ptr<CopyOutputRequest>& copy_request : copy_requests_) 141 for (std::unique_ptr<CopyOutputRequest>& copy_request : copy_requests_)
129 surface_factory_->RequestCopyOfSurface(delegated_surface_id_, 142 surface_factory_->RequestCopyOfSurface(delegated_surface_id_,
130 std::move(copy_request)); 143 std::move(copy_request));
131 copy_requests_.clear(); 144 copy_requests_.clear();
132 145
133 if (!display_->has_scheduler()) 146 if (synchronous)
134 display_->DrawAndSwap(); 147 display_->DrawAndSwap();
135 } 148 }
136 149
137 void TestDelegatingOutputSurface::DrawCallback(bool synchronous) { 150 void TestDelegatingOutputSurface::DidDrawCallback(bool synchronous) {
138 // 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
139 // that drawing is done. 152 // that drawing is done.
140 if (synchronous) { 153 if (synchronous) {
141 // For synchronous draws, this must be posted to a new stack because we are 154 // For synchronous draws, this must be posted to a new stack because we are
142 // still the original call to SwapBuffers, and we want to leave that before 155 // still the original call to SwapBuffers, and we want to leave that before
143 // saying that it is done. 156 // saying that it is done.
144 OutputSurface::PostSwapBuffersComplete(); 157 OutputSurface::PostSwapBuffersComplete();
145 } else { 158 } else {
146 client_->DidSwapBuffersComplete(); 159 client_->DidSwapBuffersComplete();
147 } 160 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 192
180 void TestDelegatingOutputSurface::DisplayOutputSurfaceLost() { 193 void TestDelegatingOutputSurface::DisplayOutputSurfaceLost() {
181 DidLoseOutputSurface(); 194 DidLoseOutputSurface();
182 } 195 }
183 196
184 void TestDelegatingOutputSurface::DisplaySetMemoryPolicy( 197 void TestDelegatingOutputSurface::DisplaySetMemoryPolicy(
185 const ManagedMemoryPolicy& policy) { 198 const ManagedMemoryPolicy& policy) {
186 SetMemoryPolicy(policy); 199 SetMemoryPolicy(policy);
187 } 200 }
188 201
202 void TestDelegatingOutputSurface::DisplayWillDrawAndSwap(
203 bool will_draw_and_swap,
204 const RenderPassList& render_passes) {
205 if (test_client_)
206 test_client_->DisplayWillDrawAndSwap(will_draw_and_swap, render_passes);
207 }
208
209 void TestDelegatingOutputSurface::DisplayDidDrawAndSwap() {
210 if (test_client_)
211 test_client_->DisplayDidDrawAndSwap();
212 }
213
189 } // namespace cc 214 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/test_delegating_output_surface.h ('k') | cc/test/test_hooks.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698