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

Unified Diff: mojo/skia/ganesh_context.cc

Issue 1687653003: Slightly improve recovery from losing GL context. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 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 | « mojo/skia/ganesh_context.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/skia/ganesh_context.cc
diff --git a/mojo/skia/ganesh_context.cc b/mojo/skia/ganesh_context.cc
index 735a902ca492579792fb7271fad22466d7bd7555..b68423151dd60194d8222ecf162011e4efaf2c50 100644
--- a/mojo/skia/ganesh_context.cc
+++ b/mojo/skia/ganesh_context.cc
@@ -46,7 +46,9 @@ GaneshContext::~GaneshContext() {
}
void GaneshContext::OnContextLost() {
- ReleaseContext();
+ context_lost_ = true;
+ if (!scope_entered_)
+ ReleaseContext();
}
void GaneshContext::ReleaseContext() {
@@ -76,12 +78,17 @@ void GaneshContext::ExitScope() {
CHECK(scope_entered_);
scope_entered_ = false;
- // Flush the Ganesh context when exiting its scope.
- if (gr_context_)
- gr_context_->flush();
+ if (gl_context_) {
+ // Flush the Ganesh context when exiting its scope.
+ if (gr_context_)
+ gr_context_->flush();
- MGLMakeCurrent(previous_mgl_context_);
- previous_mgl_context_ = MGL_NO_CONTEXT;
+ MGLMakeCurrent(previous_mgl_context_);
+ previous_mgl_context_ = MGL_NO_CONTEXT;
+
+ if (context_lost_)
+ ReleaseContext();
+ }
}
} // namespace skia
« no previous file with comments | « mojo/skia/ganesh_context.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698