diff options
author | jbauman <jbauman@chromium.org> | 2015-04-29 16:32:26 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-29 23:32:58 +0000 |
commit | de1a409ab85bbef1f04c0f964cae51769c0d9d3a (patch) | |
tree | aee2c0424116779af06b0640f3aec43bfe5c4532 /ui/compositor | |
parent | e97afea15200ca0d74f652015f0c4b5086fb71e9 (diff) | |
download | chromium_src-de1a409ab85bbef1f04c0f964cae51769c0d9d3a.zip chromium_src-de1a409ab85bbef1f04c0f964cae51769c0d9d3a.tar.gz chromium_src-de1a409ab85bbef1f04c0f964cae51769c0d9d3a.tar.bz2 |
Set background color on recreated solid color layers.
If no frame has been received from the renderer then the layer will be a SolidColorLayer and a background color needs to be set on it.
BUG=477626,469850
Review URL: https://codereview.chromium.org/1107273003
Cr-Commit-Position: refs/heads/master@{#327616}
Diffstat (limited to 'ui/compositor')
-rw-r--r-- | ui/compositor/layer.cc | 8 | ||||
-rw-r--r-- | ui/compositor/layer.h | 2 | ||||
-rw-r--r-- | ui/compositor/layer_owner.cc | 2 | ||||
-rw-r--r-- | ui/compositor/layer_owner_unittest.cc | 8 |
4 files changed, 18 insertions, 2 deletions
diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc index 2b6f921..ebafff0 100644 --- a/ui/compositor/layer.cc +++ b/ui/compositor/layer.cc @@ -652,6 +652,14 @@ void Layer::UpdateNinePatchLayerBorder(const gfx::Rect& border) { void Layer::SetColor(SkColor color) { GetAnimator()->SetColor(color); } +SkColor Layer::GetTargetColor() { + return GetAnimator()->GetTargetColor(); +} + +SkColor Layer::background_color() const { + return cc_layer_->background_color(); +} + bool Layer::SchedulePaint(const gfx::Rect& invalid_rect) { if ((type_ == LAYER_SOLID_COLOR && !texture_layer_.get()) || type_ == LAYER_NINE_PATCH || (!delegate_ && !mailbox_.IsValid())) diff --git a/ui/compositor/layer.h b/ui/compositor/layer.h index bb8b1af..4180034 100644 --- a/ui/compositor/layer.h +++ b/ui/compositor/layer.h @@ -301,6 +301,8 @@ class COMPOSITOR_EXPORT Layer // Sets the layer's fill color. May only be called for LAYER_SOLID_COLOR. void SetColor(SkColor color); + SkColor GetTargetColor(); + SkColor background_color() const; // Updates the nine patch layer's image, aperture and border. May only be // called for LAYER_NINE_PATCH. diff --git a/ui/compositor/layer_owner.cc b/ui/compositor/layer_owner.cc index 55ba0f3..227dfa9 100644 --- a/ui/compositor/layer_owner.cc +++ b/ui/compositor/layer_owner.cc @@ -46,6 +46,8 @@ scoped_ptr<Layer> LayerOwner::RecreateLayer() { new_layer->SetFillsBoundsOpaquely(old_layer->fills_bounds_opaquely()); new_layer->SetFillsBoundsCompletely(old_layer->FillsBoundsCompletely()); new_layer->SetSubpixelPositionOffset(old_layer->subpixel_position_offset()); + if (old_layer->type() == LAYER_SOLID_COLOR) + new_layer->SetColor(old_layer->GetTargetColor()); SkRegion* alpha_shape = old_layer->alpha_shape(); if (alpha_shape) new_layer->SetAlphaShape(make_scoped_ptr(new SkRegion(*alpha_shape))); diff --git a/ui/compositor/layer_owner_unittest.cc b/ui/compositor/layer_owner_unittest.cc index 60e1038..2cb8415 100644 --- a/ui/compositor/layer_owner_unittest.cc +++ b/ui/compositor/layer_owner_unittest.cc @@ -58,23 +58,27 @@ void LayerOwnerTestWithCompositor::TearDown() { } // namespace -TEST(LayerOwnerTest, RecreateLayerHonorsTargetVisibilityAndOpacity) { +TEST(LayerOwnerTest, RecreateLayerHonorsAnimationTargets) { LayerOwner owner; - Layer* layer = new Layer; + Layer* layer = new Layer(LAYER_SOLID_COLOR); layer->SetVisible(true); layer->SetOpacity(1.0f); + layer->SetColor(SK_ColorRED); owner.SetLayer(layer); ScopedLayerAnimationSettings settings(layer->GetAnimator()); layer->SetVisible(false); layer->SetOpacity(0.0f); + layer->SetColor(SK_ColorGREEN); EXPECT_TRUE(layer->visible()); EXPECT_EQ(1.0f, layer->opacity()); + EXPECT_EQ(SK_ColorRED, layer->background_color()); scoped_ptr<Layer> old_layer(owner.RecreateLayer()); EXPECT_FALSE(owner.layer()->visible()); EXPECT_EQ(0.0f, owner.layer()->opacity()); + EXPECT_EQ(SK_ColorGREEN, owner.layer()->background_color()); } TEST(LayerOwnerTest, RecreateRootLayerWithNullCompositor) { |