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

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

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