diff options
author | alokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-31 12:35:43 +0000 |
---|---|---|
committer | alokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-31 12:35:43 +0000 |
commit | 1c10e23ec78d036c81124d3af64c04a9bc01be56 (patch) | |
tree | 64d682cbc853785d0add45e92b7e99b352620222 /cc | |
parent | a24b35beeee392ff7338dea5bba98537bfe2cf10 (diff) | |
download | chromium_src-1c10e23ec78d036c81124d3af64c04a9bc01be56.zip chromium_src-1c10e23ec78d036c81124d3af64c04a9bc01be56.tar.gz chromium_src-1c10e23ec78d036c81124d3af64c04a9bc01be56.tar.bz2 |
Consider background-color opacity for TextureLayer opaque region.
TextureLayer draws both - texture and background-color.
So take background-color opacity into account when calculating
opaque region.
BUG=236982
Review URL: https://chromiumcodereview.appspot.com/21084005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214682 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/layers/texture_layer.cc | 10 | ||||
-rw-r--r-- | cc/layers/texture_layer.h | 1 | ||||
-rw-r--r-- | cc/layers/texture_layer_impl.cc | 10 | ||||
-rw-r--r-- | cc/layers/texture_layer_impl.h | 2 | ||||
-rw-r--r-- | cc/layers/texture_layer_unittest.cc | 27 |
5 files changed, 49 insertions, 1 deletions
diff --git a/cc/layers/texture_layer.cc b/cc/layers/texture_layer.cc index 5e68802..5762f5d 100644 --- a/cc/layers/texture_layer.cc +++ b/cc/layers/texture_layer.cc @@ -232,6 +232,16 @@ void TextureLayer::PushPropertiesTo(LayerImpl* layer) { content_committed_ = DrawsContent(); } +Region TextureLayer::VisibleContentOpaqueRegion() const { + if (contents_opaque()) + return visible_content_rect(); + + if (blend_background_color_ && (SkColorGetA(background_color()) == 0xFF)) + return visible_content_rect(); + + return Region(); +} + bool TextureLayer::BlocksPendingCommit() const { // Double-buffered texture layers need to be blocked until they can be made // triple-buffered. Single-buffered layers already prevent draws, so diff --git a/cc/layers/texture_layer.h b/cc/layers/texture_layer.h index d87a9d3..9e63b68 100644 --- a/cc/layers/texture_layer.h +++ b/cc/layers/texture_layer.h @@ -82,6 +82,7 @@ class CC_EXPORT TextureLayer : public Layer { virtual bool Update(ResourceUpdateQueue* queue, const OcclusionTracker* occlusion) OVERRIDE; virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; + virtual Region VisibleContentOpaqueRegion() const OVERRIDE; virtual bool BlocksPendingCommit() const OVERRIDE; virtual bool CanClipSelf() const OVERRIDE; diff --git a/cc/layers/texture_layer_impl.cc b/cc/layers/texture_layer_impl.cc index cf314ec..851bf9a 100644 --- a/cc/layers/texture_layer_impl.cc +++ b/cc/layers/texture_layer_impl.cc @@ -194,6 +194,16 @@ void TextureLayerImpl::DidDraw(ResourceProvider* resource_provider) { external_texture_resource_ = 0; } +Region TextureLayerImpl::VisibleContentOpaqueRegion() const { + if (contents_opaque()) + return visible_content_rect(); + + if (blend_background_color_ && (SkColorGetA(background_color()) == 0xFF)) + return visible_content_rect(); + + return Region(); +} + void TextureLayerImpl::DidLoseOutputSurface() { if (external_texture_resource_ && !uses_mailbox_) { ResourceProvider* resource_provider = diff --git a/cc/layers/texture_layer_impl.h b/cc/layers/texture_layer_impl.h index 8863015..f857206 100644 --- a/cc/layers/texture_layer_impl.h +++ b/cc/layers/texture_layer_impl.h @@ -32,7 +32,7 @@ class CC_EXPORT TextureLayerImpl : public LayerImpl { virtual void AppendQuads(QuadSink* quad_sink, AppendQuadsData* append_quads_data) OVERRIDE; virtual void DidDraw(ResourceProvider* resource_provider) OVERRIDE; - + virtual Region VisibleContentOpaqueRegion() const OVERRIDE; virtual void DidLoseOutputSurface() OVERRIDE; unsigned texture_id() const { return texture_id_; } diff --git a/cc/layers/texture_layer_unittest.cc b/cc/layers/texture_layer_unittest.cc index cbb66db..1c07e82 100644 --- a/cc/layers/texture_layer_unittest.cc +++ b/cc/layers/texture_layer_unittest.cc @@ -204,6 +204,33 @@ TEST_F(TextureLayerTest, CheckPropertyChangeCausesCorrectBehavior) { EXPECT_CALL(*layer_tree_host_, AcquireLayerTextures()).Times(AnyNumber()); } +TEST_F(TextureLayerTest, VisibleContentOpaqueRegion) { + const gfx::Size layer_bounds(100, 100); + const gfx::Rect layer_rect(layer_bounds); + const Region layer_region(layer_rect); + + scoped_refptr<TextureLayer> layer = TextureLayer::Create(NULL); + layer->SetBounds(layer_bounds); + layer->draw_properties().visible_content_rect = layer_rect; + layer->SetBlendBackgroundColor(true); + + // Verify initial conditions. + EXPECT_FALSE(layer->contents_opaque()); + EXPECT_EQ(0u, layer->background_color()); + EXPECT_EQ(Region().ToString(), + layer->VisibleContentOpaqueRegion().ToString()); + + // Opaque background. + layer->SetBackgroundColor(SK_ColorWHITE); + EXPECT_EQ(layer_region.ToString(), + layer->VisibleContentOpaqueRegion().ToString()); + + // Transparent background. + layer->SetBackgroundColor(SkColorSetARGB(100, 255, 255, 255)); + EXPECT_EQ(Region().ToString(), + layer->VisibleContentOpaqueRegion().ToString()); +} + class FakeTextureLayerClient : public TextureLayerClient { public: FakeTextureLayerClient() : context_(TestWebGraphicsContext3D::Create()) {} |