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

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: Test additional scales. 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, 3.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 = TestablePictureLayerTiling::Create(0.2f, layer_bounds, &client);
vmpstr 2014/08/15 20:11:57 nit: this tiling is exactly the same as the above
ernstm 2014/08/15 21:29:21 Done.
648 tiling->UpdateTilePriorities(
649 ACTIVE_TREE, viewport, 0.5f, 3.0, NULL, NULL, gfx::Transform());
650
651 priority = tiling->TileAt(5, 1)->priority(ACTIVE_TREE);
652 EXPECT_FLOAT_EQ(55.f, priority.distance_to_visible);
653
654 priority = tiling->TileAt(2, 5)->priority(ACTIVE_TREE);
655 EXPECT_FLOAT_EQ(35.f, priority.distance_to_visible);
656
657 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE);
658 EXPECT_FLOAT_EQ(30.f, priority.distance_to_visible);
632 } 659 }
633 660
634 TEST(PictureLayerTilingTest, ExpandRectEqual) { 661 TEST(PictureLayerTilingTest, ExpandRectEqual) {
635 gfx::Rect in(40, 50, 100, 200); 662 gfx::Rect in(40, 50, 100, 200);
636 gfx::Rect bounds(-1000, -1000, 10000, 10000); 663 gfx::Rect bounds(-1000, -1000, 10000, 10000);
637 int64 target_area = 100 * 200; 664 int64 target_area = 100 * 200;
638 gfx::Rect out = PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( 665 gfx::Rect out = PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy(
639 in, target_area, bounds, NULL); 666 in, target_area, bounds, NULL);
640 EXPECT_EQ(in.ToString(), out.ToString()); 667 EXPECT_EQ(in.ToString(), out.ToString());
641 } 668 }
(...skipping 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1917 for (std::vector<scoped_refptr<Tile> >::const_iterator it = tiles.begin(); 1944 for (std::vector<scoped_refptr<Tile> >::const_iterator it = tiles.begin();
1918 it != tiles.end(); 1945 it != tiles.end();
1919 ++it) { 1946 ++it) {
1920 EXPECT_EQ(TilePriority(), (*it)->priority(ACTIVE_TREE)); 1947 EXPECT_EQ(TilePriority(), (*it)->priority(ACTIVE_TREE));
1921 } 1948 }
1922 tiles.clear(); 1949 tiles.clear();
1923 } 1950 }
1924 1951
1925 } // namespace 1952 } // namespace
1926 } // namespace cc 1953 } // 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