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

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

Issue 478723002: cc: fix content_to_screen_scale in UpdateTilePriorities. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't create another tiling Created 6 years, 4 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 | Annotate | Revision Log
« 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 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 EXPECT_FLOAT_EQ(28.f, priority.distance_to_visible); 615 EXPECT_FLOAT_EQ(28.f, priority.distance_to_visible);
616 616
617 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); 617 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE);
618 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); 618 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible);
619 619
620 // Change the underlying layer scale. 620 // Change the underlying layer scale.
621 tiling->UpdateTilePriorities( 621 tiling->UpdateTilePriorities(
622 ACTIVE_TREE, viewport, 2.0f, 3.0, NULL, NULL, gfx::Transform()); 622 ACTIVE_TREE, viewport, 2.0f, 3.0, NULL, NULL, gfx::Transform());
623 623
624 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE); 624 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE);
625 EXPECT_FLOAT_EQ(34.f, priority.distance_to_visible); 625 EXPECT_FLOAT_EQ(136.f, priority.distance_to_visible);
626 626
627 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE); 627 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE);
628 EXPECT_FLOAT_EQ(14.f, priority.distance_to_visible); 628 EXPECT_FLOAT_EQ(56.f, priority.distance_to_visible);
629 629
630 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); 630 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE);
631 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible); 631 EXPECT_FLOAT_EQ(0.f, priority.distance_to_visible);
632
633 // Test additional scales.
634 tiling = TestablePictureLayerTiling::Create(0.2f, layer_bounds, &client);
635 tiling->UpdateTilePriorities(
636 ACTIVE_TREE, viewport, 1.0f, 4.0, NULL, NULL, gfx::Transform());
637
638 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE);
639 EXPECT_FLOAT_EQ(110.f, priority.distance_to_visible);
640
641 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE);
642 EXPECT_FLOAT_EQ(70.f, priority.distance_to_visible);
643
644 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE);
645 EXPECT_FLOAT_EQ(60.f, priority.distance_to_visible);
646
647 tiling->UpdateTilePriorities(
648 ACTIVE_TREE, viewport, 0.5f, 5.0, NULL, NULL, gfx::Transform());
649
650 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE);
651 EXPECT_FLOAT_EQ(55.f, priority.distance_to_visible);
652
653 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE);
654 EXPECT_FLOAT_EQ(35.f, priority.distance_to_visible);
655
656 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE);
657 EXPECT_FLOAT_EQ(30.f, priority.distance_to_visible);
632 } 658 }
633 659
634 TEST(PictureLayerTilingTest, ExpandRectEqual) { 660 TEST(PictureLayerTilingTest, ExpandRectEqual) {
635 gfx::Rect in(40, 50, 100, 200); 661 gfx::Rect in(40, 50, 100, 200);
636 gfx::Rect bounds(-1000, -1000, 10000, 10000); 662 gfx::Rect bounds(-1000, -1000, 10000, 10000);
637 int64 target_area = 100 * 200; 663 int64 target_area = 100 * 200;
638 gfx::Rect out = PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( 664 gfx::Rect out = PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy(
639 in, target_area, bounds, NULL); 665 in, target_area, bounds, NULL);
640 EXPECT_EQ(in.ToString(), out.ToString()); 666 EXPECT_EQ(in.ToString(), out.ToString());
641 } 667 }
(...skipping 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1917 for (std::vector<scoped_refptr<Tile> >::const_iterator it = tiles.begin(); 1943 for (std::vector<scoped_refptr<Tile> >::const_iterator it = tiles.begin();
1918 it != tiles.end(); 1944 it != tiles.end();
1919 ++it) { 1945 ++it) {
1920 EXPECT_EQ(TilePriority(), (*it)->priority(ACTIVE_TREE)); 1946 EXPECT_EQ(TilePriority(), (*it)->priority(ACTIVE_TREE));
1921 } 1947 }
1922 tiles.clear(); 1948 tiles.clear();
1923 } 1949 }
1924 1950
1925 } // namespace 1951 } // namespace
1926 } // namespace cc 1952 } // 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