From 1d96e0315b34e2d0668f71ae01f0d3382710df8a Mon Sep 17 00:00:00 2001 From: "luken@chromium.org" Date: Tue, 25 Mar 2014 05:59:08 +0000 Subject: plumbing fills_bounds_completely from aura to content_layer_updater BUG=313494 Review URL: https://codereview.chromium.org/191453002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@259160 0039d316-1c4b-4281-b951-d872f2087c98 --- ui/aura/window.cc | 5 +++++ ui/aura/window.h | 3 +++ ui/compositor/clone_layer.cc | 1 + ui/compositor/layer.cc | 8 ++++++++ ui/compositor/layer.h | 6 ++++++ ui/views/widget/desktop_aura/desktop_native_widget_aura.cc | 4 ++++ 6 files changed, 27 insertions(+) (limited to 'ui') diff --git a/ui/aura/window.cc b/ui/aura/window.cc index 63fe91f..9201123 100644 --- a/ui/aura/window.cc +++ b/ui/aura/window.cc @@ -301,6 +301,11 @@ void Window::SetTransparent(bool transparent) { layer()->SetFillsBoundsOpaquely(!transparent_); } +void Window::SetFillsBoundsCompletely(bool fills_bounds) { + if (layer()) + layer()->SetFillsBoundsCompletely(fills_bounds); +} + Window* Window::GetRootWindow() { return const_cast( static_cast(this)->GetRootWindow()); diff --git a/ui/aura/window.h b/ui/aura/window.h index 342503f..f456687 100644 --- a/ui/aura/window.h +++ b/ui/aura/window.h @@ -101,6 +101,9 @@ class AURA_EXPORT Window : public ui::LayerDelegate, bool transparent() const { return transparent_; } void SetTransparent(bool transparent); + // See description in Layer::SetFillsBoundsCompletely. + void SetFillsBoundsCompletely(bool fills_bounds); + WindowDelegate* delegate() { return delegate_; } const WindowDelegate* delegate() const { return delegate_; } diff --git a/ui/compositor/clone_layer.cc b/ui/compositor/clone_layer.cc index f1337b0c..f49460f 100644 --- a/ui/compositor/clone_layer.cc +++ b/ui/compositor/clone_layer.cc @@ -27,6 +27,7 @@ scoped_ptr CloneLayer(LayerOwner* layer_owner) { new_layer->SetMasksToBounds(old_layer->GetMasksToBounds()); new_layer->set_name(old_layer->name()); new_layer->SetFillsBoundsOpaquely(old_layer->fills_bounds_opaquely()); + new_layer->SetFillsBoundsCompletely(old_layer->FillsBoundsCompletely()); // Install new layer as a sibling of the old layer, stacked below it. if (old_layer->parent()) { diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc index f4c735b..1637d5e 100644 --- a/ui/compositor/layer.cc +++ b/ui/compositor/layer.cc @@ -61,6 +61,7 @@ Layer::Layer() visible_(true), force_render_surface_(false), fills_bounds_opaquely_(true), + fills_bounds_completely_(false), background_blur_radius_(0), layer_saturation_(0.0f), layer_brightness_(0.0f), @@ -85,6 +86,7 @@ Layer::Layer(LayerType type) visible_(true), force_render_surface_(false), fills_bounds_opaquely_(true), + fills_bounds_completely_(false), background_blur_radius_(0), layer_saturation_(0.0f), layer_brightness_(0.0f), @@ -444,6 +446,10 @@ void Layer::SetFillsBoundsOpaquely(bool fills_bounds_opaquely) { cc_layer_->SetContentsOpaque(fills_bounds_opaquely); } +void Layer::SetFillsBoundsCompletely(bool fills_bounds_completely) { + fills_bounds_completely_ = fills_bounds_completely; +} + void Layer::SwitchToLayer(scoped_refptr new_layer) { // Finish animations being handled by cc_layer_. if (animator_.get()) { @@ -662,6 +668,8 @@ void Layer::PaintContents(SkCanvas* sk_canvas, canvas->Restore(); } +bool Layer::FillsBoundsCompletely() const { return fills_bounds_completely_; } + unsigned Layer::PrepareTexture() { DCHECK(texture_layer_.get()); return texture_->PrepareTexture(); diff --git a/ui/compositor/layer.h b/ui/compositor/layer.h index 209e99e..ed805bf 100644 --- a/ui/compositor/layer.h +++ b/ui/compositor/layer.h @@ -249,6 +249,10 @@ class COMPOSITOR_EXPORT Layer void SetFillsBoundsOpaquely(bool fills_bounds_opaquely); bool fills_bounds_opaquely() const { return fills_bounds_opaquely_; } + // Set to true if this layer always paints completely within its bounds. If so + // we can omit an unnecessary clear, even if the layer is transparent. + void SetFillsBoundsCompletely(bool fills_bounds_completely); + const std::string& name() const { return name_; } void set_name(const std::string& name) { name_ = name; } @@ -318,6 +322,7 @@ class COMPOSITOR_EXPORT Layer virtual void PaintContents( SkCanvas* canvas, const gfx::Rect& clip, gfx::RectF* opaque) OVERRIDE; virtual void DidChangeLayerCanUseLCDText() OVERRIDE {} + virtual bool FillsBoundsCompletely() const OVERRIDE; cc::Layer* cc_layer() { return cc_layer_; } @@ -424,6 +429,7 @@ class COMPOSITOR_EXPORT Layer bool force_render_surface_; bool fills_bounds_opaquely_; + bool fills_bounds_completely_; // Union of damaged rects, in pixel coordinates, to be used when // compositor is ready to paint the content. diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc index c14d1ce..e619661 100644 --- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc +++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc @@ -1182,6 +1182,10 @@ void DesktopNativeWidgetAura::InstallInputMethodEventFilter() { void DesktopNativeWidgetAura::UpdateWindowTransparency() { content_window_->SetTransparent( desktop_window_tree_host_->ShouldWindowContentsBeTransparent()); + // Regardless of transparency or not, this root content window will always + // fill its bounds completely, so set this flag to true to avoid an + // unecessary clear before update. + content_window_->SetFillsBoundsCompletely(true); } void DesktopNativeWidgetAura::RootWindowDestroyed() { -- cgit v1.1