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

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: test 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 begin_frame_source.reset(new DelayBasedBeginFrameSource( 46 begin_frame_source.reset(new DelayBasedBeginFrameSource(
47 base::MakeUnique<DelayBasedTimeSource>(task_runner))); 47 base::MakeUnique<DelayBasedTimeSource>(task_runner)));
48 begin_frame_source->SetAuthoritativeVSyncInterval( 48 begin_frame_source->SetAuthoritativeVSyncInterval(
49 base::TimeDelta::FromMilliseconds(1000.f / 49 base::TimeDelta::FromMilliseconds(1000.f /
50 renderer_settings.refresh_rate)); 50 renderer_settings.refresh_rate));
51 } 51 }
52 scheduler.reset(new DisplayScheduler( 52 scheduler.reset(new DisplayScheduler(
53 begin_frame_source.get(), task_runner, 53 begin_frame_source.get(), task_runner,
54 display_output_surface->capabilities().max_frames_pending)); 54 display_output_surface->capabilities().max_frames_pending));
55 } 55 }
56 const bool context_shared_with_compositor = 56 display_context_shared_with_compositor_ =
57 display_output_surface->context_provider() == context_provider(); 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 capabilities_.delegated_sync_points_required = true;
danakj 2016/10/06 20:50:35 Can you leave a comment explaining why this is bei
sunnyps 2016/10/06 21:31:53 Done.
70 !context_shared_with_compositor;
71 } 70 }
72 71
73 TestCompositorFrameSink::~TestCompositorFrameSink() { 72 TestCompositorFrameSink::~TestCompositorFrameSink() {
74 DCHECK(copy_requests_.empty()); 73 DCHECK(copy_requests_.empty());
75 } 74 }
76 75
77 void TestCompositorFrameSink::RequestCopyOfOutput( 76 void TestCompositorFrameSink::RequestCopyOfOutput(
78 std::unique_ptr<CopyOutputRequest> request) { 77 std::unique_ptr<CopyOutputRequest> request) {
79 copy_requests_.push_back(std::move(request)); 78 copy_requests_.push_back(std::move(request));
80 } 79 }
81 80
82 bool TestCompositorFrameSink::BindToClient(CompositorFrameSinkClient* client) { 81 bool TestCompositorFrameSink::BindToClient(CompositorFrameSinkClient* client) {
83 if (!CompositorFrameSink::BindToClient(client)) 82 if (!CompositorFrameSink::BindToClient(client))
84 return false; 83 return false;
85 84
86 // We want the Display's OutputSurface to hear about lost context, and since 85 // We want the Display's OutputSurface to hear about lost context, and since
danakj 2016/10/06 20:50:35 and when this shares
sunnyps 2016/10/06 21:31:53 Done.
87 // this shares a context with it (when delegated_sync_points_required is 86 // 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 87 // callbacks on the context here.
89 // context here. 88 if (display_context_shared_with_compositor_ && context_provider())
90 if (!capabilities_.delegated_sync_points_required && context_provider())
91 context_provider()->SetLostContextCallback(base::Closure()); 89 context_provider()->SetLostContextCallback(base::Closure());
92 90
93 surface_manager_->RegisterFrameSinkId(frame_sink_id_); 91 surface_manager_->RegisterFrameSinkId(frame_sink_id_);
94 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this); 92 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this);
95 display_->Initialize(this, surface_manager_.get(), frame_sink_id_); 93 display_->Initialize(this, surface_manager_.get(), frame_sink_id_);
96 display_->renderer_for_testing()->SetEnlargePassTextureAmountForTesting( 94 display_->renderer_for_testing()->SetEnlargePassTextureAmountForTesting(
97 enlarge_pass_texture_amount_); 95 enlarge_pass_texture_amount_);
98 display_->SetVisible(true); 96 display_->SetVisible(true);
99 bound_ = true; 97 bound_ = true;
100 return true; 98 return true;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 if (test_client_) 188 if (test_client_)
191 test_client_->DisplayWillDrawAndSwap(will_draw_and_swap, render_passes); 189 test_client_->DisplayWillDrawAndSwap(will_draw_and_swap, render_passes);
192 } 190 }
193 191
194 void TestCompositorFrameSink::DisplayDidDrawAndSwap() { 192 void TestCompositorFrameSink::DisplayDidDrawAndSwap() {
195 if (test_client_) 193 if (test_client_)
196 test_client_->DisplayDidDrawAndSwap(); 194 test_client_->DisplayDidDrawAndSwap();
197 } 195 }
198 196
199 } // namespace cc 197 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698