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

Unified Diff: cc/layers/delegated_renderer_layer_impl_unittest.cc

Issue 311253004: Invert DSF to map from delegated frame to layer space (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix up math in d_r_l_impl_unittest Created 6 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
Index: cc/layers/delegated_renderer_layer_impl_unittest.cc
diff --git a/cc/layers/delegated_renderer_layer_impl_unittest.cc b/cc/layers/delegated_renderer_layer_impl_unittest.cc
index 3f30d15a3b79651463f9e31df14ad4a86b8e3002..9d962b74c61165ddf854c43751c5c348cd39c4c4 100644
--- a/cc/layers/delegated_renderer_layer_impl_unittest.cc
+++ b/cc/layers/delegated_renderer_layer_impl_unittest.cc
@@ -245,11 +245,8 @@ TEST_F(DelegatedRendererLayerImplTestSimple,
// The DelegatedRendererLayer is at position 3,3 compared to its target, and
// has a translation transform of 1,1. So its root RenderPass' quads should
// all be transformed by that combined amount.
- // The DelegatedRendererLayer has a size of 10x10, but the root delegated
- // RenderPass has a size of 8x8, so any quads should be scaled by 10/8.
gfx::Transform transform;
transform.Translate(4.0, 4.0);
- transform.Scale(10.0 / 8.0, 10.0 / 8.0);
EXPECT_TRANSFORMATION_MATRIX_EQ(
transform, frame.render_passes[3]->quad_list[0]->quadTransform());
@@ -280,12 +277,8 @@ TEST_F(DelegatedRendererLayerImplTestSimple, RenderPassTransformIsModified) {
// The DelegatedRendererLayer is at position 9,9 compared to the root, so all
// render pass' transforms to the root should be shifted by this amount.
- // The DelegatedRendererLayer has a size of 10x10, but the root delegated
- // RenderPass has a size of 8x8, so any render passes should be scaled by
- // 10/8.
gfx::Transform transform;
transform.Translate(9.0, 9.0);
- transform.Scale(10.0 / 8.0, 10.0 / 8.0);
// The first contributing surface has a translation of 5, 6.
gfx::Transform five_six(1, 0, 0, 1, 5, 6);
@@ -468,12 +461,9 @@ TEST_F(DelegatedRendererLayerImplTestOwnSurface,
ASSERT_EQ(6u, frame.render_passes.size());
// Because the DelegatedRendererLayer owns a RenderSurfaceImpl, its root
- // RenderPass' quads do not need to be translated at all. However, they are
- // scaled from the frame's size (8x8) to the layer's bounds (10x10).
- gfx::Transform transform;
- transform.Scale(10.0 / 8.0, 10.0 / 8.0);
+ // RenderPass' quads do not need to be translated at all.
EXPECT_TRANSFORMATION_MATRIX_EQ(
- transform, frame.render_passes[3]->quad_list[0]->quadTransform());
+ gfx::Transform(), frame.render_passes[3]->quad_list[0]->quadTransform());
// Quads from non-root RenderPasses should not be shifted either.
ASSERT_EQ(2u, frame.render_passes[2]->quad_list.size());
@@ -511,8 +501,6 @@ class DelegatedRendererLayerImplTestTransform
transform.Scale(2.0, 2.0);
transform.Translate(8.0, 8.0);
delegated_renderer_layer->SetTransform(transform);
- delegated_renderer_layer->SetTransformOrigin(
jamesr 2014/06/05 20:54:26 deleting this (which doesn't seem all that relevan
enne (OOO) 2014/06/05 23:02:14 Yeah, I don't think it's relevant to DRLI and make
- gfx::Point3F(75 * 0.5f, 75 * 0.5f, 0.0f));
ScopedPtrVector<RenderPass> delegated_render_passes;
@@ -715,16 +703,15 @@ TEST_F(DelegatedRendererLayerImplTestTransform, QuadsUnclipped_NoSurface) {
EXPECT_TRUE(root_delegated_shared_quad_state->is_clipped);
gfx::Transform expected;
- // Device scale factor is 2.
+ // Device scale factor.
expected.Scale(2.0, 2.0);
// This is the transform from the layer's space to its target.
- // The position (20) - the width / scale (75 / 2) = 20 - 37.5 = -17.5
- expected.Translate(-17.5, -17.5);
+ expected.Translate(20, 20);
expected.Scale(2.0, 2.0);
expected.Translate(8.0, 8.0);
- // The frame has size 100x100 but the layer's bounds are 75x75.
- expected.Scale(75.0 / 100.0, 75.0 / 100.0);
// This is the transform within the source frame.
+ // Inverse device scale factor to go from physical space to layer space.
+ expected.Scale(0.5, 0.5);
expected.Scale(1.5, 1.5);
expected.Translate(7.0, 7.0);
EXPECT_TRANSFORMATION_MATRIX_EQ(
@@ -763,31 +750,27 @@ TEST_F(DelegatedRendererLayerImplTestTransform, QuadsClipped_NoSurface) {
// Since the quads have a clip_rect it should be modified by delegated
// renderer layer's draw_transform.
// The position of the resulting clip_rect is:
- // (clip rect position (10) * scale to layer (75/100) + translate (8)) *
- // layer scale (2) + layer position (20) = 51
- // But the layer is centered, so: 51 - (75 / 2) = 51 - 75 / 2 = 13.5
- // The device scale is 2, so everything gets doubled, giving 27.
+ // (clip rect position (10) * inverse dsf (1/2) + translate (8)) *
+ // layer scale (2) + layer position (20) = 46
+ // The device scale is 2, so everything gets doubled, giving 92.
//
- // The size is 35x35 scaled to fit inside the layer's bounds at 75x75 from
- // a frame at 100x100: 35 * 2 (device scale) * 75 / 100 = 52.5. The device
- // scale doubles this to 105.
- EXPECT_EQ(gfx::Rect(27, 27, 105, 105).ToString(),
+ // The size is 35x35 scaled by the device scale.
+ EXPECT_EQ(gfx::Rect(92, 92, 70, 70).ToString(),
root_delegated_shared_quad_state->clip_rect.ToString());
// The quads had a clip and it should be preserved.
EXPECT_TRUE(root_delegated_shared_quad_state->is_clipped);
gfx::Transform expected;
- // Device scale factor is 2.
+ // Device scale factor.
expected.Scale(2.0, 2.0);
// This is the transform from the layer's space to its target.
- // The position (20) - the width / scale (75 / 2) = 20 - 37.5 = -17.5
- expected.Translate(-17.5, -17.5);
+ expected.Translate(20, 20);
expected.Scale(2.0, 2.0);
expected.Translate(8.0, 8.0);
- // The frame has size 100x100 but the layer's bounds are 75x75.
- expected.Scale(75.0 / 100.0, 75.0 / 100.0);
// This is the transform within the source frame.
+ // Inverse device scale factor to go from physical space to layer space.
+ expected.Scale(0.5, 0.5);
expected.Scale(1.5, 1.5);
expected.Translate(7.0, 7.0);
EXPECT_TRANSFORMATION_MATRIX_EQ(
@@ -827,11 +810,7 @@ TEST_F(DelegatedRendererLayerImplTestTransform, QuadsUnclipped_Surface) {
// When the layer owns a surface, then its position and translation are not
// a part of its draw transform.
- // The position of the resulting clip_rect is:
- // (clip rect position (10) * scale to layer (75/100)) * device scale (2) = 15
- // The size is 35x35 scaled to fit inside the layer's bounds at 75x75 from
- // a frame at 100x100: 35 * 2 (device scale) * 75 / 100 = 52.5.
- EXPECT_EQ(gfx::Rect(15, 15, 53, 53).ToString(),
+ EXPECT_EQ(gfx::Rect(10, 10, 35, 35).ToString(),
root_delegated_shared_quad_state->clip_rect.ToString());
// Since the layer owns a surface it doesn't need to clip its quads, so
@@ -839,10 +818,6 @@ TEST_F(DelegatedRendererLayerImplTestTransform, QuadsUnclipped_Surface) {
EXPECT_FALSE(root_delegated_shared_quad_state->is_clipped);
gfx::Transform expected;
- // Device scale factor is 2.
- expected.Scale(2.0, 2.0);
- // The frame has size 100x100 but the layer's bounds are 75x75.
- expected.Scale(75.0 / 100.0, 75.0 / 100.0);
// This is the transform within the source frame.
expected.Scale(1.5, 1.5);
expected.Translate(7.0, 7.0);
@@ -882,22 +857,14 @@ TEST_F(DelegatedRendererLayerImplTestTransform, QuadsClipped_Surface) {
&contrib_delegated_shared_quad_state);
// When the layer owns a surface, then its position and translation are not
- // a part of its draw transform.
- // The position of the resulting clip_rect is:
- // (clip rect position (10) * scale to layer (75/100)) * device scale (2) = 15
- // The size is 35x35 scaled to fit inside the layer's bounds at 75x75 from
- // a frame at 100x100: 35 * 2 (device scale) * 75 / 100 = 52.5.
- EXPECT_EQ(gfx::Rect(15, 15, 53, 53).ToString(),
+ // a part of its draw transform. The clip_rect should be preserved.
+ EXPECT_EQ(gfx::Rect(10, 10, 35, 35).ToString(),
root_delegated_shared_quad_state->clip_rect.ToString());
// The quads had a clip and it should be preserved.
EXPECT_TRUE(root_delegated_shared_quad_state->is_clipped);
gfx::Transform expected;
- // Device scale factor is 2.
- expected.Scale(2.0, 2.0);
- // The frame has size 100x100 but the layer's bounds are 75x75.
- expected.Scale(75.0 / 100.0, 75.0 / 100.0);
// This is the transform within the source frame.
expected.Scale(1.5, 1.5);
expected.Translate(7.0, 7.0);

Powered by Google App Engine
This is Rietveld 408576698