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

Side by Side Diff: cc/resources/picture_layer_tiling_unittest.cc

Issue 1021663002: cc: Fix skewport math (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix for empty viewport Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « cc/resources/picture_layer_tiling.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/resources/picture_layer_tiling.h" 5 #include "cc/resources/picture_layer_tiling.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <set> 8 #include <set>
9 9
10 #include "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 tiling->ComputeSkewport(1.5, gfx::Rect(-50, -50, 200, 200)); 584 tiling->ComputeSkewport(1.5, gfx::Rect(-50, -50, 200, 200));
585 585
586 // x and y moved by -75 (-50 - 75 = -125). 586 // x and y moved by -75 (-50 - 75 = -125).
587 // right side and bottom side moved by 75 [(350 - 125) - (200 - 50) = 75]. 587 // right side and bottom side moved by 75 [(350 - 125) - (200 - 50) = 75].
588 EXPECT_EQ(-125, expand_skewport.x()); 588 EXPECT_EQ(-125, expand_skewport.x());
589 EXPECT_EQ(-125, expand_skewport.y()); 589 EXPECT_EQ(-125, expand_skewport.y());
590 EXPECT_EQ(350, expand_skewport.width()); 590 EXPECT_EQ(350, expand_skewport.width());
591 EXPECT_EQ(350, expand_skewport.height()); 591 EXPECT_EQ(350, expand_skewport.height());
592 EXPECT_TRUE(expand_skewport.Contains(gfx::Rect(-50, -50, 200, 200))); 592 EXPECT_TRUE(expand_skewport.Contains(gfx::Rect(-50, -50, 200, 200)));
593 593
594 // Expand the viewport past the limit. 594 // Expand the viewport past the limit in all directions.
595 gfx::Rect big_expand_skewport = 595 gfx::Rect big_expand_skewport =
596 tiling->ComputeSkewport(1.5, gfx::Rect(-500, -500, 1500, 1500)); 596 tiling->ComputeSkewport(1.5, gfx::Rect(-500, -500, 1500, 1500));
597 597
598 EXPECT_EQ(-575, big_expand_skewport.x()); 598 EXPECT_EQ(-575, big_expand_skewport.x());
599 EXPECT_EQ(-575, big_expand_skewport.y()); 599 EXPECT_EQ(-575, big_expand_skewport.y());
600 EXPECT_EQ(1650, big_expand_skewport.width()); 600 EXPECT_EQ(1650, big_expand_skewport.width());
601 EXPECT_EQ(1650, big_expand_skewport.height()); 601 EXPECT_EQ(1650, big_expand_skewport.height());
602 EXPECT_TRUE(big_expand_skewport.Contains(gfx::Rect(-500, -500, 1500, 1500))); 602 EXPECT_TRUE(big_expand_skewport.Contains(gfx::Rect(-500, -500, 1500, 1500)));
603
604 // Shrink the skewport in all directions.
605 gfx::Rect shrink_viewport =
606 tiling->ComputeSkewport(1.5, gfx::Rect(0, 0, 100, 100));
607 EXPECT_EQ(0, shrink_viewport.x());
608 EXPECT_EQ(0, shrink_viewport.y());
609 EXPECT_EQ(100, shrink_viewport.width());
610 EXPECT_EQ(100, shrink_viewport.height());
611
612 // Move the skewport really far in one direction.
613 gfx::Rect move_skewport_far =
614 tiling->ComputeSkewport(1.5, gfx::Rect(0, 5000, 100, 100));
615 EXPECT_EQ(0, move_skewport_far.x());
616 EXPECT_EQ(5000, move_skewport_far.y());
617 EXPECT_EQ(100, move_skewport_far.width());
618 EXPECT_EQ(175, move_skewport_far.height());
619 EXPECT_TRUE(move_skewport_far.Contains(gfx::Rect(0, 5000, 100, 100)));
603 } 620 }
604 621
605 TEST(PictureLayerTilingTest, ComputeSkewport) { 622 TEST(PictureLayerTilingTest, ComputeSkewport) {
606 FakePictureLayerTilingClient client; 623 FakePictureLayerTilingClient client;
607 624
608 gfx::Rect viewport(0, 0, 100, 100); 625 gfx::Rect viewport(0, 0, 100, 100);
609 gfx::Size layer_bounds(200, 200); 626 gfx::Size layer_bounds(200, 200);
610 627
611 client.SetTileSize(gfx::Size(100, 100)); 628 client.SetTileSize(gfx::Size(100, 100));
612 client.set_tree(ACTIVE_TREE); 629 client.set_tree(ACTIVE_TREE);
(...skipping 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1959 tiling_->SetRasterSourceAndResize(pile); 1976 tiling_->SetRasterSourceAndResize(pile);
1960 1977
1961 // Tile size in the tiling should be resized to 250x200. 1978 // Tile size in the tiling should be resized to 250x200.
1962 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); 1979 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width());
1963 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); 1980 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height());
1964 EXPECT_EQ(0u, tiling_->AllRefTilesForTesting().size()); 1981 EXPECT_EQ(0u, tiling_->AllRefTilesForTesting().size());
1965 } 1982 }
1966 1983
1967 } // namespace 1984 } // namespace
1968 } // namespace cc 1985 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_layer_tiling.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698