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

Side by Side Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 774763004: Use EXPECT_EQ when possible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 unified diff | Download patch
« no previous file with comments | « cc/test/layer_tree_json_parser_unittest.cc ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "cc/animation/layer_animation_controller.h" 10 #include "cc/animation/layer_animation_controller.h"
(...skipping 1925 matching lines...) Expand 10 before | Expand all | Expand 10 after
1936 grand_child2->SetOpacity(0.5f); 1936 grand_child2->SetOpacity(0.5f);
1937 grand_child3->SetOpacity(0.5f); 1937 grand_child3->SetOpacity(0.5f);
1938 grand_child4->SetOpacity(0.5f); 1938 grand_child4->SetOpacity(0.5f);
1939 1939
1940 RenderSurfaceLayerList render_surface_layer_list; 1940 RenderSurfaceLayerList render_surface_layer_list;
1941 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( 1941 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
1942 parent.get(), parent->bounds(), &render_surface_layer_list); 1942 parent.get(), parent->bounds(), &render_surface_layer_list);
1943 inputs.can_adjust_raster_scales = true; 1943 inputs.can_adjust_raster_scales = true;
1944 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 1944 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
1945 1945
1946 EXPECT_RECT_EQ(gfx::Rect(5, 5, 10, 10), 1946 EXPECT_EQ(gfx::Rect(5, 5, 10, 10), grand_child1->drawable_content_rect());
1947 grand_child1->drawable_content_rect()); 1947 EXPECT_EQ(gfx::Rect(15, 15, 5, 5), grand_child3->drawable_content_rect());
1948 EXPECT_RECT_EQ(gfx::Rect(15, 15, 5, 5), 1948 EXPECT_EQ(gfx::Rect(15, 15, 5, 5), grand_child3->drawable_content_rect());
1949 grand_child3->drawable_content_rect());
1950 EXPECT_RECT_EQ(gfx::Rect(15, 15, 5, 5),
1951 grand_child3->drawable_content_rect());
1952 EXPECT_TRUE(grand_child4->drawable_content_rect().IsEmpty()); 1949 EXPECT_TRUE(grand_child4->drawable_content_rect().IsEmpty());
1953 } 1950 }
1954 1951
1955 TEST_F(LayerTreeHostCommonTest, ClipRectIsPropagatedCorrectlyToSurfaces) { 1952 TEST_F(LayerTreeHostCommonTest, ClipRectIsPropagatedCorrectlyToSurfaces) {
1956 // Verify that render surfaces (and their layers) get the appropriate 1953 // Verify that render surfaces (and their layers) get the appropriate
1957 // clip rects when their parent masksToBounds is true. 1954 // clip rects when their parent masksToBounds is true.
1958 // 1955 //
1959 // Layers that own render surfaces (at least for now) do not inherit any 1956 // Layers that own render surfaces (at least for now) do not inherit any
1960 // clipping; instead the surface will enforce the clip for the entire subtree. 1957 // clipping; instead the surface will enforce the clip for the entire subtree.
1961 // They may still have a clip rect of their own layer bounds, however, if 1958 // They may still have a clip rect of their own layer bounds, however, if
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
2083 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( 2080 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
2084 parent.get(), parent->bounds(), &render_surface_layer_list); 2081 parent.get(), parent->bounds(), &render_surface_layer_list);
2085 inputs.can_adjust_raster_scales = true; 2082 inputs.can_adjust_raster_scales = true;
2086 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 2083 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
2087 ASSERT_TRUE(grand_child1->render_surface()); 2084 ASSERT_TRUE(grand_child1->render_surface());
2088 ASSERT_TRUE(grand_child2->render_surface()); 2085 ASSERT_TRUE(grand_child2->render_surface());
2089 ASSERT_TRUE(grand_child3->render_surface()); 2086 ASSERT_TRUE(grand_child3->render_surface());
2090 2087
2091 // Surfaces are clipped by their parent, but un-affected by the owning layer's 2088 // Surfaces are clipped by their parent, but un-affected by the owning layer's
2092 // masksToBounds. 2089 // masksToBounds.
2093 EXPECT_RECT_EQ(gfx::Rect(0, 0, 20, 20), 2090 EXPECT_EQ(gfx::Rect(0, 0, 20, 20),
2094 grand_child1->render_surface()->clip_rect()); 2091 grand_child1->render_surface()->clip_rect());
2095 EXPECT_RECT_EQ(gfx::Rect(0, 0, 20, 20), 2092 EXPECT_EQ(gfx::Rect(0, 0, 20, 20),
2096 grand_child2->render_surface()->clip_rect()); 2093 grand_child2->render_surface()->clip_rect());
2097 EXPECT_RECT_EQ(gfx::Rect(0, 0, 20, 20), 2094 EXPECT_EQ(gfx::Rect(0, 0, 20, 20),
2098 grand_child3->render_surface()->clip_rect()); 2095 grand_child3->render_surface()->clip_rect());
2099 } 2096 }
2100 2097
2101 TEST_F(LayerTreeHostCommonTest, AnimationsForRenderSurfaceHierarchy) { 2098 TEST_F(LayerTreeHostCommonTest, AnimationsForRenderSurfaceHierarchy) {
2102 scoped_refptr<Layer> parent = Layer::Create(); 2099 scoped_refptr<Layer> parent = Layer::Create();
2103 scoped_refptr<Layer> render_surface1 = Layer::Create(); 2100 scoped_refptr<Layer> render_surface1 = Layer::Create();
2104 scoped_refptr<Layer> render_surface2 = Layer::Create(); 2101 scoped_refptr<Layer> render_surface2 = Layer::Create();
2105 scoped_refptr<Layer> child_of_root = Layer::Create(); 2102 scoped_refptr<Layer> child_of_root = Layer::Create();
2106 scoped_refptr<Layer> child_of_rs1 = Layer::Create(); 2103 scoped_refptr<Layer> child_of_rs1 = Layer::Create();
2107 scoped_refptr<Layer> child_of_rs2 = Layer::Create(); 2104 scoped_refptr<Layer> child_of_rs2 = Layer::Create();
2108 scoped_refptr<Layer> grand_child_of_root = Layer::Create(); 2105 scoped_refptr<Layer> grand_child_of_root = Layer::Create();
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
2313 // transforms. 2310 // transforms.
2314 2311
2315 gfx::Rect target_surface_rect = gfx::Rect(0, 0, 100, 100); 2312 gfx::Rect target_surface_rect = gfx::Rect(0, 0, 100, 100);
2316 gfx::Transform layer_to_surface_transform; 2313 gfx::Transform layer_to_surface_transform;
2317 2314
2318 // Case 1: Layer is contained within the surface. 2315 // Case 1: Layer is contained within the surface.
2319 gfx::Rect layer_content_rect = gfx::Rect(10, 10, 30, 30); 2316 gfx::Rect layer_content_rect = gfx::Rect(10, 10, 30, 30);
2320 gfx::Rect expected = gfx::Rect(10, 10, 30, 30); 2317 gfx::Rect expected = gfx::Rect(10, 10, 30, 30);
2321 gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect( 2318 gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect(
2322 target_surface_rect, layer_content_rect, layer_to_surface_transform); 2319 target_surface_rect, layer_content_rect, layer_to_surface_transform);
2323 EXPECT_RECT_EQ(expected, actual); 2320 EXPECT_EQ(expected, actual);
2324 2321
2325 // Case 2: Layer is outside the surface rect. 2322 // Case 2: Layer is outside the surface rect.
2326 layer_content_rect = gfx::Rect(120, 120, 30, 30); 2323 layer_content_rect = gfx::Rect(120, 120, 30, 30);
2327 actual = LayerTreeHostCommon::CalculateVisibleRect( 2324 actual = LayerTreeHostCommon::CalculateVisibleRect(
2328 target_surface_rect, layer_content_rect, layer_to_surface_transform); 2325 target_surface_rect, layer_content_rect, layer_to_surface_transform);
2329 EXPECT_TRUE(actual.IsEmpty()); 2326 EXPECT_TRUE(actual.IsEmpty());
2330 2327
2331 // Case 3: Layer is partially overlapping the surface rect. 2328 // Case 3: Layer is partially overlapping the surface rect.
2332 layer_content_rect = gfx::Rect(80, 80, 30, 30); 2329 layer_content_rect = gfx::Rect(80, 80, 30, 30);
2333 expected = gfx::Rect(80, 80, 20, 20); 2330 expected = gfx::Rect(80, 80, 20, 20);
2334 actual = LayerTreeHostCommon::CalculateVisibleRect( 2331 actual = LayerTreeHostCommon::CalculateVisibleRect(
2335 target_surface_rect, layer_content_rect, layer_to_surface_transform); 2332 target_surface_rect, layer_content_rect, layer_to_surface_transform);
2336 EXPECT_RECT_EQ(expected, actual); 2333 EXPECT_EQ(expected, actual);
2337 } 2334 }
2338 2335
2339 TEST_F(LayerTreeHostCommonTest, VisibleRectForTranslations) { 2336 TEST_F(LayerTreeHostCommonTest, VisibleRectForTranslations) {
2340 // Test the calculateVisibleRect() function works correctly for scaling 2337 // Test the calculateVisibleRect() function works correctly for scaling
2341 // transforms. 2338 // transforms.
2342 2339
2343 gfx::Rect target_surface_rect = gfx::Rect(0, 0, 100, 100); 2340 gfx::Rect target_surface_rect = gfx::Rect(0, 0, 100, 100);
2344 gfx::Rect layer_content_rect = gfx::Rect(0, 0, 30, 30); 2341 gfx::Rect layer_content_rect = gfx::Rect(0, 0, 30, 30);
2345 gfx::Transform layer_to_surface_transform; 2342 gfx::Transform layer_to_surface_transform;
2346 2343
2347 // Case 1: Layer is contained within the surface. 2344 // Case 1: Layer is contained within the surface.
2348 layer_to_surface_transform.MakeIdentity(); 2345 layer_to_surface_transform.MakeIdentity();
2349 layer_to_surface_transform.Translate(10.0, 10.0); 2346 layer_to_surface_transform.Translate(10.0, 10.0);
2350 gfx::Rect expected = gfx::Rect(0, 0, 30, 30); 2347 gfx::Rect expected = gfx::Rect(0, 0, 30, 30);
2351 gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect( 2348 gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect(
2352 target_surface_rect, layer_content_rect, layer_to_surface_transform); 2349 target_surface_rect, layer_content_rect, layer_to_surface_transform);
2353 EXPECT_RECT_EQ(expected, actual); 2350 EXPECT_EQ(expected, actual);
2354 2351
2355 // Case 2: Layer is outside the surface rect. 2352 // Case 2: Layer is outside the surface rect.
2356 layer_to_surface_transform.MakeIdentity(); 2353 layer_to_surface_transform.MakeIdentity();
2357 layer_to_surface_transform.Translate(120.0, 120.0); 2354 layer_to_surface_transform.Translate(120.0, 120.0);
2358 actual = LayerTreeHostCommon::CalculateVisibleRect( 2355 actual = LayerTreeHostCommon::CalculateVisibleRect(
2359 target_surface_rect, layer_content_rect, layer_to_surface_transform); 2356 target_surface_rect, layer_content_rect, layer_to_surface_transform);
2360 EXPECT_TRUE(actual.IsEmpty()); 2357 EXPECT_TRUE(actual.IsEmpty());
2361 2358
2362 // Case 3: Layer is partially overlapping the surface rect. 2359 // Case 3: Layer is partially overlapping the surface rect.
2363 layer_to_surface_transform.MakeIdentity(); 2360 layer_to_surface_transform.MakeIdentity();
2364 layer_to_surface_transform.Translate(80.0, 80.0); 2361 layer_to_surface_transform.Translate(80.0, 80.0);
2365 expected = gfx::Rect(0, 0, 20, 20); 2362 expected = gfx::Rect(0, 0, 20, 20);
2366 actual = LayerTreeHostCommon::CalculateVisibleRect( 2363 actual = LayerTreeHostCommon::CalculateVisibleRect(
2367 target_surface_rect, layer_content_rect, layer_to_surface_transform); 2364 target_surface_rect, layer_content_rect, layer_to_surface_transform);
2368 EXPECT_RECT_EQ(expected, actual); 2365 EXPECT_EQ(expected, actual);
2369 } 2366 }
2370 2367
2371 TEST_F(LayerTreeHostCommonTest, VisibleRectFor2DRotations) { 2368 TEST_F(LayerTreeHostCommonTest, VisibleRectFor2DRotations) {
2372 // Test the calculateVisibleRect() function works correctly for rotations 2369 // Test the calculateVisibleRect() function works correctly for rotations
2373 // about z-axis (i.e. 2D rotations). Remember that calculateVisibleRect() 2370 // about z-axis (i.e. 2D rotations). Remember that calculateVisibleRect()
2374 // should return the g in the layer's space. 2371 // should return the g in the layer's space.
2375 2372
2376 gfx::Rect target_surface_rect = gfx::Rect(0, 0, 100, 100); 2373 gfx::Rect target_surface_rect = gfx::Rect(0, 0, 100, 100);
2377 gfx::Rect layer_content_rect = gfx::Rect(0, 0, 30, 30); 2374 gfx::Rect layer_content_rect = gfx::Rect(0, 0, 30, 30);
2378 gfx::Transform layer_to_surface_transform; 2375 gfx::Transform layer_to_surface_transform;
2379 2376
2380 // Case 1: Layer is contained within the surface. 2377 // Case 1: Layer is contained within the surface.
2381 layer_to_surface_transform.MakeIdentity(); 2378 layer_to_surface_transform.MakeIdentity();
2382 layer_to_surface_transform.Translate(50.0, 50.0); 2379 layer_to_surface_transform.Translate(50.0, 50.0);
2383 layer_to_surface_transform.Rotate(45.0); 2380 layer_to_surface_transform.Rotate(45.0);
2384 gfx::Rect expected = gfx::Rect(0, 0, 30, 30); 2381 gfx::Rect expected = gfx::Rect(0, 0, 30, 30);
2385 gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect( 2382 gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect(
2386 target_surface_rect, layer_content_rect, layer_to_surface_transform); 2383 target_surface_rect, layer_content_rect, layer_to_surface_transform);
2387 EXPECT_RECT_EQ(expected, actual); 2384 EXPECT_EQ(expected, actual);
2388 2385
2389 // Case 2: Layer is outside the surface rect. 2386 // Case 2: Layer is outside the surface rect.
2390 layer_to_surface_transform.MakeIdentity(); 2387 layer_to_surface_transform.MakeIdentity();
2391 layer_to_surface_transform.Translate(-50.0, 0.0); 2388 layer_to_surface_transform.Translate(-50.0, 0.0);
2392 layer_to_surface_transform.Rotate(45.0); 2389 layer_to_surface_transform.Rotate(45.0);
2393 actual = LayerTreeHostCommon::CalculateVisibleRect( 2390 actual = LayerTreeHostCommon::CalculateVisibleRect(
2394 target_surface_rect, layer_content_rect, layer_to_surface_transform); 2391 target_surface_rect, layer_content_rect, layer_to_surface_transform);
2395 EXPECT_TRUE(actual.IsEmpty()); 2392 EXPECT_TRUE(actual.IsEmpty());
2396 2393
2397 // Case 3: The layer is rotated about its top-left corner. In surface space, 2394 // Case 3: The layer is rotated about its top-left corner. In surface space,
2398 // the layer is oriented diagonally, with the left half outside of the render 2395 // the layer is oriented diagonally, with the left half outside of the render
2399 // surface. In this case, the g should still be the entire layer 2396 // surface. In this case, the g should still be the entire layer
2400 // (remember the g is computed in layer space); both the top-left 2397 // (remember the g is computed in layer space); both the top-left
2401 // and bottom-right corners of the layer are still visible. 2398 // and bottom-right corners of the layer are still visible.
2402 layer_to_surface_transform.MakeIdentity(); 2399 layer_to_surface_transform.MakeIdentity();
2403 layer_to_surface_transform.Rotate(45.0); 2400 layer_to_surface_transform.Rotate(45.0);
2404 expected = gfx::Rect(0, 0, 30, 30); 2401 expected = gfx::Rect(0, 0, 30, 30);
2405 actual = LayerTreeHostCommon::CalculateVisibleRect( 2402 actual = LayerTreeHostCommon::CalculateVisibleRect(
2406 target_surface_rect, layer_content_rect, layer_to_surface_transform); 2403 target_surface_rect, layer_content_rect, layer_to_surface_transform);
2407 EXPECT_RECT_EQ(expected, actual); 2404 EXPECT_EQ(expected, actual);
2408 2405
2409 // Case 4: The layer is rotated about its top-left corner, and translated 2406 // Case 4: The layer is rotated about its top-left corner, and translated
2410 // upwards. In surface space, the layer is oriented diagonally, with only the 2407 // upwards. In surface space, the layer is oriented diagonally, with only the
2411 // top corner of the surface overlapping the layer. In layer space, the render 2408 // top corner of the surface overlapping the layer. In layer space, the render
2412 // surface overlaps the right side of the layer. The g should be 2409 // surface overlaps the right side of the layer. The g should be
2413 // the layer's right half. 2410 // the layer's right half.
2414 layer_to_surface_transform.MakeIdentity(); 2411 layer_to_surface_transform.MakeIdentity();
2415 layer_to_surface_transform.Translate(0.0, -sqrt(2.0) * 15.0); 2412 layer_to_surface_transform.Translate(0.0, -sqrt(2.0) * 15.0);
2416 layer_to_surface_transform.Rotate(45.0); 2413 layer_to_surface_transform.Rotate(45.0);
2417 expected = gfx::Rect(15, 0, 15, 30); // Right half of layer bounds. 2414 expected = gfx::Rect(15, 0, 15, 30); // Right half of layer bounds.
2418 actual = LayerTreeHostCommon::CalculateVisibleRect( 2415 actual = LayerTreeHostCommon::CalculateVisibleRect(
2419 target_surface_rect, layer_content_rect, layer_to_surface_transform); 2416 target_surface_rect, layer_content_rect, layer_to_surface_transform);
2420 EXPECT_RECT_EQ(expected, actual); 2417 EXPECT_EQ(expected, actual);
2421 } 2418 }
2422 2419
2423 TEST_F(LayerTreeHostCommonTest, VisibleRectFor3dOrthographicTransform) { 2420 TEST_F(LayerTreeHostCommonTest, VisibleRectFor3dOrthographicTransform) {
2424 // Test that the calculateVisibleRect() function works correctly for 3d 2421 // Test that the calculateVisibleRect() function works correctly for 3d
2425 // transforms. 2422 // transforms.
2426 2423
2427 gfx::Rect target_surface_rect = gfx::Rect(0, 0, 100, 100); 2424 gfx::Rect target_surface_rect = gfx::Rect(0, 0, 100, 100);
2428 gfx::Rect layer_content_rect = gfx::Rect(0, 0, 100, 100); 2425 gfx::Rect layer_content_rect = gfx::Rect(0, 0, 100, 100);
2429 gfx::Transform layer_to_surface_transform; 2426 gfx::Transform layer_to_surface_transform;
2430 2427
2431 // Case 1: Orthographic projection of a layer rotated about y-axis by 45 2428 // Case 1: Orthographic projection of a layer rotated about y-axis by 45
2432 // degrees, should be fully contained in the render surface. 2429 // degrees, should be fully contained in the render surface.
2433 layer_to_surface_transform.MakeIdentity(); 2430 layer_to_surface_transform.MakeIdentity();
2434 layer_to_surface_transform.RotateAboutYAxis(45.0); 2431 layer_to_surface_transform.RotateAboutYAxis(45.0);
2435 gfx::Rect expected = gfx::Rect(0, 0, 100, 100); 2432 gfx::Rect expected = gfx::Rect(0, 0, 100, 100);
2436 gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect( 2433 gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect(
2437 target_surface_rect, layer_content_rect, layer_to_surface_transform); 2434 target_surface_rect, layer_content_rect, layer_to_surface_transform);
2438 EXPECT_RECT_EQ(expected, actual); 2435 EXPECT_EQ(expected, actual);
2439 2436
2440 // Case 2: Orthographic projection of a layer rotated about y-axis by 45 2437 // Case 2: Orthographic projection of a layer rotated about y-axis by 45
2441 // degrees, but shifted to the side so only the right-half the layer would be 2438 // degrees, but shifted to the side so only the right-half the layer would be
2442 // visible on the surface. 2439 // visible on the surface.
2443 // 100 is the un-rotated layer width; divided by sqrt(2) is the rotated width. 2440 // 100 is the un-rotated layer width; divided by sqrt(2) is the rotated width.
2444 SkMScalar half_width_of_rotated_layer = 2441 SkMScalar half_width_of_rotated_layer =
2445 SkDoubleToMScalar((100.0 / sqrt(2.0)) * 0.5); 2442 SkDoubleToMScalar((100.0 / sqrt(2.0)) * 0.5);
2446 layer_to_surface_transform.MakeIdentity(); 2443 layer_to_surface_transform.MakeIdentity();
2447 layer_to_surface_transform.Translate(-half_width_of_rotated_layer, 0.0); 2444 layer_to_surface_transform.Translate(-half_width_of_rotated_layer, 0.0);
2448 layer_to_surface_transform.RotateAboutYAxis(45.0); // Rotates about the left 2445 layer_to_surface_transform.RotateAboutYAxis(45.0); // Rotates about the left
2449 // edge of the layer. 2446 // edge of the layer.
2450 expected = gfx::Rect(50, 0, 50, 100); // Tight half of the layer. 2447 expected = gfx::Rect(50, 0, 50, 100); // Tight half of the layer.
2451 actual = LayerTreeHostCommon::CalculateVisibleRect( 2448 actual = LayerTreeHostCommon::CalculateVisibleRect(
2452 target_surface_rect, layer_content_rect, layer_to_surface_transform); 2449 target_surface_rect, layer_content_rect, layer_to_surface_transform);
2453 EXPECT_RECT_EQ(expected, actual); 2450 EXPECT_EQ(expected, actual);
2454 } 2451 }
2455 2452
2456 TEST_F(LayerTreeHostCommonTest, VisibleRectFor3dPerspectiveTransform) { 2453 TEST_F(LayerTreeHostCommonTest, VisibleRectFor3dPerspectiveTransform) {
2457 // Test the calculateVisibleRect() function works correctly when the layer has 2454 // Test the calculateVisibleRect() function works correctly when the layer has
2458 // a perspective projection onto the target surface. 2455 // a perspective projection onto the target surface.
2459 2456
2460 gfx::Rect target_surface_rect = gfx::Rect(0, 0, 100, 100); 2457 gfx::Rect target_surface_rect = gfx::Rect(0, 0, 100, 100);
2461 gfx::Rect layer_content_rect = gfx::Rect(-50, -50, 200, 200); 2458 gfx::Rect layer_content_rect = gfx::Rect(-50, -50, 200, 200);
2462 gfx::Transform layer_to_surface_transform; 2459 gfx::Transform layer_to_surface_transform;
2463 2460
2464 // Case 1: Even though the layer is twice as large as the surface, due to 2461 // Case 1: Even though the layer is twice as large as the surface, due to
2465 // perspective foreshortening, the layer will fit fully in the surface when 2462 // perspective foreshortening, the layer will fit fully in the surface when
2466 // its translated more than the perspective amount. 2463 // its translated more than the perspective amount.
2467 layer_to_surface_transform.MakeIdentity(); 2464 layer_to_surface_transform.MakeIdentity();
2468 2465
2469 // The following sequence of transforms applies the perspective about the 2466 // The following sequence of transforms applies the perspective about the
2470 // center of the surface. 2467 // center of the surface.
2471 layer_to_surface_transform.Translate(50.0, 50.0); 2468 layer_to_surface_transform.Translate(50.0, 50.0);
2472 layer_to_surface_transform.ApplyPerspectiveDepth(9.0); 2469 layer_to_surface_transform.ApplyPerspectiveDepth(9.0);
2473 layer_to_surface_transform.Translate(-50.0, -50.0); 2470 layer_to_surface_transform.Translate(-50.0, -50.0);
2474 2471
2475 // This translate places the layer in front of the surface's projection plane. 2472 // This translate places the layer in front of the surface's projection plane.
2476 layer_to_surface_transform.Translate3d(0.0, 0.0, -27.0); 2473 layer_to_surface_transform.Translate3d(0.0, 0.0, -27.0);
2477 2474
2478 gfx::Rect expected = gfx::Rect(-50, -50, 200, 200); 2475 gfx::Rect expected = gfx::Rect(-50, -50, 200, 200);
2479 gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect( 2476 gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect(
2480 target_surface_rect, layer_content_rect, layer_to_surface_transform); 2477 target_surface_rect, layer_content_rect, layer_to_surface_transform);
2481 EXPECT_RECT_EQ(expected, actual); 2478 EXPECT_EQ(expected, actual);
2482 2479
2483 // Case 2: same projection as before, except that the layer is also translated 2480 // Case 2: same projection as before, except that the layer is also translated
2484 // to the side, so that only the right half of the layer should be visible. 2481 // to the side, so that only the right half of the layer should be visible.
2485 // 2482 //
2486 // Explanation of expected result: The perspective ratio is (z distance 2483 // Explanation of expected result: The perspective ratio is (z distance
2487 // between layer and camera origin) / (z distance between projection plane and 2484 // between layer and camera origin) / (z distance between projection plane and
2488 // camera origin) == ((-27 - 9) / 9) Then, by similar triangles, if we want to 2485 // camera origin) == ((-27 - 9) / 9) Then, by similar triangles, if we want to
2489 // move a layer by translating -50 units in projected surface units (so that 2486 // move a layer by translating -50 units in projected surface units (so that
2490 // only half of it is visible), then we would need to translate by (-36 / 9) * 2487 // only half of it is visible), then we would need to translate by (-36 / 9) *
2491 // -50 == -200 in the layer's units. 2488 // -50 == -200 in the layer's units.
2492 layer_to_surface_transform.Translate3d(-200.0, 0.0, 0.0); 2489 layer_to_surface_transform.Translate3d(-200.0, 0.0, 0.0);
2493 expected = gfx::Rect(gfx::Point(50, -50), 2490 expected = gfx::Rect(gfx::Point(50, -50),
2494 gfx::Size(100, 200)); // The right half of the layer's 2491 gfx::Size(100, 200)); // The right half of the layer's
2495 // bounding rect. 2492 // bounding rect.
2496 actual = LayerTreeHostCommon::CalculateVisibleRect( 2493 actual = LayerTreeHostCommon::CalculateVisibleRect(
2497 target_surface_rect, layer_content_rect, layer_to_surface_transform); 2494 target_surface_rect, layer_content_rect, layer_to_surface_transform);
2498 EXPECT_RECT_EQ(expected, actual); 2495 EXPECT_EQ(expected, actual);
2499 } 2496 }
2500 2497
2501 TEST_F(LayerTreeHostCommonTest, 2498 TEST_F(LayerTreeHostCommonTest,
2502 VisibleRectFor3dOrthographicIsNotClippedBehindSurface) { 2499 VisibleRectFor3dOrthographicIsNotClippedBehindSurface) {
2503 // There is currently no explicit concept of an orthographic projection plane 2500 // There is currently no explicit concept of an orthographic projection plane
2504 // in our code (nor in the CSS spec to my knowledge). Therefore, layers that 2501 // in our code (nor in the CSS spec to my knowledge). Therefore, layers that
2505 // are technically behind the surface in an orthographic world should not be 2502 // are technically behind the surface in an orthographic world should not be
2506 // clipped when they are flattened to the surface. 2503 // clipped when they are flattened to the surface.
2507 2504
2508 gfx::Rect target_surface_rect = gfx::Rect(0, 0, 100, 100); 2505 gfx::Rect target_surface_rect = gfx::Rect(0, 0, 100, 100);
2509 gfx::Rect layer_content_rect = gfx::Rect(0, 0, 100, 100); 2506 gfx::Rect layer_content_rect = gfx::Rect(0, 0, 100, 100);
2510 gfx::Transform layer_to_surface_transform; 2507 gfx::Transform layer_to_surface_transform;
2511 2508
2512 // This sequence of transforms effectively rotates the layer about the y-axis 2509 // This sequence of transforms effectively rotates the layer about the y-axis
2513 // at the center of the layer. 2510 // at the center of the layer.
2514 layer_to_surface_transform.MakeIdentity(); 2511 layer_to_surface_transform.MakeIdentity();
2515 layer_to_surface_transform.Translate(50.0, 0.0); 2512 layer_to_surface_transform.Translate(50.0, 0.0);
2516 layer_to_surface_transform.RotateAboutYAxis(45.0); 2513 layer_to_surface_transform.RotateAboutYAxis(45.0);
2517 layer_to_surface_transform.Translate(-50.0, 0.0); 2514 layer_to_surface_transform.Translate(-50.0, 0.0);
2518 2515
2519 gfx::Rect expected = gfx::Rect(0, 0, 100, 100); 2516 gfx::Rect expected = gfx::Rect(0, 0, 100, 100);
2520 gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect( 2517 gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect(
2521 target_surface_rect, layer_content_rect, layer_to_surface_transform); 2518 target_surface_rect, layer_content_rect, layer_to_surface_transform);
2522 EXPECT_RECT_EQ(expected, actual); 2519 EXPECT_EQ(expected, actual);
2523 } 2520 }
2524 2521
2525 TEST_F(LayerTreeHostCommonTest, VisibleRectFor3dPerspectiveWhenClippedByW) { 2522 TEST_F(LayerTreeHostCommonTest, VisibleRectFor3dPerspectiveWhenClippedByW) {
2526 // Test the calculateVisibleRect() function works correctly when projecting a 2523 // Test the calculateVisibleRect() function works correctly when projecting a
2527 // surface onto a layer, but the layer is partially behind the camera (not 2524 // surface onto a layer, but the layer is partially behind the camera (not
2528 // just behind the projection plane). In this case, the cartesian coordinates 2525 // just behind the projection plane). In this case, the cartesian coordinates
2529 // may seem to be valid, but actually they are not. The visible rect needs to 2526 // may seem to be valid, but actually they are not. The visible rect needs to
2530 // be properly clipped by the w = 0 plane in homogeneous coordinates before 2527 // be properly clipped by the w = 0 plane in homogeneous coordinates before
2531 // converting to cartesian coordinates. 2528 // converting to cartesian coordinates.
2532 2529
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2585 MathUtil::ProjectQuad( 2582 MathUtil::ProjectQuad(
2586 Inverse(layer_to_surface_transform), gfx::QuadF(clipped_rect), &clipped); 2583 Inverse(layer_to_surface_transform), gfx::QuadF(clipped_rect), &clipped);
2587 ASSERT_TRUE(clipped); 2584 ASSERT_TRUE(clipped);
2588 2585
2589 // Only the corner of the layer is not visible on the surface because of being 2586 // Only the corner of the layer is not visible on the surface because of being
2590 // clipped. But, the net result of rounding visible region to an axis-aligned 2587 // clipped. But, the net result of rounding visible region to an axis-aligned
2591 // rect is that the entire layer should still be considered visible. 2588 // rect is that the entire layer should still be considered visible.
2592 gfx::Rect expected = gfx::Rect(-10, -10, 20, 20); 2589 gfx::Rect expected = gfx::Rect(-10, -10, 20, 20);
2593 gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect( 2590 gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect(
2594 target_surface_rect, layer_content_rect, layer_to_surface_transform); 2591 target_surface_rect, layer_content_rect, layer_to_surface_transform);
2595 EXPECT_RECT_EQ(expected, actual); 2592 EXPECT_EQ(expected, actual);
2596 } 2593 }
2597 2594
2598 TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsForSimpleLayers) { 2595 TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsForSimpleLayers) {
2599 scoped_refptr<Layer> root = Layer::Create(); 2596 scoped_refptr<Layer> root = Layer::Create();
2600 scoped_refptr<LayerWithForcedDrawsContent> child1 = 2597 scoped_refptr<LayerWithForcedDrawsContent> child1 =
2601 make_scoped_refptr(new LayerWithForcedDrawsContent()); 2598 make_scoped_refptr(new LayerWithForcedDrawsContent());
2602 scoped_refptr<LayerWithForcedDrawsContent> child2 = 2599 scoped_refptr<LayerWithForcedDrawsContent> child2 =
2603 make_scoped_refptr(new LayerWithForcedDrawsContent()); 2600 make_scoped_refptr(new LayerWithForcedDrawsContent());
2604 scoped_refptr<LayerWithForcedDrawsContent> child3 = 2601 scoped_refptr<LayerWithForcedDrawsContent> child3 =
2605 make_scoped_refptr(new LayerWithForcedDrawsContent()); 2602 make_scoped_refptr(new LayerWithForcedDrawsContent());
(...skipping 29 matching lines...) Expand all
2635 SetLayerPropertiesForTesting(child3.get(), 2632 SetLayerPropertiesForTesting(child3.get(),
2636 identity_matrix, 2633 identity_matrix,
2637 gfx::Point3F(), 2634 gfx::Point3F(),
2638 gfx::PointF(125.f, 125.f), 2635 gfx::PointF(125.f, 125.f),
2639 gfx::Size(50, 50), 2636 gfx::Size(50, 50),
2640 true, 2637 true,
2641 false); 2638 false);
2642 2639
2643 ExecuteCalculateDrawProperties(root.get()); 2640 ExecuteCalculateDrawProperties(root.get());
2644 2641
2645 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), 2642 EXPECT_EQ(gfx::Rect(0, 0, 100, 100),
2646 root->render_surface()->DrawableContentRect()); 2643 root->render_surface()->DrawableContentRect());
2647 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect()); 2644 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect());
2648 2645
2649 // Layers that do not draw content should have empty visible_content_rects. 2646 // Layers that do not draw content should have empty visible_content_rects.
2650 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect()); 2647 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect());
2651 2648
2652 // layer visible_content_rects are clipped by their target surface. 2649 // layer visible_content_rects are clipped by their target surface.
2653 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect()); 2650 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect());
2654 EXPECT_RECT_EQ(gfx::Rect(0, 0, 25, 25), child2->visible_content_rect()); 2651 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), child2->visible_content_rect());
2655 EXPECT_TRUE(child3->visible_content_rect().IsEmpty()); 2652 EXPECT_TRUE(child3->visible_content_rect().IsEmpty());
2656 2653
2657 // layer drawable_content_rects are not clipped. 2654 // layer drawable_content_rects are not clipped.
2658 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child1->drawable_content_rect()); 2655 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->drawable_content_rect());
2659 EXPECT_RECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect()); 2656 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect());
2660 EXPECT_RECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect()); 2657 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect());
2661 } 2658 }
2662 2659
2663 TEST_F(LayerTreeHostCommonTest, 2660 TEST_F(LayerTreeHostCommonTest,
2664 DrawableAndVisibleContentRectsForLayersClippedByLayer) { 2661 DrawableAndVisibleContentRectsForLayersClippedByLayer) {
2665 scoped_refptr<Layer> root = Layer::Create(); 2662 scoped_refptr<Layer> root = Layer::Create();
2666 scoped_refptr<Layer> child = Layer::Create(); 2663 scoped_refptr<Layer> child = Layer::Create();
2667 scoped_refptr<LayerWithForcedDrawsContent> grand_child1 = 2664 scoped_refptr<LayerWithForcedDrawsContent> grand_child1 =
2668 make_scoped_refptr(new LayerWithForcedDrawsContent()); 2665 make_scoped_refptr(new LayerWithForcedDrawsContent());
2669 scoped_refptr<LayerWithForcedDrawsContent> grand_child2 = 2666 scoped_refptr<LayerWithForcedDrawsContent> grand_child2 =
2670 make_scoped_refptr(new LayerWithForcedDrawsContent()); 2667 make_scoped_refptr(new LayerWithForcedDrawsContent());
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2713 gfx::PointF(125.f, 125.f), 2710 gfx::PointF(125.f, 125.f),
2714 gfx::Size(50, 50), 2711 gfx::Size(50, 50),
2715 true, 2712 true,
2716 false); 2713 false);
2717 2714
2718 child->SetMasksToBounds(true); 2715 child->SetMasksToBounds(true);
2719 ExecuteCalculateDrawProperties(root.get()); 2716 ExecuteCalculateDrawProperties(root.get());
2720 2717
2721 ASSERT_FALSE(child->render_surface()); 2718 ASSERT_FALSE(child->render_surface());
2722 2719
2723 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), 2720 EXPECT_EQ(gfx::Rect(0, 0, 100, 100),
2724 root->render_surface()->DrawableContentRect()); 2721 root->render_surface()->DrawableContentRect());
2725 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect()); 2722 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect());
2726 2723
2727 // Layers that do not draw content should have empty visible content rects. 2724 // Layers that do not draw content should have empty visible content rects.
2728 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect()); 2725 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect());
2729 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), child->visible_content_rect()); 2726 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), child->visible_content_rect());
2730 2727
2731 // All grandchild visible content rects should be clipped by child. 2728 // All grandchild visible content rects should be clipped by child.
2732 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), grand_child1->visible_content_rect()); 2729 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), grand_child1->visible_content_rect());
2733 EXPECT_RECT_EQ(gfx::Rect(0, 0, 25, 25), grand_child2->visible_content_rect()); 2730 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), grand_child2->visible_content_rect());
2734 EXPECT_TRUE(grand_child3->visible_content_rect().IsEmpty()); 2731 EXPECT_TRUE(grand_child3->visible_content_rect().IsEmpty());
2735 2732
2736 // All grandchild DrawableContentRects should also be clipped by child. 2733 // All grandchild DrawableContentRects should also be clipped by child.
2737 EXPECT_RECT_EQ(gfx::Rect(5, 5, 50, 50), 2734 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), grand_child1->drawable_content_rect());
2738 grand_child1->drawable_content_rect()); 2735 EXPECT_EQ(gfx::Rect(75, 75, 25, 25), grand_child2->drawable_content_rect());
2739 EXPECT_RECT_EQ(gfx::Rect(75, 75, 25, 25),
2740 grand_child2->drawable_content_rect());
2741 EXPECT_TRUE(grand_child3->drawable_content_rect().IsEmpty()); 2736 EXPECT_TRUE(grand_child3->drawable_content_rect().IsEmpty());
2742 } 2737 }
2743 2738
2744 TEST_F(LayerTreeHostCommonTest, 2739 TEST_F(LayerTreeHostCommonTest,
2745 DrawableAndVisibleContentRectsForLayersInUnclippedRenderSurface) { 2740 DrawableAndVisibleContentRectsForLayersInUnclippedRenderSurface) {
2746 scoped_refptr<Layer> root = Layer::Create(); 2741 scoped_refptr<Layer> root = Layer::Create();
2747 scoped_refptr<Layer> render_surface1 = Layer::Create(); 2742 scoped_refptr<Layer> render_surface1 = Layer::Create();
2748 scoped_refptr<LayerWithForcedDrawsContent> child1 = 2743 scoped_refptr<LayerWithForcedDrawsContent> child1 =
2749 make_scoped_refptr(new LayerWithForcedDrawsContent()); 2744 make_scoped_refptr(new LayerWithForcedDrawsContent());
2750 scoped_refptr<LayerWithForcedDrawsContent> child2 = 2745 scoped_refptr<LayerWithForcedDrawsContent> child2 =
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2794 gfx::PointF(125.f, 125.f), 2789 gfx::PointF(125.f, 125.f),
2795 gfx::Size(50, 50), 2790 gfx::Size(50, 50),
2796 true, 2791 true,
2797 false); 2792 false);
2798 2793
2799 render_surface1->SetForceRenderSurface(true); 2794 render_surface1->SetForceRenderSurface(true);
2800 ExecuteCalculateDrawProperties(root.get()); 2795 ExecuteCalculateDrawProperties(root.get());
2801 2796
2802 ASSERT_TRUE(render_surface1->render_surface()); 2797 ASSERT_TRUE(render_surface1->render_surface());
2803 2798
2804 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), 2799 EXPECT_EQ(gfx::Rect(0, 0, 100, 100),
2805 root->render_surface()->DrawableContentRect()); 2800 root->render_surface()->DrawableContentRect());
2806 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect()); 2801 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect());
2807 2802
2808 // Layers that do not draw content should have empty visible content rects. 2803 // Layers that do not draw content should have empty visible content rects.
2809 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect()); 2804 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect());
2810 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), 2805 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface1->visible_content_rect());
2811 render_surface1->visible_content_rect());
2812 2806
2813 // An unclipped surface grows its DrawableContentRect to include all drawable 2807 // An unclipped surface grows its DrawableContentRect to include all drawable
2814 // regions of the subtree. 2808 // regions of the subtree.
2815 EXPECT_RECT_EQ(gfx::Rect(5, 5, 170, 170), 2809 EXPECT_EQ(gfx::Rect(5, 5, 170, 170),
2816 render_surface1->render_surface()->DrawableContentRect()); 2810 render_surface1->render_surface()->DrawableContentRect());
2817 2811
2818 // All layers that draw content into the unclipped surface are also unclipped. 2812 // All layers that draw content into the unclipped surface are also unclipped.
2819 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect()); 2813 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect());
2820 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_content_rect()); 2814 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_content_rect());
2821 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_content_rect()); 2815 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_content_rect());
2822 2816
2823 EXPECT_RECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect()); 2817 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect());
2824 EXPECT_RECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect()); 2818 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect());
2825 EXPECT_RECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect()); 2819 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect());
2826 } 2820 }
2827 2821
2828 TEST_F(LayerTreeHostCommonTest, 2822 TEST_F(LayerTreeHostCommonTest,
2829 VisibleContentRectsForClippedSurfaceWithEmptyClip) { 2823 VisibleContentRectsForClippedSurfaceWithEmptyClip) {
2830 scoped_refptr<Layer> root = Layer::Create(); 2824 scoped_refptr<Layer> root = Layer::Create();
2831 scoped_refptr<LayerWithForcedDrawsContent> child1 = 2825 scoped_refptr<LayerWithForcedDrawsContent> child1 =
2832 make_scoped_refptr(new LayerWithForcedDrawsContent()); 2826 make_scoped_refptr(new LayerWithForcedDrawsContent());
2833 scoped_refptr<LayerWithForcedDrawsContent> child2 = 2827 scoped_refptr<LayerWithForcedDrawsContent> child2 =
2834 make_scoped_refptr(new LayerWithForcedDrawsContent()); 2828 make_scoped_refptr(new LayerWithForcedDrawsContent());
2835 scoped_refptr<LayerWithForcedDrawsContent> child3 = 2829 scoped_refptr<LayerWithForcedDrawsContent> child3 =
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
3078 gfx::Size(50, 50), 3072 gfx::Size(50, 50),
3079 true, 3073 true,
3080 false); 3074 false);
3081 3075
3082 root->SetMasksToBounds(true); 3076 root->SetMasksToBounds(true);
3083 render_surface1->SetForceRenderSurface(true); 3077 render_surface1->SetForceRenderSurface(true);
3084 ExecuteCalculateDrawProperties(root.get()); 3078 ExecuteCalculateDrawProperties(root.get());
3085 3079
3086 ASSERT_TRUE(render_surface1->render_surface()); 3080 ASSERT_TRUE(render_surface1->render_surface());
3087 3081
3088 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), 3082 EXPECT_EQ(gfx::Rect(0, 0, 100, 100),
3089 root->render_surface()->DrawableContentRect()); 3083 root->render_surface()->DrawableContentRect());
3090 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect()); 3084 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect());
3091 3085
3092 // Layers that do not draw content should have empty visible content rects. 3086 // Layers that do not draw content should have empty visible content rects.
3093 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect()); 3087 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect());
3094 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), 3088 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface1->visible_content_rect());
3095 render_surface1->visible_content_rect());
3096 3089
3097 // A clipped surface grows its DrawableContentRect to include all drawable 3090 // A clipped surface grows its DrawableContentRect to include all drawable
3098 // regions of the subtree, but also gets clamped by the ancestor's clip. 3091 // regions of the subtree, but also gets clamped by the ancestor's clip.
3099 EXPECT_RECT_EQ(gfx::Rect(5, 5, 95, 95), 3092 EXPECT_EQ(gfx::Rect(5, 5, 95, 95),
3100 render_surface1->render_surface()->DrawableContentRect()); 3093 render_surface1->render_surface()->DrawableContentRect());
3101 3094
3102 // All layers that draw content into the surface have their visible content 3095 // All layers that draw content into the surface have their visible content
3103 // rect clipped by the surface clip rect. 3096 // rect clipped by the surface clip rect.
3104 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect()); 3097 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect());
3105 EXPECT_RECT_EQ(gfx::Rect(0, 0, 25, 25), child2->visible_content_rect()); 3098 EXPECT_EQ(gfx::Rect(0, 0, 25, 25), child2->visible_content_rect());
3106 EXPECT_TRUE(child3->visible_content_rect().IsEmpty()); 3099 EXPECT_TRUE(child3->visible_content_rect().IsEmpty());
3107 3100
3108 // But the DrawableContentRects are unclipped. 3101 // But the DrawableContentRects are unclipped.
3109 EXPECT_RECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect()); 3102 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect());
3110 EXPECT_RECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect()); 3103 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect());
3111 EXPECT_RECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect()); 3104 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect());
3112 } 3105 }
3113 3106
3114 TEST_F(LayerTreeHostCommonTest, 3107 TEST_F(LayerTreeHostCommonTest,
3115 DrawableAndVisibleContentRectsForSurfaceHierarchy) { 3108 DrawableAndVisibleContentRectsForSurfaceHierarchy) {
3116 // Check that clipping does not propagate down surfaces. 3109 // Check that clipping does not propagate down surfaces.
3117 scoped_refptr<Layer> root = Layer::Create(); 3110 scoped_refptr<Layer> root = Layer::Create();
3118 scoped_refptr<Layer> render_surface1 = Layer::Create(); 3111 scoped_refptr<Layer> render_surface1 = Layer::Create();
3119 scoped_refptr<Layer> render_surface2 = Layer::Create(); 3112 scoped_refptr<Layer> render_surface2 = Layer::Create();
3120 scoped_refptr<LayerWithForcedDrawsContent> child1 = 3113 scoped_refptr<LayerWithForcedDrawsContent> child1 =
3121 make_scoped_refptr(new LayerWithForcedDrawsContent()); 3114 make_scoped_refptr(new LayerWithForcedDrawsContent());
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
3177 false); 3170 false);
3178 3171
3179 root->SetMasksToBounds(true); 3172 root->SetMasksToBounds(true);
3180 render_surface1->SetForceRenderSurface(true); 3173 render_surface1->SetForceRenderSurface(true);
3181 render_surface2->SetForceRenderSurface(true); 3174 render_surface2->SetForceRenderSurface(true);
3182 ExecuteCalculateDrawProperties(root.get()); 3175 ExecuteCalculateDrawProperties(root.get());
3183 3176
3184 ASSERT_TRUE(render_surface1->render_surface()); 3177 ASSERT_TRUE(render_surface1->render_surface());
3185 ASSERT_TRUE(render_surface2->render_surface()); 3178 ASSERT_TRUE(render_surface2->render_surface());
3186 3179
3187 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), 3180 EXPECT_EQ(gfx::Rect(0, 0, 100, 100),
3188 root->render_surface()->DrawableContentRect()); 3181 root->render_surface()->DrawableContentRect());
3189 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect()); 3182 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect());
3190 3183
3191 // Layers that do not draw content should have empty visible content rects. 3184 // Layers that do not draw content should have empty visible content rects.
3192 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect()); 3185 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect());
3193 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), 3186 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface1->visible_content_rect());
3194 render_surface1->visible_content_rect()); 3187 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface2->visible_content_rect());
3195 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0),
3196 render_surface2->visible_content_rect());
3197 3188
3198 // A clipped surface grows its DrawableContentRect to include all drawable 3189 // A clipped surface grows its DrawableContentRect to include all drawable
3199 // regions of the subtree, but also gets clamped by the ancestor's clip. 3190 // regions of the subtree, but also gets clamped by the ancestor's clip.
3200 EXPECT_RECT_EQ(gfx::Rect(5, 5, 95, 95), 3191 EXPECT_EQ(gfx::Rect(5, 5, 95, 95),
3201 render_surface1->render_surface()->DrawableContentRect()); 3192 render_surface1->render_surface()->DrawableContentRect());
3202 3193
3203 // render_surface1 lives in the "unclipped universe" of render_surface1, and 3194 // render_surface1 lives in the "unclipped universe" of render_surface1, and
3204 // is only implicitly clipped by render_surface1's content rect. So, 3195 // is only implicitly clipped by render_surface1's content rect. So,
3205 // render_surface2 grows to enclose all drawable content of its subtree. 3196 // render_surface2 grows to enclose all drawable content of its subtree.
3206 EXPECT_RECT_EQ(gfx::Rect(5, 5, 170, 170), 3197 EXPECT_EQ(gfx::Rect(5, 5, 170, 170),
3207 render_surface2->render_surface()->DrawableContentRect()); 3198 render_surface2->render_surface()->DrawableContentRect());
3208 3199
3209 // All layers that draw content into render_surface2 think they are unclipped. 3200 // All layers that draw content into render_surface2 think they are unclipped.
3210 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect()); 3201 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect());
3211 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_content_rect()); 3202 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_content_rect());
3212 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_content_rect()); 3203 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_content_rect());
3213 3204
3214 // DrawableContentRects are also unclipped. 3205 // DrawableContentRects are also unclipped.
3215 EXPECT_RECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect()); 3206 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect());
3216 EXPECT_RECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect()); 3207 EXPECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect());
3217 EXPECT_RECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect()); 3208 EXPECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect());
3218 } 3209 }
3219 3210
3220 TEST_F(LayerTreeHostCommonTest, 3211 TEST_F(LayerTreeHostCommonTest,
3221 DrawableAndVisibleContentRectsWithTransformOnUnclippedSurface) { 3212 DrawableAndVisibleContentRectsWithTransformOnUnclippedSurface) {
3222 // Layers that have non-axis aligned bounds (due to transforms) have an 3213 // Layers that have non-axis aligned bounds (due to transforms) have an
3223 // expanded, axis-aligned DrawableContentRect and visible content rect. 3214 // expanded, axis-aligned DrawableContentRect and visible content rect.
3224 3215
3225 scoped_refptr<Layer> root = Layer::Create(); 3216 scoped_refptr<Layer> root = Layer::Create();
3226 scoped_refptr<Layer> render_surface1 = Layer::Create(); 3217 scoped_refptr<Layer> render_surface1 = Layer::Create();
3227 scoped_refptr<LayerWithForcedDrawsContent> child1 = 3218 scoped_refptr<LayerWithForcedDrawsContent> child1 =
(...skipping 27 matching lines...) Expand all
3255 gfx::PointF(25.f, 25.f), 3246 gfx::PointF(25.f, 25.f),
3256 gfx::Size(50, 50), 3247 gfx::Size(50, 50),
3257 true, 3248 true,
3258 false); 3249 false);
3259 3250
3260 render_surface1->SetForceRenderSurface(true); 3251 render_surface1->SetForceRenderSurface(true);
3261 ExecuteCalculateDrawProperties(root.get()); 3252 ExecuteCalculateDrawProperties(root.get());
3262 3253
3263 ASSERT_TRUE(render_surface1->render_surface()); 3254 ASSERT_TRUE(render_surface1->render_surface());
3264 3255
3265 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), 3256 EXPECT_EQ(gfx::Rect(0, 0, 100, 100),
3266 root->render_surface()->DrawableContentRect()); 3257 root->render_surface()->DrawableContentRect());
3267 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect()); 3258 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect());
3268 3259
3269 // Layers that do not draw content should have empty visible content rects. 3260 // Layers that do not draw content should have empty visible content rects.
3270 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect()); 3261 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect());
3271 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), 3262 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), render_surface1->visible_content_rect());
3272 render_surface1->visible_content_rect());
3273 3263
3274 // The unclipped surface grows its DrawableContentRect to include all drawable 3264 // The unclipped surface grows its DrawableContentRect to include all drawable
3275 // regions of the subtree. 3265 // regions of the subtree.
3276 int diagonal_radius = ceil(sqrt(2.0) * 25.0); 3266 int diagonal_radius = ceil(sqrt(2.0) * 25.0);
3277 gfx::Rect expected_surface_drawable_content = 3267 gfx::Rect expected_surface_drawable_content =
3278 gfx::Rect(50 - diagonal_radius, 3268 gfx::Rect(50 - diagonal_radius,
3279 50 - diagonal_radius, 3269 50 - diagonal_radius,
3280 diagonal_radius * 2, 3270 diagonal_radius * 2,
3281 diagonal_radius * 2); 3271 diagonal_radius * 2);
3282 EXPECT_RECT_EQ(expected_surface_drawable_content, 3272 EXPECT_EQ(expected_surface_drawable_content,
3283 render_surface1->render_surface()->DrawableContentRect()); 3273 render_surface1->render_surface()->DrawableContentRect());
3284 3274
3285 // All layers that draw content into the unclipped surface are also unclipped. 3275 // All layers that draw content into the unclipped surface are also unclipped.
3286 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect()); 3276 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect());
3287 EXPECT_RECT_EQ(expected_surface_drawable_content, 3277 EXPECT_EQ(expected_surface_drawable_content, child1->drawable_content_rect());
3288 child1->drawable_content_rect());
3289 } 3278 }
3290 3279
3291 TEST_F(LayerTreeHostCommonTest, 3280 TEST_F(LayerTreeHostCommonTest,
3292 DrawableAndVisibleContentRectsWithTransformOnClippedSurface) { 3281 DrawableAndVisibleContentRectsWithTransformOnClippedSurface) {
3293 // Layers that have non-axis aligned bounds (due to transforms) have an 3282 // Layers that have non-axis aligned bounds (due to transforms) have an
3294 // expanded, axis-aligned DrawableContentRect and visible content rect. 3283 // expanded, axis-aligned DrawableContentRect and visible content rect.
3295 3284
3296 scoped_refptr<Layer> root = Layer::Create(); 3285 scoped_refptr<Layer> root = Layer::Create();
3297 scoped_refptr<Layer> render_surface1 = Layer::Create(); 3286 scoped_refptr<Layer> render_surface1 = Layer::Create();
3298 scoped_refptr<LayerWithForcedDrawsContent> child1 = 3287 scoped_refptr<LayerWithForcedDrawsContent> child1 =
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
3337 3326
3338 // The clipped surface clamps the DrawableContentRect that encloses the 3327 // The clipped surface clamps the DrawableContentRect that encloses the
3339 // rotated layer. 3328 // rotated layer.
3340 int diagonal_radius = ceil(sqrt(2.0) * 25.0); 3329 int diagonal_radius = ceil(sqrt(2.0) * 25.0);
3341 gfx::Rect unclipped_surface_content = gfx::Rect(50 - diagonal_radius, 3330 gfx::Rect unclipped_surface_content = gfx::Rect(50 - diagonal_radius,
3342 50 - diagonal_radius, 3331 50 - diagonal_radius,
3343 diagonal_radius * 2, 3332 diagonal_radius * 2,
3344 diagonal_radius * 2); 3333 diagonal_radius * 2);
3345 gfx::Rect expected_surface_drawable_content = 3334 gfx::Rect expected_surface_drawable_content =
3346 gfx::IntersectRects(unclipped_surface_content, gfx::Rect(0, 0, 50, 50)); 3335 gfx::IntersectRects(unclipped_surface_content, gfx::Rect(0, 0, 50, 50));
3347 EXPECT_RECT_EQ(expected_surface_drawable_content, 3336 EXPECT_EQ(expected_surface_drawable_content,
3348 render_surface1->render_surface()->DrawableContentRect()); 3337 render_surface1->render_surface()->DrawableContentRect());
3349 3338
3350 // On the clipped surface, only a quarter of the child1 is visible, but when 3339 // On the clipped surface, only a quarter of the child1 is visible, but when
3351 // rotating it back to child1's content space, the actual enclosing rect ends 3340 // rotating it back to child1's content space, the actual enclosing rect ends
3352 // up covering the full left half of child1. 3341 // up covering the full left half of child1.
3353 // 3342 //
3354 // Given the floating point math, this number is a little bit fuzzy. 3343 // Given the floating point math, this number is a little bit fuzzy.
3355 EXPECT_RECT_EQ(gfx::Rect(0, 0, 26, 50), child1->visible_content_rect()); 3344 EXPECT_EQ(gfx::Rect(0, 0, 26, 50), child1->visible_content_rect());
3356 3345
3357 // The child's DrawableContentRect is unclipped. 3346 // The child's DrawableContentRect is unclipped.
3358 EXPECT_RECT_EQ(unclipped_surface_content, child1->drawable_content_rect()); 3347 EXPECT_EQ(unclipped_surface_content, child1->drawable_content_rect());
3359 } 3348 }
3360 3349
3361 TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsInHighDPI) { 3350 TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsInHighDPI) {
3362 MockContentLayerClient client; 3351 MockContentLayerClient client;
3363 3352
3364 scoped_refptr<Layer> root = Layer::Create(); 3353 scoped_refptr<Layer> root = Layer::Create();
3365 scoped_refptr<FakePictureLayer> render_surface1 = 3354 scoped_refptr<FakePictureLayer> render_surface1 =
3366 CreateDrawablePictureLayer(&client); 3355 CreateDrawablePictureLayer(&client);
3367 scoped_refptr<FakePictureLayer> render_surface2 = 3356 scoped_refptr<FakePictureLayer> render_surface2 =
3368 CreateDrawablePictureLayer(&client); 3357 CreateDrawablePictureLayer(&client);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
3427 root->SetMasksToBounds(true); 3416 root->SetMasksToBounds(true);
3428 render_surface1->SetForceRenderSurface(true); 3417 render_surface1->SetForceRenderSurface(true);
3429 render_surface2->SetForceRenderSurface(true); 3418 render_surface2->SetForceRenderSurface(true);
3430 ExecuteCalculateDrawProperties(root.get(), device_scale_factor); 3419 ExecuteCalculateDrawProperties(root.get(), device_scale_factor);
3431 3420
3432 ASSERT_TRUE(render_surface1->render_surface()); 3421 ASSERT_TRUE(render_surface1->render_surface());
3433 ASSERT_TRUE(render_surface2->render_surface()); 3422 ASSERT_TRUE(render_surface2->render_surface());
3434 3423
3435 // drawable_content_rects for all layers and surfaces are scaled by 3424 // drawable_content_rects for all layers and surfaces are scaled by
3436 // device_scale_factor. 3425 // device_scale_factor.
3437 EXPECT_RECT_EQ(gfx::Rect(0, 0, 200, 200), 3426 EXPECT_EQ(gfx::Rect(0, 0, 200, 200),
3438 root->render_surface()->DrawableContentRect()); 3427 root->render_surface()->DrawableContentRect());
3439 EXPECT_RECT_EQ(gfx::Rect(0, 0, 200, 200), root->drawable_content_rect()); 3428 EXPECT_EQ(gfx::Rect(0, 0, 200, 200), root->drawable_content_rect());
3440 EXPECT_RECT_EQ(gfx::Rect(10, 10, 190, 190), 3429 EXPECT_EQ(gfx::Rect(10, 10, 190, 190),
3441 render_surface1->render_surface()->DrawableContentRect()); 3430 render_surface1->render_surface()->DrawableContentRect());
3442 3431
3443 // render_surface2 lives in the "unclipped universe" of render_surface1, and 3432 // render_surface2 lives in the "unclipped universe" of render_surface1, and
3444 // is only implicitly clipped by render_surface1. 3433 // is only implicitly clipped by render_surface1.
3445 EXPECT_RECT_EQ(gfx::Rect(10, 10, 350, 350), 3434 EXPECT_EQ(gfx::Rect(10, 10, 350, 350),
3446 render_surface2->render_surface()->DrawableContentRect()); 3435 render_surface2->render_surface()->DrawableContentRect());
3447 3436
3448 EXPECT_RECT_EQ(gfx::Rect(10, 10, 100, 100), child1->drawable_content_rect()); 3437 EXPECT_EQ(gfx::Rect(10, 10, 100, 100), child1->drawable_content_rect());
3449 EXPECT_RECT_EQ(gfx::Rect(150, 150, 100, 100), 3438 EXPECT_EQ(gfx::Rect(150, 150, 100, 100), child2->drawable_content_rect());
3450 child2->drawable_content_rect()); 3439 EXPECT_EQ(gfx::Rect(250, 250, 100, 100), child3->drawable_content_rect());
3451 EXPECT_RECT_EQ(gfx::Rect(250, 250, 100, 100),
3452 child3->drawable_content_rect());
3453 3440
3454 // The root layer does not actually draw content of its own. 3441 // The root layer does not actually draw content of its own.
3455 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect()); 3442 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect());
3456 3443
3457 // All layer visible content rects are not expressed in content space of each 3444 // All layer visible content rects are not expressed in content space of each
3458 // layer, so they are not scaled by the device_scale_factor. 3445 // layer, so they are not scaled by the device_scale_factor.
3459 EXPECT_RECT_EQ(gfx::Rect(0, 0, 3, 4), 3446 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), render_surface1->visible_content_rect());
3460 render_surface1->visible_content_rect()); 3447 EXPECT_EQ(gfx::Rect(0, 0, 7, 13), render_surface2->visible_content_rect());
3461 EXPECT_RECT_EQ(gfx::Rect(0, 0, 7, 13), 3448 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect());
3462 render_surface2->visible_content_rect()); 3449 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_content_rect());
3463 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect()); 3450 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_content_rect());
3464 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_content_rect());
3465 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_content_rect());
3466 } 3451 }
3467 3452
3468 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithoutPreserves3d) { 3453 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithoutPreserves3d) {
3469 // Verify the behavior of back-face culling when there are no preserve-3d 3454 // Verify the behavior of back-face culling when there are no preserve-3d
3470 // layers. Note that 3d transforms still apply in this case, but they are 3455 // layers. Note that 3d transforms still apply in this case, but they are
3471 // "flattened" to each parent layer according to current W3C spec. 3456 // "flattened" to each parent layer according to current W3C spec.
3472 3457
3473 const gfx::Transform identity_matrix; 3458 const gfx::Transform identity_matrix;
3474 scoped_refptr<Layer> parent = Layer::Create(); 3459 scoped_refptr<Layer> parent = Layer::Create();
3475 scoped_refptr<LayerWithForcedDrawsContent> front_facing_child = 3460 scoped_refptr<LayerWithForcedDrawsContent> front_facing_child =
(...skipping 1975 matching lines...) Expand 10 before | Expand all | Expand 10 after
5451 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_screen_space_transform, 5436 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_screen_space_transform,
5452 child->screen_space_transform()); 5437 child->screen_space_transform());
5453 5438
5454 gfx::Transform expected_duplicate_child_draw_transform = 5439 gfx::Transform expected_duplicate_child_draw_transform =
5455 child->draw_transform(); 5440 child->draw_transform();
5456 EXPECT_TRANSFORMATION_MATRIX_EQ(child->draw_transform(), 5441 EXPECT_TRANSFORMATION_MATRIX_EQ(child->draw_transform(),
5457 duplicate_child_non_owner->draw_transform()); 5442 duplicate_child_non_owner->draw_transform());
5458 EXPECT_TRANSFORMATION_MATRIX_EQ( 5443 EXPECT_TRANSFORMATION_MATRIX_EQ(
5459 child->screen_space_transform(), 5444 child->screen_space_transform(),
5460 duplicate_child_non_owner->screen_space_transform()); 5445 duplicate_child_non_owner->screen_space_transform());
5461 EXPECT_RECT_EQ(child->drawable_content_rect(), 5446 EXPECT_EQ(child->drawable_content_rect(),
5462 duplicate_child_non_owner->drawable_content_rect()); 5447 duplicate_child_non_owner->drawable_content_rect());
5463 EXPECT_EQ(child->content_bounds(), 5448 EXPECT_EQ(child->content_bounds(),
5464 duplicate_child_non_owner->content_bounds()); 5449 duplicate_child_non_owner->content_bounds());
5465 5450
5466 gfx::Transform expected_render_surface_draw_transform; 5451 gfx::Transform expected_render_surface_draw_transform;
5467 expected_render_surface_draw_transform.Translate( 5452 expected_render_surface_draw_transform.Translate(
5468 device_scale_factor * child->position().x(), 5453 device_scale_factor * child->position().x(),
5469 device_scale_factor * child->position().y()); 5454 device_scale_factor * child->position().y());
5470 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_render_surface_draw_transform, 5455 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_render_surface_draw_transform,
5471 child->render_surface()->draw_transform()); 5456 child->render_surface()->draw_transform());
5472 5457
(...skipping 3198 matching lines...) Expand 10 before | Expand all | Expand 10 after
8671 // by the viewport. 8656 // by the viewport.
8672 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), root->visible_content_rect()); 8657 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), root->visible_content_rect());
8673 8658
8674 // Layers drawing to a child render surface should still have their visible 8659 // Layers drawing to a child render surface should still have their visible
8675 // content rect clipped by the viewport. 8660 // content rect clipped by the viewport.
8676 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), content->visible_content_rect()); 8661 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), content->visible_content_rect());
8677 } 8662 }
8678 8663
8679 } // namespace 8664 } // namespace
8680 } // namespace cc 8665 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_tree_json_parser_unittest.cc ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698