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

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

Issue 2387333003: cc: Set sync token on resource even if context is lost. (Closed)
Patch Set: danakj's review 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
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 17 matching lines...) Expand all
28 base::SingleThreadTaskRunner* task_runner, 28 base::SingleThreadTaskRunner* task_runner,
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(frame_sink_id_)), 35 surface_id_allocator_(new SurfaceIdAllocator(frame_sink_id_)),
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_(
39 display_output_surface->context_provider() == context_provider()),
38 weak_ptrs_(this) { 40 weak_ptrs_(this) {
39 std::unique_ptr<SyntheticBeginFrameSource> begin_frame_source; 41 std::unique_ptr<SyntheticBeginFrameSource> begin_frame_source;
40 std::unique_ptr<DisplayScheduler> scheduler; 42 std::unique_ptr<DisplayScheduler> scheduler;
41 if (!synchronous_composite) { 43 if (!synchronous_composite) {
42 if (renderer_settings.disable_display_vsync) { 44 if (renderer_settings.disable_display_vsync) {
43 begin_frame_source.reset(new BackToBackBeginFrameSource( 45 begin_frame_source.reset(new BackToBackBeginFrameSource(
44 base::MakeUnique<DelayBasedTimeSource>(task_runner))); 46 base::MakeUnique<DelayBasedTimeSource>(task_runner)));
45 } else { 47 } else {
46 begin_frame_source.reset(new DelayBasedBeginFrameSource( 48 begin_frame_source.reset(new DelayBasedBeginFrameSource(
47 base::MakeUnique<DelayBasedTimeSource>(task_runner))); 49 base::MakeUnique<DelayBasedTimeSource>(task_runner)));
48 begin_frame_source->SetAuthoritativeVSyncInterval( 50 begin_frame_source->SetAuthoritativeVSyncInterval(
49 base::TimeDelta::FromMilliseconds(1000.f / 51 base::TimeDelta::FromMilliseconds(1000.f /
50 renderer_settings.refresh_rate)); 52 renderer_settings.refresh_rate));
51 } 53 }
52 scheduler.reset(new DisplayScheduler( 54 scheduler.reset(new DisplayScheduler(
53 begin_frame_source.get(), task_runner, 55 begin_frame_source.get(), task_runner,
54 display_output_surface->capabilities().max_frames_pending)); 56 display_output_surface->capabilities().max_frames_pending));
55 } 57 }
56 const bool context_shared_with_compositor =
57 display_output_surface->context_provider() == context_provider();
58 display_.reset( 58 display_.reset(
59 new Display(shared_bitmap_manager, gpu_memory_buffer_manager, 59 new Display(shared_bitmap_manager, gpu_memory_buffer_manager,
60 renderer_settings, std::move(begin_frame_source), 60 renderer_settings, std::move(begin_frame_source),
61 std::move(display_output_surface), std::move(scheduler), 61 std::move(display_output_surface), std::move(scheduler),
62 base::MakeUnique<TextureMailboxDeleter>(task_runner))); 62 base::MakeUnique<TextureMailboxDeleter>(task_runner)));
63 63
64 // Since this CompositorFrameSink and the Display are tightly coupled and in 64 // Since this CompositorFrameSink and the Display are tightly coupled and in
65 // the same process/thread, the LayerTreeHostImpl can reclaim resources from 65 // the same process/thread, the LayerTreeHostImpl can reclaim resources from
66 // the Display. But we allow tests to disable this to mimic an out-of-process 66 // the Display. But we allow tests to disable this to mimic an out-of-process
67 // Display. 67 // Display.
68 capabilities_.can_force_reclaim_resources = !force_disable_reclaim_resources; 68 capabilities_.can_force_reclaim_resources = !force_disable_reclaim_resources;
69 capabilities_.delegated_sync_points_required = 69 // Always use sync tokens so that code paths in resource provider that deal
70 !context_shared_with_compositor; 70 // with sync tokens are tested.
71 capabilities_.delegated_sync_points_required = true;
71 } 72 }
72 73
73 TestCompositorFrameSink::~TestCompositorFrameSink() { 74 TestCompositorFrameSink::~TestCompositorFrameSink() {
74 DCHECK(copy_requests_.empty()); 75 DCHECK(copy_requests_.empty());
75 } 76 }
76 77
77 void TestCompositorFrameSink::RequestCopyOfOutput( 78 void TestCompositorFrameSink::RequestCopyOfOutput(
78 std::unique_ptr<CopyOutputRequest> request) { 79 std::unique_ptr<CopyOutputRequest> request) {
79 copy_requests_.push_back(std::move(request)); 80 copy_requests_.push_back(std::move(request));
80 } 81 }
81 82
82 bool TestCompositorFrameSink::BindToClient(CompositorFrameSinkClient* client) { 83 bool TestCompositorFrameSink::BindToClient(CompositorFrameSinkClient* client) {
83 if (!CompositorFrameSink::BindToClient(client)) 84 if (!CompositorFrameSink::BindToClient(client))
84 return false; 85 return false;
85 86
86 // We want the Display's OutputSurface to hear about lost context, and since 87 // We want the Display's OutputSurface to hear about lost context, and when
87 // this shares a context with it (when delegated_sync_points_required is 88 // this shares a context with it we should not be listening for lost context
88 // false), we should not be listening for lost context callbacks on the 89 // callbacks on the context here.
89 // context here. 90 if (display_context_shared_with_compositor_ && context_provider())
90 if (!capabilities_.delegated_sync_points_required && context_provider())
91 context_provider()->SetLostContextCallback(base::Closure()); 91 context_provider()->SetLostContextCallback(base::Closure());
92 92
93 surface_manager_->RegisterFrameSinkId(frame_sink_id_); 93 surface_manager_->RegisterFrameSinkId(frame_sink_id_);
94 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this); 94 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this);
95 display_->Initialize(this, surface_manager_.get(), frame_sink_id_); 95 display_->Initialize(this, surface_manager_.get(), frame_sink_id_);
96 display_->renderer_for_testing()->SetEnlargePassTextureAmountForTesting( 96 display_->renderer_for_testing()->SetEnlargePassTextureAmountForTesting(
97 enlarge_pass_texture_amount_); 97 enlarge_pass_texture_amount_);
98 display_->SetVisible(true); 98 display_->SetVisible(true);
99 bound_ = true; 99 bound_ = true;
100 return true; 100 return true;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 if (test_client_) 190 if (test_client_)
191 test_client_->DisplayWillDrawAndSwap(will_draw_and_swap, render_passes); 191 test_client_->DisplayWillDrawAndSwap(will_draw_and_swap, render_passes);
192 } 192 }
193 193
194 void TestCompositorFrameSink::DisplayDidDrawAndSwap() { 194 void TestCompositorFrameSink::DisplayDidDrawAndSwap() {
195 if (test_client_) 195 if (test_client_)
196 test_client_->DisplayDidDrawAndSwap(); 196 test_client_->DisplayDidDrawAndSwap();
197 } 197 }
198 198
199 } // namespace cc 199 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698