summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cc/layers/content_layer.cc2
-rw-r--r--cc/layers/content_layer_client.h4
-rw-r--r--cc/layers/content_layer_unittest.cc1
-rw-r--r--cc/layers/picture_image_layer.cc12
-rw-r--r--cc/layers/picture_image_layer.h1
-rw-r--r--cc/layers/picture_layer.cc2
-rw-r--r--cc/layers/picture_layer_unittest.cc3
-rw-r--r--cc/resources/content_layer_updater.cc11
-rw-r--r--cc/resources/content_layer_updater.h6
-rw-r--r--cc/resources/layer_updater.h3
-rw-r--r--cc/resources/picture_pile.cc17
-rw-r--r--cc/resources/picture_pile.h16
-rw-r--r--cc/resources/picture_pile_base.cc3
-rw-r--r--cc/resources/picture_pile_base.h1
-rw-r--r--cc/resources/picture_pile_impl.cc15
-rw-r--r--cc/resources/picture_pile_unittest.cc1
-rw-r--r--cc/test/fake_content_layer_client.cc2
-rw-r--r--cc/test/fake_content_layer_client.h1
-rw-r--r--cc/test/solid_color_content_layer_client.cc4
-rw-r--r--cc/test/solid_color_content_layer_client.h1
-rw-r--r--cc/trees/layer_tree_host_common_unittest.cc1
-rw-r--r--cc/trees/layer_tree_host_pixeltest_masks.cc2
-rw-r--r--cc/trees/layer_tree_host_pixeltest_on_demand_raster.cc2
-rw-r--r--cc/trees/layer_tree_host_unittest.cc4
-rw-r--r--ui/aura/window.cc5
-rw-r--r--ui/aura/window.h3
-rw-r--r--ui/compositor/clone_layer.cc1
-rw-r--r--ui/compositor/layer.cc8
-rw-r--r--ui/compositor/layer.h6
-rw-r--r--ui/views/widget/desktop_aura/desktop_native_widget_aura.cc4
-rw-r--r--webkit/renderer/compositor_bindings/web_content_layer_impl.cc2
-rw-r--r--webkit/renderer/compositor_bindings/web_content_layer_impl.h1
32 files changed, 118 insertions, 27 deletions
diff --git a/cc/layers/content_layer.cc b/cc/layers/content_layer.cc
index edca5ed..178211f 100644
--- a/cc/layers/content_layer.cc
+++ b/cc/layers/content_layer.cc
@@ -126,6 +126,8 @@ void ContentLayer::CreateUpdaterIfNeeded() {
id());
}
updater_->SetOpaque(contents_opaque());
+ if (client_)
+ updater_->SetFillsBoundsCompletely(client_->FillsBoundsCompletely());
SetTextureFormat(
layer_tree_host()->GetRendererCapabilities().best_texture_format);
diff --git a/cc/layers/content_layer_client.h b/cc/layers/content_layer_client.h
index eac1a87..6a77dab 100644
--- a/cc/layers/content_layer_client.h
+++ b/cc/layers/content_layer_client.h
@@ -26,6 +26,10 @@ class CC_EXPORT ContentLayerClient {
// If the client paints LCD text, it may want to invalidate the layer.
virtual void DidChangeLayerCanUseLCDText() = 0;
+ // If true the layer may skip clearing the background before rasterizing,
+ // because it will cover any uncleared data with content.
+ virtual bool FillsBoundsCompletely() const = 0;
+
protected:
virtual ~ContentLayerClient() {}
};
diff --git a/cc/layers/content_layer_unittest.cc b/cc/layers/content_layer_unittest.cc
index 17cf11b..8770303 100644
--- a/cc/layers/content_layer_unittest.cc
+++ b/cc/layers/content_layer_unittest.cc
@@ -26,6 +26,7 @@ class MockContentLayerClient : public ContentLayerClient {
*opaque = gfx::RectF(opaque_layer_rect_);
}
virtual void DidChangeLayerCanUseLCDText() OVERRIDE {}
+ virtual bool FillsBoundsCompletely() const OVERRIDE { return false; }
private:
gfx::Rect opaque_layer_rect_;
diff --git a/cc/layers/picture_image_layer.cc b/cc/layers/picture_image_layer.cc
index 127560d..caf8c0b 100644
--- a/cc/layers/picture_image_layer.cc
+++ b/cc/layers/picture_image_layer.cc
@@ -52,7 +52,17 @@ void PictureImageLayer::PaintContents(SkCanvas* canvas,
SkFloatToScalar(static_cast<float>(bounds().height()) / bitmap_.height());
canvas->scale(content_to_layer_scale_x, content_to_layer_scale_y);
- canvas->drawBitmap(bitmap_, 0, 0);
+ // Because PictureImageLayer always FillsBoundsCompletely it will not clear
+ // before painting on playback. As a result we must configure the paint to
+ // copy over the uncleared destination, rather than blending with it.
+ SkPaint paint;
+ paint.setXfermodeMode(SkXfermode::kSrc_Mode);
+ canvas->drawBitmap(bitmap_, 0, 0, &paint);
+}
+
+bool PictureImageLayer::FillsBoundsCompletely() const {
+ // PictureImageLayer will always paint to the entire layer bounds.
+ return true;
}
} // namespace cc
diff --git a/cc/layers/picture_image_layer.h b/cc/layers/picture_image_layer.h
index 8066428..1457a9f 100644
--- a/cc/layers/picture_image_layer.h
+++ b/cc/layers/picture_image_layer.h
@@ -30,6 +30,7 @@ class CC_EXPORT PictureImageLayer : public PictureLayer, ContentLayerClient {
const gfx::Rect& clip,
gfx::RectF* opaque) OVERRIDE;
virtual void DidChangeLayerCanUseLCDText() OVERRIDE {}
+ virtual bool FillsBoundsCompletely() const OVERRIDE;
private:
PictureImageLayer();
diff --git a/cc/layers/picture_layer.cc b/cc/layers/picture_layer.cc
index 3a474d3..dee9a78 100644
--- a/cc/layers/picture_layer.cc
+++ b/cc/layers/picture_layer.cc
@@ -111,9 +111,11 @@ bool PictureLayer::Update(ResourceUpdateQueue* queue,
// the full page content must always be provided in the picture layer.
visible_layer_rect = gfx::Rect(bounds());
}
+ DCHECK(client_);
updated |= pile_->Update(client_,
SafeOpaqueBackgroundColor(),
contents_opaque(),
+ client_->FillsBoundsCompletely(),
pile_invalidation_,
visible_layer_rect,
update_source_frame_number_,
diff --git a/cc/layers/picture_layer_unittest.cc b/cc/layers/picture_layer_unittest.cc
index 25bfd99..3ff1de5 100644
--- a/cc/layers/picture_layer_unittest.cc
+++ b/cc/layers/picture_layer_unittest.cc
@@ -24,6 +24,9 @@ class MockContentLayerClient : public ContentLayerClient {
const gfx::Rect& clip,
gfx::RectF* opaque) OVERRIDE {}
virtual void DidChangeLayerCanUseLCDText() OVERRIDE {}
+ virtual bool FillsBoundsCompletely() const OVERRIDE {
+ return false;
+ };
};
TEST(PictureLayerTest, NoTilesIfEmptyBounds) {
diff --git a/cc/resources/content_layer_updater.cc b/cc/resources/content_layer_updater.cc
index a176ac4..f0711df 100644
--- a/cc/resources/content_layer_updater.cc
+++ b/cc/resources/content_layer_updater.cc
@@ -24,6 +24,7 @@ ContentLayerUpdater::ContentLayerUpdater(
: rendering_stats_instrumentation_(stats_instrumentation),
layer_id_(layer_id),
layer_is_opaque_(false),
+ layer_fills_bounds_completely_(false),
painter_(painter.Pass()) {}
ContentLayerUpdater::~ContentLayerUpdater() {}
@@ -61,9 +62,9 @@ void ContentLayerUpdater::PaintContents(SkCanvas* canvas,
canvas->clipRect(layer_sk_rect);
- // If the layer has opaque contents then there is no need to
- // clear the canvas before painting.
- if (!layer_is_opaque_) {
+ // If the layer has opaque contents or will fill the bounds completely there
+ // is no need to clear the canvas before painting.
+ if (!layer_is_opaque_ && !layer_fills_bounds_completely_) {
TRACE_EVENT0("cc", "Clear");
canvas->drawColor(SK_ColorTRANSPARENT, SkXfermode::kSrc_Mode);
}
@@ -83,4 +84,8 @@ void ContentLayerUpdater::SetOpaque(bool opaque) {
layer_is_opaque_ = opaque;
}
+void ContentLayerUpdater::SetFillsBoundsCompletely(bool fills_bounds) {
+ layer_fills_bounds_completely_ = fills_bounds;
+}
+
} // namespace cc
diff --git a/cc/resources/content_layer_updater.h b/cc/resources/content_layer_updater.h
index 6af2195..7ab2429 100644
--- a/cc/resources/content_layer_updater.h
+++ b/cc/resources/content_layer_updater.h
@@ -23,6 +23,7 @@ class CC_EXPORT ContentLayerUpdater : public LayerUpdater {
public:
void set_rendering_stats_instrumentation(RenderingStatsInstrumentation* rsi);
virtual void SetOpaque(bool opaque) OVERRIDE;
+ virtual void SetFillsBoundsCompletely(bool fills_bounds) OVERRIDE;
protected:
ContentLayerUpdater(scoped_ptr<LayerPainter> painter,
@@ -38,12 +39,17 @@ class CC_EXPORT ContentLayerUpdater : public LayerUpdater {
gfx::Rect content_rect() const { return content_rect_; }
bool layer_is_opaque() const { return layer_is_opaque_; }
+ bool layer_fills_bounds_completely() const {
+ return layer_fills_bounds_completely_;
+ }
RenderingStatsInstrumentation* rendering_stats_instrumentation_;
int layer_id_;
// True when it is known that all output pixels will be opaque.
bool layer_is_opaque_;
+ // True when it is known that all output pixels will be filled.
+ bool layer_fills_bounds_completely_;
private:
gfx::Rect content_rect_;
diff --git a/cc/resources/layer_updater.h b/cc/resources/layer_updater.h
index 44c6765..47f4410 100644
--- a/cc/resources/layer_updater.h
+++ b/cc/resources/layer_updater.h
@@ -59,6 +59,9 @@ class CC_EXPORT LayerUpdater : public base::RefCounted<LayerUpdater> {
// Set true by the layer when it is known that the entire output is going to
// be opaque.
virtual void SetOpaque(bool opaque) {}
+ // Set true by the layer when it is known that the entire output bounds will
+ // be rasterized.
+ virtual void SetFillsBoundsCompletely(bool fills_bounds) {}
protected:
virtual ~LayerUpdater() {}
diff --git a/cc/resources/picture_pile.cc b/cc/resources/picture_pile.cc
index e82a23e..1af8b4c 100644
--- a/cc/resources/picture_pile.cc
+++ b/cc/resources/picture_pile.cc
@@ -147,16 +147,17 @@ PicturePile::PicturePile() {
PicturePile::~PicturePile() {
}
-bool PicturePile::Update(
- ContentLayerClient* painter,
- SkColor background_color,
- bool contents_opaque,
- const Region& invalidation,
- const gfx::Rect& visible_layer_rect,
- int frame_number,
- RenderingStatsInstrumentation* stats_instrumentation) {
+bool PicturePile::Update(ContentLayerClient* painter,
+ SkColor background_color,
+ bool contents_opaque,
+ bool contents_fill_bounds_completely,
+ const Region& invalidation,
+ const gfx::Rect& visible_layer_rect,
+ int frame_number,
+ RenderingStatsInstrumentation* stats_instrumentation) {
background_color_ = background_color;
contents_opaque_ = contents_opaque;
+ contents_fill_bounds_completely_ = contents_fill_bounds_completely;
gfx::Rect interest_rect = visible_layer_rect;
interest_rect.Inset(
diff --git a/cc/resources/picture_pile.h b/cc/resources/picture_pile.h
index d83adde..804a679 100644
--- a/cc/resources/picture_pile.h
+++ b/cc/resources/picture_pile.h
@@ -20,14 +20,14 @@ class CC_EXPORT PicturePile : public PicturePileBase {
// Re-record parts of the picture that are invalid.
// Invalidations are in layer space.
// Return true iff the pile was modified.
- bool Update(
- ContentLayerClient* painter,
- SkColor background_color,
- bool contents_opaque,
- const Region& invalidation,
- const gfx::Rect& visible_layer_rect,
- int frame_number,
- RenderingStatsInstrumentation* stats_instrumentation);
+ bool Update(ContentLayerClient* painter,
+ SkColor background_color,
+ bool contents_opaque,
+ bool contents_fill_bounds_completely,
+ const Region& invalidation,
+ const gfx::Rect& visible_layer_rect,
+ int frame_number,
+ RenderingStatsInstrumentation* stats_instrumentation);
void set_slow_down_raster_scale_factor(int factor) {
slow_down_raster_scale_factor_for_debug_ = factor;
diff --git a/cc/resources/picture_pile_base.cc b/cc/resources/picture_pile_base.cc
index ee2f519..2fb6ef5 100644
--- a/cc/resources/picture_pile_base.cc
+++ b/cc/resources/picture_pile_base.cc
@@ -43,6 +43,7 @@ PicturePileBase::PicturePileBase()
background_color_(SkColorSetARGBInline(0, 0, 0, 0)),
slow_down_raster_scale_factor_for_debug_(0),
contents_opaque_(false),
+ contents_fill_bounds_completely_(false),
show_debug_picture_borders_(false),
clear_canvas_with_debug_color_(kDefaultClearCanvasSetting),
has_any_recordings_(false) {
@@ -62,6 +63,7 @@ PicturePileBase::PicturePileBase(const PicturePileBase* other)
slow_down_raster_scale_factor_for_debug_(
other->slow_down_raster_scale_factor_for_debug_),
contents_opaque_(other->contents_opaque_),
+ contents_fill_bounds_completely_(other->contents_fill_bounds_completely_),
show_debug_picture_borders_(other->show_debug_picture_borders_),
clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_),
has_any_recordings_(other->has_any_recordings_) {}
@@ -76,6 +78,7 @@ PicturePileBase::PicturePileBase(const PicturePileBase* other,
slow_down_raster_scale_factor_for_debug_(
other->slow_down_raster_scale_factor_for_debug_),
contents_opaque_(other->contents_opaque_),
+ contents_fill_bounds_completely_(other->contents_fill_bounds_completely_),
show_debug_picture_borders_(other->show_debug_picture_borders_),
clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_),
has_any_recordings_(other->has_any_recordings_) {
diff --git a/cc/resources/picture_pile_base.h b/cc/resources/picture_pile_base.h
index afdf1d9..be9955e 100644
--- a/cc/resources/picture_pile_base.h
+++ b/cc/resources/picture_pile_base.h
@@ -105,6 +105,7 @@ class CC_EXPORT PicturePileBase : public base::RefCounted<PicturePileBase> {
SkColor background_color_;
int slow_down_raster_scale_factor_for_debug_;
bool contents_opaque_;
+ bool contents_fill_bounds_completely_;
bool show_debug_picture_borders_;
bool clear_canvas_with_debug_color_;
// A hint about whether there are any recordings. This may be a false
diff --git a/cc/resources/picture_pile_impl.cc b/cc/resources/picture_pile_impl.cc
index 415f9a7..2e771fa 100644
--- a/cc/resources/picture_pile_impl.cc
+++ b/cc/resources/picture_pile_impl.cc
@@ -105,17 +105,13 @@ void PicturePileImpl::RasterToBitmap(
// If this picture has opaque contents, it is guaranteeing that it will
// draw an opaque rect the size of the layer. If it is not, then we must
// clear this canvas ourselves.
- if (!contents_opaque_) {
- // Clearing is about ~4x faster than drawing a rect even if the content
- // isn't covering a majority of the canvas.
- canvas->clear(SK_ColorTRANSPARENT);
- } else {
+ if (contents_opaque_) {
// Even if it is opaque, on any rasterizations that touch the edge of the
// layer, we also need to raster the background color underneath the last
// texel (since the recording won't cover it) and outside the last texel
// (due to linear filtering when using this texture).
- gfx::SizeF total_content_size = gfx::ScaleSize(tiling_.total_size(),
- contents_scale);
+ gfx::SizeF total_content_size =
+ gfx::ScaleSize(tiling_.total_size(), contents_scale);
gfx::Rect content_rect(gfx::ToCeiledSize(total_content_size));
// The final texel of content may only be partially covered by a
@@ -137,6 +133,11 @@ void PicturePileImpl::RasterToBitmap(
canvas->drawColor(background_color_, SkXfermode::kSrc_Mode);
canvas->restore();
}
+ } else if (!contents_fill_bounds_completely_) {
+ TRACE_EVENT_INSTANT0("cc", "SkCanvas::clear", TRACE_EVENT_SCOPE_THREAD);
+ // Clearing is about ~4x faster than drawing a rect even if the content
+ // isn't covering a majority of the canvas.
+ canvas->clear(SK_ColorTRANSPARENT);
}
RasterCommon(canvas,
diff --git a/cc/resources/picture_pile_unittest.cc b/cc/resources/picture_pile_unittest.cc
index 5c1a57ad..c64d420 100644
--- a/cc/resources/picture_pile_unittest.cc
+++ b/cc/resources/picture_pile_unittest.cc
@@ -56,6 +56,7 @@ class PicturePileTest : public testing::Test {
return pile_->Update(&client_,
background_color_,
contents_opaque_,
+ false,
invalidation,
visible_layer_rect,
frame_number_,
diff --git a/cc/test/fake_content_layer_client.cc b/cc/test/fake_content_layer_client.cc
index 563e945..2d1c304 100644
--- a/cc/test/fake_content_layer_client.cc
+++ b/cc/test/fake_content_layer_client.cc
@@ -39,4 +39,6 @@ void FakeContentLayerClient::PaintContents(SkCanvas* canvas,
}
}
+bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; }
+
} // namespace cc
diff --git a/cc/test/fake_content_layer_client.h b/cc/test/fake_content_layer_client.h
index 1f8a1c6..8410f3e 100644
--- a/cc/test/fake_content_layer_client.h
+++ b/cc/test/fake_content_layer_client.h
@@ -31,6 +31,7 @@ class FakeContentLayerClient : public ContentLayerClient {
const gfx::Rect& rect,
gfx::RectF* opaque_rect) OVERRIDE;
virtual void DidChangeLayerCanUseLCDText() OVERRIDE {}
+ virtual bool FillsBoundsCompletely() const OVERRIDE;
void set_paint_all_opaque(bool opaque) { paint_all_opaque_ = opaque; }
diff --git a/cc/test/solid_color_content_layer_client.cc b/cc/test/solid_color_content_layer_client.cc
index 2f0d1df..5e9d37e 100644
--- a/cc/test/solid_color_content_layer_client.cc
+++ b/cc/test/solid_color_content_layer_client.cc
@@ -26,4 +26,8 @@ void SolidColorContentLayerClient::PaintContents(
*opaque_rect = rect;
}
+bool SolidColorContentLayerClient::FillsBoundsCompletely() const {
+ return false;
+}
+
} // namespace cc
diff --git a/cc/test/solid_color_content_layer_client.h b/cc/test/solid_color_content_layer_client.h
index eaca9e7..d854004 100644
--- a/cc/test/solid_color_content_layer_client.h
+++ b/cc/test/solid_color_content_layer_client.h
@@ -20,6 +20,7 @@ class SolidColorContentLayerClient : public ContentLayerClient {
virtual void PaintContents(SkCanvas* canvas,
const gfx::Rect& rect,
gfx::RectF* opaque_rect) OVERRIDE;
+ virtual bool FillsBoundsCompletely() const OVERRIDE;
private:
SkColor color_;
diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc
index d6c7cf7..377dc86 100644
--- a/cc/trees/layer_tree_host_common_unittest.cc
+++ b/cc/trees/layer_tree_host_common_unittest.cc
@@ -199,6 +199,7 @@ class MockContentLayerClient : public ContentLayerClient {
const gfx::Rect& clip,
gfx::RectF* opaque) OVERRIDE {}
virtual void DidChangeLayerCanUseLCDText() OVERRIDE {}
+ virtual bool FillsBoundsCompletely() const OVERRIDE { return false; }
};
scoped_refptr<ContentLayer> CreateDrawableContentLayer(
diff --git a/cc/trees/layer_tree_host_pixeltest_masks.cc b/cc/trees/layer_tree_host_pixeltest_masks.cc
index 4e07199..08c16f1 100644
--- a/cc/trees/layer_tree_host_pixeltest_masks.cc
+++ b/cc/trees/layer_tree_host_pixeltest_masks.cc
@@ -24,6 +24,8 @@ class MaskContentLayerClient : public ContentLayerClient {
virtual void DidChangeLayerCanUseLCDText() OVERRIDE {}
+ virtual bool FillsBoundsCompletely() const OVERRIDE { return false; }
+
virtual void PaintContents(SkCanvas* canvas,
const gfx::Rect& rect,
gfx::RectF* opaque_rect) OVERRIDE {
diff --git a/cc/trees/layer_tree_host_pixeltest_on_demand_raster.cc b/cc/trees/layer_tree_host_pixeltest_on_demand_raster.cc
index 5164027..8f6242d 100644
--- a/cc/trees/layer_tree_host_pixeltest_on_demand_raster.cc
+++ b/cc/trees/layer_tree_host_pixeltest_on_demand_raster.cc
@@ -63,6 +63,8 @@ class BlueYellowLayerClient : public ContentLayerClient {
virtual void DidChangeLayerCanUseLCDText() OVERRIDE { }
+ virtual bool FillsBoundsCompletely() const OVERRIDE { return false; }
+
virtual void PaintContents(SkCanvas* canvas,
const gfx::Rect& clip,
gfx::RectF* opaque) OVERRIDE {
diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc
index da53dc3..f94cfd5 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -1313,6 +1313,7 @@ class TestOpacityChangeLayerDelegate : public ContentLayerClient {
test_layer_->SetOpacity(0.f);
}
virtual void DidChangeLayerCanUseLCDText() OVERRIDE {}
+ virtual bool FillsBoundsCompletely() const OVERRIDE { return false; }
private:
Layer* test_layer_;
@@ -2595,6 +2596,7 @@ class LayerTreeHostTestLCDNotification : public LayerTreeHostTest {
++lcd_notification_count_;
layer_->SetNeedsDisplay();
}
+ virtual bool FillsBoundsCompletely() const OVERRIDE { return false; }
private:
Layer* layer_;
@@ -2834,6 +2836,8 @@ class LayerTreeHostTestChangeLayerPropertiesInPaintContents
virtual void DidChangeLayerCanUseLCDText() OVERRIDE {}
+ virtual bool FillsBoundsCompletely() const OVERRIDE { return false; }
+
private:
Layer* layer_;
};
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<Window*>(
static_cast<const Window*>(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<ui::Layer> 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<cc::Layer> 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() {
diff --git a/webkit/renderer/compositor_bindings/web_content_layer_impl.cc b/webkit/renderer/compositor_bindings/web_content_layer_impl.cc
index 9ae09fe..95a4b7f 100644
--- a/webkit/renderer/compositor_bindings/web_content_layer_impl.cc
+++ b/webkit/renderer/compositor_bindings/web_content_layer_impl.cc
@@ -82,4 +82,6 @@ void WebContentLayerImpl::DidChangeLayerCanUseLCDText() {
layer_->invalidate();
}
+bool WebContentLayerImpl::FillsBoundsCompletely() const { return false; }
+
} // namespace webkit
diff --git a/webkit/renderer/compositor_bindings/web_content_layer_impl.h b/webkit/renderer/compositor_bindings/web_content_layer_impl.h
index 5ff88a3..a6bb7d2 100644
--- a/webkit/renderer/compositor_bindings/web_content_layer_impl.h
+++ b/webkit/renderer/compositor_bindings/web_content_layer_impl.h
@@ -40,6 +40,7 @@ class WebContentLayerImpl : public blink::WebContentLayer,
const gfx::Rect& clip,
gfx::RectF* opaque) OVERRIDE;
virtual void DidChangeLayerCanUseLCDText() OVERRIDE;
+ virtual bool FillsBoundsCompletely() const OVERRIDE;
scoped_ptr<WebLayerImpl> layer_;
blink::WebContentLayerClient* client_;