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

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

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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_set.cc ('k') | cc/resources/picture_pile.h » ('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 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 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 scoped_refptr<FakePicturePileImpl> pile = 684 scoped_refptr<FakePicturePileImpl> pile =
685 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); 685 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds);
686 scoped_ptr<TestablePictureLayerTiling> tiling = 686 scoped_ptr<TestablePictureLayerTiling> tiling =
687 TestablePictureLayerTiling::Create(0.25f, pile, &client, settings); 687 TestablePictureLayerTiling::Create(0.25f, pile, &client, settings);
688 gfx::Rect viewport_in_content_space = 688 gfx::Rect viewport_in_content_space =
689 gfx::ToEnclosedRect(gfx::ScaleRect(viewport, 0.25f)); 689 gfx::ToEnclosedRect(gfx::ScaleRect(viewport, 0.25f));
690 690
691 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion()); 691 tiling->ComputeTilePriorityRects(viewport, 1.f, 1.0, Occlusion());
692 tiling->UpdateAllTilePrioritiesForTesting(); 692 tiling->UpdateAllTilePrioritiesForTesting();
693 693
694 gfx::Rect soon_rect = viewport; 694 // Compute the soon border.
695 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); 695 float inset = PictureLayerTiling::CalculateSoonBorderDistance(
696 gfx::Rect soon_rect_in_content_space = 696 viewport_in_content_space, 1.0f / 0.25f);
697 gfx::ToEnclosedRect(gfx::ScaleRect(soon_rect, 0.25f)); 697 gfx::Rect soon_rect_in_content_space = viewport_in_content_space;
698 soon_rect_in_content_space.Inset(-inset, -inset);
698 699
699 // Sanity checks. 700 // Sanity checks.
700 for (int i = 0; i < 47; ++i) { 701 for (int i = 0; i < 47; ++i) {
701 for (int j = 0; j < 47; ++j) { 702 for (int j = 0; j < 47; ++j) {
702 EXPECT_TRUE(tiling->TileAt(i, j)) << "i: " << i << " j: " << j; 703 EXPECT_TRUE(tiling->TileAt(i, j)) << "i: " << i << " j: " << j;
703 } 704 }
704 } 705 }
705 for (int i = 0; i < 47; ++i) { 706 for (int i = 0; i < 47; ++i) {
706 EXPECT_FALSE(tiling->TileAt(i, 47)) << "i: " << i; 707 EXPECT_FALSE(tiling->TileAt(i, 47)) << "i: " << i;
707 EXPECT_FALSE(tiling->TileAt(47, i)) << "i: " << i; 708 EXPECT_FALSE(tiling->TileAt(47, i)) << "i: " << i;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 757
757 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE); 758 priority = tiling->TileAt(3, 4)->priority(ACTIVE_TREE);
758 EXPECT_FLOAT_EQ(40.f, priority.distance_to_visible); 759 EXPECT_FLOAT_EQ(40.f, priority.distance_to_visible);
759 760
760 // Move the viewport down 40 pixels. 761 // Move the viewport down 40 pixels.
761 viewport = gfx::Rect(0, 40, 100, 100); 762 viewport = gfx::Rect(0, 40, 100, 100);
762 viewport_in_content_space = 763 viewport_in_content_space =
763 gfx::ToEnclosedRect(gfx::ScaleRect(viewport, 0.25f)); 764 gfx::ToEnclosedRect(gfx::ScaleRect(viewport, 0.25f));
764 gfx::Rect skewport = tiling->ComputeSkewport(2.0, viewport_in_content_space); 765 gfx::Rect skewport = tiling->ComputeSkewport(2.0, viewport_in_content_space);
765 766
766 soon_rect = viewport; 767 // Compute the soon border.
767 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); 768 inset = PictureLayerTiling::CalculateSoonBorderDistance(
768 soon_rect_in_content_space = 769 viewport_in_content_space, 1.0f / 0.25f);
769 gfx::ToEnclosedRect(gfx::ScaleRect(soon_rect, 0.25f)); 770 soon_rect_in_content_space = viewport_in_content_space;
771 soon_rect_in_content_space.Inset(-inset, -inset);
770 772
771 EXPECT_EQ(0, skewport.x()); 773 EXPECT_EQ(0, skewport.x());
772 EXPECT_EQ(10, skewport.y()); 774 EXPECT_EQ(10, skewport.y());
773 EXPECT_EQ(25, skewport.width()); 775 EXPECT_EQ(25, skewport.width());
774 EXPECT_EQ(35, skewport.height()); 776 EXPECT_EQ(35, skewport.height());
775 777
776 tiling->ComputeTilePriorityRects(viewport, 1.f, 2.0, Occlusion()); 778 tiling->ComputeTilePriorityRects(viewport, 1.f, 2.0, Occlusion());
777 tiling->UpdateAllTilePrioritiesForTesting(); 779 tiling->UpdateAllTilePrioritiesForTesting();
778 780
779 have_now = false; 781 have_now = false;
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1888 tiling_->SetRasterSourceAndResize(pile); 1890 tiling_->SetRasterSourceAndResize(pile);
1889 1891
1890 // Tile size in the tiling should be resized to 250x200. 1892 // Tile size in the tiling should be resized to 250x200.
1891 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); 1893 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width());
1892 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); 1894 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height());
1893 EXPECT_EQ(0u, tiling_->AllRefTilesForTesting().size()); 1895 EXPECT_EQ(0u, tiling_->AllRefTilesForTesting().size());
1894 } 1896 }
1895 1897
1896 } // namespace 1898 } // namespace
1897 } // namespace cc 1899 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_layer_tiling_set.cc ('k') | cc/resources/picture_pile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698