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

Side by Side Diff: cc/layers/picture_layer_impl_unittest.cc

Issue 678773002: cc: Always use invalidation on the pending tree when deciding to share (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: getpendinginvalidation: . Created 6 years, 1 month 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/layers/picture_layer_impl.cc ('k') | cc/resources/picture_layer_tiling.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/layers/picture_layer_impl.h" 5 #include "cc/layers/picture_layer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 2008 matching lines...) Expand 10 before | Expand all | Expand 10 after
2019 host_impl_.ActivateSyncTree(); 2019 host_impl_.ActivateSyncTree();
2020 2020
2021 active_layer_ = static_cast<FakePictureLayerImpl*>( 2021 active_layer_ = static_cast<FakePictureLayerImpl*>(
2022 host_impl_.active_tree()->LayerById(id_)); 2022 host_impl_.active_tree()->LayerById(id_));
2023 2023
2024 EXPECT_EQ(0u, active_layer_->num_tilings()); 2024 EXPECT_EQ(0u, active_layer_->num_tilings());
2025 EXPECT_EQ(raster_page_scale, active_layer_->raster_page_scale()); 2025 EXPECT_EQ(raster_page_scale, active_layer_->raster_page_scale());
2026 EXPECT_FALSE(active_layer_->needs_post_commit_initialization()); 2026 EXPECT_FALSE(active_layer_->needs_post_commit_initialization());
2027 } 2027 }
2028 2028
2029 TEST_F(PictureLayerImplTest, ShareTilesOnNextFrame) {
2030 SetupDefaultTrees(gfx::Size(1500, 1500));
2031
2032 PictureLayerTiling* tiling = pending_layer_->AddTiling(1.f);
2033 gfx::Rect first_invalidate = tiling->TilingDataForTesting().TileBounds(0, 0);
2034 first_invalidate.Inset(tiling->TilingDataForTesting().border_texels(),
2035 tiling->TilingDataForTesting().border_texels());
2036 gfx::Rect second_invalidate = tiling->TilingDataForTesting().TileBounds(1, 1);
2037 second_invalidate.Inset(tiling->TilingDataForTesting().border_texels(),
2038 tiling->TilingDataForTesting().border_texels());
2039
2040 // Make a pending tree with an invalidated raster tile 0,0.
2041 tiling->CreateAllTilesForTesting();
2042 pending_layer_->set_invalidation(first_invalidate);
2043
2044 // Activate and make a pending tree with an invalidated raster tile 1,1.
2045 ActivateTree();
2046
2047 host_impl_.CreatePendingTree();
2048 pending_layer_ = static_cast<FakePictureLayerImpl*>(
2049 host_impl_.pending_tree()->root_layer());
2050 pending_layer_->set_invalidation(second_invalidate);
2051
2052 // TODO(danakj): Remove this when twins are set up better.
2053 // https://codereview.chromium.org/676953003/
2054 pending_layer_->DoPostCommitInitializationIfNeeded();
2055
2056 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0);
2057 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0);
2058
2059 pending_tiling->CreateAllTilesForTesting();
2060
2061 // Tile 0,0 should be shared, but tile 1,1 should not be.
2062 EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0));
2063 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0));
2064 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1));
2065 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1));
2066 EXPECT_TRUE(pending_tiling->TileAt(0, 0)->is_shared());
2067 EXPECT_TRUE(pending_tiling->TileAt(1, 0)->is_shared());
2068 EXPECT_TRUE(pending_tiling->TileAt(0, 1)->is_shared());
2069 EXPECT_FALSE(pending_tiling->TileAt(1, 1)->is_shared());
2070
2071 // Drop the tiles on the active tree and recreate them. The same tiles
2072 // should be shared or not.
2073 active_tiling->ComputeTilePriorityRects(
2074 ACTIVE_TREE, gfx::Rect(), 1.f, 1.0, Occlusion());
2075 EXPECT_TRUE(active_tiling->AllTilesForTesting().empty());
2076 active_tiling->CreateAllTilesForTesting();
2077
2078 // Tile 0,0 should be shared, but tile 1,1 should not be.
2079 EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0));
2080 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0));
2081 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1));
2082 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1));
2083 EXPECT_TRUE(pending_tiling->TileAt(0, 0)->is_shared());
2084 EXPECT_TRUE(pending_tiling->TileAt(1, 0)->is_shared());
2085 EXPECT_TRUE(pending_tiling->TileAt(0, 1)->is_shared());
2086 EXPECT_FALSE(pending_tiling->TileAt(1, 1)->is_shared());
2087 }
2088
2029 TEST_F(PictureLayerImplTest, ShareTilesOnSync) { 2089 TEST_F(PictureLayerImplTest, ShareTilesOnSync) {
2030 SetupDefaultTrees(gfx::Size(1500, 1500)); 2090 SetupDefaultTrees(gfx::Size(1500, 1500));
2031 AddDefaultTilingsWithInvalidation(gfx::Rect()); 2091 AddDefaultTilingsWithInvalidation(gfx::Rect());
2032 2092
2033 host_impl_.ActivateSyncTree(); 2093 host_impl_.ActivateSyncTree();
2034 host_impl_.CreatePendingTree(); 2094 host_impl_.CreatePendingTree();
2035 active_layer_ = static_cast<FakePictureLayerImpl*>( 2095 active_layer_ = static_cast<FakePictureLayerImpl*>(
2036 host_impl_.active_tree()->LayerById(id_)); 2096 host_impl_.active_tree()->LayerById(id_));
2037 2097
2038 // Force the active tree to sync to the pending tree "post-commit". 2098 // Force the active tree to sync to the pending tree "post-commit".
(...skipping 2608 matching lines...) Expand 10 before | Expand all | Expand 10 after
4647 result = layer->CalculateTileSize(gfx::Size(447, 400)); 4707 result = layer->CalculateTileSize(gfx::Size(447, 400));
4648 EXPECT_EQ(result.width(), 448); 4708 EXPECT_EQ(result.width(), 448);
4649 EXPECT_EQ(result.height(), 448); 4709 EXPECT_EQ(result.height(), 448);
4650 result = layer->CalculateTileSize(gfx::Size(500, 499)); 4710 result = layer->CalculateTileSize(gfx::Size(500, 499));
4651 EXPECT_EQ(result.width(), 512); 4711 EXPECT_EQ(result.width(), 512);
4652 EXPECT_EQ(result.height(), 500 + 2); 4712 EXPECT_EQ(result.height(), 500 + 2);
4653 } 4713 }
4654 4714
4655 } // namespace 4715 } // namespace
4656 } // namespace cc 4716 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | cc/resources/picture_layer_tiling.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698