Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(806)

Unified Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 2018983003: cc: Use FilterOperations::MapRect in RenderSurfaceImpl::DrawableContentRect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove logging Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/layers/render_surface_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_common_unittest.cc
diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc
index a115de7c112bf0eab1388ceed14c2e7eadd1211e..3565848489f42a37e77ea103fff276fa487e27f2 100644
--- a/cc/trees/layer_tree_host_common_unittest.cc
+++ b/cc/trees/layer_tree_host_common_unittest.cc
@@ -46,6 +46,7 @@
#include "cc/trees/task_runner_provider.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/skia/include/effects/SkOffsetImageFilter.h"
#include "ui/gfx/geometry/quad_f.h"
#include "ui/gfx/geometry/vector2d_conversions.h"
#include "ui/gfx/transform.h"
@@ -1407,10 +1408,72 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceListForFilter) {
ASSERT_TRUE(parent->render_surface());
EXPECT_EQ(2U, parent->render_surface()->layer_list().size());
EXPECT_EQ(4U, render_surface_layer_list.size());
- EXPECT_EQ(gfx::RectF(-30, -30, 160, 160),
+
+ // The rectangle enclosing child1 and child2 (0,0 50x50), expanded for the
+ // blur (-30,-30 110x110), and then scaled by the scale matrix
+ // (-60,-60 220x220).
ajuma 2016/06/06 18:08:21 Thanks for adding this comment (and for the simila
+ EXPECT_EQ(gfx::RectF(-60, -60, 220, 220),
parent->render_surface()->DrawableContentRect());
}
+TEST_F(LayerTreeHostCommonTest, DrawableContentRectForReferenceFilter) {
+ LayerImpl* root = root_layer();
+ LayerImpl* child = AddChild<LayerImpl>(root);
+ child->SetDrawsContent(true);
+
+ SetLayerPropertiesForTesting(root, gfx::Transform(), gfx::Point3F(),
+ gfx::PointF(), gfx::Size(100, 100), true, false,
+ true);
+ SetLayerPropertiesForTesting(child, gfx::Transform(), gfx::Point3F(),
+ gfx::PointF(), gfx::Size(25, 25), true, false,
+ true);
+
+ FilterOperations filters;
+ filters.Append(FilterOperation::CreateReferenceFilter(
+ SkOffsetImageFilter::Make(50, 50, nullptr)));
+ child->SetFilters(filters);
+
+ ExecuteCalculateDrawProperties(root);
+
+ // The render surface's size should be unaffected by the offset image filter;
+ // it need only have a drawable content rect large enough to contain the
+ // contents (at the new offset).
+ ASSERT_TRUE(child->render_surface());
+ EXPECT_EQ(gfx::RectF(50, 50, 25, 25),
+ child->render_surface()->DrawableContentRect());
+}
+
+TEST_F(LayerTreeHostCommonTest, DrawableContentRectForReferenceFilterHighDpi) {
+ const float device_scale_factor = 2.0f;
+
+ LayerImpl* root = root_layer();
+ root->layer_tree_impl()->SetDeviceScaleFactor(device_scale_factor);
+ LayerImpl* child = AddChild<LayerImpl>(root);
+ child->SetDrawsContent(true);
+
+ SetLayerPropertiesForTesting(root, gfx::Transform(), gfx::Point3F(),
+ gfx::PointF(), gfx::Size(100, 100), true, false,
+ true);
+ SetLayerPropertiesForTesting(child, gfx::Transform(), gfx::Point3F(),
+ gfx::PointF(), gfx::Size(25, 25), true, false,
+ true);
+
+ FilterOperations filters;
+ filters.Append(FilterOperation::CreateReferenceFilter(
+ SkOffsetImageFilter::Make(50, 50, nullptr)));
+ child->SetFilters(filters);
+
+ ExecuteCalculateDrawProperties(root, device_scale_factor);
+
+ // The render surface's size should be unaffected by the offset image filter;
+ // it need only have a drawable content rect large enough to contain the
+ // contents (at the new offset). All coordinates should be scaled by 2,
+ // corresponding to the device scale factor.
+ ASSERT_TRUE(child->render_surface());
+ EXPECT_EQ(gfx::RectF(100, 100, 50, 50),
+ child->render_surface()->DrawableContentRect());
+}
+
TEST_F(LayerTreeHostCommonTest, RenderSurfaceForBlendMode) {
LayerImpl* parent = root_layer();
LayerImpl* child = AddChild<LayerImpl>(parent);
« no previous file with comments | « cc/layers/render_surface_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698