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

Unified Diff: cc/trees/layer_tree_host_impl.cc

Issue 1135743004: cc: Add null checks for GrContext created by ContextProviderCommandBuffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Worker context provider's lock must be held during GrContext creation. Created 5 years, 7 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/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_impl.cc
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index 61253372be19003f42f111f0856321cc61acb389..4df38079d7e90d537a30baacd0557964e6af7b1b 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -1584,6 +1584,20 @@ void LayerTreeHostImpl::FinishAllRendering() {
renderer_->Finish();
}
+bool LayerTreeHostImpl::CanUseGpuRasterization() {
+ if (!(output_surface_ && output_surface_->context_provider() &&
+ output_surface_->worker_context_provider()))
+ return false;
+
+ ContextProvider* context_provider =
+ output_surface_->worker_context_provider();
+ base::AutoLock context_lock(*context_provider->GetLock());
+ if (!context_provider->GrContext())
+ return false;
+
+ return true;
+}
+
void LayerTreeHostImpl::UpdateGpuRasterizationStatus() {
bool use_gpu = false;
bool use_msaa = false;
@@ -1613,6 +1627,17 @@ void LayerTreeHostImpl::UpdateGpuRasterizationStatus() {
gpu_rasterization_status_ = GpuRasterizationStatus::OFF_CONTENT;
}
+ if (use_gpu && !use_gpu_rasterization_) {
+ if (!CanUseGpuRasterization()) {
+ // If GPU rasterization is unusable, e.g. if GlContext could not
+ // be created due to losing the GL context, force use of software
+ // raster.
+ use_gpu = false;
+ use_msaa = false;
+ gpu_rasterization_status_ = GpuRasterizationStatus::OFF_DEVICE;
+ }
+ }
+
if (use_gpu == use_gpu_rasterization_ && use_msaa == use_msaa_)
return;
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698