diff options
author | jun.a.jiang@intel.com <jun.a.jiang@intel.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-05 04:59:04 +0000 |
---|---|---|
committer | jun.a.jiang@intel.com <jun.a.jiang@intel.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-05 04:59:04 +0000 |
commit | 0a7465e3c2aec71ebdec2a9569542adc3fbe2f30 (patch) | |
tree | 61c6912b53fd19077e5a6043939c20a9b490c561 | |
parent | 89c20ffd91a6a98d79439ccdd1785b343c34b1db (diff) | |
download | chromium_src-0a7465e3c2aec71ebdec2a9569542adc3fbe2f30.zip chromium_src-0a7465e3c2aec71ebdec2a9569542adc3fbe2f30.tar.gz chromium_src-0a7465e3c2aec71ebdec2a9569542adc3fbe2f30.tar.bz2 |
Remove PerformClipping(),CanClipSelf() and the related logic in LTHCommon.
There is a precision lost issue for texture layers with CSS
transforms(Scaling) when applying TextureDrawQuad::PerformClipping()
to avoid explicitly setting a scissor. The rect is first divided by
the scale_factor, then round to integer value and finally multiplied
by the scale_factor in GLRenderer::EnqueueTextureQuad(). The round
process loses precision and the later scale operation enlarges the
error. This error leads to wrong width and height drawn and
introduces visual defects.
BUG=240259
Review URL: https://codereview.chromium.org/24427006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@227177 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | cc/layers/draw_properties.h | 5 | ||||
-rw-r--r-- | cc/layers/layer.cc | 4 | ||||
-rw-r--r-- | cc/layers/layer.h | 2 | ||||
-rw-r--r-- | cc/layers/layer_impl.cc | 4 | ||||
-rw-r--r-- | cc/layers/layer_impl.h | 2 | ||||
-rw-r--r-- | cc/layers/texture_layer.cc | 4 | ||||
-rw-r--r-- | cc/layers/texture_layer.h | 2 | ||||
-rw-r--r-- | cc/layers/texture_layer_impl.cc | 11 | ||||
-rw-r--r-- | cc/layers/texture_layer_impl.h | 2 | ||||
-rw-r--r-- | cc/quads/draw_quad_unittest.cc | 96 | ||||
-rw-r--r-- | cc/quads/texture_draw_quad.cc | 74 | ||||
-rw-r--r-- | cc/quads/texture_draw_quad.h | 2 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_common.cc | 23 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_common_unittest.cc | 156 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_pixeltest_readback.cc | 40 |
15 files changed, 5 insertions, 422 deletions
diff --git a/cc/layers/draw_properties.h b/cc/layers/draw_properties.h index 181d900..06c8834 100644 --- a/cc/layers/draw_properties.h +++ b/cc/layers/draw_properties.h @@ -28,7 +28,6 @@ struct CC_EXPORT DrawProperties { contents_scale_y(1.f), num_descendants_that_draw_content(0), num_unclipped_descendants(0), - descendants_can_clip_selves(false), can_draw_directly_to_backbuffer(false), layer_or_descendant_has_copy_request(false) {} @@ -93,10 +92,6 @@ struct CC_EXPORT DrawProperties { // does not include our clip children because they are clipped by us. int num_unclipped_descendants; - // If true, every descendant in the sub-tree can clip itself without the - // need to use hardware sissoring or a new render target. - bool descendants_can_clip_selves; - bool can_draw_directly_to_backbuffer; // If true, the layer or some layer in its sub-tree has a CopyOutputRequest diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc index b505362..5a9f859 100644 --- a/cc/layers/layer.cc +++ b/cc/layers/layer.cc @@ -206,10 +206,6 @@ skia::RefPtr<SkPicture> Layer::GetPicture() const { return skia::RefPtr<SkPicture>(); } -bool Layer::CanClipSelf() const { - return false; -} - void Layer::SetParent(Layer* layer) { DCHECK(!layer || !layer->HasAncestor(this)); diff --git a/cc/layers/layer.h b/cc/layers/layer.h index e710e2d7..6e86d3e 100644 --- a/cc/layers/layer.h +++ b/cc/layers/layer.h @@ -397,8 +397,6 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>, virtual skia::RefPtr<SkPicture> GetPicture() const; - virtual bool CanClipSelf() const; - // Constructs a LayerImpl of the correct runtime type for this Layer type. virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl); diff --git a/cc/layers/layer_impl.cc b/cc/layers/layer_impl.cc index 6f230e6..847b450 100644 --- a/cc/layers/layer_impl.cc +++ b/cc/layers/layer_impl.cc @@ -472,10 +472,6 @@ skia::RefPtr<SkPicture> LayerImpl::GetPicture() { return skia::RefPtr<SkPicture>(); } -bool LayerImpl::CanClipSelf() const { - return false; -} - bool LayerImpl::AreVisibleResourcesReady() const { return true; } diff --git a/cc/layers/layer_impl.h b/cc/layers/layer_impl.h index 616810f..d583cd7 100644 --- a/cc/layers/layer_impl.h +++ b/cc/layers/layer_impl.h @@ -466,8 +466,6 @@ class CC_EXPORT LayerImpl : LayerAnimationValueObserver { virtual skia::RefPtr<SkPicture> GetPicture(); - virtual bool CanClipSelf() const; - virtual bool AreVisibleResourcesReady() const; virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl); diff --git a/cc/layers/texture_layer.cc b/cc/layers/texture_layer.cc index 340526e..18410fb 100644 --- a/cc/layers/texture_layer.cc +++ b/cc/layers/texture_layer.cc @@ -268,10 +268,6 @@ Region TextureLayer::VisibleContentOpaqueRegion() const { return Region(); } -bool TextureLayer::CanClipSelf() const { - return true; -} - TextureLayer::MailboxHolder::MainThreadReference::MainThreadReference( MailboxHolder* holder) : holder_(holder) { diff --git a/cc/layers/texture_layer.h b/cc/layers/texture_layer.h index 5fb214c..b0edb22 100644 --- a/cc/layers/texture_layer.h +++ b/cc/layers/texture_layer.h @@ -143,8 +143,6 @@ class CC_EXPORT TextureLayer : public Layer { virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; virtual Region VisibleContentOpaqueRegion() const OVERRIDE; - virtual bool CanClipSelf() const OVERRIDE; - protected: TextureLayer(TextureLayerClient* client, bool uses_mailbox); virtual ~TextureLayer(); diff --git a/cc/layers/texture_layer_impl.cc b/cc/layers/texture_layer_impl.cc index e16fd3c..98837b8 100644 --- a/cc/layers/texture_layer_impl.cc +++ b/cc/layers/texture_layer_impl.cc @@ -183,12 +183,7 @@ void TextureLayerImpl::AppendQuads(QuadSink* quad_sink, bg_color, vertex_opacity_, flipped_); - - // Perform explicit clipping on a quad to avoid setting a scissor later. - if (shared_quad_state->is_clipped && quad->PerformClipping()) - shared_quad_state->is_clipped = false; - if (!quad->rect.IsEmpty()) - quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); + quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); } void TextureLayerImpl::DidDraw(ResourceProvider* resource_provider) { @@ -229,10 +224,6 @@ const char* TextureLayerImpl::LayerTypeAsString() const { return "cc::TextureLayerImpl"; } -bool TextureLayerImpl::CanClipSelf() const { - return true; -} - void TextureLayerImpl::FreeTextureMailbox() { if (!uses_mailbox_) return; diff --git a/cc/layers/texture_layer_impl.h b/cc/layers/texture_layer_impl.h index 90c2692..c20d960 100644 --- a/cc/layers/texture_layer_impl.h +++ b/cc/layers/texture_layer_impl.h @@ -60,8 +60,6 @@ class CC_EXPORT TextureLayerImpl : public LayerImpl { vertex_opacity_[3] = vertex_opacity[3]; } - virtual bool CanClipSelf() const OVERRIDE; - void SetTextureMailbox(const TextureMailbox& mailbox, scoped_ptr<SingleReleaseCallback> release_callback); diff --git a/cc/quads/draw_quad_unittest.cc b/cc/quads/draw_quad_unittest.cc index 08a1a7a..986d3d6 100644 --- a/cc/quads/draw_quad_unittest.cc +++ b/cc/quads/draw_quad_unittest.cc @@ -506,102 +506,6 @@ TEST(DrawQuadTest, CopyTextureDrawQuad) { EXPECT_EQ(flipped, copy_quad->flipped); } -TEST(DrawQuadTest, ClipTextureDrawQuad) { - gfx::Rect opaque_rect(3, 7, 10, 12); - unsigned resource_id = 82; - bool premultiplied_alpha = true; - bool flipped = true; - CREATE_SHARED_STATE(); - // The original quad position is (30, 40) its size is 50*60. - shared_state->content_to_target_transform = - gfx::Transform(1.f, 0.f, 0.f, 1.f, 10.f, 20.f); - // After transformation, the quad position is (40, 60) its size is 50*60. - shared_state->clip_rect = gfx::Rect(50, 70, 30, 20); - - // The original quad is 'ABCD', the clipped quad is 'abcd': - // 40 50 90 - // B--:-------C 60 - // | b----c -|-70 - // | | | | - // | a----d -|-90 - // | | - // A----------D 120 - // UV and vertex opacity are stored per vertex on the parent rectangle 'ABCD'. - - // This is the UV value for vertex 'B'. - gfx::PointF uv_top_left(0.1f, 0.2f); - // This is the UV value for vertex 'D'. - gfx::PointF uv_bottom_right(0.9f, 0.8f); - // This the vertex opacity for the vertices 'ABCD'. - const float vertex_opacity[] = { 0.3f, 0.4f, 0.7f, 0.8f }; - { - CREATE_QUAD_8_NEW(TextureDrawQuad, - opaque_rect, - resource_id, - premultiplied_alpha, - uv_top_left, - uv_bottom_right, - SK_ColorTRANSPARENT, - vertex_opacity, - flipped); - CREATE_QUAD_7_ALL(TextureDrawQuad, - resource_id, - premultiplied_alpha, - uv_top_left, - uv_bottom_right, - SK_ColorTRANSPARENT, - vertex_opacity, - flipped); - EXPECT_TRUE(quad_all->PerformClipping()); - - // This is the expected UV value for vertex 'b'. - // uv(b) = uv(B) + (Bb / BD) * (uv(D) - uv(B)) - // 0.3 = 0.2 + (10 / 60) * (0.8 - 0.2) - gfx::PointF uv_top_left_clipped(0.26f, 0.3f); - // This is the expected UV value for vertex 'd'. - // uv(d) = uv(B) + (Bd / BD) * (uv(D) - uv(B)) - gfx::PointF uv_bottom_right_clipped(0.74f, 0.5f); - // This the expected vertex opacity for the vertices 'abcd'. - // They are computed with a bilinear interpolation of the corner values. - const float vertex_opacity_clipped[] = { 0.43f, 0.45f, 0.65f, 0.67f }; - - EXPECT_EQ(uv_top_left_clipped, quad_all->uv_top_left); - EXPECT_EQ(uv_bottom_right_clipped, quad_all->uv_bottom_right); - EXPECT_FLOAT_ARRAY_EQ(vertex_opacity_clipped, quad_all->vertex_opacity, 4); - } - - uv_top_left = gfx::PointF(0.8f, 0.7f); - uv_bottom_right = gfx::PointF(0.2f, 0.1f); - { - CREATE_QUAD_8_NEW(TextureDrawQuad, - opaque_rect, - resource_id, - premultiplied_alpha, - uv_top_left, - uv_bottom_right, - SK_ColorTRANSPARENT, - vertex_opacity, - flipped); - CREATE_QUAD_7_ALL(TextureDrawQuad, - resource_id, - premultiplied_alpha, - uv_top_left, - uv_bottom_right, - SK_ColorTRANSPARENT, - vertex_opacity, - flipped); - EXPECT_TRUE(quad_all->PerformClipping()); - - // This is the expected UV value for vertex 'b'. - gfx::PointF uv_top_left_clipped(0.68f, 0.6f); - // This is the expected UV value for vertex 'd'. - gfx::PointF uv_bottom_right_clipped(0.32f, 0.4f); - - EXPECT_EQ(uv_top_left_clipped, quad_all->uv_top_left); - EXPECT_EQ(uv_bottom_right_clipped, quad_all->uv_bottom_right); - } -} - TEST(DrawQuadTest, CopyTileDrawQuad) { gfx::Rect opaque_rect(33, 44, 22, 33); unsigned resource_id = 104; diff --git a/cc/quads/texture_draw_quad.cc b/cc/quads/texture_draw_quad.cc index ae7cfd6..191dcc4 100644 --- a/cc/quads/texture_draw_quad.cc +++ b/cc/quads/texture_draw_quad.cc @@ -84,80 +84,6 @@ const TextureDrawQuad* TextureDrawQuad::MaterialCast(const DrawQuad* quad) { return static_cast<const TextureDrawQuad*>(quad); } -bool TextureDrawQuad::PerformClipping() { - // This only occurs if the rect is only scaled and translated (and thus still - // axis aligned). - if (!quadTransform().IsPositiveScaleOrTranslation()) - return false; - - // Grab our scale and make sure it's positive. - float x_scale = static_cast<float>(quadTransform().matrix().getDouble(0, 0)); - float y_scale = static_cast<float>(quadTransform().matrix().getDouble(1, 1)); - - // Grab our offset. - gfx::Vector2dF offset( - static_cast<float>(quadTransform().matrix().getDouble(0, 3)), - static_cast<float>(quadTransform().matrix().getDouble(1, 3))); - - // Transform the rect by the scale and offset. - gfx::RectF rect_f = rect; - rect_f.Scale(x_scale, y_scale); - rect_f += offset; - - // Perform clipping and check to see if the result is empty. - gfx::RectF clipped_rect = IntersectRects(rect_f, clipRect()); - if (clipped_rect.IsEmpty()) { - rect = gfx::Rect(); - uv_top_left = gfx::PointF(); - uv_bottom_right = gfx::PointF(); - return true; - } - - // Create a new uv-rect by clipping the old one to the new bounds. - gfx::Vector2dF uv_scale(uv_bottom_right - uv_top_left); - uv_scale.Scale(1.f / rect_f.width(), 1.f / rect_f.height()); - uv_bottom_right = uv_top_left + - gfx::ScaleVector2d( - clipped_rect.bottom_right() - rect_f.origin(), - uv_scale.x(), - uv_scale.y()); - uv_top_left = uv_top_left + - gfx::ScaleVector2d( - clipped_rect.origin() - rect_f.origin(), - uv_scale.x(), - uv_scale.y()); - - // Indexing according to the quad vertex generation: - // 1--2 - // | | - // 0--3 - if (vertex_opacity[0] != vertex_opacity[1] - || vertex_opacity[0] != vertex_opacity[2] - || vertex_opacity[0] != vertex_opacity[3]) { - const float x1 = (clipped_rect.x() - rect_f.x()) / rect_f.width(); - const float y1 = (clipped_rect.y() - rect_f.y()) / rect_f.height(); - const float x3 = (clipped_rect.right() - rect_f.x()) / rect_f.width(); - const float y3 = (clipped_rect.bottom() - rect_f.y()) / rect_f.height(); - const float x1y1 = x1 * vertex_opacity[2] + (1.0f - x1) * vertex_opacity[1]; - const float x1y3 = x1 * vertex_opacity[3] + (1.0f - x1) * vertex_opacity[0]; - const float x3y1 = x3 * vertex_opacity[2] + (1.0f - x3) * vertex_opacity[1]; - const float x3y3 = x3 * vertex_opacity[3] + (1.0f - x3) * vertex_opacity[0]; - vertex_opacity[0] = y3 * x1y3 + (1.0f - y3) * x1y1; - vertex_opacity[1] = y1 * x1y3 + (1.0f - y1) * x1y1; - vertex_opacity[2] = y1 * x3y3 + (1.0f - y1) * x3y1; - vertex_opacity[3] = y3 * x3y3 + (1.0f - y3) * x3y1; - } - - // Move the clipped rectangle back into its space. - clipped_rect -= offset; - clipped_rect.Scale(1.0f / x_scale, 1.0f / y_scale); - rect = gfx::Rect(static_cast<int>(clipped_rect.x() + 0.5f), - static_cast<int>(clipped_rect.y() + 0.5f), - static_cast<int>(clipped_rect.width() + 0.5f), - static_cast<int>(clipped_rect.height() + 0.5f)); - return true; -} - void TextureDrawQuad::ExtendValue(base::DictionaryValue* value) const { value->SetInteger("resource_id", resource_id); value->SetBoolean("premultiplied_alpha", premultiplied_alpha); diff --git a/cc/quads/texture_draw_quad.h b/cc/quads/texture_draw_quad.h index 7f06618..4aa4d7a 100644 --- a/cc/quads/texture_draw_quad.h +++ b/cc/quads/texture_draw_quad.h @@ -53,8 +53,6 @@ class CC_EXPORT TextureDrawQuad : public DrawQuad { static const TextureDrawQuad* MaterialCast(const DrawQuad*); - bool PerformClipping(); - private: TextureDrawQuad(); virtual void ExtendValue(base::DictionaryValue* value) const OVERRIDE; diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc index d483cc6..9556b68 100644 --- a/cc/trees/layer_tree_host_common.cc +++ b/cc/trees/layer_tree_host_common.cc @@ -589,7 +589,7 @@ static bool SubtreeShouldRenderToSeparateSurface( bool layer_clips_external_content = LayerClipsSubtree(layer) || layer->HasDelegatedContent(); if (layer_clips_external_content && !axis_aligned_with_respect_to_parent && - !layer->draw_properties().descendants_can_clip_selves) { + num_descendants_that_draw_content > 0) { TRACE_EVENT_INSTANT0( "cc", "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface clipping", @@ -1036,7 +1036,6 @@ static void PreCalculateMetaInformation( PreCalculateMetaInformationRecursiveData* recursive_data) { bool has_delegated_content = layer->HasDelegatedContent(); int num_descendants_that_draw_content = 0; - bool descendants_can_clip_selves = true; if (has_delegated_content) { // Layers with delegated content need to be treated as if they have as @@ -1044,7 +1043,6 @@ static void PreCalculateMetaInformation( // Since we don't know this number right now, we choose one that acts like // infinity for our purposes. num_descendants_that_draw_content = 1000; - descendants_can_clip_selves = false; } if (layer->clip_parent()) @@ -1057,20 +1055,9 @@ static void PreCalculateMetaInformation( PreCalculateMetaInformationRecursiveData data_for_child; PreCalculateMetaInformation(child_layer, &data_for_child); - if (!has_delegated_content) { - bool sublayer_transform_prevents_clip = - !layer->sublayer_transform().IsPositiveScaleOrTranslation(); - - num_descendants_that_draw_content += child_layer->DrawsContent() ? 1 : 0; - num_descendants_that_draw_content += - child_layer->draw_properties().num_descendants_that_draw_content; - - if ((child_layer->DrawsContent() && !child_layer->CanClipSelf()) || - !child_layer->draw_properties().descendants_can_clip_selves || - sublayer_transform_prevents_clip || - !child_layer->transform().IsPositiveScaleOrTranslation()) - descendants_can_clip_selves = false; - } + num_descendants_that_draw_content += child_layer->DrawsContent() ? 1 : 0; + num_descendants_that_draw_content += + child_layer->draw_properties().num_descendants_that_draw_content; recursive_data->Merge(data_for_child); } @@ -1088,8 +1075,6 @@ static void PreCalculateMetaInformation( num_descendants_that_draw_content; layer->draw_properties().num_unclipped_descendants = recursive_data->num_unclipped_descendants; - layer->draw_properties().descendants_can_clip_selves = - descendants_can_clip_selves; layer->draw_properties().layer_or_descendant_has_copy_request = recursive_data->layer_or_descendant_has_copy_request; } diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc index 40cc92a..6b02c96 100644 --- a/cc/trees/layer_tree_host_common_unittest.cc +++ b/cc/trees/layer_tree_host_common_unittest.cc @@ -186,23 +186,8 @@ class LayerWithForcedDrawsContent : public Layer { virtual ~LayerWithForcedDrawsContent() {} }; -class LayerCanClipSelf : public Layer { - public: - LayerCanClipSelf() : Layer() {} - - virtual bool DrawsContent() const OVERRIDE; - virtual bool CanClipSelf() const OVERRIDE; - - private: - virtual ~LayerCanClipSelf() {} -}; - bool LayerWithForcedDrawsContent::DrawsContent() const { return true; } -bool LayerCanClipSelf::DrawsContent() const { return true; } - -bool LayerCanClipSelf::CanClipSelf() const { return true; } - class MockContentLayerClient : public ContentLayerClient { public: MockContentLayerClient() {} @@ -850,147 +835,6 @@ TEST_F(LayerTreeHostCommonTest, SublayerTransformWithAnchorPoint) { child->draw_transform()); } -TEST_F(LayerTreeHostCommonTest, SeparateRenderTargetRequirementWithClipping) { - scoped_refptr<Layer> root = Layer::Create(); - scoped_refptr<Layer> parent = Layer::Create(); - scoped_refptr<Layer> child = Layer::Create(); - scoped_refptr<Layer> grand_child = make_scoped_refptr(new LayerCanClipSelf()); - root->AddChild(parent); - parent->AddChild(child); - child->AddChild(grand_child); - parent->SetMasksToBounds(true); - child->SetMasksToBounds(true); - - scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); - host->SetRootLayer(root); - - gfx::Transform identity_matrix; - gfx::Transform parent_layer_transform; - gfx::Transform parent_sublayer_matrix; - gfx::Transform child_layer_matrix; - - // No render surface should exist yet. - EXPECT_FALSE(root->render_surface()); - EXPECT_FALSE(parent->render_surface()); - EXPECT_FALSE(child->render_surface()); - EXPECT_FALSE(grand_child->render_surface()); - - // One-time setup of root layer - parent_layer_transform.Scale3d(1.f, 0.9f, 1.f); - parent_sublayer_matrix.Scale3d(0.9f, 1.f, 3.3f); - child_layer_matrix.Rotate(20.0); - - SetLayerPropertiesForTesting(root.get(), - identity_matrix, - identity_matrix, - gfx::PointF(), - gfx::PointF(), - gfx::Size(1, 2), - false); - SetLayerPropertiesForTesting(parent.get(), - parent_layer_transform, - parent_sublayer_matrix, - gfx::PointF(0.25f, 0.25f), - gfx::PointF(), - gfx::Size(100, 120), - false); - SetLayerPropertiesForTesting(child.get(), - child_layer_matrix, - identity_matrix, - gfx::PointF(), - gfx::PointF(), - gfx::Size(16, 18), - false); - SetLayerPropertiesForTesting(grand_child.get(), - identity_matrix, - identity_matrix, - gfx::PointF(), - gfx::PointF(), - gfx::Size(8, 10), - false); - - ExecuteCalculateDrawProperties(root.get()); - - // Render surfaces should have been created according to clipping rules now - // (grandchild can clip self). - EXPECT_TRUE(root->render_surface()); - EXPECT_FALSE(parent->render_surface()); - EXPECT_FALSE(child->render_surface()); - EXPECT_FALSE(grand_child->render_surface()); -} - -TEST_F(LayerTreeHostCommonTest, - SeparateRenderTargetRequirementWithoutClipping) { - scoped_refptr<Layer> root = Layer::Create(); - scoped_refptr<Layer> parent = Layer::Create(); - scoped_refptr<Layer> child = Layer::Create(); - // This layer cannot clip itself, a feature we are testing here. - scoped_refptr<Layer> grand_child = - make_scoped_refptr(new LayerWithForcedDrawsContent()); - root->AddChild(parent); - parent->AddChild(child); - child->AddChild(grand_child); - parent->SetMasksToBounds(true); - child->SetMasksToBounds(true); - - scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); - host->SetRootLayer(root); - - gfx::Transform identity_matrix; - gfx::Transform parent_layer_transform; - gfx::Transform parent_sublayer_matrix; - gfx::Transform child_layer_matrix; - - // No render surface should exist yet. - EXPECT_FALSE(root->render_surface()); - EXPECT_FALSE(parent->render_surface()); - EXPECT_FALSE(child->render_surface()); - EXPECT_FALSE(grand_child->render_surface()); - - // One-time setup of root layer - parent_layer_transform.Scale3d(1.f, 0.9f, 1.f); - parent_sublayer_matrix.Scale3d(0.9f, 1.f, 3.3f); - child_layer_matrix.Rotate(20.0); - - SetLayerPropertiesForTesting(root.get(), - identity_matrix, - identity_matrix, - gfx::PointF(), - gfx::PointF(), - gfx::Size(1, 2), - false); - SetLayerPropertiesForTesting(parent.get(), - parent_layer_transform, - parent_sublayer_matrix, - gfx::PointF(0.25f, 0.25f), - gfx::PointF(), - gfx::Size(100, 120), - false); - SetLayerPropertiesForTesting(child.get(), - child_layer_matrix, - identity_matrix, - gfx::PointF(), - gfx::PointF(), - gfx::Size(16, 18), - false); - SetLayerPropertiesForTesting(grand_child.get(), - identity_matrix, - identity_matrix, - gfx::PointF(), - gfx::PointF(), - gfx::Size(8, 10), - false); - - ExecuteCalculateDrawProperties(root.get()); - - // Render surfaces should have been created according to clipping rules now - // (grandchild can't clip self). - EXPECT_TRUE(root->render_surface()); - EXPECT_FALSE(parent->render_surface()); - EXPECT_TRUE(child->render_surface()); - EXPECT_FALSE(grand_child->render_surface()); -} - TEST_F(LayerTreeHostCommonTest, TransformsForReplica) { scoped_refptr<Layer> root = Layer::Create(); scoped_refptr<Layer> parent = Layer::Create(); diff --git a/cc/trees/layer_tree_host_pixeltest_readback.cc b/cc/trees/layer_tree_host_pixeltest_readback.cc index d8e2861..9ee45ec 100644 --- a/cc/trees/layer_tree_host_pixeltest_readback.cc +++ b/cc/trees/layer_tree_host_pixeltest_readback.cc @@ -992,46 +992,6 @@ TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayerOutsideViewport) { "green_with_blue_corner.png"))); } -// TextureLayers are clipped differently than SolidColorLayers, verify they -// also can be copied when outside of the viewport. -TEST_F(LayerTreeHostReadbackPixelTest, - ReadbackNonRootTextureLayerOutsideViewport) { - scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( - gfx::Rect(200, 200), SK_ColorWHITE); - - SkBitmap bitmap; - bitmap.setConfig(SkBitmap::kARGB_8888_Config, 200, 200); - bitmap.allocPixels(); - bitmap.eraseColor(SK_ColorGREEN); - { - SkBitmapDevice device(bitmap); - skia::RefPtr<SkCanvas> canvas = skia::AdoptRef(new SkCanvas(&device)); - SkPaint paint; - paint.setStyle(SkPaint::kFill_Style); - paint.setColor(SK_ColorBLUE); - canvas->drawRect(SkRect::MakeXYWH(150, 150, 50, 50), paint); - } - - scoped_refptr<TextureLayer> texture = CreateTextureLayer( - gfx::Rect(200, 200), bitmap); - - // Tests with solid color layers verify correctness when CanClipSelf is false. - EXPECT_FALSE(background->CanClipSelf()); - // This test verifies correctness when CanClipSelf is true. - EXPECT_TRUE(texture->CanClipSelf()); - - // Only the top left quarter of the layer is inside the viewport, so the - // blue corner is entirely outside. - texture->SetPosition(gfx::Point(100, 100)); - background->AddChild(texture); - - RunPixelTestWithReadbackTarget(GL_WITH_DEFAULT, - background, - texture.get(), - base::FilePath(FILE_PATH_LITERAL( - "green_with_blue_corner.png"))); -} - } // namespace } // namespace cc |