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

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

Issue 2609253003: Remove ForceReclaimResources (Closed)
Patch Set: cleanup Created 3 years, 11 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_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"
11 #include "cc/output/compositor_frame_sink_client.h" 11 #include "cc/output/compositor_frame_sink_client.h"
12 #include "cc/output/copy_output_request.h" 12 #include "cc/output/copy_output_request.h"
13 #include "cc/output/direct_renderer.h" 13 #include "cc/output/direct_renderer.h"
14 #include "cc/output/output_surface.h" 14 #include "cc/output/output_surface.h"
15 #include "cc/output/texture_mailbox_deleter.h" 15 #include "cc/output/texture_mailbox_deleter.h"
16 16
17 namespace cc { 17 namespace cc {
18 18
19 static constexpr FrameSinkId kCompositorFrameSinkId(1, 1); 19 static constexpr FrameSinkId kCompositorFrameSinkId(1, 1);
20 20
21 TestCompositorFrameSink::TestCompositorFrameSink( 21 TestCompositorFrameSink::TestCompositorFrameSink(
22 scoped_refptr<ContextProvider> compositor_context_provider, 22 scoped_refptr<ContextProvider> compositor_context_provider,
23 scoped_refptr<ContextProvider> worker_context_provider, 23 scoped_refptr<ContextProvider> worker_context_provider,
24 SharedBitmapManager* shared_bitmap_manager, 24 SharedBitmapManager* shared_bitmap_manager,
25 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 25 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
26 const RendererSettings& renderer_settings, 26 const RendererSettings& renderer_settings,
27 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 27 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
28 bool synchronous_composite, 28 bool synchronous_composite)
29 bool force_disable_reclaim_resources)
30 : CompositorFrameSink(std::move(compositor_context_provider), 29 : CompositorFrameSink(std::move(compositor_context_provider),
31 std::move(worker_context_provider), 30 std::move(worker_context_provider),
32 gpu_memory_buffer_manager, 31 gpu_memory_buffer_manager,
33 shared_bitmap_manager), 32 shared_bitmap_manager),
34 synchronous_composite_(synchronous_composite), 33 synchronous_composite_(synchronous_composite),
35 renderer_settings_(renderer_settings), 34 renderer_settings_(renderer_settings),
36 task_runner_(std::move(task_runner)), 35 task_runner_(std::move(task_runner)),
37 frame_sink_id_(kCompositorFrameSinkId), 36 frame_sink_id_(kCompositorFrameSinkId),
38 surface_manager_(new SurfaceManager), 37 surface_manager_(new SurfaceManager),
39 surface_id_allocator_(new SurfaceIdAllocator()), 38 surface_id_allocator_(new SurfaceIdAllocator()),
40 surface_factory_( 39 surface_factory_(
41 new SurfaceFactory(frame_sink_id_, surface_manager_.get(), this)), 40 new SurfaceFactory(frame_sink_id_, surface_manager_.get(), this)),
42 weak_ptr_factory_(this) { 41 weak_ptr_factory_(this) {
43 // Since this CompositorFrameSink and the Display are tightly coupled and in
44 // the same process/thread, the LayerTreeHostImpl can reclaim resources from
45 // the Display. But we allow tests to disable this to mimic an out-of-process
46 // Display.
47 capabilities_.can_force_reclaim_resources = !force_disable_reclaim_resources;
48 // Always use sync tokens so that code paths in resource provider that deal 42 // Always use sync tokens so that code paths in resource provider that deal
49 // with sync tokens are tested. 43 // with sync tokens are tested.
50 capabilities_.delegated_sync_points_required = true; 44 capabilities_.delegated_sync_points_required = true;
51 } 45 }
52 46
53 TestCompositorFrameSink::~TestCompositorFrameSink() { 47 TestCompositorFrameSink::~TestCompositorFrameSink() {
54 DCHECK(copy_requests_.empty()); 48 DCHECK(copy_requests_.empty());
55 } 49 }
56 50
57 void TestCompositorFrameSink::RequestCopyOfOutput( 51 void TestCompositorFrameSink::RequestCopyOfOutput(
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 weak_ptr_factory_.GetWeakPtr())); 158 weak_ptr_factory_.GetWeakPtr()));
165 } 159 }
166 } 160 }
167 161
168 void TestCompositorFrameSink::DidDrawCallback() { 162 void TestCompositorFrameSink::DidDrawCallback() {
169 // This is to unthrottle the next frame, not actually a notice that drawing is 163 // This is to unthrottle the next frame, not actually a notice that drawing is
170 // done. 164 // done.
171 client_->DidReceiveCompositorFrameAck(); 165 client_->DidReceiveCompositorFrameAck();
172 } 166 }
173 167
174 void TestCompositorFrameSink::ForceReclaimResources() {
175 if (capabilities_.can_force_reclaim_resources &&
176 delegated_local_frame_id_.is_valid()) {
177 surface_factory_->ClearSurface();
178 }
179 }
180
181 void TestCompositorFrameSink::ReturnResources( 168 void TestCompositorFrameSink::ReturnResources(
182 const ReturnedResourceArray& resources) { 169 const ReturnedResourceArray& resources) {
183 client_->ReclaimResources(resources); 170 client_->ReclaimResources(resources);
184 } 171 }
185 172
186 void TestCompositorFrameSink::SetBeginFrameSource( 173 void TestCompositorFrameSink::SetBeginFrameSource(
187 BeginFrameSource* begin_frame_source) { 174 BeginFrameSource* begin_frame_source) {
188 client_->SetBeginFrameSource(begin_frame_source); 175 client_->SetBeginFrameSource(begin_frame_source);
189 } 176 }
190 177
191 void TestCompositorFrameSink::DisplayOutputSurfaceLost() { 178 void TestCompositorFrameSink::DisplayOutputSurfaceLost() {
192 client_->DidLoseCompositorFrameSink(); 179 client_->DidLoseCompositorFrameSink();
193 } 180 }
194 181
195 void TestCompositorFrameSink::DisplayWillDrawAndSwap( 182 void TestCompositorFrameSink::DisplayWillDrawAndSwap(
196 bool will_draw_and_swap, 183 bool will_draw_and_swap,
197 const RenderPassList& render_passes) { 184 const RenderPassList& render_passes) {
198 test_client_->DisplayWillDrawAndSwap(will_draw_and_swap, render_passes); 185 test_client_->DisplayWillDrawAndSwap(will_draw_and_swap, render_passes);
199 } 186 }
200 187
201 void TestCompositorFrameSink::DisplayDidDrawAndSwap() { 188 void TestCompositorFrameSink::DisplayDidDrawAndSwap() {
202 test_client_->DisplayDidDrawAndSwap(); 189 test_client_->DisplayDidDrawAndSwap();
190 if (force_reclaim_resources_after_swap_ &&
191 delegated_local_frame_id_.is_valid()) {
192 surface_factory_->ClearSurface();
danakj 2017/01/04 18:43:38 Oh I lied, this is now a test-only method. Hm. Wou
ericrk 2017/01/11 19:17:54 Removed this and added an extra dummy swap in the
193 }
203 } 194 }
204 195
205 } // namespace cc 196 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698