summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorvmiura <vmiura@chromium.org>2015-05-15 09:16:20 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-15 16:16:37 +0000
commit4e7e199cb73c95ee81c0804cf14a3d6ab015c75c (patch)
tree6227bf1e14f6880ece6e7d428b1efe1cd7574d3a /cc
parent4746a790d8682c550b2a57381985c3646e51096f (diff)
downloadchromium_src-4e7e199cb73c95ee81c0804cf14a3d6ab015c75c.zip
chromium_src-4e7e199cb73c95ee81c0804cf14a3d6ab015c75c.tar.gz
chromium_src-4e7e199cb73c95ee81c0804cf14a3d6ab015c75c.tar.bz2
cc: Add null checks for GrContext created by ContextProviderCommandBuffer.
GrContext::Create may return NULL if the base GL context was lost. - Check for the NULL case in GlRenderer. - For the GPU rasterizer, don't allow GPU rasterization to be initialized with a NULL GrContext. BUG=464892 Review URL: https://codereview.chromium.org/1135743004 Cr-Commit-Position: refs/heads/master@{#330104}
Diffstat (limited to 'cc')
-rw-r--r--cc/output/gl_renderer.cc8
-rw-r--r--cc/test/fake_output_surface.h8
-rw-r--r--cc/trees/layer_tree_host_impl.cc25
-rw-r--r--cc/trees/layer_tree_host_impl.h1
-rw-r--r--cc/trees/layer_tree_host_impl_unittest.cc3
5 files changed, 39 insertions, 6 deletions
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc
index bdb537a..93a4114 100644
--- a/cc/output/gl_renderer.cc
+++ b/cc/output/gl_renderer.cc
@@ -163,7 +163,13 @@ class GLRenderer::ScopedUseGrContext {
public:
static scoped_ptr<ScopedUseGrContext> Create(GLRenderer* renderer,
DrawingFrame* frame) {
- return make_scoped_ptr(new ScopedUseGrContext(renderer, frame));
+ // GrContext for filters is created lazily, and may fail if the context
+ // is lost.
+ // TODO(vmiura,bsalomon): crbug.com/487850 Ensure that
+ // ContextProvider::GrContext() does not return NULL.
+ if (renderer->output_surface_->context_provider()->GrContext())
+ return make_scoped_ptr(new ScopedUseGrContext(renderer, frame));
+ return nullptr;
}
~ScopedUseGrContext() {
diff --git a/cc/test/fake_output_surface.h b/cc/test/fake_output_surface.h
index 6028cad..7041a44 100644
--- a/cc/test/fake_output_surface.h
+++ b/cc/test/fake_output_surface.h
@@ -29,7 +29,8 @@ class FakeOutputSurface : public OutputSurface {
static scoped_ptr<FakeOutputSurface> Create3d(
scoped_refptr<ContextProvider> context_provider) {
- return make_scoped_ptr(new FakeOutputSurface(context_provider, false));
+ return make_scoped_ptr(new FakeOutputSurface(
+ context_provider, TestContextProvider::Create(), false));
}
static scoped_ptr<FakeOutputSurface> Create3d(
@@ -41,8 +42,9 @@ class FakeOutputSurface : public OutputSurface {
static scoped_ptr<FakeOutputSurface> Create3d(
scoped_ptr<TestWebGraphicsContext3D> context) {
- return make_scoped_ptr(new FakeOutputSurface(
- TestContextProvider::Create(context.Pass()), false));
+ return make_scoped_ptr(
+ new FakeOutputSurface(TestContextProvider::Create(context.Pass()),
+ TestContextProvider::Create(), false));
}
static scoped_ptr<FakeOutputSurface> CreateSoftware(
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index 6125337..4df3807 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;
diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h
index 54776e7..7e01faf 100644
--- a/cc/trees/layer_tree_host_impl.h
+++ b/cc/trees/layer_tree_host_impl.h
@@ -327,6 +327,7 @@ class CC_EXPORT LayerTreeHostImpl
void set_content_is_suitable_for_gpu_rasterization(bool flag) {
content_is_suitable_for_gpu_rasterization_ = flag;
}
+ bool CanUseGpuRasterization();
void UpdateGpuRasterizationStatus();
bool use_gpu_rasterization() const { return use_gpu_rasterization_; }
bool use_msaa() const { return use_msaa_; }
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index cc239da..9476645 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -5931,8 +5931,7 @@ TEST_F(LayerTreeHostImplTest, MemoryPolicy) {
// when visible.
LayerTreeSettings settings;
settings.gpu_rasterization_enabled = true;
- host_impl_ = LayerTreeHostImpl::Create(
- settings, this, &proxy_, &stats_instrumentation_, NULL, NULL, NULL, 0);
+ CreateHostImpl(settings, CreateOutputSurface());
host_impl_->set_content_is_suitable_for_gpu_rasterization(true);
host_impl_->set_has_gpu_rasterization_trigger(true);
host_impl_->UpdateGpuRasterizationStatus();