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

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: windows-pixeltests-default-renderer-settings 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
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 begin_frame_source.reset(new DelayBasedBeginFrameSource(
39 base::MakeUnique<DelayBasedTimeSource>(task_runner))); 40 base::MakeUnique<DelayBasedTimeSource>(task_runner)));
41 begin_frame_source->SetAuthoritativeVSyncInterval(
42 base::TimeDelta::FromMilliseconds(1000.f /
43 renderer_settings.refresh_rate));
40 scheduler.reset(new DisplayScheduler( 44 scheduler.reset(new DisplayScheduler(
41 begin_frame_source.get(), task_runner, 45 begin_frame_source.get(), task_runner,
42 display_output_surface->capabilities().max_frames_pending)); 46 display_output_surface->capabilities().max_frames_pending));
43 } 47 }
44 const bool context_shared_with_compositor = 48 const bool context_shared_with_compositor =
45 display_output_surface->context_provider() == context_provider(); 49 display_output_surface->context_provider() == context_provider();
46 display_.reset( 50 display_.reset(
47 new Display(shared_bitmap_manager, gpu_memory_buffer_manager, 51 new Display(shared_bitmap_manager, gpu_memory_buffer_manager,
48 renderer_settings, std::move(begin_frame_source), 52 renderer_settings, std::move(begin_frame_source),
49 std::move(display_output_surface), std::move(scheduler), 53 std::move(display_output_surface), std::move(scheduler),
50 base::MakeUnique<TextureMailboxDeleter>(task_runner))); 54 base::MakeUnique<TextureMailboxDeleter>(task_runner)));
51 55
52 capabilities_.delegated_rendering = true; 56 capabilities_.delegated_rendering = true;
53 // Since this OutputSurface and the Display are tightly coupled and in the 57 // Since this OutputSurface and the Display are tightly coupled and in the
54 // same process/thread, the LayerTreeHostImpl can reclaim resources from 58 // same process/thread, the LayerTreeHostImpl can reclaim resources from
55 // the Display. 59 // the Display. But we allow tests to disable this to mimic an out-of-process
56 capabilities_.can_force_reclaim_resources = true; 60 // Display.
61 capabilities_.can_force_reclaim_resources = !force_disable_reclaim_resources;
57 capabilities_.delegated_sync_points_required = 62 capabilities_.delegated_sync_points_required =
58 !context_shared_with_compositor; 63 !context_shared_with_compositor;
59 } 64 }
60 65
61 TestDelegatingOutputSurface::~TestDelegatingOutputSurface() { 66 TestDelegatingOutputSurface::~TestDelegatingOutputSurface() {
62 DCHECK(copy_requests_.empty()); 67 DCHECK(copy_requests_.empty());
63 } 68 }
64 69
65 void TestDelegatingOutputSurface::RequestCopyOfOutput( 70 void TestDelegatingOutputSurface::RequestCopyOfOutput(
66 std::unique_ptr<CopyOutputRequest> request) { 71 std::unique_ptr<CopyOutputRequest> request) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } 105 }
101 display_ = nullptr; 106 display_ = nullptr;
102 surface_factory_ = nullptr; 107 surface_factory_ = nullptr;
103 surface_id_allocator_ = nullptr; 108 surface_id_allocator_ = nullptr;
104 surface_manager_ = nullptr; 109 surface_manager_ = nullptr;
105 weak_ptrs_.InvalidateWeakPtrs(); 110 weak_ptrs_.InvalidateWeakPtrs();
106 OutputSurface::DetachFromClient(); 111 OutputSurface::DetachFromClient();
107 } 112 }
108 113
109 void TestDelegatingOutputSurface::SwapBuffers(CompositorFrame frame) { 114 void TestDelegatingOutputSurface::SwapBuffers(CompositorFrame frame) {
115 if (test_client_)
116 test_client_->DisplayReceivedCompositorFrame(frame);
117
110 if (delegated_surface_id_.is_null()) { 118 if (delegated_surface_id_.is_null()) {
111 delegated_surface_id_ = surface_id_allocator_->GenerateId(); 119 delegated_surface_id_ = surface_id_allocator_->GenerateId();
112 surface_factory_->Create(delegated_surface_id_); 120 surface_factory_->Create(delegated_surface_id_);
113 } 121 }
114 display_->SetSurfaceId(delegated_surface_id_, 122 display_->SetSurfaceId(delegated_surface_id_,
115 frame.metadata.device_scale_factor); 123 frame.metadata.device_scale_factor);
116 124
117 gfx::Size frame_size = 125 gfx::Size frame_size =
118 frame.delegated_frame_data->render_pass_list.back()->output_rect.size(); 126 frame.delegated_frame_data->render_pass_list.back()->output_rect.size();
119 display_->Resize(frame_size); 127 display_->Resize(frame_size);
120 128
121 bool synchronous = !display_->has_scheduler(); 129 bool synchronous = !display_->has_scheduler();
122 130
123 surface_factory_->SubmitCompositorFrame( 131 surface_factory_->SubmitCompositorFrame(
124 delegated_surface_id_, std::move(frame), 132 delegated_surface_id_, std::move(frame),
125 base::Bind(&TestDelegatingOutputSurface::DrawCallback, 133 base::Bind(&TestDelegatingOutputSurface::DidDrawCallback,
126 weak_ptrs_.GetWeakPtr(), synchronous)); 134 weak_ptrs_.GetWeakPtr(), synchronous));
127 135
128 for (std::unique_ptr<CopyOutputRequest>& copy_request : copy_requests_) 136 for (std::unique_ptr<CopyOutputRequest>& copy_request : copy_requests_)
129 surface_factory_->RequestCopyOfSurface(delegated_surface_id_, 137 surface_factory_->RequestCopyOfSurface(delegated_surface_id_,
130 std::move(copy_request)); 138 std::move(copy_request));
131 copy_requests_.clear(); 139 copy_requests_.clear();
132 140
133 if (!display_->has_scheduler()) 141 if (synchronous)
134 display_->DrawAndSwap(); 142 display_->DrawAndSwap();
135 } 143 }
136 144
137 void TestDelegatingOutputSurface::DrawCallback(bool synchronous) { 145 void TestDelegatingOutputSurface::DidDrawCallback(bool synchronous) {
138 // This is the frame ack to unthrottle the next frame, not actually a notice 146 // This is the frame ack to unthrottle the next frame, not actually a notice
139 // that drawing is done. 147 // that drawing is done.
140 if (synchronous) { 148 if (synchronous) {
141 // For synchronous draws, this must be posted to a new stack because we are 149 // 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 150 // still the original call to SwapBuffers, and we want to leave that before
143 // saying that it is done. 151 // saying that it is done.
144 OutputSurface::PostSwapBuffersComplete(); 152 OutputSurface::PostSwapBuffersComplete();
145 } else { 153 } else {
146 client_->DidSwapBuffersComplete(); 154 client_->DidSwapBuffersComplete();
147 } 155 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 187
180 void TestDelegatingOutputSurface::DisplayOutputSurfaceLost() { 188 void TestDelegatingOutputSurface::DisplayOutputSurfaceLost() {
181 DidLoseOutputSurface(); 189 DidLoseOutputSurface();
182 } 190 }
183 191
184 void TestDelegatingOutputSurface::DisplaySetMemoryPolicy( 192 void TestDelegatingOutputSurface::DisplaySetMemoryPolicy(
185 const ManagedMemoryPolicy& policy) { 193 const ManagedMemoryPolicy& policy) {
186 SetMemoryPolicy(policy); 194 SetMemoryPolicy(policy);
187 } 195 }
188 196
197 void TestDelegatingOutputSurface::DisplayWillDrawAndSwap(
198 bool will_draw_and_swap,
199 const RenderPassList& render_passes) {
200 if (test_client_)
201 test_client_->DisplayWillDrawAndSwap(will_draw_and_swap, render_passes);
202 }
203
204 void TestDelegatingOutputSurface::DisplayDidDrawAndSwap() {
205 if (test_client_)
206 test_client_->DisplayDidDrawAndSwap();
207 }
208
189 } // namespace cc 209 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698