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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/surfaces/display.h ('k') | cc/surfaces/display_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/surfaces/display.cc
diff --git a/cc/surfaces/display.cc b/cc/surfaces/display.cc
index 3550a39efda0071a17fe5a195c511c171bf4916a..30700f8b8afeccad862447c85a31f3c2292dfb9c 100644
--- a/cc/surfaces/display.cc
+++ b/cc/surfaces/display.cc
@@ -53,6 +53,8 @@ Display::Display(SharedBitmapManager* bitmap_manager,
Display::~Display() {
// Only do this if Initialize() happened.
if (client_) {
+ if (auto* context = output_surface_->context_provider())
+ context->SetLostContextCallback(base::Closure());
if (begin_frame_source_)
surface_manager_->UnregisterBeginFrameSource(begin_frame_source_.get());
surface_manager_->RemoveObserver(this);
@@ -84,11 +86,19 @@ void Display::Initialize(DisplayClient* client,
frame_sink_id_);
}
- bool ok = output_surface_->BindToClient(this);
- // The context given to the Display's OutputSurface should already be
- // initialized, so Bind can not fail.
- DCHECK(ok);
+ output_surface_->BindToClient(this);
InitializeRenderer();
+
+ if (auto* context = output_surface_->context_provider()) {
+ // This depends on assumptions that Display::Initialize will happen
+ // on the same callstack as the ContextProvider being created/initialized
+ // or else it could miss a callback before setting this.
+ context->SetLostContextCallback(base::Bind(
+ &Display::DidLoseContextProvider,
+ // Unretained is safe since the callback is unset in this class'
+ // destructor and is never posted.
+ base::Unretained(this)));
+ }
}
void Display::SetSurfaceId(const SurfaceId& id, float device_scale_factor) {
@@ -202,14 +212,6 @@ void Display::InitializeRenderer() {
aggregator_->set_output_is_secure(output_is_secure_);
}
-void Display::DidLoseOutputSurface() {
- if (scheduler_)
- scheduler_->OutputSurfaceLost();
- // WARNING: The client may delete the Display in this method call. Do not
- // make any additional references to members after this call.
- client_->DisplayOutputSurfaceLost();
-}
-
void Display::UpdateRootSurfaceResourcesLocked() {
Surface* surface = surface_manager_->GetSurfaceForId(current_surface_id_);
bool root_surface_resources_locked =
@@ -218,6 +220,14 @@ void Display::UpdateRootSurfaceResourcesLocked() {
scheduler_->SetRootSurfaceResourcesLocked(root_surface_resources_locked);
}
+void Display::DidLoseContextProvider() {
+ if (scheduler_)
+ scheduler_->OutputSurfaceLost();
+ // WARNING: The client may delete the Display in this method call. Do not
+ // make any additional references to members after this call.
+ client_->DisplayOutputSurfaceLost();
+}
+
bool Display::DrawAndSwap() {
TRACE_EVENT0("cc", "Display::DrawAndSwap");
« 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