diff options
author | ajuma@chromium.org <ajuma@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-30 10:23:01 +0000 |
---|---|---|
committer | ajuma@chromium.org <ajuma@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-30 10:23:01 +0000 |
commit | 27a747d49ac6b6eed8a5cd2021b6d8c39c18e4c9 (patch) | |
tree | 56a46fa828aec97bb0980b71c6013910804e82f5 | |
parent | 45d527fca84f11ef9fd5c89e5d31f11525811a09 (diff) | |
download | chromium_src-27a747d49ac6b6eed8a5cd2021b6d8c39c18e4c9.zip chromium_src-27a747d49ac6b6eed8a5cd2021b6d8c39c18e4c9.tar.gz chromium_src-27a747d49ac6b6eed8a5cd2021b6d8c39c18e4c9.tar.bz2 |
Trigger GPU rasterization based on viewport rather than per-layer hints
This makes GPU rasterization triggerable on a LayerTreeHost rather
than per-layer. GPU rasterization is triggered on a LayerTreeHost
based on WebViewClient::heuristicsForGpuRasterizationUpdated.
This depends on https://codereview.chromium.org/259683002/
BUG=367202
Review URL: https://codereview.chromium.org/256613002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@267152 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | cc/layers/picture_layer.cc | 23 | ||||
-rw-r--r-- | cc/layers/picture_layer.h | 4 | ||||
-rw-r--r-- | cc/layers/picture_layer_unittest.cc | 20 | ||||
-rw-r--r-- | cc/trees/layer_tree_host.cc | 9 | ||||
-rw-r--r-- | cc/trees/layer_tree_host.h | 8 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_unittest.cc | 10 | ||||
-rw-r--r-- | content/renderer/gpu/render_widget_compositor.cc | 5 | ||||
-rw-r--r-- | content/renderer/gpu/render_widget_compositor.h | 1 | ||||
-rw-r--r-- | webkit/renderer/compositor_bindings/web_content_layer_impl.cc | 6 |
9 files changed, 35 insertions, 51 deletions
diff --git a/cc/layers/picture_layer.cc b/cc/layers/picture_layer.cc index 656f4ab..c219230 100644 --- a/cc/layers/picture_layer.cc +++ b/cc/layers/picture_layer.cc @@ -21,7 +21,6 @@ PictureLayer::PictureLayer(ContentLayerClient* client) pile_(make_scoped_refptr(new PicturePile())), instrumentation_object_tracker_(id()), is_mask_(false), - has_gpu_rasterization_hint_(TRIBOOL_UNKNOWN), update_source_frame_number_(-1) {} PictureLayer::~PictureLayer() { @@ -143,32 +142,12 @@ void PictureLayer::SetIsMask(bool is_mask) { is_mask_ = is_mask; } -void PictureLayer::SetHasGpuRasterizationHint(bool has_hint) { - switch (has_gpu_rasterization_hint_) { - case TRIBOOL_UNKNOWN: // Fall-through. - case TRIBOOL_TRUE: - has_gpu_rasterization_hint_ = has_hint ? TRIBOOL_TRUE : TRIBOOL_FALSE; - break; - case TRIBOOL_FALSE: - // GPU rasterization cannot be enabled once disabled. - // This is done to prevent frequent invalidations and visual flashing. - break; - default: - NOTREACHED(); - } - // No need to set needs commit or push-properties. - // If only the hint changes and the layer is still valid, there is no need - // to invalidate the rasterization for the whole layer. If there is an - // invalidation (current or future) we will re-raster everything so that it - // is consistent across the layer. -} - bool PictureLayer::ShouldUseGpuRasterization() const { switch (layer_tree_host()->settings().rasterization_site) { case LayerTreeSettings::CpuRasterization: return false; case LayerTreeSettings::HybridRasterization: - return has_gpu_rasterization_hint_ == TRIBOOL_TRUE && + return layer_tree_host()->has_gpu_rasterization_trigger() && pile_->is_suitable_for_gpu_rasterization(); case LayerTreeSettings::GpuRasterization: return true; diff --git a/cc/layers/picture_layer.h b/cc/layers/picture_layer.h index 28f4f90..184eea7 100644 --- a/cc/layers/picture_layer.h +++ b/cc/layers/picture_layer.h @@ -40,7 +40,6 @@ class CC_EXPORT PictureLayer : public Layer { ContentLayerClient* client() { return client_; } - void SetHasGpuRasterizationHint(bool has_hint); bool ShouldUseGpuRasterization() const; PicturePile* GetPicturePileForTesting() const { return pile_.get(); } @@ -61,9 +60,6 @@ class CC_EXPORT PictureLayer : public Layer { gfx::Rect last_updated_visible_content_rect_; bool is_mask_; - enum TriBool { TRIBOOL_UNKNOWN, TRIBOOL_FALSE, TRIBOOL_TRUE }; - TriBool has_gpu_rasterization_hint_; - int update_source_frame_number_; DISALLOW_COPY_AND_ASSIGN(PictureLayer); diff --git a/cc/layers/picture_layer_unittest.cc b/cc/layers/picture_layer_unittest.cc index 7342c1a..abbe869 100644 --- a/cc/layers/picture_layer_unittest.cc +++ b/cc/layers/picture_layer_unittest.cc @@ -80,7 +80,7 @@ TEST(PictureLayerTest, ForcedCpuRaster) { EXPECT_FALSE(layer->ShouldUseGpuRasterization()); // Gpu rasterization cannot be enabled even with raster hint. - layer->SetHasGpuRasterizationHint(true); + host->set_has_gpu_rasterization_trigger(true); EXPECT_FALSE(layer->ShouldUseGpuRasterization()); } @@ -96,7 +96,7 @@ TEST(PictureLayerTest, ForcedGpuRaster) { EXPECT_TRUE(layer->ShouldUseGpuRasterization()); // Gpu rasterization cannot be disabled even with raster hint. - layer->SetHasGpuRasterizationHint(false); + host->set_has_gpu_rasterization_trigger(false); EXPECT_TRUE(layer->ShouldUseGpuRasterization()); // Gpu rasterization cannot be disabled even with skia veto. @@ -117,17 +117,17 @@ TEST(PictureLayerTest, HybridRaster) { // The default value is false. EXPECT_FALSE(layer->ShouldUseGpuRasterization()); - // Gpu rasterization can be enabled first time. - layer->SetHasGpuRasterizationHint(true); + // Gpu rasterization can be enabled. + host->set_has_gpu_rasterization_trigger(true); EXPECT_TRUE(layer->ShouldUseGpuRasterization()); - // Gpu rasterization can always be disabled. - layer->SetHasGpuRasterizationHint(false); + // Gpu rasterization can be disabled. + host->set_has_gpu_rasterization_trigger(false); EXPECT_FALSE(layer->ShouldUseGpuRasterization()); - // Gpu rasterization cannot be enabled once disabled. - layer->SetHasGpuRasterizationHint(true); - EXPECT_FALSE(layer->ShouldUseGpuRasterization()); + // Gpu rasterization can be enabled again. + host->set_has_gpu_rasterization_trigger(true); + EXPECT_TRUE(layer->ShouldUseGpuRasterization()); } TEST(PictureLayerTest, VetoGpuRaster) { @@ -140,7 +140,7 @@ TEST(PictureLayerTest, VetoGpuRaster) { EXPECT_FALSE(layer->ShouldUseGpuRasterization()); - layer->SetHasGpuRasterizationHint(true); + host->set_has_gpu_rasterization_trigger(true); EXPECT_TRUE(layer->ShouldUseGpuRasterization()); // Veto gpu rasterization. diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc index cf79492..dcf124e 100644 --- a/cc/trees/layer_tree_host.cc +++ b/cc/trees/layer_tree_host.cc @@ -86,11 +86,9 @@ scoped_ptr<LayerTreeHost> LayerTreeHost::CreateSingleThreaded( return layer_tree_host.Pass(); } - -LayerTreeHost::LayerTreeHost( - LayerTreeHostClient* client, - SharedBitmapManager* manager, - const LayerTreeSettings& settings) +LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, + SharedBitmapManager* manager, + const LayerTreeSettings& settings) : micro_benchmark_controller_(this), next_ui_resource_id_(1), animating_(false), @@ -110,6 +108,7 @@ LayerTreeHost::LayerTreeHost( min_page_scale_factor_(1.f), max_page_scale_factor_(1.f), trigger_idle_updates_(true), + has_gpu_rasterization_trigger_(false), background_color_(SK_ColorWHITE), has_transparent_background_(false), partial_texture_update_requests_(0), diff --git a/cc/trees/layer_tree_host.h b/cc/trees/layer_tree_host.h index 90bcc25..b58ce39 100644 --- a/cc/trees/layer_tree_host.h +++ b/cc/trees/layer_tree_host.h @@ -191,6 +191,13 @@ class CC_EXPORT LayerTreeHost { void SetDebugState(const LayerTreeDebugState& debug_state); const LayerTreeDebugState& debug_state() const { return debug_state_; } + bool has_gpu_rasterization_trigger() const { + return has_gpu_rasterization_trigger_; + } + void set_has_gpu_rasterization_trigger(bool has_trigger) { + has_gpu_rasterization_trigger_ = has_trigger; + } + void SetViewportSize(const gfx::Size& device_viewport_size); void SetOverdrawBottomHeight(float overdraw_bottom_height); @@ -391,6 +398,7 @@ class CC_EXPORT LayerTreeHost { float max_page_scale_factor_; gfx::Transform impl_transform_; bool trigger_idle_updates_; + bool has_gpu_rasterization_trigger_; SkColor background_color_; bool has_transparent_background_; diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc index e942bc7..01c5a18 100644 --- a/cc/trees/layer_tree_host_unittest.cc +++ b/cc/trees/layer_tree_host_unittest.cc @@ -4981,7 +4981,7 @@ class LayerTreeHostTestHybridRasterizationSetting : public LayerTreeHostTest { child->SetBounds(gfx::Size(10, 10)); parent->AddChild(child); - parent->SetHasGpuRasterizationHint(true); + layer_tree_host()->set_has_gpu_rasterization_trigger(true); } virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } @@ -4993,9 +4993,8 @@ class LayerTreeHostTestHybridRasterizationSetting : public LayerTreeHostTest { PictureLayerImpl* child = static_cast<PictureLayerImpl*>(parent->children()[0]); - // Only layers with a GPU rasterization hint should use GPU rasterization. EXPECT_TRUE(parent->ShouldUseGpuRasterization()); - EXPECT_FALSE(child->ShouldUseGpuRasterization()); + EXPECT_TRUE(child->ShouldUseGpuRasterization()); } virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { @@ -5005,9 +5004,8 @@ class LayerTreeHostTestHybridRasterizationSetting : public LayerTreeHostTest { PictureLayerImpl* child = static_cast<PictureLayerImpl*>(parent->children()[0]); - // Only layers with a GPU rasterization hint should use GPU rasterization. EXPECT_TRUE(parent->ShouldUseGpuRasterization()); - EXPECT_FALSE(child->ShouldUseGpuRasterization()); + EXPECT_TRUE(child->ShouldUseGpuRasterization()); EndTest(); } @@ -5036,7 +5034,7 @@ class LayerTreeHostTestGpuRasterizationSetting : public LayerTreeHostTest { child->SetBounds(gfx::Size(10, 10)); parent->AddChild(child); - parent->SetHasGpuRasterizationHint(true); + layer_tree_host()->set_has_gpu_rasterization_trigger(false); } virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } diff --git a/content/renderer/gpu/render_widget_compositor.cc b/content/renderer/gpu/render_widget_compositor.cc index e10b3ca..e6ae6ce 100644 --- a/content/renderer/gpu/render_widget_compositor.cc +++ b/content/renderer/gpu/render_widget_compositor.cc @@ -498,6 +498,11 @@ void RenderWidgetCompositor::startPageScaleAnimation( duration); } +void RenderWidgetCompositor::heuristicsForGpuRasterizationUpdated( + bool matches_heuristics) { + layer_tree_host_->set_has_gpu_rasterization_trigger(matches_heuristics); +} + void RenderWidgetCompositor::setNeedsAnimate() { layer_tree_host_->SetNeedsAnimate(); } diff --git a/content/renderer/gpu/render_widget_compositor.h b/content/renderer/gpu/render_widget_compositor.h index f0b4e68..c1578d5 100644 --- a/content/renderer/gpu/render_widget_compositor.h +++ b/content/renderer/gpu/render_widget_compositor.h @@ -96,6 +96,7 @@ class RenderWidgetCompositor : public blink::WebLayerTreeView, bool use_anchor, float new_page_scale, double duration_sec); + virtual void heuristicsForGpuRasterizationUpdated(bool matches_heuristics); virtual void setNeedsAnimate(); virtual bool commitRequested() const; virtual void didStopFlinging(); diff --git a/webkit/renderer/compositor_bindings/web_content_layer_impl.cc b/webkit/renderer/compositor_bindings/web_content_layer_impl.cc index 95a4b7f..e337e48 100644 --- a/webkit/renderer/compositor_bindings/web_content_layer_impl.cc +++ b/webkit/renderer/compositor_bindings/web_content_layer_impl.cc @@ -47,10 +47,8 @@ void WebContentLayerImpl::setDrawCheckerboardForMissingTiles(bool enable) { } void WebContentLayerImpl::setHasGpuRasterizationHint(bool has_hint) { - if (WebLayerImpl::UsingPictureLayer()) { - static_cast<PictureLayer*>(layer_->layer()) - ->SetHasGpuRasterizationHint(has_hint); - } + // TODO(ajuma): Convert per-layer GPU rasterization hints to per-layer + // prepaint-disabling hints (crbug.com/365885). } void WebContentLayerImpl::PaintContents(SkCanvas* canvas, |