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

Side by Side Diff: cc/surfaces/display.cc

Issue 2443003004: cc: Make OutputSurface::BindToClient pure virtual and not return bool (Closed)
Patch Set: bindtoclient-pure-virtual: rebase Created 4 years, 1 month 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/surfaces/display.h ('k') | cc/surfaces/display_unittest.cc » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/surfaces/display.h" 5 #include "cc/surfaces/display.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 texture_mailbox_deleter_(std::move(texture_mailbox_deleter)) { 46 texture_mailbox_deleter_(std::move(texture_mailbox_deleter)) {
47 DCHECK(output_surface_); 47 DCHECK(output_surface_);
48 DCHECK_EQ(!scheduler_, !begin_frame_source_); 48 DCHECK_EQ(!scheduler_, !begin_frame_source_);
49 if (scheduler_) 49 if (scheduler_)
50 scheduler_->SetClient(this); 50 scheduler_->SetClient(this);
51 } 51 }
52 52
53 Display::~Display() { 53 Display::~Display() {
54 // Only do this if Initialize() happened. 54 // Only do this if Initialize() happened.
55 if (client_) { 55 if (client_) {
56 if (auto* context = output_surface_->context_provider())
57 context->SetLostContextCallback(base::Closure());
56 if (begin_frame_source_) 58 if (begin_frame_source_)
57 surface_manager_->UnregisterBeginFrameSource(begin_frame_source_.get()); 59 surface_manager_->UnregisterBeginFrameSource(begin_frame_source_.get());
58 surface_manager_->RemoveObserver(this); 60 surface_manager_->RemoveObserver(this);
59 } 61 }
60 if (aggregator_) { 62 if (aggregator_) {
61 for (const auto& id_entry : aggregator_->previous_contained_surfaces()) { 63 for (const auto& id_entry : aggregator_->previous_contained_surfaces()) {
62 Surface* surface = surface_manager_->GetSurfaceForId(id_entry.first); 64 Surface* surface = surface_manager_->GetSurfaceForId(id_entry.first);
63 if (surface) 65 if (surface)
64 surface->RunDrawCallbacks(); 66 surface->RunDrawCallbacks();
65 } 67 }
(...skipping 11 matching lines...) Expand all
77 79
78 surface_manager_->AddObserver(this); 80 surface_manager_->AddObserver(this);
79 81
80 // This must be done in Initialize() so that the caller can delay this until 82 // This must be done in Initialize() so that the caller can delay this until
81 // they are ready to receive a BeginFrameSource. 83 // they are ready to receive a BeginFrameSource.
82 if (begin_frame_source_) { 84 if (begin_frame_source_) {
83 surface_manager_->RegisterBeginFrameSource(begin_frame_source_.get(), 85 surface_manager_->RegisterBeginFrameSource(begin_frame_source_.get(),
84 frame_sink_id_); 86 frame_sink_id_);
85 } 87 }
86 88
87 bool ok = output_surface_->BindToClient(this); 89 output_surface_->BindToClient(this);
88 // The context given to the Display's OutputSurface should already be
89 // initialized, so Bind can not fail.
90 DCHECK(ok);
91 InitializeRenderer(); 90 InitializeRenderer();
91
92 if (auto* context = output_surface_->context_provider()) {
93 // This depends on assumptions that Display::Initialize will happen
94 // on the same callstack as the ContextProvider being created/initialized
95 // or else it could miss a callback before setting this.
96 context->SetLostContextCallback(base::Bind(
97 &Display::DidLoseContextProvider,
98 // Unretained is safe since the callback is unset in this class'
99 // destructor and is never posted.
100 base::Unretained(this)));
101 }
92 } 102 }
93 103
94 void Display::SetSurfaceId(const SurfaceId& id, float device_scale_factor) { 104 void Display::SetSurfaceId(const SurfaceId& id, float device_scale_factor) {
95 DCHECK(id.frame_sink_id() == frame_sink_id_); 105 DCHECK(id.frame_sink_id() == frame_sink_id_);
96 if (current_surface_id_ == id && device_scale_factor_ == device_scale_factor) 106 if (current_surface_id_ == id && device_scale_factor_ == device_scale_factor)
97 return; 107 return;
98 108
99 TRACE_EVENT0("cc", "Display::SetSurfaceId"); 109 TRACE_EVENT0("cc", "Display::SetSurfaceId");
100 current_surface_id_ = id; 110 current_surface_id_ = id;
101 device_scale_factor_ = device_scale_factor; 111 device_scale_factor_ = device_scale_factor;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 205
196 // TODO(jbauman): Outputting an incomplete quad list doesn't work when using 206 // TODO(jbauman): Outputting an incomplete quad list doesn't work when using
197 // overlays. 207 // overlays.
198 bool output_partial_list = renderer_->use_partial_swap() && 208 bool output_partial_list = renderer_->use_partial_swap() &&
199 !output_surface_->GetOverlayCandidateValidator(); 209 !output_surface_->GetOverlayCandidateValidator();
200 aggregator_.reset(new SurfaceAggregator( 210 aggregator_.reset(new SurfaceAggregator(
201 surface_manager_, resource_provider_.get(), output_partial_list)); 211 surface_manager_, resource_provider_.get(), output_partial_list));
202 aggregator_->set_output_is_secure(output_is_secure_); 212 aggregator_->set_output_is_secure(output_is_secure_);
203 } 213 }
204 214
205 void Display::DidLoseOutputSurface() {
206 if (scheduler_)
207 scheduler_->OutputSurfaceLost();
208 // WARNING: The client may delete the Display in this method call. Do not
209 // make any additional references to members after this call.
210 client_->DisplayOutputSurfaceLost();
211 }
212
213 void Display::UpdateRootSurfaceResourcesLocked() { 215 void Display::UpdateRootSurfaceResourcesLocked() {
214 Surface* surface = surface_manager_->GetSurfaceForId(current_surface_id_); 216 Surface* surface = surface_manager_->GetSurfaceForId(current_surface_id_);
215 bool root_surface_resources_locked = 217 bool root_surface_resources_locked =
216 !surface || !surface->GetEligibleFrame().delegated_frame_data; 218 !surface || !surface->GetEligibleFrame().delegated_frame_data;
217 if (scheduler_) 219 if (scheduler_)
218 scheduler_->SetRootSurfaceResourcesLocked(root_surface_resources_locked); 220 scheduler_->SetRootSurfaceResourcesLocked(root_surface_resources_locked);
219 } 221 }
220 222
223 void Display::DidLoseContextProvider() {
224 if (scheduler_)
225 scheduler_->OutputSurfaceLost();
226 // WARNING: The client may delete the Display in this method call. Do not
227 // make any additional references to members after this call.
228 client_->DisplayOutputSurfaceLost();
229 }
230
221 bool Display::DrawAndSwap() { 231 bool Display::DrawAndSwap() {
222 TRACE_EVENT0("cc", "Display::DrawAndSwap"); 232 TRACE_EVENT0("cc", "Display::DrawAndSwap");
223 233
224 if (current_surface_id_.is_null()) { 234 if (current_surface_id_.is_null()) {
225 TRACE_EVENT_INSTANT0("cc", "No root surface.", TRACE_EVENT_SCOPE_THREAD); 235 TRACE_EVENT_INSTANT0("cc", "No root surface.", TRACE_EVENT_SCOPE_THREAD);
226 return false; 236 return false;
227 } 237 }
228 238
229 if (!output_surface_) { 239 if (!output_surface_) {
230 TRACE_EVENT_INSTANT0("cc", "No output surface", TRACE_EVENT_SCOPE_THREAD); 240 TRACE_EVENT_INSTANT0("cc", "No output surface", TRACE_EVENT_SCOPE_THREAD);
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 const SurfaceId& Display::CurrentSurfaceId() { 398 const SurfaceId& Display::CurrentSurfaceId() {
389 return current_surface_id_; 399 return current_surface_id_;
390 } 400 }
391 401
392 void Display::ForceImmediateDrawAndSwapIfPossible() { 402 void Display::ForceImmediateDrawAndSwapIfPossible() {
393 if (scheduler_) 403 if (scheduler_)
394 scheduler_->ForceImmediateSwapIfPossible(); 404 scheduler_->ForceImmediateSwapIfPossible();
395 } 405 }
396 406
397 } // namespace cc 407 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/display.h ('k') | cc/surfaces/display_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698