summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-23 19:02:37 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-23 19:02:37 +0000
commit0cfda3032843c4769cbd68ddc3c83e1753d0e611 (patch)
tree62608cc71961da534c30cca97019d5bcba1a924c /cc
parent33091bea397cb6d7ca3116f001764865c636b9bd (diff)
downloadchromium_src-0cfda3032843c4769cbd68ddc3c83e1753d0e611.zip
chromium_src-0cfda3032843c4769cbd68ddc3c83e1753d0e611.tar.gz
chromium_src-0cfda3032843c4769cbd68ddc3c83e1753d0e611.tar.bz2
cc: Remove code paths for branches that are always true.
The Renderer::Create methods always return a valid pointer, and the ResourceProvider can no longer fail to initialize, so stop branching on these things that can't happen. R=enne@chromium.org BUG=366130 Review URL: https://codereview.chromium.org/248873003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@265700 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/output/delegating_renderer.cc28
-rw-r--r--cc/output/delegating_renderer.h1
-rw-r--r--cc/resources/resource_provider.cc16
-rw-r--r--cc/resources/resource_provider.h2
-rw-r--r--cc/resources/resource_provider_unittest.cc2
-rw-r--r--cc/trees/layer_tree_host_impl.cc74
6 files changed, 46 insertions, 77 deletions
diff --git a/cc/output/delegating_renderer.cc b/cc/output/delegating_renderer.cc
index 8770187..2b35955 100644
--- a/cc/output/delegating_renderer.cc
+++ b/cc/output/delegating_renderer.cc
@@ -35,11 +35,8 @@ scoped_ptr<DelegatingRenderer> DelegatingRenderer::Create(
const LayerTreeSettings* settings,
OutputSurface* output_surface,
ResourceProvider* resource_provider) {
- scoped_ptr<DelegatingRenderer> renderer(new DelegatingRenderer(
+ return make_scoped_ptr(new DelegatingRenderer(
client, settings, output_surface, resource_provider));
- if (!renderer->Initialize())
- return scoped_ptr<DelegatingRenderer>();
- return renderer.Pass();
}
DelegatingRenderer::DelegatingRenderer(RendererClient* client,
@@ -51,9 +48,7 @@ DelegatingRenderer::DelegatingRenderer(RendererClient* client,
resource_provider_(resource_provider),
visible_(true) {
DCHECK(resource_provider_);
-}
-bool DelegatingRenderer::Initialize() {
capabilities_.using_partial_swap = false;
capabilities_.max_texture_size = resource_provider_->max_texture_size();
capabilities_.best_texture_format = resource_provider_->best_texture_format();
@@ -63,21 +58,18 @@ bool DelegatingRenderer::Initialize() {
if (!output_surface_->context_provider()) {
capabilities_.using_shared_memory_resources = true;
capabilities_.using_map_image = true;
- return true;
- }
-
- const ContextProvider::Capabilities& caps =
- output_surface_->context_provider()->ContextCapabilities();
+ } else {
+ const ContextProvider::Capabilities& caps =
+ output_surface_->context_provider()->ContextCapabilities();
- DCHECK(!caps.gpu.iosurface || caps.gpu.texture_rectangle);
+ DCHECK(!caps.gpu.iosurface || caps.gpu.texture_rectangle);
- capabilities_.using_egl_image = caps.gpu.egl_image_external;
- capabilities_.using_map_image =
- settings_->use_map_image && caps.gpu.map_image;
+ capabilities_.using_egl_image = caps.gpu.egl_image_external;
+ capabilities_.using_map_image =
+ settings_->use_map_image && caps.gpu.map_image;
- capabilities_.allow_rasterize_on_demand = false;
-
- return true;
+ capabilities_.allow_rasterize_on_demand = false;
+ }
}
DelegatingRenderer::~DelegatingRenderer() {}
diff --git a/cc/output/delegating_renderer.h b/cc/output/delegating_renderer.h
index 456d1ef..a4f8c26 100644
--- a/cc/output/delegating_renderer.h
+++ b/cc/output/delegating_renderer.h
@@ -56,7 +56,6 @@ class CC_EXPORT DelegatingRenderer : public Renderer {
const LayerTreeSettings* settings,
OutputSurface* output_surface,
ResourceProvider* resource_provider);
- bool Initialize();
OutputSurface* output_surface_;
ResourceProvider* resource_provider_;
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc
index 7ad1492..3ce8d63 100644
--- a/cc/resources/resource_provider.cc
+++ b/cc/resources/resource_provider.cc
@@ -600,16 +600,10 @@ scoped_ptr<ResourceProvider> ResourceProvider::Create(
use_rgba_4444_texture_format,
id_allocation_chunk_size));
- bool success = false;
- if (resource_provider->ContextGL()) {
- success = resource_provider->InitializeGL();
- } else {
+ if (resource_provider->ContextGL())
+ resource_provider->InitializeGL();
+ else
resource_provider->InitializeSoftware();
- success = true;
- }
-
- if (!success)
- return scoped_ptr<ResourceProvider>();
DCHECK_NE(InvalidType, resource_provider->default_resource_type());
return resource_provider.Pass();
@@ -1285,7 +1279,7 @@ void ResourceProvider::InitializeSoftware() {
best_texture_format_ = RGBA_8888;
}
-bool ResourceProvider::InitializeGL() {
+void ResourceProvider::InitializeGL() {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(!texture_uploader_);
DCHECK_NE(GLTexture, default_resource_type_);
@@ -1315,8 +1309,6 @@ bool ResourceProvider::InitializeGL() {
new TextureIdAllocator(gl, id_allocation_chunk_size_));
buffer_id_allocator_.reset(
new BufferIdAllocator(gl, id_allocation_chunk_size_));
-
- return true;
}
void ResourceProvider::CleanUpGLIfNeeded() {
diff --git a/cc/resources/resource_provider.h b/cc/resources/resource_provider.h
index 312dd7c..addc05f 100644
--- a/cc/resources/resource_provider.h
+++ b/cc/resources/resource_provider.h
@@ -79,7 +79,7 @@ class CC_EXPORT ResourceProvider {
virtual ~ResourceProvider();
void InitializeSoftware();
- bool InitializeGL();
+ void InitializeGL();
void DidLoseOutputSurface() { lost_output_surface_ = true; }
diff --git a/cc/resources/resource_provider_unittest.cc b/cc/resources/resource_provider_unittest.cc
index f72a68a..509fc50 100644
--- a/cc/resources/resource_provider_unittest.cc
+++ b/cc/resources/resource_provider_unittest.cc
@@ -3169,7 +3169,7 @@ void InitializeGLAndCheck(ContextSharedData* shared_data,
TestContextProvider::Create(
context_owned.PassAs<TestWebGraphicsContext3D>());
output_surface->InitializeAndSetContext3d(context_provider, NULL);
- EXPECT_TRUE(resource_provider->InitializeGL());
+ resource_provider->InitializeGL();
CheckCreateResource(ResourceProvider::GLTexture, resource_provider, context);
}
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index 80dd6c0..447bfc0 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -1781,19 +1781,18 @@ void LayerTreeHostImpl::CreateAndSetRenderer(
renderer_ = SoftwareRenderer::Create(
this, &settings_, output_surface, resource_provider);
}
+ DCHECK(renderer_);
- if (renderer_) {
- renderer_->SetVisible(visible_);
- SetFullRootLayerDamage();
+ renderer_->SetVisible(visible_);
+ SetFullRootLayerDamage();
- // See note in LayerTreeImpl::UpdateDrawProperties. Renderer needs to be
- // initialized to get max texture size. Also, after releasing resources,
- // trees need another update to generate new ones.
- active_tree_->set_needs_update_draw_properties();
- if (pending_tree_)
- pending_tree_->set_needs_update_draw_properties();
- client_->UpdateRendererCapabilitiesOnImplThread();
- }
+ // See note in LayerTreeImpl::UpdateDrawProperties. Renderer needs to be
+ // initialized to get max texture size. Also, after releasing resources,
+ // trees need another update to generate new ones.
+ active_tree_->set_needs_update_draw_properties();
+ if (pending_tree_)
+ pending_tree_->set_needs_update_draw_properties();
+ client_->UpdateRendererCapabilitiesOnImplThread();
}
void LayerTreeHostImpl::CreateAndSetTileManager(
@@ -1873,8 +1872,6 @@ bool LayerTreeHostImpl::InitializeRenderer(
settings_.highp_threshold_min,
settings_.use_rgba_4444_textures,
settings_.texture_id_allocation_chunk_size);
- if (!resource_provider)
- return false;
if (output_surface->capabilities().deferred_gl_initialization)
EnforceZeroBudget(true);
@@ -1883,9 +1880,6 @@ bool LayerTreeHostImpl::InitializeRenderer(
CreateAndSetRenderer(
output_surface.get(), resource_provider.get(), skip_gl_renderer);
- if (!renderer_)
- return false;
-
if (settings_.impl_side_painting) {
CreateAndSetTileManager(
resource_provider.get(),
@@ -1932,22 +1926,16 @@ bool LayerTreeHostImpl::DeferredInitialize(
ReleaseTreeResources();
renderer_.reset();
- bool resource_provider_success = resource_provider_->InitializeGL();
+ resource_provider_->InitializeGL();
- bool success = resource_provider_success;
- if (success) {
- bool skip_gl_renderer = false;
- CreateAndSetRenderer(
- output_surface_.get(), resource_provider_.get(), skip_gl_renderer);
- if (!renderer_)
- success = false;
- }
+ bool skip_gl_renderer = false;
+ CreateAndSetRenderer(
+ output_surface_.get(), resource_provider_.get(), skip_gl_renderer);
- if (success) {
- if (offscreen_context_provider.get() &&
- !offscreen_context_provider->BindToCurrentThread())
- success = false;
- }
+ bool success = true;
+ if (offscreen_context_provider.get() &&
+ !offscreen_context_provider->BindToCurrentThread())
+ success = false;
if (success) {
EnforceZeroBudget(false);
@@ -1961,19 +1949,18 @@ bool LayerTreeHostImpl::DeferredInitialize(
client_->DidLoseOutputSurfaceOnImplThread();
- if (resource_provider_success) {
- // If this fails the context provider will be dropped from the output
- // surface and destroyed. But the GLRenderer expects the output surface
- // to stick around - and hold onto the context3d - as long as it is alive.
- // TODO(danakj): Remove the need for this code path: crbug.com/276411
- renderer_.reset();
-
- // The resource provider can't stay in GL mode or it tries to clean up GL
- // stuff, but the context provider is going away on the output surface
- // which contradicts being in GL mode.
- // TODO(danakj): Remove the need for this code path: crbug.com/276411
- resource_provider_->InitializeSoftware();
- }
+ // If this method fails, the context provider will be dropped from the
+ // output surface and destroyed. But the GLRenderer expects the output
+ // surface to stick around - and hold onto the context3d - as long as it is
+ // alive.
+ // TODO(danakj): Remove the need for this code path: crbug.com/276411
+ renderer_.reset();
+
+ // The resource provider can't stay in GL mode or it tries to clean up GL
+ // stuff, but the context provider is going away on the output surface
+ // which contradicts being in GL mode.
+ // TODO(danakj): Remove the need for this code path: crbug.com/276411
+ resource_provider_->InitializeSoftware();
}
SetOffscreenContextProvider(offscreen_context_provider);
@@ -1996,7 +1983,6 @@ void LayerTreeHostImpl::ReleaseGL() {
bool skip_gl_renderer = true;
CreateAndSetRenderer(
output_surface_.get(), resource_provider_.get(), skip_gl_renderer);
- DCHECK(renderer_);
EnforceZeroBudget(true);
CreateAndSetTileManager(resource_provider_.get(),