OLD | NEW |
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 16 matching lines...) Expand all Loading... |
27 #include "cc/test/test_shared_bitmap_manager.h" | 27 #include "cc/test/test_shared_bitmap_manager.h" |
28 #include "cc/test/test_web_graphics_context_3d.h" | 28 #include "cc/test/test_web_graphics_context_3d.h" |
29 #include "cc/trees/layer_tree_impl.h" | 29 #include "cc/trees/layer_tree_impl.h" |
30 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
31 #include "ui/gfx/geometry/rect_conversions.h" | 31 #include "ui/gfx/geometry/rect_conversions.h" |
32 #include "ui/gfx/geometry/size_conversions.h" | 32 #include "ui/gfx/geometry/size_conversions.h" |
33 | 33 |
34 namespace cc { | 34 namespace cc { |
35 namespace { | 35 namespace { |
36 | 36 |
| 37 #define EXPECT_BOTH_EQ(expression, x) \ |
| 38 do { \ |
| 39 EXPECT_EQ(x, pending_layer_->expression); \ |
| 40 EXPECT_EQ(x, active_layer_->expression); \ |
| 41 } while (false) |
| 42 |
| 43 #define EXPECT_BOTH_NE(expression, x) \ |
| 44 do { \ |
| 45 EXPECT_NE(x, pending_layer_->expression); \ |
| 46 EXPECT_NE(x, active_layer_->expression); \ |
| 47 } while (false) |
| 48 |
37 class MockCanvas : public SkCanvas { | 49 class MockCanvas : public SkCanvas { |
38 public: | 50 public: |
39 explicit MockCanvas(int w, int h) : SkCanvas(w, h) {} | 51 explicit MockCanvas(int w, int h) : SkCanvas(w, h) {} |
40 | 52 |
41 void drawRect(const SkRect& rect, const SkPaint& paint) override { | 53 void drawRect(const SkRect& rect, const SkPaint& paint) override { |
42 // Capture calls before SkCanvas quickReject() kicks in. | 54 // Capture calls before SkCanvas quickReject() kicks in. |
43 rects_.push_back(rect); | 55 rects_.push_back(rect); |
44 } | 56 } |
45 | 57 |
46 std::vector<SkRect> rects_; | 58 std::vector<SkRect> rects_; |
47 }; | 59 }; |
48 | 60 |
49 class NoLowResTilingsSettings : public ImplSidePaintingSettings {}; | 61 class NoLowResTilingsSettings : public ImplSidePaintingSettings {}; |
50 | 62 |
51 class LowResTilingsSettings : public ImplSidePaintingSettings { | 63 class LowResTilingsSettings : public ImplSidePaintingSettings { |
52 public: | 64 public: |
53 LowResTilingsSettings() { create_low_res_tiling = true; } | 65 LowResTilingsSettings() { create_low_res_tiling = true; } |
54 }; | 66 }; |
55 | 67 |
56 class PictureLayerImplTest : public testing::Test { | 68 class PictureLayerImplTest : public testing::Test { |
57 public: | 69 public: |
58 PictureLayerImplTest() | 70 PictureLayerImplTest() |
59 : proxy_(base::MessageLoopProxy::current()), | 71 : proxy_(base::MessageLoopProxy::current()), |
60 host_impl_(LowResTilingsSettings(), &proxy_, &shared_bitmap_manager_), | 72 host_impl_(LowResTilingsSettings(), &proxy_, &shared_bitmap_manager_), |
| 73 root_id_(6), |
61 id_(7), | 74 id_(7), |
62 pending_layer_(nullptr), | 75 pending_layer_(nullptr), |
63 old_pending_layer_(nullptr), | 76 old_pending_layer_(nullptr), |
64 active_layer_(nullptr) {} | 77 active_layer_(nullptr) { |
| 78 host_impl_.SetViewportSize(gfx::Size(10000, 10000)); |
| 79 } |
65 | 80 |
66 explicit PictureLayerImplTest(const LayerTreeSettings& settings) | 81 explicit PictureLayerImplTest(const LayerTreeSettings& settings) |
67 : proxy_(base::MessageLoopProxy::current()), | 82 : proxy_(base::MessageLoopProxy::current()), |
68 host_impl_(settings, &proxy_, &shared_bitmap_manager_), | 83 host_impl_(settings, &proxy_, &shared_bitmap_manager_), |
69 id_(7) {} | 84 root_id_(6), |
| 85 id_(7) { |
| 86 host_impl_.SetViewportSize(gfx::Size(10000, 10000)); |
| 87 } |
70 | 88 |
71 virtual ~PictureLayerImplTest() { | 89 virtual ~PictureLayerImplTest() { |
72 } | 90 } |
73 | 91 |
74 void SetUp() override { InitializeRenderer(); } | 92 void SetUp() override { InitializeRenderer(); } |
75 | 93 |
76 virtual void InitializeRenderer() { | 94 virtual void InitializeRenderer() { |
77 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d()); | 95 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d()); |
78 } | 96 } |
79 | 97 |
80 void SetupDefaultTrees(const gfx::Size& layer_bounds) { | 98 void SetupDefaultTrees(const gfx::Size& layer_bounds) { |
81 gfx::Size tile_size(100, 100); | 99 gfx::Size tile_size(100, 100); |
82 | 100 |
83 scoped_refptr<FakePicturePileImpl> pending_pile = | 101 scoped_refptr<FakePicturePileImpl> pending_pile = |
84 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 102 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
85 scoped_refptr<FakePicturePileImpl> active_pile = | 103 scoped_refptr<FakePicturePileImpl> active_pile = |
86 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 104 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
87 | 105 |
88 SetupTrees(pending_pile, active_pile); | 106 SetupTrees(pending_pile, active_pile); |
89 } | 107 } |
90 | 108 |
| 109 void SetupDefaultTreesWithInvalidation(const gfx::Size& layer_bounds, |
| 110 const Region& invalidation) { |
| 111 gfx::Size tile_size(100, 100); |
| 112 |
| 113 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 114 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 115 scoped_refptr<FakePicturePileImpl> active_pile = |
| 116 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 117 |
| 118 SetupTreesWithInvalidation(pending_pile, active_pile, invalidation); |
| 119 } |
| 120 |
91 void ActivateTree() { | 121 void ActivateTree() { |
92 host_impl_.ActivateSyncTree(); | 122 host_impl_.ActivateSyncTree(); |
93 CHECK(!host_impl_.pending_tree()); | 123 CHECK(!host_impl_.pending_tree()); |
94 CHECK(host_impl_.recycle_tree()); | 124 CHECK(host_impl_.recycle_tree()); |
95 old_pending_layer_ = pending_layer_; | 125 old_pending_layer_ = pending_layer_; |
96 pending_layer_ = nullptr; | 126 pending_layer_ = nullptr; |
97 active_layer_ = static_cast<FakePictureLayerImpl*>( | 127 active_layer_ = static_cast<FakePictureLayerImpl*>( |
98 host_impl_.active_tree()->LayerById(id_)); | 128 host_impl_.active_tree()->LayerById(id_)); |
| 129 |
| 130 host_impl_.active_tree()->UpdateDrawProperties(); |
99 } | 131 } |
100 | 132 |
101 void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds, | 133 void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds, |
102 const gfx::Size& tile_size) { | 134 const gfx::Size& tile_size, |
103 SetupDefaultTrees(layer_bounds); | 135 const Region& invalidation) { |
104 pending_layer_->set_fixed_tile_size(tile_size); | 136 gfx::Size pile_tile_size(100, 100); |
105 active_layer_->set_fixed_tile_size(tile_size); | 137 |
| 138 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 139 FakePicturePileImpl::CreateFilledPile(pile_tile_size, layer_bounds); |
| 140 scoped_refptr<FakePicturePileImpl> active_pile = |
| 141 FakePicturePileImpl::CreateFilledPile(pile_tile_size, layer_bounds); |
| 142 |
| 143 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, |
| 144 invalidation); |
106 } | 145 } |
107 | 146 |
108 void SetupTrees( | 147 void SetupTrees( |
109 scoped_refptr<PicturePileImpl> pending_pile, | 148 scoped_refptr<PicturePileImpl> pending_pile, |
110 scoped_refptr<PicturePileImpl> active_pile) { | 149 scoped_refptr<PicturePileImpl> active_pile) { |
111 SetupPendingTree(active_pile); | 150 SetupPendingTree(active_pile); |
112 ActivateTree(); | 151 ActivateTree(); |
113 SetupPendingTree(pending_pile); | 152 SetupPendingTreeInternal(pending_pile, gfx::Size(), Region()); |
114 } | 153 } |
115 | 154 |
116 void CreateHighLowResAndSetAllTilesVisible() { | 155 void SetupTreesWithInvalidation(scoped_refptr<PicturePileImpl> pending_pile, |
117 // Active layer must get updated first so pending layer can share from it. | 156 scoped_refptr<PicturePileImpl> active_pile, |
118 active_layer_->CreateDefaultTilingsAndTiles(); | 157 const Region& pending_invalidation) { |
119 active_layer_->SetAllTilesVisible(); | 158 SetupPendingTreeInternal(active_pile, gfx::Size(), Region()); |
120 pending_layer_->CreateDefaultTilingsAndTiles(); | 159 ActivateTree(); |
121 pending_layer_->SetAllTilesVisible(); | 160 SetupPendingTreeInternal(pending_pile, gfx::Size(), pending_invalidation); |
122 } | 161 } |
123 | 162 |
124 void AddDefaultTilingsWithInvalidation(const Region& invalidation) { | 163 void SetupTreesWithFixedTileSize(scoped_refptr<PicturePileImpl> pending_pile, |
125 active_layer_->AddTiling(2.3f); | 164 scoped_refptr<PicturePileImpl> active_pile, |
126 active_layer_->AddTiling(1.0f); | 165 const gfx::Size& tile_size, |
127 active_layer_->AddTiling(0.5f); | 166 const Region& pending_invalidation) { |
128 for (size_t i = 0; i < active_layer_->tilings()->num_tilings(); ++i) | 167 SetupPendingTreeInternal(active_pile, tile_size, Region()); |
129 active_layer_->tilings()->tiling_at(i)->CreateAllTilesForTesting(); | 168 ActivateTree(); |
130 pending_layer_->set_invalidation(invalidation); | 169 SetupPendingTreeInternal(pending_pile, tile_size, pending_invalidation); |
131 for (size_t i = 0; i < pending_layer_->tilings()->num_tilings(); ++i) | |
132 pending_layer_->tilings()->tiling_at(i)->CreateAllTilesForTesting(); | |
133 } | 170 } |
134 | 171 |
135 void SetupPendingTree(scoped_refptr<RasterSource> raster_source) { | 172 void SetupPendingTree(scoped_refptr<RasterSource> raster_source) { |
| 173 SetupPendingTreeInternal(raster_source, gfx::Size(), Region()); |
| 174 } |
| 175 |
| 176 void SetupPendingTreeWithInvalidation( |
| 177 scoped_refptr<RasterSource> raster_source, |
| 178 const Region& invalidation) { |
| 179 SetupPendingTreeInternal(raster_source, gfx::Size(), invalidation); |
| 180 } |
| 181 |
| 182 void SetupPendingTreeWithFixedTileSize( |
| 183 scoped_refptr<RasterSource> raster_source, |
| 184 const gfx::Size& tile_size, |
| 185 const Region& invalidation) { |
| 186 SetupPendingTreeInternal(raster_source, tile_size, invalidation); |
| 187 } |
| 188 |
| 189 void SetupPendingTreeInternal(scoped_refptr<RasterSource> raster_source, |
| 190 const gfx::Size& tile_size, |
| 191 const Region& invalidation) { |
136 host_impl_.CreatePendingTree(); | 192 host_impl_.CreatePendingTree(); |
137 host_impl_.pending_tree()->PushPageScaleFromMainThread(1.f, 0.25f, 100.f); | 193 host_impl_.pending_tree()->PushPageScaleFromMainThread(1.f, 0.25f, 100.f); |
138 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); | 194 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); |
139 | 195 |
140 // Steal from the recycled tree. | 196 // Steal from the recycled tree if possible. |
141 scoped_ptr<LayerImpl> old_pending_root = pending_tree->DetachLayerTree(); | 197 scoped_ptr<LayerImpl> pending_root = pending_tree->DetachLayerTree(); |
142 DCHECK_IMPLIES(old_pending_root, old_pending_root->id() == id_); | |
143 | |
144 scoped_ptr<FakePictureLayerImpl> pending_layer; | 198 scoped_ptr<FakePictureLayerImpl> pending_layer; |
145 if (old_pending_root) { | 199 DCHECK_IMPLIES(pending_root, pending_root->id() == root_id_); |
146 pending_layer.reset( | 200 if (!pending_root) { |
147 static_cast<FakePictureLayerImpl*>(old_pending_root.release())); | 201 pending_root = LayerImpl::Create(pending_tree, root_id_); |
148 pending_layer->SetRasterSource(raster_source); | 202 pending_layer = FakePictureLayerImpl::Create(pending_tree, id_); |
| 203 if (!tile_size.IsEmpty()) |
| 204 pending_layer->set_fixed_tile_size(tile_size); |
| 205 pending_layer->SetDrawsContent(true); |
149 } else { | 206 } else { |
150 pending_layer = FakePictureLayerImpl::CreateWithRasterSource( | 207 pending_layer.reset(static_cast<FakePictureLayerImpl*>( |
151 pending_tree, id_, raster_source); | 208 pending_root->RemoveChild(pending_root->children()[0]).release())); |
152 pending_layer->SetDrawsContent(true); | 209 if (!tile_size.IsEmpty()) |
| 210 pending_layer->set_fixed_tile_size(tile_size); |
153 } | 211 } |
154 // The bounds() just mirror the pile size. | 212 // The bounds() just mirror the pile size. |
155 pending_layer->SetBounds(pending_layer->raster_source()->GetSize()); | 213 pending_layer->SetBounds(raster_source->GetSize()); |
156 pending_tree->SetRootLayer(pending_layer.Pass()); | 214 pending_layer->SetContentBounds(raster_source->GetSize()); |
| 215 pending_layer->SetRasterSourceOnPending(raster_source, invalidation, false); |
| 216 |
| 217 pending_root->AddChild(pending_layer.Pass()); |
| 218 pending_tree->SetRootLayer(pending_root.Pass()); |
157 | 219 |
158 pending_layer_ = static_cast<FakePictureLayerImpl*>( | 220 pending_layer_ = static_cast<FakePictureLayerImpl*>( |
159 host_impl_.pending_tree()->LayerById(id_)); | 221 host_impl_.pending_tree()->LayerById(id_)); |
160 pending_layer_->DoPostCommitInitializationIfNeeded(); | 222 pending_layer_->DoPostCommitInitializationIfNeeded(); |
| 223 |
| 224 // Add tilings/tiles for the layer. |
| 225 host_impl_.pending_tree()->UpdateDrawProperties(); |
161 } | 226 } |
162 | 227 |
163 void SetupDrawPropertiesAndUpdateTiles(FakePictureLayerImpl* layer, | 228 void SetupDrawPropertiesAndUpdateTiles(FakePictureLayerImpl* layer, |
164 float ideal_contents_scale, | 229 float ideal_contents_scale, |
165 float device_scale_factor, | 230 float device_scale_factor, |
166 float page_scale_factor, | 231 float page_scale_factor, |
167 float maximum_animation_contents_scale, | 232 float maximum_animation_contents_scale, |
168 bool animating_transform_to_screen) { | 233 bool animating_transform_to_screen) { |
169 layer->draw_properties().ideal_contents_scale = ideal_contents_scale; | 234 layer->draw_properties().ideal_contents_scale = ideal_contents_scale; |
170 layer->draw_properties().device_scale_factor = device_scale_factor; | 235 layer->draw_properties().device_scale_factor = device_scale_factor; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 contents_scale, | 271 contents_scale, |
207 device_scale_factor, | 272 device_scale_factor, |
208 page_scale_factor, | 273 page_scale_factor, |
209 maximum_animation_contents_scale, | 274 maximum_animation_contents_scale, |
210 animating_transform); | 275 animating_transform); |
211 } | 276 } |
212 | 277 |
213 void ResetTilingsAndRasterScales() { | 278 void ResetTilingsAndRasterScales() { |
214 pending_layer_->ReleaseResources(); | 279 pending_layer_->ReleaseResources(); |
215 active_layer_->ReleaseResources(); | 280 active_layer_->ReleaseResources(); |
| 281 if (pending_layer_) |
| 282 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 283 if (active_layer_) |
| 284 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
216 } | 285 } |
217 | 286 |
218 void AssertAllTilesRequired(PictureLayerTiling* tiling) { | 287 void AssertAllTilesRequired(PictureLayerTiling* tiling) { |
219 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); | 288 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
220 for (size_t i = 0; i < tiles.size(); ++i) | 289 for (size_t i = 0; i < tiles.size(); ++i) |
221 EXPECT_TRUE(tiles[i]->required_for_activation()) << "i: " << i; | 290 EXPECT_TRUE(tiles[i]->required_for_activation()) << "i: " << i; |
222 EXPECT_GT(tiles.size(), 0u); | 291 EXPECT_GT(tiles.size(), 0u); |
223 } | 292 } |
224 | 293 |
225 void AssertNoTilesRequired(PictureLayerTiling* tiling) { | 294 void AssertNoTilesRequired(PictureLayerTiling* tiling) { |
226 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); | 295 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
227 for (size_t i = 0; i < tiles.size(); ++i) | 296 for (size_t i = 0; i < tiles.size(); ++i) |
228 EXPECT_FALSE(tiles[i]->required_for_activation()) << "i: " << i; | 297 EXPECT_FALSE(tiles[i]->required_for_activation()) << "i: " << i; |
229 EXPECT_GT(tiles.size(), 0u); | 298 EXPECT_GT(tiles.size(), 0u); |
230 } | 299 } |
231 | 300 |
232 protected: | 301 protected: |
233 void TestTileGridAlignmentCommon() { | |
234 // Layer to span 4 raster tiles in x and in y | |
235 ImplSidePaintingSettings settings; | |
236 gfx::Size layer_size( | |
237 settings.default_tile_size.width() * 7 / 2, | |
238 settings.default_tile_size.height() * 7 / 2); | |
239 | |
240 scoped_refptr<FakePicturePileImpl> pending_pile = | |
241 FakePicturePileImpl::CreateFilledPile(layer_size, layer_size); | |
242 scoped_refptr<FakePicturePileImpl> active_pile = | |
243 FakePicturePileImpl::CreateFilledPile(layer_size, layer_size); | |
244 | |
245 SetupTrees(pending_pile, active_pile); | |
246 | |
247 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false); | |
248 | |
249 // Add 1x1 rects at the centers of each tile, then re-record pile contents | |
250 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | |
251 std::vector<Tile*> tiles = | |
252 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); | |
253 EXPECT_EQ(16u, tiles.size()); | |
254 std::vector<SkRect> rects; | |
255 std::vector<Tile*>::const_iterator tile_iter; | |
256 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) { | |
257 gfx::Point tile_center = (*tile_iter)->content_rect().CenterPoint(); | |
258 gfx::Rect rect(tile_center.x(), tile_center.y(), 1, 1); | |
259 active_pile->add_draw_rect(rect); | |
260 rects.push_back(SkRect::MakeXYWH(rect.x(), rect.y(), 1, 1)); | |
261 } | |
262 // Force re-record with newly injected content | |
263 active_pile->RemoveRecordingAt(0, 0); | |
264 active_pile->AddRecordingAt(0, 0); | |
265 | |
266 std::vector<SkRect>::const_iterator rect_iter = rects.begin(); | |
267 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) { | |
268 MockCanvas mock_canvas(1000, 1000); | |
269 active_pile->PlaybackToSharedCanvas(&mock_canvas, | |
270 (*tile_iter)->content_rect(), 1.0f); | |
271 | |
272 // This test verifies that when drawing the contents of a specific tile | |
273 // at content scale 1.0, the playback canvas never receives content from | |
274 // neighboring tiles which indicates that the tile grid embedded in | |
275 // SkPicture is perfectly aligned with the compositor's tiles. | |
276 EXPECT_EQ(1u, mock_canvas.rects_.size()); | |
277 EXPECT_EQ(*rect_iter, mock_canvas.rects_[0]); | |
278 rect_iter++; | |
279 } | |
280 } | |
281 | |
282 void TestQuadsForSolidColor(bool test_for_solid); | 302 void TestQuadsForSolidColor(bool test_for_solid); |
283 | 303 |
284 FakeImplProxy proxy_; | 304 FakeImplProxy proxy_; |
285 TestSharedBitmapManager shared_bitmap_manager_; | 305 TestSharedBitmapManager shared_bitmap_manager_; |
286 FakeLayerTreeHostImpl host_impl_; | 306 FakeLayerTreeHostImpl host_impl_; |
| 307 int root_id_; |
287 int id_; | 308 int id_; |
288 FakePictureLayerImpl* pending_layer_; | 309 FakePictureLayerImpl* pending_layer_; |
289 FakePictureLayerImpl* old_pending_layer_; | 310 FakePictureLayerImpl* old_pending_layer_; |
290 FakePictureLayerImpl* active_layer_; | 311 FakePictureLayerImpl* active_layer_; |
291 | 312 |
292 private: | 313 private: |
293 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplTest); | 314 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplTest); |
294 }; | 315 }; |
295 | 316 |
| 317 class NoLowResPictureLayerImplTest : public PictureLayerImplTest { |
| 318 public: |
| 319 NoLowResPictureLayerImplTest() |
| 320 : PictureLayerImplTest(NoLowResTilingsSettings()) {} |
| 321 }; |
| 322 |
296 TEST_F(PictureLayerImplTest, TileGridAlignment) { | 323 TEST_F(PictureLayerImplTest, TileGridAlignment) { |
297 host_impl_.SetDeviceScaleFactor(1.f); | 324 // Layer to span 4 raster tiles in x and in y |
298 TestTileGridAlignmentCommon(); | 325 ImplSidePaintingSettings settings; |
299 } | 326 gfx::Size layer_size(settings.default_tile_size.width() * 7 / 2, |
| 327 settings.default_tile_size.height() * 7 / 2); |
300 | 328 |
301 TEST_F(PictureLayerImplTest, TileGridAlignmentHiDPI) { | 329 scoped_refptr<FakePicturePileImpl> pending_pile = |
302 host_impl_.SetDeviceScaleFactor(2.f); | 330 FakePicturePileImpl::CreateFilledPile(layer_size, layer_size); |
303 TestTileGridAlignmentCommon(); | 331 scoped_refptr<FakePicturePileImpl> active_pile = |
| 332 FakePicturePileImpl::CreateFilledPile(layer_size, layer_size); |
| 333 |
| 334 SetupTrees(pending_pile, active_pile); |
| 335 |
| 336 // Add 1x1 rects at the centers of each tile, then re-record pile contents |
| 337 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
| 338 std::vector<Tile*> tiles = |
| 339 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); |
| 340 EXPECT_EQ(16u, tiles.size()); |
| 341 std::vector<SkRect> rects; |
| 342 std::vector<Tile*>::const_iterator tile_iter; |
| 343 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) { |
| 344 gfx::Point tile_center = (*tile_iter)->content_rect().CenterPoint(); |
| 345 gfx::Rect rect(tile_center.x(), tile_center.y(), 1, 1); |
| 346 active_pile->add_draw_rect(rect); |
| 347 rects.push_back(SkRect::MakeXYWH(rect.x(), rect.y(), 1, 1)); |
| 348 } |
| 349 // Force re-raster with newly injected content |
| 350 active_pile->RemoveRecordingAt(0, 0); |
| 351 active_pile->AddRecordingAt(0, 0); |
| 352 |
| 353 std::vector<SkRect>::const_iterator rect_iter = rects.begin(); |
| 354 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) { |
| 355 MockCanvas mock_canvas(1000, 1000); |
| 356 active_pile->PlaybackToSharedCanvas(&mock_canvas, |
| 357 (*tile_iter)->content_rect(), 1.0f); |
| 358 |
| 359 // This test verifies that when drawing the contents of a specific tile |
| 360 // at content scale 1.0, the playback canvas never receives content from |
| 361 // neighboring tiles which indicates that the tile grid embedded in |
| 362 // SkPicture is perfectly aligned with the compositor's tiles. |
| 363 EXPECT_EQ(1u, mock_canvas.rects_.size()); |
| 364 EXPECT_EQ(*rect_iter, mock_canvas.rects_[0]); |
| 365 rect_iter++; |
| 366 } |
304 } | 367 } |
305 | 368 |
306 TEST_F(PictureLayerImplTest, CloneNoInvalidation) { | 369 TEST_F(PictureLayerImplTest, CloneNoInvalidation) { |
307 gfx::Size tile_size(100, 100); | 370 gfx::Size tile_size(100, 100); |
308 gfx::Size layer_bounds(400, 400); | 371 gfx::Size layer_bounds(400, 400); |
309 | 372 |
310 scoped_refptr<FakePicturePileImpl> pending_pile = | 373 scoped_refptr<FakePicturePileImpl> pending_pile = |
311 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 374 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
312 scoped_refptr<FakePicturePileImpl> active_pile = | 375 scoped_refptr<FakePicturePileImpl> active_pile = |
313 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 376 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
314 | 377 |
315 SetupTrees(pending_pile, active_pile); | 378 SetupTreesWithInvalidation(pending_pile, active_pile, Region()); |
316 | |
317 Region invalidation; | |
318 AddDefaultTilingsWithInvalidation(invalidation); | |
319 | 379 |
320 EXPECT_EQ(pending_layer_->tilings()->num_tilings(), | 380 EXPECT_EQ(pending_layer_->tilings()->num_tilings(), |
321 active_layer_->tilings()->num_tilings()); | 381 active_layer_->tilings()->num_tilings()); |
322 | 382 |
323 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); | 383 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); |
324 EXPECT_GT(tilings->num_tilings(), 0u); | 384 EXPECT_GT(tilings->num_tilings(), 0u); |
325 for (size_t i = 0; i < tilings->num_tilings(); ++i) | 385 for (size_t i = 0; i < tilings->num_tilings(); ++i) |
326 VerifyAllTilesExistAndHavePile(tilings->tiling_at(i), active_pile.get()); | 386 VerifyAllTilesExistAndHavePile(tilings->tiling_at(i), pending_pile.get()); |
327 } | 387 } |
328 | 388 |
329 TEST_F(PictureLayerImplTest, ExternalViewportRectForPrioritizingTiles) { | 389 TEST_F(PictureLayerImplTest, ExternalViewportRectForPrioritizingTiles) { |
330 base::TimeTicks time_ticks; | 390 base::TimeTicks time_ticks; |
331 time_ticks += base::TimeDelta::FromMilliseconds(1); | 391 time_ticks += base::TimeDelta::FromMilliseconds(1); |
332 host_impl_.SetCurrentBeginFrameArgs( | 392 host_impl_.SetCurrentBeginFrameArgs( |
333 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 393 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
334 gfx::Size tile_size(100, 100); | 394 gfx::Size tile_size(100, 100); |
335 gfx::Size layer_bounds(400, 400); | 395 gfx::Size layer_bounds(400, 400); |
336 | 396 |
337 scoped_refptr<FakePicturePileImpl> pending_pile = | 397 scoped_refptr<FakePicturePileImpl> pending_pile = |
338 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 398 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
339 scoped_refptr<FakePicturePileImpl> active_pile = | 399 scoped_refptr<FakePicturePileImpl> active_pile = |
340 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 400 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
341 | 401 |
342 SetupTrees(pending_pile, active_pile); | 402 SetupTreesWithInvalidation(pending_pile, active_pile, Region()); |
343 | 403 |
344 Region invalidation; | |
345 AddDefaultTilingsWithInvalidation(invalidation); | |
346 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false); | 404 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false); |
347 | 405 |
348 time_ticks += base::TimeDelta::FromMilliseconds(200); | 406 time_ticks += base::TimeDelta::FromMilliseconds(200); |
349 host_impl_.SetCurrentBeginFrameArgs( | 407 host_impl_.SetCurrentBeginFrameArgs( |
350 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 408 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
351 | 409 |
352 // Update tiles with viewport for tile priority as (0, 0, 100, 100) and the | 410 // Update tiles with viewport for tile priority as (0, 0, 100, 100) and the |
353 // identify transform for tile priority. | 411 // identify transform for tile priority. |
354 bool resourceless_software_draw = false; | 412 bool resourceless_software_draw = false; |
355 gfx::Rect viewport = gfx::Rect(layer_bounds), | 413 gfx::Rect viewport = gfx::Rect(layer_bounds), |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 487 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
430 | 488 |
431 gfx::Size tile_size(100, 100); | 489 gfx::Size tile_size(100, 100); |
432 gfx::Size layer_bounds(400, 400); | 490 gfx::Size layer_bounds(400, 400); |
433 | 491 |
434 scoped_refptr<FakePicturePileImpl> pending_pile = | 492 scoped_refptr<FakePicturePileImpl> pending_pile = |
435 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 493 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
436 scoped_refptr<FakePicturePileImpl> active_pile = | 494 scoped_refptr<FakePicturePileImpl> active_pile = |
437 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 495 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
438 | 496 |
439 SetupTrees(pending_pile, active_pile); | 497 SetupTreesWithInvalidation(pending_pile, active_pile, Region()); |
440 | 498 |
441 Region invalidation; | |
442 AddDefaultTilingsWithInvalidation(invalidation); | |
443 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false); | 499 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false); |
444 | 500 |
445 // UpdateTiles with valid viewport. Should update tile viewport. | 501 // UpdateTiles with valid viewport. Should update tile viewport. |
446 // Note viewport is considered invalid if and only if in resourceless | 502 // Note viewport is considered invalid if and only if in resourceless |
447 // software draw. | 503 // software draw. |
448 bool resourceless_software_draw = false; | 504 bool resourceless_software_draw = false; |
449 gfx::Rect viewport = gfx::Rect(layer_bounds); | 505 gfx::Rect viewport = gfx::Rect(layer_bounds); |
450 gfx::Transform transform; | 506 gfx::Transform transform; |
451 host_impl_.SetExternalDrawConstraints(transform, | 507 host_impl_.SetExternalDrawConstraints(transform, |
452 viewport, | 508 viewport, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 TEST_F(PictureLayerImplTest, ClonePartialInvalidation) { | 566 TEST_F(PictureLayerImplTest, ClonePartialInvalidation) { |
511 gfx::Size tile_size(100, 100); | 567 gfx::Size tile_size(100, 100); |
512 gfx::Size layer_bounds(400, 400); | 568 gfx::Size layer_bounds(400, 400); |
513 gfx::Rect layer_invalidation(150, 200, 30, 180); | 569 gfx::Rect layer_invalidation(150, 200, 30, 180); |
514 | 570 |
515 scoped_refptr<FakePicturePileImpl> pending_pile = | 571 scoped_refptr<FakePicturePileImpl> pending_pile = |
516 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 572 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
517 scoped_refptr<FakePicturePileImpl> active_pile = | 573 scoped_refptr<FakePicturePileImpl> active_pile = |
518 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 574 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
519 | 575 |
520 SetupTrees(pending_pile, active_pile); | 576 SetupTreesWithFixedTileSize(pending_pile, active_pile, gfx::Size(50, 50), |
521 | 577 layer_invalidation); |
522 Region invalidation(layer_invalidation); | |
523 AddDefaultTilingsWithInvalidation(invalidation); | |
524 | 578 |
525 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); | 579 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); |
526 EXPECT_GT(tilings->num_tilings(), 0u); | 580 EXPECT_GT(tilings->num_tilings(), 0u); |
527 for (size_t i = 0; i < tilings->num_tilings(); ++i) { | 581 for (size_t i = 0; i < tilings->num_tilings(); ++i) { |
528 const PictureLayerTiling* tiling = tilings->tiling_at(i); | 582 const PictureLayerTiling* tiling = tilings->tiling_at(i); |
529 gfx::Rect content_invalidation = gfx::ScaleToEnclosingRect( | 583 gfx::Rect content_invalidation = gfx::ScaleToEnclosingRect( |
530 layer_invalidation, | 584 layer_invalidation, |
531 tiling->contents_scale()); | 585 tiling->contents_scale()); |
532 for (PictureLayerTiling::CoverageIterator iter( | 586 for (PictureLayerTiling::CoverageIterator iter( |
533 tiling, | 587 tiling, |
534 tiling->contents_scale(), | 588 tiling->contents_scale(), |
535 gfx::Rect(tiling->tiling_size())); | 589 gfx::Rect(tiling->tiling_size())); |
536 iter; | 590 iter; |
537 ++iter) { | 591 ++iter) { |
538 EXPECT_TRUE(*iter); | 592 EXPECT_TRUE(*iter); |
539 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); | 593 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); |
540 if (iter.geometry_rect().Intersects(content_invalidation)) | 594 EXPECT_EQ(pending_pile.get(), iter->raster_source()); |
541 EXPECT_EQ(pending_pile.get(), iter->raster_source()); | |
542 else | |
543 EXPECT_EQ(active_pile.get(), iter->raster_source()); | |
544 } | 595 } |
545 } | 596 } |
546 } | |
547 | 597 |
548 TEST_F(PictureLayerImplTest, CloneFullInvalidation) { | 598 tilings = active_layer_->tilings(); |
549 gfx::Size tile_size(90, 80); | |
550 gfx::Size layer_bounds(300, 500); | |
551 | |
552 scoped_refptr<FakePicturePileImpl> pending_pile = | |
553 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | |
554 scoped_refptr<FakePicturePileImpl> active_pile = | |
555 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | |
556 | |
557 SetupTrees(pending_pile, active_pile); | |
558 | |
559 Region invalidation((gfx::Rect(layer_bounds))); | |
560 AddDefaultTilingsWithInvalidation(invalidation); | |
561 | |
562 EXPECT_EQ(pending_layer_->tilings()->num_tilings(), | |
563 active_layer_->tilings()->num_tilings()); | |
564 | |
565 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); | |
566 EXPECT_GT(tilings->num_tilings(), 0u); | |
567 for (size_t i = 0; i < tilings->num_tilings(); ++i) | |
568 VerifyAllTilesExistAndHavePile(tilings->tiling_at(i), pending_pile.get()); | |
569 } | |
570 | |
571 TEST_F(PictureLayerImplTest, NoInvalidationBoundsChange) { | |
572 gfx::Size tile_size(90, 80); | |
573 gfx::Size active_layer_bounds(300, 500); | |
574 gfx::Size pending_layer_bounds(400, 800); | |
575 | |
576 scoped_refptr<FakePicturePileImpl> pending_pile = | |
577 FakePicturePileImpl::CreateFilledPile(tile_size, | |
578 pending_layer_bounds); | |
579 scoped_refptr<FakePicturePileImpl> active_pile = | |
580 FakePicturePileImpl::CreateFilledPile(tile_size, active_layer_bounds); | |
581 | |
582 SetupTrees(pending_pile, active_pile); | |
583 pending_layer_->set_fixed_tile_size(gfx::Size(100, 100)); | |
584 | |
585 Region invalidation; | |
586 AddDefaultTilingsWithInvalidation(invalidation); | |
587 | |
588 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); | |
589 EXPECT_GT(tilings->num_tilings(), 0u); | 599 EXPECT_GT(tilings->num_tilings(), 0u); |
590 for (size_t i = 0; i < tilings->num_tilings(); ++i) { | 600 for (size_t i = 0; i < tilings->num_tilings(); ++i) { |
591 const PictureLayerTiling* tiling = tilings->tiling_at(i); | 601 const PictureLayerTiling* tiling = tilings->tiling_at(i); |
592 gfx::Rect active_content_bounds = gfx::ScaleToEnclosingRect( | 602 gfx::Rect content_invalidation = |
593 gfx::Rect(active_layer_bounds), | 603 gfx::ScaleToEnclosingRect(layer_invalidation, tiling->contents_scale()); |
594 tiling->contents_scale()); | |
595 for (PictureLayerTiling::CoverageIterator iter( | 604 for (PictureLayerTiling::CoverageIterator iter( |
596 tiling, | 605 tiling, |
597 tiling->contents_scale(), | 606 tiling->contents_scale(), |
598 gfx::Rect(tiling->tiling_size())); | 607 gfx::Rect(tiling->tiling_size())); |
599 iter; | 608 iter; |
600 ++iter) { | 609 ++iter) { |
601 EXPECT_TRUE(*iter); | 610 EXPECT_TRUE(*iter); |
602 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); | 611 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); |
603 std::vector<Tile*> active_tiles = | 612 if (iter.geometry_rect().Intersects(content_invalidation)) |
604 active_layer_->tilings()->tiling_at(i)->AllTilesForTesting(); | 613 EXPECT_EQ(active_pile.get(), iter->raster_source()); |
605 std::vector<Tile*> pending_tiles = tiling->AllTilesForTesting(); | 614 else |
606 if (iter.geometry_rect().right() >= active_content_bounds.width() || | |
607 iter.geometry_rect().bottom() >= active_content_bounds.height() || | |
608 active_tiles[0]->content_rect().size() != | |
609 pending_tiles[0]->content_rect().size()) { | |
610 EXPECT_EQ(pending_pile.get(), iter->raster_source()); | 615 EXPECT_EQ(pending_pile.get(), iter->raster_source()); |
611 } else { | |
612 EXPECT_EQ(active_pile.get(), iter->raster_source()); | |
613 } | |
614 } | 616 } |
615 } | 617 } |
616 } | 618 } |
617 | 619 |
618 TEST_F(PictureLayerImplTest, AddTilesFromNewRecording) { | 620 TEST_F(PictureLayerImplTest, CloneFullInvalidation) { |
619 gfx::Size tile_size(400, 400); | 621 gfx::Size tile_size(90, 80); |
620 gfx::Size layer_bounds(1300, 1900); | 622 gfx::Size layer_bounds(300, 500); |
621 | 623 |
622 scoped_refptr<FakePicturePileImpl> pending_pile = | 624 scoped_refptr<FakePicturePileImpl> pending_pile = |
623 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | 625 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
624 scoped_refptr<FakePicturePileImpl> active_pile = | 626 scoped_refptr<FakePicturePileImpl> active_pile = |
625 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | 627 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
626 | 628 |
627 // Fill in some of active pile, but more of pending pile. | 629 SetupTreesWithInvalidation(pending_pile, active_pile, |
628 int hole_count = 0; | 630 gfx::Rect(layer_bounds)); |
629 for (int x = 0; x < active_pile->tiling().num_tiles_x(); ++x) { | |
630 for (int y = 0; y < active_pile->tiling().num_tiles_y(); ++y) { | |
631 if ((x + y) % 2) { | |
632 pending_pile->AddRecordingAt(x, y); | |
633 active_pile->AddRecordingAt(x, y); | |
634 } else { | |
635 hole_count++; | |
636 if (hole_count % 2) | |
637 pending_pile->AddRecordingAt(x, y); | |
638 } | |
639 } | |
640 } | |
641 | 631 |
642 SetupTrees(pending_pile, active_pile); | 632 EXPECT_EQ(pending_layer_->tilings()->num_tilings(), |
643 Region invalidation; | 633 active_layer_->tilings()->num_tilings()); |
644 AddDefaultTilingsWithInvalidation(invalidation); | |
645 | 634 |
646 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); | 635 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); |
647 EXPECT_GT(tilings->num_tilings(), 0u); | 636 EXPECT_GT(tilings->num_tilings(), 0u); |
648 for (size_t i = 0; i < tilings->num_tilings(); ++i) { | 637 for (size_t i = 0; i < tilings->num_tilings(); ++i) |
649 const PictureLayerTiling* tiling = tilings->tiling_at(i); | 638 VerifyAllTilesExistAndHavePile(tilings->tiling_at(i), pending_pile.get()); |
650 | |
651 for (PictureLayerTiling::CoverageIterator iter( | |
652 tiling, | |
653 tiling->contents_scale(), | |
654 gfx::Rect(tiling->tiling_size())); | |
655 iter; | |
656 ++iter) { | |
657 EXPECT_FALSE(iter.full_tile_geometry_rect().IsEmpty()); | |
658 // Ensure there is a recording for this tile. | |
659 bool in_pending = pending_pile->CoversRect(iter.full_tile_geometry_rect(), | |
660 tiling->contents_scale()); | |
661 bool in_active = active_pile->CoversRect(iter.full_tile_geometry_rect(), | |
662 tiling->contents_scale()); | |
663 | |
664 if (in_pending && !in_active) | |
665 EXPECT_EQ(pending_pile.get(), iter->raster_source()); | |
666 else if (in_active) | |
667 EXPECT_EQ(active_pile.get(), iter->raster_source()); | |
668 else | |
669 EXPECT_FALSE(*iter); | |
670 } | |
671 } | |
672 } | |
673 | |
674 TEST_F(PictureLayerImplTest, ManageTilingsWithNoRecording) { | |
675 gfx::Size tile_size(400, 400); | |
676 gfx::Size layer_bounds(1300, 1900); | |
677 | |
678 scoped_refptr<FakePicturePileImpl> pending_pile = | |
679 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | |
680 scoped_refptr<FakePicturePileImpl> active_pile = | |
681 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | |
682 | |
683 SetupTrees(pending_pile, active_pile); | |
684 | |
685 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); | |
686 | |
687 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | |
688 } | 639 } |
689 | 640 |
690 TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) { | 641 TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) { |
691 gfx::Size tile_size(400, 400); | 642 gfx::Size tile_size(400, 400); |
692 gfx::Size layer_bounds(1300, 1900); | 643 gfx::Size layer_bounds(1300, 1900); |
693 | 644 |
| 645 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 646 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 647 scoped_refptr<FakePicturePileImpl> active_pile = |
| 648 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 649 |
| 650 SetupTrees(pending_pile, active_pile); |
| 651 |
| 652 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
| 653 EXPECT_LT(low_res_factor, 1.f); |
| 654 |
| 655 active_layer_->ReleaseResources(); |
| 656 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
| 657 |
| 658 SetupDrawPropertiesAndUpdateTiles(active_layer_, |
| 659 6.f, // ideal contents scale |
| 660 3.f, // device scale |
| 661 2.f, // page scale |
| 662 1.f, // maximum animation scale |
| 663 false); |
| 664 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
| 665 EXPECT_FLOAT_EQ(6.f, |
| 666 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 667 EXPECT_FLOAT_EQ(6.f * low_res_factor, |
| 668 active_layer_->tilings()->tiling_at(1)->contents_scale()); |
| 669 |
| 670 // If we change the page scale factor, then we should get new tilings. |
| 671 SetupDrawPropertiesAndUpdateTiles(active_layer_, |
| 672 6.6f, // ideal contents scale |
| 673 3.f, // device scale |
| 674 2.2f, // page scale |
| 675 1.f, // maximum animation scale |
| 676 false); |
| 677 ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); |
| 678 EXPECT_FLOAT_EQ(6.6f, |
| 679 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 680 EXPECT_FLOAT_EQ(6.6f * low_res_factor, |
| 681 active_layer_->tilings()->tiling_at(2)->contents_scale()); |
| 682 |
| 683 // If we change the device scale factor, then we should get new tilings. |
| 684 SetupDrawPropertiesAndUpdateTiles(active_layer_, |
| 685 7.26f, // ideal contents scale |
| 686 3.3f, // device scale |
| 687 2.2f, // page scale |
| 688 1.f, // maximum animation scale |
| 689 false); |
| 690 ASSERT_EQ(6u, active_layer_->tilings()->num_tilings()); |
| 691 EXPECT_FLOAT_EQ(7.26f, |
| 692 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 693 EXPECT_FLOAT_EQ(7.26f * low_res_factor, |
| 694 active_layer_->tilings()->tiling_at(3)->contents_scale()); |
| 695 |
| 696 // If we change the device scale factor, but end up at the same total scale |
| 697 // factor somehow, then we don't get new tilings. |
| 698 SetupDrawPropertiesAndUpdateTiles(active_layer_, |
| 699 7.26f, // ideal contents scale |
| 700 2.2f, // device scale |
| 701 3.3f, // page scale |
| 702 1.f, // maximum animation scale |
| 703 false); |
| 704 ASSERT_EQ(6u, active_layer_->tilings()->num_tilings()); |
| 705 EXPECT_FLOAT_EQ(7.26f, |
| 706 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 707 EXPECT_FLOAT_EQ(7.26f * low_res_factor, |
| 708 active_layer_->tilings()->tiling_at(3)->contents_scale()); |
| 709 } |
| 710 |
| 711 TEST_F(PictureLayerImplTest, PendingLayerOnlyHasHighAndLowResTiling) { |
| 712 gfx::Size tile_size(400, 400); |
| 713 gfx::Size layer_bounds(1300, 1900); |
| 714 |
694 scoped_refptr<FakePicturePileImpl> pending_pile = | 715 scoped_refptr<FakePicturePileImpl> pending_pile = |
695 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 716 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
696 scoped_refptr<FakePicturePileImpl> active_pile = | 717 scoped_refptr<FakePicturePileImpl> active_pile = |
697 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 718 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
698 | 719 |
699 SetupTrees(pending_pile, active_pile); | 720 SetupTrees(pending_pile, active_pile); |
700 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | |
701 | 721 |
702 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 722 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
703 EXPECT_LT(low_res_factor, 1.f); | 723 EXPECT_LT(low_res_factor, 1.f); |
704 | 724 |
| 725 pending_layer_->ReleaseResources(); |
| 726 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
| 727 |
705 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | 728 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
706 6.f, // ideal contents scale | 729 6.f, // ideal contents scale |
707 3.f, // device scale | 730 3.f, // device scale |
708 2.f, // page scale | 731 2.f, // page scale |
709 1.f, // maximum animation scale | 732 1.f, // maximum animation scale |
710 false); | 733 false); |
711 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 734 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
712 EXPECT_FLOAT_EQ(6.f, | 735 EXPECT_FLOAT_EQ(6.f, |
713 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 736 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
714 EXPECT_FLOAT_EQ(6.f * low_res_factor, | 737 EXPECT_FLOAT_EQ(6.f * low_res_factor, |
715 pending_layer_->tilings()->tiling_at(1)->contents_scale()); | 738 pending_layer_->tilings()->tiling_at(1)->contents_scale()); |
716 | 739 |
717 // If we change the page scale factor, then we should get new tilings. | 740 // If we change the page scale factor, then we should get new tilings. |
718 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | 741 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
719 6.6f, // ideal contents scale | 742 6.6f, // ideal contents scale |
720 3.f, // device scale | 743 3.f, // device scale |
721 2.2f, // page scale | 744 2.2f, // page scale |
722 1.f, // maximum animation scale | 745 1.f, // maximum animation scale |
723 false); | 746 false); |
724 ASSERT_EQ(4u, pending_layer_->tilings()->num_tilings()); | 747 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
725 EXPECT_FLOAT_EQ(6.6f, | 748 EXPECT_FLOAT_EQ(6.6f, |
726 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 749 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
727 EXPECT_FLOAT_EQ(6.6f * low_res_factor, | 750 EXPECT_FLOAT_EQ(6.6f * low_res_factor, |
728 pending_layer_->tilings()->tiling_at(2)->contents_scale()); | 751 pending_layer_->tilings()->tiling_at(1)->contents_scale()); |
729 | 752 |
730 // If we change the device scale factor, then we should get new tilings. | 753 // If we change the device scale factor, then we should get new tilings. |
731 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | 754 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
732 7.26f, // ideal contents scale | 755 7.26f, // ideal contents scale |
733 3.3f, // device scale | 756 3.3f, // device scale |
734 2.2f, // page scale | 757 2.2f, // page scale |
735 1.f, // maximum animation scale | 758 1.f, // maximum animation scale |
736 false); | 759 false); |
737 ASSERT_EQ(6u, pending_layer_->tilings()->num_tilings()); | 760 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
738 EXPECT_FLOAT_EQ(7.26f, | 761 EXPECT_FLOAT_EQ(7.26f, |
739 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 762 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
740 EXPECT_FLOAT_EQ(7.26f * low_res_factor, | 763 EXPECT_FLOAT_EQ(7.26f * low_res_factor, |
741 pending_layer_->tilings()->tiling_at(3)->contents_scale()); | 764 pending_layer_->tilings()->tiling_at(1)->contents_scale()); |
742 | 765 |
743 // If we change the device scale factor, but end up at the same total scale | 766 // If we change the device scale factor, but end up at the same total scale |
744 // factor somehow, then we don't get new tilings. | 767 // factor somehow, then we don't get new tilings. |
745 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | 768 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
746 7.26f, // ideal contents scale | 769 7.26f, // ideal contents scale |
747 2.2f, // device scale | 770 2.2f, // device scale |
748 3.3f, // page scale | 771 3.3f, // page scale |
749 1.f, // maximum animation scale | 772 1.f, // maximum animation scale |
750 false); | 773 false); |
751 ASSERT_EQ(6u, pending_layer_->tilings()->num_tilings()); | 774 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
752 EXPECT_FLOAT_EQ(7.26f, | 775 EXPECT_FLOAT_EQ(7.26f, |
753 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 776 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
754 EXPECT_FLOAT_EQ(7.26f * low_res_factor, | 777 EXPECT_FLOAT_EQ(7.26f * low_res_factor, |
755 pending_layer_->tilings()->tiling_at(3)->contents_scale()); | 778 pending_layer_->tilings()->tiling_at(1)->contents_scale()); |
756 } | 779 } |
757 | 780 |
758 TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { | 781 TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { |
759 // This test makes sure that if a layer can have tilings, then a commit makes | 782 // This test makes sure that if a layer can have tilings, then a commit makes |
760 // it not able to have tilings (empty size), and then a future commit that | 783 // it not able to have tilings (empty size), and then a future commit that |
761 // makes it valid again should be able to create tilings. | 784 // makes it valid again should be able to create tilings. |
762 gfx::Size tile_size(400, 400); | 785 gfx::Size tile_size(400, 400); |
763 gfx::Size layer_bounds(1300, 1900); | 786 gfx::Size layer_bounds(1300, 1900); |
764 | 787 |
765 scoped_refptr<FakePicturePileImpl> empty_pile = | 788 scoped_refptr<FakePicturePileImpl> empty_pile = |
766 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | 789 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); |
767 scoped_refptr<FakePicturePileImpl> valid_pile = | 790 scoped_refptr<FakePicturePileImpl> valid_pile = |
768 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 791 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
769 | 792 |
770 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | |
771 EXPECT_LT(low_res_factor, 1.f); | |
772 | |
773 float high_res_scale = 1.3f; | |
774 float low_res_scale = high_res_scale * low_res_factor; | |
775 float device_scale = 1.7f; | |
776 float page_scale = 3.2f; | |
777 float maximum_animation_scale = 1.f; | |
778 | |
779 SetupPendingTree(valid_pile); | 793 SetupPendingTree(valid_pile); |
780 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | |
781 high_res_scale, | |
782 device_scale, | |
783 page_scale, | |
784 maximum_animation_scale, | |
785 false); | |
786 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 794 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
787 EXPECT_FLOAT_EQ(high_res_scale, | |
788 pending_layer_->HighResTiling()->contents_scale()); | |
789 EXPECT_FLOAT_EQ(low_res_scale, | |
790 pending_layer_->LowResTiling()->contents_scale()); | |
791 | 795 |
792 ActivateTree(); | 796 ActivateTree(); |
793 SetupPendingTree(empty_pile); | 797 SetupPendingTree(empty_pile); |
794 EXPECT_FALSE(pending_layer_->CanHaveTilings()); | 798 EXPECT_FALSE(pending_layer_->CanHaveTilings()); |
795 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | |
796 high_res_scale, | |
797 device_scale, | |
798 page_scale, | |
799 maximum_animation_scale, | |
800 false); | |
801 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 799 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
802 ASSERT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 800 ASSERT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
803 | 801 |
804 ActivateTree(); | 802 ActivateTree(); |
805 EXPECT_FALSE(active_layer_->CanHaveTilings()); | 803 EXPECT_FALSE(active_layer_->CanHaveTilings()); |
806 SetupDrawPropertiesAndUpdateTiles(active_layer_, | |
807 high_res_scale, | |
808 device_scale, | |
809 page_scale, | |
810 maximum_animation_scale, | |
811 false); | |
812 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); | 804 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); |
813 | 805 |
814 SetupPendingTree(valid_pile); | 806 SetupPendingTree(valid_pile); |
815 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | |
816 high_res_scale, | |
817 device_scale, | |
818 page_scale, | |
819 maximum_animation_scale, | |
820 false); | |
821 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 807 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
822 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); | 808 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); |
823 EXPECT_FLOAT_EQ(high_res_scale, | |
824 pending_layer_->HighResTiling()->contents_scale()); | |
825 EXPECT_FLOAT_EQ(low_res_scale, | |
826 pending_layer_->LowResTiling()->contents_scale()); | |
827 } | 809 } |
828 | 810 |
829 TEST_F(PictureLayerImplTest, ZoomOutCrash) { | 811 TEST_F(PictureLayerImplTest, ZoomOutCrash) { |
830 gfx::Size tile_size(400, 400); | 812 gfx::Size tile_size(400, 400); |
831 gfx::Size layer_bounds(1300, 1900); | 813 gfx::Size layer_bounds(1300, 1900); |
832 | 814 |
833 // Set up the high and low res tilings before pinch zoom. | 815 // Set up the high and low res tilings before pinch zoom. |
834 scoped_refptr<FakePicturePileImpl> pending_pile = | 816 scoped_refptr<FakePicturePileImpl> pending_pile = |
835 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 817 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
836 scoped_refptr<FakePicturePileImpl> active_pile = | 818 scoped_refptr<FakePicturePileImpl> active_pile = |
837 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 819 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
838 | 820 |
839 SetupTrees(pending_pile, active_pile); | 821 SetupTrees(pending_pile, active_pile); |
| 822 ResetTilingsAndRasterScales(); |
840 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 823 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
841 SetContentsScaleOnBothLayers(32.0f, 1.0f, 32.0f, 1.0f, false); | 824 SetContentsScaleOnBothLayers(32.0f, 1.0f, 32.0f, 1.0f, false); |
| 825 EXPECT_EQ(32.f, active_layer_->HighResTiling()->contents_scale()); |
842 host_impl_.PinchGestureBegin(); | 826 host_impl_.PinchGestureBegin(); |
843 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, false); | 827 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, false); |
844 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, false); | 828 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, false); |
845 EXPECT_EQ(active_layer_->tilings()->NumHighResTilings(), 1); | 829 EXPECT_EQ(active_layer_->tilings()->NumHighResTilings(), 1); |
846 } | 830 } |
847 | 831 |
848 TEST_F(PictureLayerImplTest, PinchGestureTilings) { | 832 TEST_F(PictureLayerImplTest, PinchGestureTilings) { |
849 gfx::Size tile_size(400, 400); | 833 gfx::Size tile_size(400, 400); |
850 gfx::Size layer_bounds(1300, 1900); | 834 gfx::Size layer_bounds(1300, 1900); |
851 | 835 |
| 836 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
| 837 |
852 scoped_refptr<FakePicturePileImpl> pending_pile = | 838 scoped_refptr<FakePicturePileImpl> pending_pile = |
853 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 839 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
854 scoped_refptr<FakePicturePileImpl> active_pile = | 840 scoped_refptr<FakePicturePileImpl> active_pile = |
855 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 841 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
856 | 842 |
857 // Set up the high and low res tilings before pinch zoom. | 843 // Set up the high and low res tilings before pinch zoom. |
858 SetupTrees(pending_pile, active_pile); | 844 SetupTrees(pending_pile, active_pile); |
859 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 845 ResetTilingsAndRasterScales(); |
860 SetContentsScaleOnBothLayers(2.0f, 1.0f, 1.0f, 1.0f, false); | 846 |
861 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 847 SetContentsScaleOnBothLayers(2.f, 1.0f, 2.f, 1.0f, false); |
862 EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); | 848 EXPECT_BOTH_EQ(num_tilings(), 2u); |
863 EXPECT_FLOAT_EQ(2.0f, | 849 EXPECT_BOTH_EQ(tilings()->tiling_at(0)->contents_scale(), 2.f); |
864 active_layer_->tilings()->tiling_at(0)->contents_scale()); | 850 EXPECT_BOTH_EQ(tilings()->tiling_at(1)->contents_scale(), |
865 EXPECT_FLOAT_EQ(2.0f * low_res_factor, | 851 2.f * low_res_factor); |
866 active_layer_->tilings()->tiling_at(1)->contents_scale()); | |
867 | 852 |
868 // Start a pinch gesture. | 853 // Start a pinch gesture. |
869 host_impl_.PinchGestureBegin(); | 854 host_impl_.PinchGestureBegin(); |
870 | 855 |
871 // Zoom out by a small amount. We should create a tiling at half | 856 // Zoom out by a small amount. We should create a tiling at half |
872 // the scale (2/kMaxScaleRatioDuringPinch). | 857 // the scale (2/kMaxScaleRatioDuringPinch). |
873 SetContentsScaleOnBothLayers(1.8f, 1.0f, 0.9f, 1.0f, false); | 858 SetContentsScaleOnBothLayers(1.8f, 1.0f, 1.8f, 1.0f, false); |
874 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); | 859 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); |
875 EXPECT_FLOAT_EQ(2.0f, | 860 EXPECT_FLOAT_EQ(2.0f, |
876 active_layer_->tilings()->tiling_at(0)->contents_scale()); | 861 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
877 EXPECT_FLOAT_EQ(1.0f, | 862 EXPECT_FLOAT_EQ(1.0f, |
878 active_layer_->tilings()->tiling_at(1)->contents_scale()); | 863 active_layer_->tilings()->tiling_at(1)->contents_scale()); |
879 EXPECT_FLOAT_EQ(2.0f * low_res_factor, | 864 EXPECT_FLOAT_EQ(2.0f * low_res_factor, |
880 active_layer_->tilings()->tiling_at(2)->contents_scale()); | 865 active_layer_->tilings()->tiling_at(2)->contents_scale()); |
881 | 866 |
882 // Zoom out further, close to our low-res scale factor. We should | 867 // Zoom out further, close to our low-res scale factor. We should |
883 // use that tiling as high-res, and not create a new tiling. | 868 // use that tiling as high-res, and not create a new tiling. |
884 SetContentsScaleOnBothLayers(low_res_factor * 2.1f, 1.0f, | 869 SetContentsScaleOnBothLayers(low_res_factor * 2.1f, 1.0f, |
885 low_res_factor * 2.1f, 1.0f, false); | 870 low_res_factor * 2.1f, 1.0f, false); |
886 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); | 871 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); |
887 | 872 |
888 // Zoom in a lot now. Since we increase by increments of | 873 // Zoom in a lot now. Since we increase by increments of |
889 // kMaxScaleRatioDuringPinch, this will create a new tiling at 4.0. | 874 // kMaxScaleRatioDuringPinch, this will create a new tiling at 4.0. |
890 SetContentsScaleOnBothLayers(3.8f, 1.0f, 2.1f, 1.f, false); | 875 SetContentsScaleOnBothLayers(3.8f, 1.0f, 3.8f, 1.f, false); |
891 EXPECT_EQ(4u, active_layer_->tilings()->num_tilings()); | 876 EXPECT_EQ(4u, active_layer_->tilings()->num_tilings()); |
892 EXPECT_FLOAT_EQ(4.0f, | 877 EXPECT_FLOAT_EQ(4.0f, |
893 active_layer_->tilings()->tiling_at(0)->contents_scale()); | 878 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
894 } | 879 } |
895 | 880 |
896 TEST_F(PictureLayerImplTest, SnappedTilingDuringZoom) { | 881 TEST_F(PictureLayerImplTest, SnappedTilingDuringZoom) { |
897 gfx::Size tile_size(300, 300); | 882 gfx::Size tile_size(300, 300); |
898 gfx::Size layer_bounds(2600, 3800); | 883 gfx::Size layer_bounds(2600, 3800); |
899 | 884 |
900 scoped_refptr<FakePicturePileImpl> pending_pile = | 885 scoped_refptr<FakePicturePileImpl> pending_pile = |
901 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 886 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
902 scoped_refptr<FakePicturePileImpl> active_pile = | 887 scoped_refptr<FakePicturePileImpl> active_pile = |
903 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 888 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
904 | 889 |
| 890 SetupTrees(pending_pile, active_pile); |
| 891 |
| 892 ResetTilingsAndRasterScales(); |
| 893 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
| 894 |
905 // Set up the high and low res tilings before pinch zoom. | 895 // Set up the high and low res tilings before pinch zoom. |
906 SetupTrees(pending_pile, active_pile); | |
907 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | |
908 SetContentsScaleOnBothLayers(0.24f, 1.0f, 0.24f, 1.0f, false); | 896 SetContentsScaleOnBothLayers(0.24f, 1.0f, 0.24f, 1.0f, false); |
909 EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); | 897 EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); |
910 EXPECT_FLOAT_EQ(0.24f, | 898 EXPECT_FLOAT_EQ(0.24f, |
911 active_layer_->tilings()->tiling_at(0)->contents_scale()); | 899 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
912 EXPECT_FLOAT_EQ(0.0625f, | 900 EXPECT_FLOAT_EQ(0.0625f, |
913 active_layer_->tilings()->tiling_at(1)->contents_scale()); | 901 active_layer_->tilings()->tiling_at(1)->contents_scale()); |
914 | 902 |
915 // Start a pinch gesture. | 903 // Start a pinch gesture. |
916 host_impl_.PinchGestureBegin(); | 904 host_impl_.PinchGestureBegin(); |
917 | 905 |
(...skipping 30 matching lines...) Expand all Loading... |
948 gfx::Size tile_size(400, 400); | 936 gfx::Size tile_size(400, 400); |
949 gfx::Size layer_bounds(1300, 1900); | 937 gfx::Size layer_bounds(1300, 1900); |
950 | 938 |
951 scoped_refptr<FakePicturePileImpl> pending_pile = | 939 scoped_refptr<FakePicturePileImpl> pending_pile = |
952 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 940 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
953 scoped_refptr<FakePicturePileImpl> active_pile = | 941 scoped_refptr<FakePicturePileImpl> active_pile = |
954 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 942 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
955 | 943 |
956 std::vector<PictureLayerTiling*> used_tilings; | 944 std::vector<PictureLayerTiling*> used_tilings; |
957 | 945 |
958 SetupTrees(pending_pile, active_pile); | |
959 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | |
960 | |
961 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 946 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
962 EXPECT_LT(low_res_factor, 1.f); | 947 EXPECT_LT(low_res_factor, 1.f); |
963 | 948 |
964 float device_scale = 1.7f; | |
965 float page_scale = 3.2f; | |
966 float scale = 1.f; | 949 float scale = 1.f; |
| 950 float page_scale = 1.f; |
967 | 951 |
968 SetContentsScaleOnBothLayers(scale, device_scale, page_scale, 1.f, false); | 952 SetupTrees(pending_pile, active_pile); |
969 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 953 EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); |
| 954 EXPECT_EQ(1.f, active_layer_->HighResTiling()->contents_scale()); |
970 | 955 |
971 // We only have ideal tilings, so they aren't removed. | 956 // We only have ideal tilings, so they aren't removed. |
972 used_tilings.clear(); | 957 used_tilings.clear(); |
973 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 958 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
974 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 959 EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); |
975 | 960 |
976 host_impl_.PinchGestureBegin(); | 961 host_impl_.PinchGestureBegin(); |
977 | 962 |
978 // Changing the ideal but not creating new tilings. | 963 // Changing the ideal but not creating new tilings. |
979 scale *= 1.5f; | 964 scale = 1.5f; |
980 page_scale *= 1.5f; | 965 page_scale = 1.5f; |
981 SetContentsScaleOnBothLayers(scale, device_scale, page_scale, 1.f, false); | 966 SetContentsScaleOnBothLayers(scale, 1.f, page_scale, 1.f, false); |
982 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 967 EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); |
983 | 968 |
984 // The tilings are still our target scale, so they aren't removed. | 969 // The tilings are still our target scale, so they aren't removed. |
985 used_tilings.clear(); | 970 used_tilings.clear(); |
986 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 971 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
987 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 972 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
988 | 973 |
989 host_impl_.PinchGestureEnd(); | 974 host_impl_.PinchGestureEnd(); |
990 | 975 |
991 // Create a 1.2 scale tiling. Now we have 1.0 and 1.2 tilings. Ideal = 1.2. | 976 // Create a 1.2 scale tiling. Now we have 1.0 and 1.2 tilings. Ideal = 1.2. |
992 scale /= 4.f; | 977 scale = 1.2f; |
993 page_scale /= 4.f; | 978 page_scale = 1.2f; |
994 SetContentsScaleOnBothLayers(1.2f, device_scale, page_scale, 1.f, false); | 979 SetContentsScaleOnBothLayers(1.2f, 1.f, page_scale, 1.f, false); |
995 ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); | 980 ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); |
996 EXPECT_FLOAT_EQ( | 981 EXPECT_FLOAT_EQ( |
997 1.f, | 982 1.f, |
998 active_layer_->tilings()->tiling_at(1)->contents_scale()); | 983 active_layer_->tilings()->tiling_at(1)->contents_scale()); |
999 EXPECT_FLOAT_EQ( | 984 EXPECT_FLOAT_EQ( |
1000 1.f * low_res_factor, | 985 1.f * low_res_factor, |
1001 active_layer_->tilings()->tiling_at(3)->contents_scale()); | 986 active_layer_->tilings()->tiling_at(3)->contents_scale()); |
1002 | 987 |
1003 // Mark the non-ideal tilings as used. They won't be removed. | 988 // Mark the non-ideal tilings as used. They won't be removed. |
1004 used_tilings.clear(); | 989 used_tilings.clear(); |
1005 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); | 990 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); |
1006 used_tilings.push_back(active_layer_->tilings()->tiling_at(3)); | 991 used_tilings.push_back(active_layer_->tilings()->tiling_at(3)); |
1007 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 992 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
1008 ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); | 993 ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); |
1009 | 994 |
1010 // Now move the ideal scale to 0.5. Our target stays 1.2. | 995 // Now move the ideal scale to 0.5. Our target stays 1.2. |
1011 SetContentsScaleOnBothLayers(0.5f, device_scale, page_scale, 1.f, false); | 996 SetContentsScaleOnBothLayers(0.5f, 1.f, page_scale, 1.f, false); |
1012 | 997 |
1013 // The high resolution tiling is between target and ideal, so is not | 998 // The high resolution tiling is between target and ideal, so is not |
1014 // removed. The low res tiling for the old ideal=1.0 scale is removed. | 999 // removed. The low res tiling for the old ideal=1.0 scale is removed. |
1015 used_tilings.clear(); | 1000 used_tilings.clear(); |
1016 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 1001 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
1017 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 1002 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
1018 | 1003 |
1019 // Now move the ideal scale to 1.0. Our target stays 1.2. | 1004 // Now move the ideal scale to 1.0. Our target stays 1.2. |
1020 SetContentsScaleOnBothLayers(1.f, device_scale, page_scale, 1.f, false); | 1005 SetContentsScaleOnBothLayers(1.f, 1.f, page_scale, 1.f, false); |
1021 | 1006 |
1022 // All the tilings are between are target and the ideal, so they are not | 1007 // All the tilings are between are target and the ideal, so they are not |
1023 // removed. | 1008 // removed. |
1024 used_tilings.clear(); | 1009 used_tilings.clear(); |
1025 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 1010 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
1026 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 1011 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
1027 | 1012 |
1028 // Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2. | 1013 // Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2. |
1029 SetupDrawPropertiesAndUpdateTiles( | 1014 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.1f, 1.f, page_scale, 1.f, |
1030 active_layer_, 1.1f, device_scale, page_scale, 1.f, false); | 1015 false); |
1031 | 1016 |
1032 // Because the pending layer's ideal scale is still 1.0, our tilings fall | 1017 // Because the pending layer's ideal scale is still 1.0, our tilings fall |
1033 // in the range [1.0,1.2] and are kept. | 1018 // in the range [1.0,1.2] and are kept. |
1034 used_tilings.clear(); | 1019 used_tilings.clear(); |
1035 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 1020 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
1036 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 1021 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
1037 | 1022 |
1038 // Move the ideal scale on the pending layer to 1.1 as well. Our target stays | 1023 // Move the ideal scale on the pending layer to 1.1 as well. Our target stays |
1039 // 1.2 still. | 1024 // 1.2 still. |
1040 SetupDrawPropertiesAndUpdateTiles( | 1025 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.1f, 1.f, page_scale, 1.f, |
1041 pending_layer_, 1.1f, device_scale, page_scale, 1.f, false); | 1026 false); |
1042 | 1027 |
1043 // Our 1.0 tiling now falls outside the range between our ideal scale and our | 1028 // Our 1.0 tiling now falls outside the range between our ideal scale and our |
1044 // target raster scale. But it is in our used tilings set, so nothing is | 1029 // target raster scale. But it is in our used tilings set, so nothing is |
1045 // deleted. | 1030 // deleted. |
1046 used_tilings.clear(); | 1031 used_tilings.clear(); |
1047 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); | 1032 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); |
1048 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 1033 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
1049 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 1034 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
1050 | 1035 |
1051 // If we remove it from our used tilings set, it is outside the range to keep | 1036 // If we remove it from our used tilings set, it is outside the range to keep |
1052 // so it is deleted. | 1037 // so it is deleted. |
1053 used_tilings.clear(); | 1038 used_tilings.clear(); |
1054 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 1039 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
1055 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 1040 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
1056 } | 1041 } |
1057 | 1042 |
1058 #define EXPECT_BOTH_EQ(expression, x) \ | |
1059 do { \ | |
1060 EXPECT_EQ(x, pending_layer_->expression); \ | |
1061 EXPECT_EQ(x, active_layer_->expression); \ | |
1062 } while (false) | |
1063 | |
1064 #define EXPECT_BOTH_NE(expression, x) \ | |
1065 do { \ | |
1066 EXPECT_NE(x, pending_layer_->expression); \ | |
1067 EXPECT_NE(x, active_layer_->expression); \ | |
1068 } while (false) | |
1069 | |
1070 TEST_F(PictureLayerImplTest, DontAddLowResDuringAnimation) { | 1043 TEST_F(PictureLayerImplTest, DontAddLowResDuringAnimation) { |
1071 // Make sure this layer covers multiple tiles, since otherwise low | 1044 // Make sure this layer covers multiple tiles, since otherwise low |
1072 // res won't get created because it is too small. | 1045 // res won't get created because it is too small. |
1073 gfx::Size tile_size(host_impl_.settings().default_tile_size); | 1046 gfx::Size tile_size(host_impl_.settings().default_tile_size); |
1074 SetupDefaultTrees(gfx::Size(tile_size.width() + 1, tile_size.height() + 1)); | |
1075 // Avoid max untiled layer size heuristics via fixed tile size. | 1047 // Avoid max untiled layer size heuristics via fixed tile size. |
1076 pending_layer_->set_fixed_tile_size(tile_size); | 1048 gfx::Size layer_bounds(tile_size.width() + 1, tile_size.height() + 1); |
1077 active_layer_->set_fixed_tile_size(tile_size); | 1049 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
1078 | 1050 |
1079 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 1051 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
1080 float contents_scale = 1.f; | 1052 float contents_scale = 1.f; |
1081 float device_scale = 1.f; | 1053 float device_scale = 1.f; |
1082 float page_scale = 1.f; | 1054 float page_scale = 1.f; |
1083 float maximum_animation_scale = 1.f; | 1055 float maximum_animation_scale = 1.f; |
1084 bool animating_transform = true; | 1056 bool animating_transform = true; |
1085 | 1057 |
| 1058 ResetTilingsAndRasterScales(); |
| 1059 |
1086 // Animating, so don't create low res even if there isn't one already. | 1060 // Animating, so don't create low res even if there isn't one already. |
1087 SetContentsScaleOnBothLayers(contents_scale, | 1061 SetContentsScaleOnBothLayers(contents_scale, |
1088 device_scale, | 1062 device_scale, |
1089 page_scale, | 1063 page_scale, |
1090 maximum_animation_scale, | 1064 maximum_animation_scale, |
1091 animating_transform); | 1065 animating_transform); |
1092 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 1066 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
1093 EXPECT_BOTH_EQ(num_tilings(), 1u); | 1067 EXPECT_BOTH_EQ(num_tilings(), 1u); |
1094 | 1068 |
1095 // Stop animating, low res gets created. | 1069 // Stop animating, low res gets created. |
1096 animating_transform = false; | 1070 animating_transform = false; |
1097 SetContentsScaleOnBothLayers(contents_scale, | 1071 SetContentsScaleOnBothLayers(contents_scale, |
1098 device_scale, | 1072 device_scale, |
1099 page_scale, | 1073 page_scale, |
1100 maximum_animation_scale, | 1074 maximum_animation_scale, |
1101 animating_transform); | 1075 animating_transform); |
1102 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 1076 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
1103 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), low_res_factor); | 1077 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), low_res_factor); |
1104 EXPECT_BOTH_EQ(num_tilings(), 2u); | 1078 EXPECT_BOTH_EQ(num_tilings(), 2u); |
1105 | 1079 |
1106 // Page scale animation, new high res, but no low res. We still have | 1080 // Page scale animation, new high res, but no low res. We still have |
1107 // a tiling at the previous scale, it's just not marked as low res. | 1081 // a tiling at the previous scale, it's just not marked as low res on the |
| 1082 // active layer. The pending layer drops non-ideal tilings. |
1108 contents_scale = 2.f; | 1083 contents_scale = 2.f; |
1109 page_scale = 2.f; | 1084 page_scale = 2.f; |
1110 maximum_animation_scale = 2.f; | 1085 maximum_animation_scale = 2.f; |
1111 animating_transform = true; | 1086 animating_transform = true; |
1112 SetContentsScaleOnBothLayers(contents_scale, | 1087 SetContentsScaleOnBothLayers(contents_scale, |
1113 device_scale, | 1088 device_scale, |
1114 page_scale, | 1089 page_scale, |
1115 maximum_animation_scale, | 1090 maximum_animation_scale, |
1116 animating_transform); | 1091 animating_transform); |
1117 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); | 1092 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); |
1118 EXPECT_FALSE(active_layer_->LowResTiling()); | 1093 EXPECT_FALSE(active_layer_->LowResTiling()); |
1119 EXPECT_FALSE(pending_layer_->LowResTiling()); | 1094 EXPECT_FALSE(pending_layer_->LowResTiling()); |
1120 EXPECT_BOTH_EQ(num_tilings(), 3u); | 1095 EXPECT_EQ(3u, active_layer_->num_tilings()); |
| 1096 EXPECT_EQ(1u, pending_layer_->num_tilings()); |
1121 | 1097 |
1122 // Stop animating, new low res gets created for final page scale. | 1098 // Stop animating, new low res gets created for final page scale. |
1123 animating_transform = false; | 1099 animating_transform = false; |
1124 SetContentsScaleOnBothLayers(contents_scale, | 1100 SetContentsScaleOnBothLayers(contents_scale, |
1125 device_scale, | 1101 device_scale, |
1126 page_scale, | 1102 page_scale, |
1127 maximum_animation_scale, | 1103 maximum_animation_scale, |
1128 animating_transform); | 1104 animating_transform); |
1129 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); | 1105 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); |
1130 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), 2.f * low_res_factor); | 1106 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), 2.f * low_res_factor); |
1131 EXPECT_BOTH_EQ(num_tilings(), 4u); | 1107 EXPECT_EQ(4u, active_layer_->num_tilings()); |
| 1108 EXPECT_EQ(2u, pending_layer_->num_tilings()); |
1132 } | 1109 } |
1133 | 1110 |
1134 TEST_F(PictureLayerImplTest, DontAddLowResForSmallLayers) { | 1111 TEST_F(PictureLayerImplTest, DontAddLowResForSmallLayers) { |
1135 gfx::Size layer_bounds(host_impl_.settings().default_tile_size); | 1112 gfx::Size layer_bounds(host_impl_.settings().default_tile_size); |
1136 gfx::Size tile_size(100, 100); | 1113 gfx::Size tile_size(100, 100); |
1137 | 1114 |
1138 scoped_refptr<FakePicturePileImpl> pending_pile = | 1115 scoped_refptr<FakePicturePileImpl> pending_pile = |
1139 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1116 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1140 scoped_refptr<FakePicturePileImpl> active_pile = | 1117 scoped_refptr<FakePicturePileImpl> active_pile = |
1141 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1118 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1178 SetContentsScaleOnBothLayers(contents_scale, | 1155 SetContentsScaleOnBothLayers(contents_scale, |
1179 device_scale, | 1156 device_scale, |
1180 page_scale, | 1157 page_scale, |
1181 maximum_animation_scale, | 1158 maximum_animation_scale, |
1182 animating_transform); | 1159 animating_transform); |
1183 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); | 1160 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); |
1184 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), | 1161 EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), |
1185 contents_scale * low_res_factor); | 1162 contents_scale * low_res_factor); |
1186 EXPECT_BOTH_EQ(num_tilings(), 2u); | 1163 EXPECT_BOTH_EQ(num_tilings(), 2u); |
1187 | 1164 |
1188 ResetTilingsAndRasterScales(); | 1165 // Mask layers dont create low res since they always fit on one tile. |
| 1166 scoped_ptr<FakePictureLayerImpl> mask = |
| 1167 FakePictureLayerImpl::CreateMaskWithRasterSource( |
| 1168 host_impl_.pending_tree(), 3, pending_pile); |
| 1169 mask->SetBounds(layer_bounds); |
| 1170 mask->SetContentBounds(layer_bounds); |
| 1171 mask->SetDrawsContent(true); |
1189 | 1172 |
1190 // Mask layers dont create low res since they always fit on one tile. | 1173 SetupDrawPropertiesAndUpdateTiles(mask.get(), contents_scale, device_scale, |
1191 pending_layer_->set_is_mask(true); | 1174 page_scale, maximum_animation_scale, |
1192 active_layer_->set_is_mask(true); | 1175 animating_transform); |
1193 SetContentsScaleOnBothLayers(contents_scale, | 1176 EXPECT_EQ(mask->HighResTiling()->contents_scale(), contents_scale); |
1194 device_scale, | 1177 EXPECT_EQ(mask->num_tilings(), 1u); |
1195 page_scale, | |
1196 maximum_animation_scale, | |
1197 animating_transform); | |
1198 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); | |
1199 EXPECT_BOTH_EQ(num_tilings(), 1u); | |
1200 } | 1178 } |
1201 | 1179 |
1202 TEST_F(PictureLayerImplTest, HugeMasksDontGetTiles) { | 1180 TEST_F(PictureLayerImplTest, HugeMasksDontGetTiles) { |
| 1181 base::TimeTicks time_ticks; |
| 1182 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 1183 host_impl_.SetCurrentBeginFrameArgs( |
| 1184 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 1185 |
1203 gfx::Size tile_size(100, 100); | 1186 gfx::Size tile_size(100, 100); |
| 1187 gfx::Size layer_bounds(1000, 1000); |
1204 | 1188 |
1205 scoped_refptr<FakePicturePileImpl> valid_pile = | 1189 scoped_refptr<FakePicturePileImpl> valid_pile = |
1206 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1000, 1000)); | 1190 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1207 SetupPendingTree(valid_pile); | 1191 SetupPendingTree(valid_pile); |
1208 pending_layer_->set_is_mask(true); | |
1209 | 1192 |
1210 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); | 1193 scoped_ptr<FakePictureLayerImpl> mask_ptr = |
1211 EXPECT_EQ(1.f, pending_layer_->HighResTiling()->contents_scale()); | 1194 FakePictureLayerImpl::CreateMaskWithRasterSource( |
1212 EXPECT_EQ(1u, pending_layer_->num_tilings()); | 1195 host_impl_.pending_tree(), 3, valid_pile); |
| 1196 mask_ptr->SetBounds(layer_bounds); |
| 1197 mask_ptr->SetContentBounds(layer_bounds); |
| 1198 mask_ptr->SetDrawsContent(true); |
| 1199 pending_layer_->SetMaskLayer(mask_ptr.Pass()); |
1213 | 1200 |
1214 pending_layer_->HighResTiling()->CreateAllTilesForTesting(); | 1201 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 1202 host_impl_.SetCurrentBeginFrameArgs( |
| 1203 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 1204 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 1205 |
| 1206 FakePictureLayerImpl* pending_mask = |
| 1207 static_cast<FakePictureLayerImpl*>(pending_layer_->mask_layer()); |
| 1208 |
| 1209 EXPECT_EQ(1.f, pending_mask->HighResTiling()->contents_scale()); |
| 1210 EXPECT_EQ(1u, pending_mask->num_tilings()); |
| 1211 |
1215 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( | 1212 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( |
1216 pending_layer_->HighResTiling()->AllTilesForTesting()); | 1213 pending_mask->HighResTiling()->AllTilesForTesting()); |
1217 | 1214 |
1218 ActivateTree(); | 1215 ActivateTree(); |
1219 | 1216 |
| 1217 FakePictureLayerImpl* active_mask = |
| 1218 static_cast<FakePictureLayerImpl*>(active_layer_->mask_layer()); |
| 1219 |
1220 // Mask layers have a tiling with a single tile in it. | 1220 // Mask layers have a tiling with a single tile in it. |
1221 EXPECT_EQ(1u, active_layer_->HighResTiling()->AllTilesForTesting().size()); | 1221 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); |
1222 // The mask resource exists. | 1222 // The mask resource exists. |
1223 ResourceProvider::ResourceId mask_resource_id; | 1223 ResourceProvider::ResourceId mask_resource_id; |
1224 gfx::Size mask_texture_size; | 1224 gfx::Size mask_texture_size; |
1225 active_layer_->GetContentsResourceId(&mask_resource_id, &mask_texture_size); | 1225 active_mask->GetContentsResourceId(&mask_resource_id, &mask_texture_size); |
| 1226 EXPECT_NE(0u, mask_resource_id); |
| 1227 EXPECT_EQ(mask_texture_size, active_mask->bounds()); |
| 1228 |
| 1229 // Drop resources and recreate them, still the same. |
| 1230 pending_mask->ReleaseResources(); |
| 1231 active_mask->ReleaseResources(); |
| 1232 SetupDrawPropertiesAndUpdateTiles(active_mask, 1.f, 1.f, 1.f, 1.f, false); |
| 1233 active_mask->HighResTiling()->CreateAllTilesForTesting(); |
| 1234 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); |
1226 EXPECT_NE(0u, mask_resource_id); | 1235 EXPECT_NE(0u, mask_resource_id); |
1227 EXPECT_EQ(mask_texture_size, active_layer_->bounds()); | 1236 EXPECT_EQ(mask_texture_size, active_layer_->bounds()); |
1228 | 1237 |
1229 // Drop resources and recreate them, still the same. | 1238 // Drop resources and recreate them, still the same. |
1230 old_pending_layer_->ReleaseResources(); | 1239 pending_mask->ReleaseResources(); |
1231 active_layer_->ReleaseResources(); | 1240 active_mask->ReleaseResources(); |
1232 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false); | 1241 SetupDrawPropertiesAndUpdateTiles(active_mask, 1.f, 1.f, 1.f, 1.f, false); |
1233 active_layer_->HighResTiling()->CreateAllTilesForTesting(); | 1242 active_mask->HighResTiling()->CreateAllTilesForTesting(); |
1234 EXPECT_EQ(1u, active_layer_->HighResTiling()->AllTilesForTesting().size()); | 1243 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); |
1235 EXPECT_NE(0u, mask_resource_id); | 1244 EXPECT_NE(0u, mask_resource_id); |
1236 EXPECT_EQ(mask_texture_size, active_layer_->bounds()); | 1245 EXPECT_EQ(mask_texture_size, active_mask->bounds()); |
1237 | 1246 |
1238 // Resize larger than the max texture size. | 1247 // Resize larger than the max texture size. |
1239 int max_texture_size = host_impl_.GetRendererCapabilities().max_texture_size; | 1248 int max_texture_size = host_impl_.GetRendererCapabilities().max_texture_size; |
| 1249 gfx::Size huge_bounds(max_texture_size + 1, 10); |
1240 scoped_refptr<FakePicturePileImpl> huge_pile = | 1250 scoped_refptr<FakePicturePileImpl> huge_pile = |
1241 FakePicturePileImpl::CreateFilledPile( | 1251 FakePicturePileImpl::CreateFilledPile(tile_size, huge_bounds); |
1242 tile_size, gfx::Size(max_texture_size + 1, 10)); | 1252 |
1243 SetupPendingTree(huge_pile); | 1253 SetupPendingTree(huge_pile); |
1244 pending_layer_->set_is_mask(true); | 1254 pending_mask->SetBounds(huge_bounds); |
| 1255 pending_mask->SetContentBounds(huge_bounds); |
| 1256 bool is_mask = true; |
| 1257 pending_mask->SetRasterSourceOnPending(huge_pile, Region(), is_mask); |
1245 | 1258 |
1246 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); | 1259 time_ticks += base::TimeDelta::FromMilliseconds(1); |
1247 EXPECT_EQ(1.f, pending_layer_->HighResTiling()->contents_scale()); | 1260 host_impl_.SetCurrentBeginFrameArgs( |
1248 EXPECT_EQ(1u, pending_layer_->num_tilings()); | 1261 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 1262 host_impl_.pending_tree()->UpdateDrawProperties(); |
1249 | 1263 |
1250 pending_layer_->HighResTiling()->CreateAllTilesForTesting(); | 1264 EXPECT_EQ(1.f, pending_mask->HighResTiling()->contents_scale()); |
| 1265 EXPECT_EQ(1u, pending_mask->num_tilings()); |
| 1266 |
| 1267 // pending_layer_->HighResTiling()->CreateAllTilesForTesting(); |
1251 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( | 1268 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( |
1252 pending_layer_->HighResTiling()->AllTilesForTesting()); | 1269 pending_mask->HighResTiling()->AllTilesForTesting()); |
1253 | 1270 |
1254 ActivateTree(); | 1271 ActivateTree(); |
1255 | 1272 |
1256 // Mask layers have a tiling, but there should be no tiles in it. | 1273 // Mask layers have a tiling, but there should be no tiles in it. |
1257 EXPECT_EQ(0u, active_layer_->HighResTiling()->AllTilesForTesting().size()); | 1274 EXPECT_EQ(0u, active_mask->HighResTiling()->AllTilesForTesting().size()); |
1258 // The mask resource is empty. | 1275 // The mask resource is empty. |
1259 active_layer_->GetContentsResourceId(&mask_resource_id, &mask_texture_size); | 1276 active_layer_->GetContentsResourceId(&mask_resource_id, &mask_texture_size); |
1260 EXPECT_EQ(0u, mask_resource_id); | 1277 EXPECT_EQ(0u, mask_resource_id); |
1261 | 1278 |
1262 // Drop resources and recreate them, still the same. | 1279 // Drop resources and recreate them, still the same. |
1263 old_pending_layer_->ReleaseResources(); | 1280 pending_mask->ReleaseResources(); |
1264 active_layer_->ReleaseResources(); | 1281 active_mask->ReleaseResources(); |
1265 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false); | 1282 SetupDrawPropertiesAndUpdateTiles(active_mask, 1.f, 1.f, 1.f, 1.f, false); |
1266 active_layer_->HighResTiling()->CreateAllTilesForTesting(); | 1283 active_mask->HighResTiling()->CreateAllTilesForTesting(); |
1267 EXPECT_EQ(0u, active_layer_->HighResTiling()->AllTilesForTesting().size()); | 1284 EXPECT_EQ(0u, active_mask->HighResTiling()->AllTilesForTesting().size()); |
1268 active_layer_->GetContentsResourceId(&mask_resource_id, &mask_texture_size); | 1285 active_mask->GetContentsResourceId(&mask_resource_id, &mask_texture_size); |
1269 EXPECT_EQ(0u, mask_resource_id); | 1286 EXPECT_EQ(0u, mask_resource_id); |
1270 } | 1287 } |
1271 | 1288 |
1272 TEST_F(PictureLayerImplTest, ScaledMaskLayer) { | 1289 TEST_F(PictureLayerImplTest, ScaledMaskLayer) { |
| 1290 base::TimeTicks time_ticks; |
| 1291 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 1292 host_impl_.SetCurrentBeginFrameArgs( |
| 1293 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 1294 |
1273 gfx::Size tile_size(100, 100); | 1295 gfx::Size tile_size(100, 100); |
| 1296 gfx::Size layer_bounds(1000, 1000); |
| 1297 |
| 1298 host_impl_.SetDeviceScaleFactor(1.3f); |
1274 | 1299 |
1275 scoped_refptr<FakePicturePileImpl> valid_pile = | 1300 scoped_refptr<FakePicturePileImpl> valid_pile = |
1276 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1000, 1000)); | 1301 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1277 SetupPendingTree(valid_pile); | 1302 SetupPendingTree(valid_pile); |
1278 pending_layer_->set_is_mask(true); | |
1279 | 1303 |
1280 float ideal_contents_scale = 1.3f; | 1304 scoped_ptr<FakePictureLayerImpl> mask_ptr = |
1281 SetupDrawPropertiesAndUpdateTiles( | 1305 FakePictureLayerImpl::CreateMaskWithRasterSource( |
1282 pending_layer_, ideal_contents_scale, 1.f, 1.f, 1.f, false); | 1306 host_impl_.pending_tree(), 3, valid_pile); |
1283 EXPECT_EQ(ideal_contents_scale, | 1307 mask_ptr->SetBounds(layer_bounds); |
1284 pending_layer_->HighResTiling()->contents_scale()); | 1308 mask_ptr->SetContentBounds(layer_bounds); |
1285 EXPECT_EQ(1u, pending_layer_->num_tilings()); | 1309 mask_ptr->SetDrawsContent(true); |
| 1310 pending_layer_->SetMaskLayer(mask_ptr.Pass()); |
1286 | 1311 |
1287 pending_layer_->HighResTiling()->CreateAllTilesForTesting(); | 1312 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 1313 host_impl_.SetCurrentBeginFrameArgs( |
| 1314 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 1315 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 1316 |
| 1317 FakePictureLayerImpl* pending_mask = |
| 1318 static_cast<FakePictureLayerImpl*>(pending_layer_->mask_layer()); |
| 1319 |
| 1320 // Masks are scaled, and do not have a low res tiling. |
| 1321 EXPECT_EQ(1.3f, pending_mask->HighResTiling()->contents_scale()); |
| 1322 EXPECT_EQ(1u, pending_mask->num_tilings()); |
| 1323 |
1288 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( | 1324 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( |
1289 pending_layer_->HighResTiling()->AllTilesForTesting()); | 1325 pending_mask->HighResTiling()->AllTilesForTesting()); |
1290 | 1326 |
1291 ActivateTree(); | 1327 ActivateTree(); |
1292 | 1328 |
| 1329 FakePictureLayerImpl* active_mask = |
| 1330 static_cast<FakePictureLayerImpl*>(active_layer_->mask_layer()); |
| 1331 |
1293 // Mask layers have a tiling with a single tile in it. | 1332 // Mask layers have a tiling with a single tile in it. |
1294 EXPECT_EQ(1u, active_layer_->HighResTiling()->AllTilesForTesting().size()); | 1333 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); |
1295 // The mask resource exists. | 1334 // The mask resource exists. |
1296 ResourceProvider::ResourceId mask_resource_id; | 1335 ResourceProvider::ResourceId mask_resource_id; |
1297 gfx::Size mask_texture_size; | 1336 gfx::Size mask_texture_size; |
1298 active_layer_->GetContentsResourceId(&mask_resource_id, &mask_texture_size); | 1337 active_mask->GetContentsResourceId(&mask_resource_id, &mask_texture_size); |
1299 EXPECT_NE(0u, mask_resource_id); | 1338 EXPECT_NE(0u, mask_resource_id); |
1300 gfx::Size expected_mask_texture_size = gfx::ToCeiledSize( | 1339 gfx::Size expected_mask_texture_size = |
1301 gfx::ScaleSize(active_layer_->bounds(), ideal_contents_scale)); | 1340 gfx::ToCeiledSize(gfx::ScaleSize(active_mask->bounds(), 1.3f)); |
1302 EXPECT_EQ(mask_texture_size, expected_mask_texture_size); | 1341 EXPECT_EQ(mask_texture_size, expected_mask_texture_size); |
1303 } | 1342 } |
1304 | 1343 |
1305 TEST_F(PictureLayerImplTest, ReleaseResources) { | 1344 TEST_F(PictureLayerImplTest, ReleaseResources) { |
1306 gfx::Size tile_size(400, 400); | 1345 gfx::Size tile_size(400, 400); |
1307 gfx::Size layer_bounds(1300, 1900); | 1346 gfx::Size layer_bounds(1300, 1900); |
1308 | 1347 |
1309 scoped_refptr<FakePicturePileImpl> pending_pile = | 1348 scoped_refptr<FakePicturePileImpl> pending_pile = |
1310 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1349 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1311 scoped_refptr<FakePicturePileImpl> active_pile = | 1350 scoped_refptr<FakePicturePileImpl> active_pile = |
1312 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1351 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1313 | 1352 |
1314 SetupTrees(pending_pile, active_pile); | 1353 SetupTrees(pending_pile, active_pile); |
1315 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | |
1316 | |
1317 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | |
1318 1.3f, // ideal contents scale | |
1319 2.7f, // device scale | |
1320 3.2f, // page scale | |
1321 1.f, // maximum animation scale | |
1322 false); | |
1323 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 1354 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
1324 | 1355 |
1325 // All tilings should be removed when losing output surface. | 1356 // All tilings should be removed when losing output surface. |
1326 active_layer_->ReleaseResources(); | 1357 active_layer_->ReleaseResources(); |
1327 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 1358 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
1328 pending_layer_->ReleaseResources(); | 1359 pending_layer_->ReleaseResources(); |
1329 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1360 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
1330 | 1361 |
1331 // This should create new tilings. | 1362 // This should create new tilings. |
1332 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | 1363 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
1333 1.3f, // ideal contents scale | 1364 1.f, // ideal contents scale |
1334 2.7f, // device scale | 1365 1.f, // device scale |
1335 3.2f, // page scale | 1366 1.f, // page scale |
1336 1.f, // maximum animation scale | 1367 1.f, // maximum animation scale |
1337 false); | 1368 false); |
1338 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 1369 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
1339 } | 1370 } |
1340 | 1371 |
1341 TEST_F(PictureLayerImplTest, ClampTilesToToMaxTileSize) { | 1372 TEST_F(PictureLayerImplTest, ClampTilesToToMaxTileSize) { |
1342 // The default max tile size is larger than 400x400. | 1373 // The default max tile size is larger than 400x400. |
1343 gfx::Size tile_size(400, 400); | 1374 gfx::Size tile_size(400, 400); |
1344 gfx::Size layer_bounds(5000, 5000); | 1375 gfx::Size layer_bounds(5000, 5000); |
1345 | 1376 |
1346 scoped_refptr<FakePicturePileImpl> pending_pile = | 1377 scoped_refptr<FakePicturePileImpl> pending_pile = |
1347 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1378 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1348 scoped_refptr<FakePicturePileImpl> active_pile = | 1379 scoped_refptr<FakePicturePileImpl> active_pile = |
1349 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1380 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1350 | 1381 |
1351 SetupTrees(pending_pile, active_pile); | 1382 SetupTrees(pending_pile, active_pile); |
1352 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1383 EXPECT_GE(pending_layer_->tilings()->num_tilings(), 1u); |
1353 | |
1354 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); | |
1355 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | |
1356 | 1384 |
1357 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1385 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
1358 | 1386 |
1359 // The default value. | 1387 // The default value. |
1360 EXPECT_EQ(gfx::Size(256, 256).ToString(), | 1388 EXPECT_EQ(gfx::Size(256, 256).ToString(), |
1361 host_impl_.settings().default_tile_size.ToString()); | 1389 host_impl_.settings().default_tile_size.ToString()); |
1362 | 1390 |
1363 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; | 1391 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; |
1364 EXPECT_EQ(gfx::Size(256, 256).ToString(), | 1392 EXPECT_EQ(gfx::Size(256, 256).ToString(), |
1365 tile->content_rect().size().ToString()); | 1393 tile->content_rect().size().ToString()); |
1366 | 1394 |
1367 pending_layer_->ReleaseResources(); | 1395 ResetTilingsAndRasterScales(); |
1368 | 1396 |
1369 // Change the max texture size on the output surface context. | 1397 // Change the max texture size on the output surface context. |
1370 scoped_ptr<TestWebGraphicsContext3D> context = | 1398 scoped_ptr<TestWebGraphicsContext3D> context = |
1371 TestWebGraphicsContext3D::Create(); | 1399 TestWebGraphicsContext3D::Create(); |
1372 context->set_max_texture_size(140); | 1400 context->set_max_texture_size(140); |
1373 host_impl_.DidLoseOutputSurface(); | 1401 host_impl_.DidLoseOutputSurface(); |
1374 host_impl_.InitializeRenderer( | 1402 host_impl_.InitializeRenderer( |
1375 FakeOutputSurface::Create3d(context.Pass()).Pass()); | 1403 FakeOutputSurface::Create3d(context.Pass()).Pass()); |
1376 | 1404 |
1377 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); | 1405 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
(...skipping 11 matching lines...) Expand all Loading... |
1389 // The default max tile size is larger than 400x400. | 1417 // The default max tile size is larger than 400x400. |
1390 gfx::Size tile_size(400, 400); | 1418 gfx::Size tile_size(400, 400); |
1391 gfx::Size layer_bounds(500, 500); | 1419 gfx::Size layer_bounds(500, 500); |
1392 | 1420 |
1393 scoped_refptr<FakePicturePileImpl> pending_pile = | 1421 scoped_refptr<FakePicturePileImpl> pending_pile = |
1394 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1422 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1395 scoped_refptr<FakePicturePileImpl> active_pile = | 1423 scoped_refptr<FakePicturePileImpl> active_pile = |
1396 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1424 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1397 | 1425 |
1398 SetupTrees(pending_pile, active_pile); | 1426 SetupTrees(pending_pile, active_pile); |
1399 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 1427 EXPECT_GE(pending_layer_->tilings()->num_tilings(), 1u); |
1400 | |
1401 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); | |
1402 ASSERT_LE(1u, pending_layer_->tilings()->num_tilings()); | |
1403 | 1428 |
1404 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 1429 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
1405 | 1430 |
1406 // The default value. The layer is smaller than this. | 1431 // The default value. The layer is smaller than this. |
1407 EXPECT_EQ(gfx::Size(512, 512).ToString(), | 1432 EXPECT_EQ(gfx::Size(512, 512).ToString(), |
1408 host_impl_.settings().max_untiled_layer_size.ToString()); | 1433 host_impl_.settings().max_untiled_layer_size.ToString()); |
1409 | 1434 |
1410 // There should be a single tile since the layer is small. | 1435 // There should be a single tile since the layer is small. |
1411 PictureLayerTiling* high_res_tiling = pending_layer_->tilings()->tiling_at(0); | 1436 PictureLayerTiling* high_res_tiling = pending_layer_->tilings()->tiling_at(0); |
1412 EXPECT_EQ(1u, high_res_tiling->AllTilesForTesting().size()); | 1437 EXPECT_EQ(1u, high_res_tiling->AllTilesForTesting().size()); |
1413 | 1438 |
1414 pending_layer_->ReleaseResources(); | 1439 ResetTilingsAndRasterScales(); |
1415 | 1440 |
1416 // Change the max texture size on the output surface context. | 1441 // Change the max texture size on the output surface context. |
1417 scoped_ptr<TestWebGraphicsContext3D> context = | 1442 scoped_ptr<TestWebGraphicsContext3D> context = |
1418 TestWebGraphicsContext3D::Create(); | 1443 TestWebGraphicsContext3D::Create(); |
1419 context->set_max_texture_size(140); | 1444 context->set_max_texture_size(140); |
1420 host_impl_.DidLoseOutputSurface(); | 1445 host_impl_.DidLoseOutputSurface(); |
1421 host_impl_.InitializeRenderer( | 1446 host_impl_.InitializeRenderer( |
1422 FakeOutputSurface::Create3d(context.Pass()).Pass()); | 1447 FakeOutputSurface::Create3d(context.Pass()).Pass()); |
1423 | 1448 |
1424 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); | 1449 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
(...skipping 16 matching lines...) Expand all Loading... |
1441 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 1466 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
1442 | 1467 |
1443 gfx::Size tile_size(400, 400); | 1468 gfx::Size tile_size(400, 400); |
1444 gfx::Size layer_bounds(1300, 1900); | 1469 gfx::Size layer_bounds(1300, 1900); |
1445 | 1470 |
1446 scoped_refptr<FakePicturePileImpl> pending_pile = | 1471 scoped_refptr<FakePicturePileImpl> pending_pile = |
1447 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1472 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1448 scoped_refptr<FakePicturePileImpl> active_pile = | 1473 scoped_refptr<FakePicturePileImpl> active_pile = |
1449 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1474 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1450 | 1475 |
1451 SetupTrees(pending_pile, active_pile); | 1476 gfx::Rect layer_invalidation(150, 200, 30, 180); |
| 1477 SetupTreesWithInvalidation(pending_pile, active_pile, layer_invalidation); |
1452 | 1478 |
1453 active_layer_->draw_properties().visible_content_rect = | 1479 active_layer_->draw_properties().visible_content_rect = |
1454 gfx::Rect(layer_bounds); | 1480 gfx::Rect(layer_bounds); |
1455 | 1481 |
1456 gfx::Rect layer_invalidation(150, 200, 30, 180); | |
1457 Region invalidation(layer_invalidation); | |
1458 AddDefaultTilingsWithInvalidation(invalidation); | |
1459 | |
1460 AppendQuadsData data; | 1482 AppendQuadsData data; |
1461 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, nullptr); | 1483 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, nullptr); |
1462 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); | 1484 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); |
1463 active_layer_->DidDraw(nullptr); | 1485 active_layer_->DidDraw(nullptr); |
1464 | 1486 |
1465 ASSERT_EQ(1U, render_pass->quad_list.size()); | 1487 ASSERT_EQ(1U, render_pass->quad_list.size()); |
1466 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, | 1488 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, |
1467 render_pass->quad_list.front()->material); | 1489 render_pass->quad_list.front()->material); |
1468 } | 1490 } |
1469 | 1491 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1507 scoped_refptr<FakePicturePileImpl> pending_pile = | 1529 scoped_refptr<FakePicturePileImpl> pending_pile = |
1508 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( | 1530 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( |
1509 tile_size, layer_bounds); | 1531 tile_size, layer_bounds); |
1510 scoped_refptr<FakePicturePileImpl> active_pile = | 1532 scoped_refptr<FakePicturePileImpl> active_pile = |
1511 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( | 1533 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( |
1512 tile_size, layer_bounds); | 1534 tile_size, layer_bounds); |
1513 | 1535 |
1514 pending_pile->set_is_solid_color(false); | 1536 pending_pile->set_is_solid_color(false); |
1515 active_pile->set_is_solid_color(true); | 1537 active_pile->set_is_solid_color(true); |
1516 SetupTrees(pending_pile, active_pile); | 1538 SetupTrees(pending_pile, active_pile); |
1517 // Solid color layer should not have tilings. | 1539 // Solid color pile should not allow tilings at any scale. |
1518 ASSERT_FALSE(active_layer_->CanHaveTilings()); | |
1519 | |
1520 // Update properties with solid color pile should not allow tilings at any | |
1521 // scale. | |
1522 host_impl_.active_tree()->UpdateDrawProperties(); | |
1523 EXPECT_FALSE(active_layer_->CanHaveTilings()); | 1540 EXPECT_FALSE(active_layer_->CanHaveTilings()); |
1524 EXPECT_EQ(0.f, active_layer_->ideal_contents_scale()); | 1541 EXPECT_EQ(0.f, active_layer_->ideal_contents_scale()); |
1525 | 1542 |
1526 // Push non-solid-color pending pile makes active layer can have tilings. | 1543 // Activate non-solid-color pending pile makes active layer can have tilings. |
1527 active_layer_->UpdateRasterSource(pending_pile); | 1544 ActivateTree(); |
1528 ASSERT_TRUE(active_layer_->CanHaveTilings()); | |
1529 | |
1530 // Update properties with non-solid color pile should allow tilings. | |
1531 host_impl_.active_tree()->UpdateDrawProperties(); | |
1532 EXPECT_TRUE(active_layer_->CanHaveTilings()); | 1545 EXPECT_TRUE(active_layer_->CanHaveTilings()); |
1533 EXPECT_GT(active_layer_->ideal_contents_scale(), 0.f); | 1546 EXPECT_GT(active_layer_->ideal_contents_scale(), 0.f); |
1534 } | 1547 } |
1535 | 1548 |
1536 TEST_F(PictureLayerImplTest, MarkRequiredOffscreenTiles) { | 1549 TEST_F(NoLowResPictureLayerImplTest, MarkRequiredOffscreenTiles) { |
1537 gfx::Size tile_size(100, 100); | 1550 gfx::Size tile_size(100, 100); |
1538 gfx::Size layer_bounds(200, 200); | 1551 gfx::Size layer_bounds(200, 200); |
1539 | 1552 |
1540 scoped_refptr<FakePicturePileImpl> pending_pile = | |
1541 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | |
1542 SetupPendingTree(pending_pile); | |
1543 | |
1544 gfx::Transform transform; | 1553 gfx::Transform transform; |
1545 gfx::Transform transform_for_tile_priority; | 1554 gfx::Transform transform_for_tile_priority; |
1546 bool resourceless_software_draw = false; | 1555 bool resourceless_software_draw = false; |
1547 gfx::Rect viewport(0, 0, 100, 200); | 1556 gfx::Rect viewport(0, 0, 100, 200); |
1548 host_impl_.SetExternalDrawConstraints(transform, | 1557 host_impl_.SetExternalDrawConstraints(transform, |
1549 viewport, | 1558 viewport, |
1550 viewport, | 1559 viewport, |
1551 viewport, | 1560 viewport, |
1552 transform, | 1561 transform, |
1553 resourceless_software_draw); | 1562 resourceless_software_draw); |
1554 | 1563 |
1555 pending_layer_->set_fixed_tile_size(tile_size); | 1564 scoped_refptr<FakePicturePileImpl> pending_pile = |
1556 ASSERT_TRUE(pending_layer_->CanHaveTilings()); | 1565 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1557 PictureLayerTiling* tiling = pending_layer_->AddTiling(1.f); | 1566 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); |
1558 host_impl_.pending_tree()->UpdateDrawProperties(); | 1567 |
| 1568 EXPECT_EQ(1u, pending_layer_->num_tilings()); |
1559 EXPECT_EQ(viewport, pending_layer_->visible_rect_for_tile_priority()); | 1569 EXPECT_EQ(viewport, pending_layer_->visible_rect_for_tile_priority()); |
1560 | 1570 |
1561 base::TimeTicks time_ticks; | 1571 base::TimeTicks time_ticks; |
1562 time_ticks += base::TimeDelta::FromMilliseconds(1); | 1572 time_ticks += base::TimeDelta::FromMilliseconds(1); |
1563 host_impl_.SetCurrentBeginFrameArgs( | 1573 host_impl_.SetCurrentBeginFrameArgs( |
1564 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 1574 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
1565 pending_layer_->UpdateTiles(Occlusion(), resourceless_software_draw); | 1575 pending_layer_->UpdateTiles(Occlusion(), resourceless_software_draw); |
1566 EXPECT_EQ(HIGH_RESOLUTION, tiling->resolution()); | |
1567 | 1576 |
1568 int num_visible = 0; | 1577 int num_visible = 0; |
1569 int num_offscreen = 0; | 1578 int num_offscreen = 0; |
1570 | 1579 |
1571 for (PictureLayerTiling::TilingRasterTileIterator iter(tiling); iter; | 1580 for (PictureLayerTiling::TilingRasterTileIterator iter( |
1572 ++iter) { | 1581 pending_layer_->HighResTiling()); |
| 1582 iter; ++iter) { |
1573 const Tile* tile = *iter; | 1583 const Tile* tile = *iter; |
1574 DCHECK(tile); | 1584 DCHECK(tile); |
1575 if (tile->priority(PENDING_TREE).distance_to_visible == 0.f) { | 1585 if (tile->priority(PENDING_TREE).distance_to_visible == 0.f) { |
1576 EXPECT_TRUE(tile->required_for_activation()); | 1586 EXPECT_TRUE(tile->required_for_activation()); |
1577 num_visible++; | 1587 num_visible++; |
1578 } else { | 1588 } else { |
1579 EXPECT_FALSE(tile->required_for_activation()); | 1589 EXPECT_FALSE(tile->required_for_activation()); |
1580 num_offscreen++; | 1590 num_offscreen++; |
1581 } | 1591 } |
1582 } | 1592 } |
1583 | 1593 |
1584 EXPECT_GT(num_visible, 0); | 1594 EXPECT_GT(num_visible, 0); |
1585 EXPECT_GT(num_offscreen, 0); | 1595 EXPECT_GT(num_offscreen, 0); |
1586 } | 1596 } |
1587 | 1597 |
1588 TEST_F(PictureLayerImplTest, TileOutsideOfViewportForTilePriorityNotRequired) { | 1598 TEST_F(NoLowResPictureLayerImplTest, |
| 1599 TileOutsideOfViewportForTilePriorityNotRequired) { |
1589 base::TimeTicks time_ticks; | 1600 base::TimeTicks time_ticks; |
1590 time_ticks += base::TimeDelta::FromMilliseconds(1); | 1601 time_ticks += base::TimeDelta::FromMilliseconds(1); |
1591 host_impl_.SetCurrentBeginFrameArgs( | 1602 host_impl_.SetCurrentBeginFrameArgs( |
1592 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 1603 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
1593 | 1604 |
1594 gfx::Size tile_size(100, 100); | 1605 gfx::Size tile_size(100, 100); |
1595 gfx::Size layer_bounds(400, 400); | 1606 gfx::Size layer_bounds(400, 400); |
1596 gfx::Rect external_viewport_for_tile_priority(400, 200); | 1607 gfx::Rect external_viewport_for_tile_priority(400, 200); |
1597 gfx::Rect visible_content_rect(200, 400); | 1608 gfx::Rect visible_content_rect(200, 400); |
1598 | 1609 |
1599 scoped_refptr<FakePicturePileImpl> active_pile = | 1610 scoped_refptr<FakePicturePileImpl> active_pile = |
1600 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1611 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1601 scoped_refptr<FakePicturePileImpl> pending_pile = | 1612 scoped_refptr<FakePicturePileImpl> pending_pile = |
1602 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1613 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1603 SetupTrees(pending_pile, active_pile); | 1614 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); |
1604 | 1615 |
1605 active_layer_->set_fixed_tile_size(tile_size); | 1616 ASSERT_EQ(1u, pending_layer_->num_tilings()); |
1606 pending_layer_->set_fixed_tile_size(tile_size); | 1617 ASSERT_EQ(1.f, pending_layer_->HighResTiling()->contents_scale()); |
1607 ASSERT_TRUE(pending_layer_->CanHaveTilings()); | |
1608 PictureLayerTiling* tiling = pending_layer_->AddTiling(1.f); | |
1609 | 1618 |
1610 // Set external viewport for tile priority. | 1619 // Set external viewport for tile priority. |
1611 gfx::Rect viewport = gfx::Rect(layer_bounds); | 1620 gfx::Rect viewport = gfx::Rect(layer_bounds); |
1612 gfx::Transform transform; | 1621 gfx::Transform transform; |
1613 gfx::Transform transform_for_tile_priority; | 1622 gfx::Transform transform_for_tile_priority; |
1614 bool resourceless_software_draw = false; | 1623 bool resourceless_software_draw = false; |
1615 host_impl_.SetExternalDrawConstraints(transform, | 1624 host_impl_.SetExternalDrawConstraints(transform, |
1616 viewport, | 1625 viewport, |
1617 viewport, | 1626 viewport, |
1618 external_viewport_for_tile_priority, | 1627 external_viewport_for_tile_priority, |
1619 transform_for_tile_priority, | 1628 transform_for_tile_priority, |
1620 resourceless_software_draw); | 1629 resourceless_software_draw); |
| 1630 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 1631 host_impl_.SetCurrentBeginFrameArgs( |
| 1632 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
1621 host_impl_.pending_tree()->UpdateDrawProperties(); | 1633 host_impl_.pending_tree()->UpdateDrawProperties(); |
1622 | 1634 |
1623 // Set visible content rect that is different from | 1635 // Set visible content rect that is different from |
1624 // external_viewport_for_tile_priority. | 1636 // external_viewport_for_tile_priority. |
1625 pending_layer_->draw_properties().visible_content_rect = visible_content_rect; | 1637 pending_layer_->draw_properties().visible_content_rect = visible_content_rect; |
1626 time_ticks += base::TimeDelta::FromMilliseconds(200); | 1638 time_ticks += base::TimeDelta::FromMilliseconds(200); |
1627 host_impl_.SetCurrentBeginFrameArgs( | 1639 host_impl_.SetCurrentBeginFrameArgs( |
1628 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 1640 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
1629 pending_layer_->UpdateTiles(Occlusion(), resourceless_software_draw); | 1641 pending_layer_->UpdateTiles(Occlusion(), resourceless_software_draw); |
1630 | 1642 |
1631 // Intersect the two rects. Any tile outside should not be required for | 1643 // Intersect the two rects. Any tile outside should not be required for |
1632 // activation. | 1644 // activation. |
1633 gfx::Rect viewport_for_tile_priority = | 1645 gfx::Rect viewport_for_tile_priority = |
1634 pending_layer_->GetViewportForTilePriorityInContentSpace(); | 1646 pending_layer_->GetViewportForTilePriorityInContentSpace(); |
1635 viewport_for_tile_priority.Intersect(pending_layer_->visible_content_rect()); | 1647 viewport_for_tile_priority.Intersect(pending_layer_->visible_content_rect()); |
1636 | 1648 |
1637 int num_inside = 0; | 1649 int num_inside = 0; |
1638 int num_outside = 0; | 1650 int num_outside = 0; |
1639 for (PictureLayerTiling::CoverageIterator iter( | 1651 for (PictureLayerTiling::CoverageIterator iter( |
1640 tiling, pending_layer_->contents_scale_x(), gfx::Rect(layer_bounds)); | 1652 pending_layer_->HighResTiling(), 1.f, gfx::Rect(layer_bounds)); |
1641 iter; | 1653 iter; ++iter) { |
1642 ++iter) { | |
1643 if (!*iter) | 1654 if (!*iter) |
1644 continue; | 1655 continue; |
1645 Tile* tile = *iter; | 1656 Tile* tile = *iter; |
1646 if (viewport_for_tile_priority.Intersects(iter.geometry_rect())) { | 1657 if (viewport_for_tile_priority.Intersects(iter.geometry_rect())) { |
1647 num_inside++; | 1658 num_inside++; |
1648 // Mark everything in viewport for tile priority as ready to draw. | 1659 // Mark everything in viewport for tile priority as ready to draw. |
1649 ManagedTileState::DrawInfo& draw_info = tile->draw_info(); | 1660 ManagedTileState::DrawInfo& draw_info = tile->draw_info(); |
1650 draw_info.SetSolidColorForTesting(SK_ColorRED); | 1661 draw_info.SetSolidColorForTesting(SK_ColorRED); |
1651 } else { | 1662 } else { |
1652 num_outside++; | 1663 num_outside++; |
(...skipping 23 matching lines...) Expand all Loading... |
1676 | 1687 |
1677 TEST_F(PictureLayerImplTest, HighResTileIsComplete) { | 1688 TEST_F(PictureLayerImplTest, HighResTileIsComplete) { |
1678 base::TimeTicks time_ticks; | 1689 base::TimeTicks time_ticks; |
1679 time_ticks += base::TimeDelta::FromMilliseconds(1); | 1690 time_ticks += base::TimeDelta::FromMilliseconds(1); |
1680 host_impl_.SetCurrentBeginFrameArgs( | 1691 host_impl_.SetCurrentBeginFrameArgs( |
1681 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 1692 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
1682 | 1693 |
1683 gfx::Size tile_size(100, 100); | 1694 gfx::Size tile_size(100, 100); |
1684 gfx::Size layer_bounds(200, 200); | 1695 gfx::Size layer_bounds(200, 200); |
1685 | 1696 |
1686 host_impl_.SetViewportSize(layer_bounds); | |
1687 | |
1688 scoped_refptr<FakePicturePileImpl> pending_pile = | 1697 scoped_refptr<FakePicturePileImpl> pending_pile = |
1689 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1698 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1690 SetupPendingTree(pending_pile); | 1699 |
| 1700 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); |
1691 ActivateTree(); | 1701 ActivateTree(); |
1692 | 1702 |
1693 // All high res tiles have resources. | 1703 // All high res tiles have resources. |
1694 active_layer_->set_fixed_tile_size(tile_size); | |
1695 host_impl_.active_tree()->UpdateDrawProperties(); | |
1696 std::vector<Tile*> tiles = | 1704 std::vector<Tile*> tiles = |
1697 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); | 1705 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); |
1698 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); | 1706 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); |
1699 | 1707 |
1700 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 1708 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
1701 AppendQuadsData data; | 1709 AppendQuadsData data; |
1702 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); | 1710 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); |
1703 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); | 1711 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); |
1704 active_layer_->DidDraw(nullptr); | 1712 active_layer_->DidDraw(nullptr); |
1705 | 1713 |
1706 // All high res tiles drew, nothing was incomplete. | 1714 // All high res tiles drew, nothing was incomplete. |
1707 EXPECT_EQ(9u, render_pass->quad_list.size()); | 1715 EXPECT_EQ(9u, render_pass->quad_list.size()); |
1708 EXPECT_EQ(0u, data.num_missing_tiles); | 1716 EXPECT_EQ(0u, data.num_missing_tiles); |
1709 EXPECT_EQ(0u, data.num_incomplete_tiles); | 1717 EXPECT_EQ(0u, data.num_incomplete_tiles); |
1710 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); | 1718 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); |
1711 } | 1719 } |
1712 | 1720 |
1713 TEST_F(PictureLayerImplTest, HighResTileIsIncomplete) { | 1721 TEST_F(PictureLayerImplTest, HighResTileIsIncomplete) { |
1714 base::TimeTicks time_ticks; | 1722 base::TimeTicks time_ticks; |
1715 time_ticks += base::TimeDelta::FromMilliseconds(1); | 1723 time_ticks += base::TimeDelta::FromMilliseconds(1); |
1716 host_impl_.SetCurrentBeginFrameArgs( | 1724 host_impl_.SetCurrentBeginFrameArgs( |
1717 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 1725 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
1718 | 1726 |
1719 gfx::Size tile_size(100, 100); | 1727 gfx::Size tile_size(100, 100); |
1720 gfx::Size layer_bounds(200, 200); | 1728 gfx::Size layer_bounds(200, 200); |
1721 | 1729 |
1722 host_impl_.SetViewportSize(layer_bounds); | |
1723 | |
1724 scoped_refptr<FakePicturePileImpl> pending_pile = | 1730 scoped_refptr<FakePicturePileImpl> pending_pile = |
1725 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1731 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1726 SetupPendingTree(pending_pile); | 1732 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); |
1727 ActivateTree(); | 1733 ActivateTree(); |
1728 | 1734 |
1729 active_layer_->set_fixed_tile_size(tile_size); | |
1730 host_impl_.active_tree()->UpdateDrawProperties(); | |
1731 | |
1732 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 1735 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
1733 AppendQuadsData data; | 1736 AppendQuadsData data; |
1734 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); | 1737 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); |
1735 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); | 1738 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); |
1736 active_layer_->DidDraw(nullptr); | 1739 active_layer_->DidDraw(nullptr); |
1737 | 1740 |
1738 EXPECT_EQ(1u, render_pass->quad_list.size()); | 1741 EXPECT_EQ(1u, render_pass->quad_list.size()); |
1739 EXPECT_EQ(1u, data.num_missing_tiles); | 1742 EXPECT_EQ(1u, data.num_missing_tiles); |
1740 EXPECT_EQ(0u, data.num_incomplete_tiles); | 1743 EXPECT_EQ(0u, data.num_incomplete_tiles); |
1741 EXPECT_TRUE(active_layer_->only_used_low_res_last_append_quads()); | 1744 EXPECT_TRUE(active_layer_->only_used_low_res_last_append_quads()); |
1742 } | 1745 } |
1743 | 1746 |
1744 TEST_F(PictureLayerImplTest, HighResTileIsIncompleteLowResComplete) { | 1747 TEST_F(PictureLayerImplTest, HighResTileIsIncompleteLowResComplete) { |
1745 base::TimeTicks time_ticks; | 1748 base::TimeTicks time_ticks; |
1746 time_ticks += base::TimeDelta::FromMilliseconds(1); | 1749 time_ticks += base::TimeDelta::FromMilliseconds(1); |
1747 host_impl_.SetCurrentBeginFrameArgs( | 1750 host_impl_.SetCurrentBeginFrameArgs( |
1748 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 1751 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
1749 | 1752 |
1750 gfx::Size tile_size(100, 100); | 1753 gfx::Size tile_size(100, 100); |
1751 gfx::Size layer_bounds(200, 200); | 1754 gfx::Size layer_bounds(200, 200); |
1752 | 1755 |
1753 host_impl_.SetViewportSize(layer_bounds); | |
1754 | |
1755 scoped_refptr<FakePicturePileImpl> pending_pile = | 1756 scoped_refptr<FakePicturePileImpl> pending_pile = |
1756 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1757 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1757 SetupPendingTree(pending_pile); | 1758 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); |
1758 ActivateTree(); | 1759 ActivateTree(); |
1759 | 1760 |
1760 active_layer_->set_fixed_tile_size(tile_size); | |
1761 host_impl_.active_tree()->UpdateDrawProperties(); | |
1762 std::vector<Tile*> low_tiles = | 1761 std::vector<Tile*> low_tiles = |
1763 active_layer_->tilings()->tiling_at(1)->AllTilesForTesting(); | 1762 active_layer_->tilings()->tiling_at(1)->AllTilesForTesting(); |
1764 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(low_tiles); | 1763 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(low_tiles); |
1765 | 1764 |
1766 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 1765 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
1767 AppendQuadsData data; | 1766 AppendQuadsData data; |
1768 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); | 1767 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); |
1769 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); | 1768 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); |
1770 active_layer_->DidDraw(nullptr); | 1769 active_layer_->DidDraw(nullptr); |
1771 | 1770 |
1772 EXPECT_EQ(1u, render_pass->quad_list.size()); | 1771 EXPECT_EQ(1u, render_pass->quad_list.size()); |
1773 EXPECT_EQ(0u, data.num_missing_tiles); | 1772 EXPECT_EQ(0u, data.num_missing_tiles); |
1774 EXPECT_EQ(1u, data.num_incomplete_tiles); | 1773 EXPECT_EQ(1u, data.num_incomplete_tiles); |
1775 EXPECT_TRUE(active_layer_->only_used_low_res_last_append_quads()); | 1774 EXPECT_TRUE(active_layer_->only_used_low_res_last_append_quads()); |
1776 } | 1775 } |
1777 | 1776 |
1778 TEST_F(PictureLayerImplTest, LowResTileIsIncomplete) { | 1777 TEST_F(PictureLayerImplTest, LowResTileIsIncomplete) { |
1779 base::TimeTicks time_ticks; | 1778 base::TimeTicks time_ticks; |
1780 time_ticks += base::TimeDelta::FromMilliseconds(1); | 1779 time_ticks += base::TimeDelta::FromMilliseconds(1); |
1781 host_impl_.SetCurrentBeginFrameArgs( | 1780 host_impl_.SetCurrentBeginFrameArgs( |
1782 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 1781 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
1783 | 1782 |
1784 gfx::Size tile_size(100, 100); | 1783 gfx::Size tile_size(100, 100); |
1785 gfx::Size layer_bounds(200, 200); | 1784 gfx::Size layer_bounds(200, 200); |
1786 | 1785 |
1787 host_impl_.SetViewportSize(layer_bounds); | |
1788 | |
1789 scoped_refptr<FakePicturePileImpl> pending_pile = | 1786 scoped_refptr<FakePicturePileImpl> pending_pile = |
1790 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1787 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1791 SetupPendingTree(pending_pile); | 1788 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); |
1792 ActivateTree(); | 1789 ActivateTree(); |
1793 | 1790 |
1794 // All high res tiles have resources except one. | 1791 // All high res tiles have resources except one. |
1795 active_layer_->set_fixed_tile_size(tile_size); | |
1796 host_impl_.active_tree()->UpdateDrawProperties(); | |
1797 std::vector<Tile*> high_tiles = | 1792 std::vector<Tile*> high_tiles = |
1798 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); | 1793 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); |
1799 high_tiles.erase(high_tiles.begin()); | 1794 high_tiles.erase(high_tiles.begin()); |
1800 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(high_tiles); | 1795 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(high_tiles); |
1801 | 1796 |
1802 // All low res tiles have resources. | 1797 // All low res tiles have resources. |
1803 std::vector<Tile*> low_tiles = | 1798 std::vector<Tile*> low_tiles = |
1804 active_layer_->tilings()->tiling_at(1)->AllTilesForTesting(); | 1799 active_layer_->tilings()->tiling_at(1)->AllTilesForTesting(); |
1805 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(low_tiles); | 1800 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(low_tiles); |
1806 | 1801 |
(...skipping 12 matching lines...) Expand all Loading... |
1819 | 1814 |
1820 TEST_F(PictureLayerImplTest, | 1815 TEST_F(PictureLayerImplTest, |
1821 HighResAndIdealResTileIsCompleteWhenRasterScaleIsNotIdeal) { | 1816 HighResAndIdealResTileIsCompleteWhenRasterScaleIsNotIdeal) { |
1822 base::TimeTicks time_ticks; | 1817 base::TimeTicks time_ticks; |
1823 time_ticks += base::TimeDelta::FromMilliseconds(1); | 1818 time_ticks += base::TimeDelta::FromMilliseconds(1); |
1824 host_impl_.SetCurrentBeginFrameArgs( | 1819 host_impl_.SetCurrentBeginFrameArgs( |
1825 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 1820 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
1826 | 1821 |
1827 gfx::Size tile_size(100, 100); | 1822 gfx::Size tile_size(100, 100); |
1828 gfx::Size layer_bounds(200, 200); | 1823 gfx::Size layer_bounds(200, 200); |
| 1824 gfx::Size viewport_size(400, 400); |
1829 | 1825 |
1830 host_impl_.SetViewportSize(layer_bounds); | 1826 host_impl_.SetViewportSize(viewport_size); |
| 1827 host_impl_.SetDeviceScaleFactor(2.f); |
1831 | 1828 |
1832 scoped_refptr<FakePicturePileImpl> pending_pile = | 1829 scoped_refptr<FakePicturePileImpl> pending_pile = |
1833 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1830 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1834 scoped_refptr<FakePicturePileImpl> active_pile = | 1831 scoped_refptr<FakePicturePileImpl> active_pile = |
1835 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1832 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1836 SetupTrees(pending_pile, active_pile); | 1833 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); |
1837 | |
1838 active_layer_->set_fixed_tile_size(tile_size); | |
1839 | |
1840 active_layer_->draw_properties().visible_content_rect = | |
1841 gfx::Rect(layer_bounds); | |
1842 SetupDrawPropertiesAndUpdateTiles(active_layer_, 2.f, 1.f, 1.f, 1.f, false); | |
1843 | 1834 |
1844 // One ideal tile exists, this will get used when drawing. | 1835 // One ideal tile exists, this will get used when drawing. |
1845 std::vector<Tile*> ideal_tiles; | 1836 std::vector<Tile*> ideal_tiles; |
1846 EXPECT_EQ(2.f, active_layer_->HighResTiling()->contents_scale()); | 1837 EXPECT_EQ(2.f, active_layer_->HighResTiling()->contents_scale()); |
1847 ideal_tiles.push_back(active_layer_->HighResTiling()->TileAt(0, 0)); | 1838 ideal_tiles.push_back(active_layer_->HighResTiling()->TileAt(0, 0)); |
1848 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( | 1839 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( |
1849 ideal_tiles); | 1840 ideal_tiles); |
1850 | 1841 |
1851 // Due to layer scale throttling, the raster contents scale is changed to 1, | 1842 // Due to layer scale throttling, the raster contents scale is changed to 1, |
1852 // while the ideal is still 2. | 1843 // while the ideal is still 2. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1884 // Neither the high res nor the ideal tiles were considered as incomplete. | 1875 // Neither the high res nor the ideal tiles were considered as incomplete. |
1885 EXPECT_EQ(0u, data.num_missing_tiles); | 1876 EXPECT_EQ(0u, data.num_missing_tiles); |
1886 EXPECT_EQ(0u, data.num_incomplete_tiles); | 1877 EXPECT_EQ(0u, data.num_incomplete_tiles); |
1887 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); | 1878 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); |
1888 } | 1879 } |
1889 | 1880 |
1890 TEST_F(PictureLayerImplTest, HighResRequiredWhenUnsharedActiveAllReady) { | 1881 TEST_F(PictureLayerImplTest, HighResRequiredWhenUnsharedActiveAllReady) { |
1891 gfx::Size layer_bounds(400, 400); | 1882 gfx::Size layer_bounds(400, 400); |
1892 gfx::Size tile_size(100, 100); | 1883 gfx::Size tile_size(100, 100); |
1893 | 1884 |
1894 host_impl_.SetViewportSize(layer_bounds); | |
1895 | |
1896 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | |
1897 | |
1898 // No tiles shared. | 1885 // No tiles shared. |
1899 pending_layer_->set_invalidation(gfx::Rect(layer_bounds)); | 1886 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, |
1900 | 1887 gfx::Rect(layer_bounds)); |
1901 CreateHighLowResAndSetAllTilesVisible(); | |
1902 | 1888 |
1903 active_layer_->SetAllTilesReady(); | 1889 active_layer_->SetAllTilesReady(); |
1904 | 1890 |
1905 // No shared tiles and all active tiles ready, so pending can only | 1891 // No shared tiles and all active tiles ready, so pending can only |
1906 // activate with all high res tiles. | 1892 // activate with all high res tiles. |
1907 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 1893 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
1908 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 1894 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
1909 | 1895 |
1910 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 1896 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
1911 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 1897 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
1912 } | 1898 } |
1913 | 1899 |
1914 TEST_F(PictureLayerImplTest, HighResRequiredWhenMissingHighResFlagOn) { | 1900 TEST_F(PictureLayerImplTest, HighResRequiredWhenMissingHighResFlagOn) { |
1915 gfx::Size layer_bounds(400, 400); | 1901 gfx::Size layer_bounds(400, 400); |
1916 gfx::Size tile_size(100, 100); | 1902 gfx::Size tile_size(100, 100); |
1917 | 1903 |
1918 host_impl_.SetViewportSize(layer_bounds); | |
1919 | |
1920 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | |
1921 | |
1922 // All tiles shared (no invalidation). | 1904 // All tiles shared (no invalidation). |
1923 CreateHighLowResAndSetAllTilesVisible(); | 1905 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
1924 | 1906 |
1925 // Verify active tree not ready. | 1907 // Verify active tree not ready. |
1926 Tile* some_active_tile = | 1908 Tile* some_active_tile = |
1927 active_layer_->HighResTiling()->AllTilesForTesting()[0]; | 1909 active_layer_->HighResTiling()->AllTilesForTesting()[0]; |
1928 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); | 1910 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); |
1929 | 1911 |
1930 // When high res are required, even if the active tree is not ready, | 1912 // When high res are required, even if the active tree is not ready, |
1931 // the high res tiles must be ready. | 1913 // the high res tiles must be ready. |
1932 host_impl_.SetRequiresHighResToDraw(); | 1914 host_impl_.SetRequiresHighResToDraw(); |
1933 | 1915 |
1934 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 1916 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
1935 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 1917 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
1936 | 1918 |
1937 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 1919 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
1938 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 1920 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
1939 } | 1921 } |
1940 | 1922 |
1941 TEST_F(PictureLayerImplTest, AllHighResRequiredEvenIfShared) { | 1923 TEST_F(PictureLayerImplTest, AllHighResRequiredEvenIfShared) { |
1942 gfx::Size layer_bounds(400, 400); | 1924 gfx::Size layer_bounds(400, 400); |
1943 gfx::Size tile_size(100, 100); | 1925 gfx::Size tile_size(100, 100); |
1944 | 1926 |
1945 host_impl_.SetViewportSize(layer_bounds); | 1927 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
1946 | |
1947 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | |
1948 | |
1949 CreateHighLowResAndSetAllTilesVisible(); | |
1950 | 1928 |
1951 Tile* some_active_tile = | 1929 Tile* some_active_tile = |
1952 active_layer_->HighResTiling()->AllTilesForTesting()[0]; | 1930 active_layer_->HighResTiling()->AllTilesForTesting()[0]; |
1953 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); | 1931 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); |
1954 | 1932 |
1955 // All tiles shared (no invalidation), so even though the active tree's | 1933 // All tiles shared (no invalidation), so even though the active tree's |
1956 // tiles aren't ready, the high res tiles are required for activation. | 1934 // tiles aren't ready, the high res tiles are required for activation. |
1957 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 1935 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
1958 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 1936 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
1959 | 1937 |
1960 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 1938 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
1961 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 1939 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
1962 } | 1940 } |
1963 | 1941 |
1964 TEST_F(PictureLayerImplTest, DisallowRequiredForActivation) { | 1942 TEST_F(PictureLayerImplTest, DisallowRequiredForActivation) { |
1965 gfx::Size layer_bounds(400, 400); | 1943 gfx::Size layer_bounds(400, 400); |
1966 gfx::Size tile_size(100, 100); | 1944 gfx::Size tile_size(100, 100); |
1967 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | |
1968 | 1945 |
1969 CreateHighLowResAndSetAllTilesVisible(); | 1946 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
1970 | 1947 |
1971 Tile* some_active_tile = | 1948 Tile* some_active_tile = |
1972 active_layer_->HighResTiling()->AllTilesForTesting()[0]; | 1949 active_layer_->HighResTiling()->AllTilesForTesting()[0]; |
1973 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); | 1950 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); |
1974 | 1951 |
1975 pending_layer_->HighResTiling()->set_can_require_tiles_for_activation(false); | 1952 pending_layer_->HighResTiling()->set_can_require_tiles_for_activation(false); |
1976 pending_layer_->LowResTiling()->set_can_require_tiles_for_activation(false); | 1953 pending_layer_->LowResTiling()->set_can_require_tiles_for_activation(false); |
1977 | 1954 |
1978 // If we disallow required for activation, no tiles can be required. | 1955 // If we disallow required for activation, no tiles can be required. |
1979 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 1956 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
1980 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 1957 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
1981 | 1958 |
1982 AssertNoTilesRequired(pending_layer_->HighResTiling()); | 1959 AssertNoTilesRequired(pending_layer_->HighResTiling()); |
1983 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 1960 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
1984 } | 1961 } |
1985 | 1962 |
1986 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { | 1963 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { |
1987 gfx::Size layer_bounds(400, 400); | 1964 gfx::Size layer_bounds(400, 400); |
1988 gfx::Size tile_size(100, 100); | 1965 gfx::Size tile_size(100, 100); |
| 1966 |
1989 scoped_refptr<FakePicturePileImpl> pending_pile = | 1967 scoped_refptr<FakePicturePileImpl> pending_pile = |
1990 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1968 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
1991 // This pile will create tilings, but has no recordings so will not create any | 1969 // This pile will create tilings, but has no recordings so will not create any |
1992 // tiles. This is attempting to simulate scrolling past the end of recorded | 1970 // tiles. This is attempting to simulate scrolling past the end of recorded |
1993 // content on the active layer, where the recordings are so far away that | 1971 // content on the active layer, where the recordings are so far away that |
1994 // no tiles are created. | 1972 // no tiles are created. |
1995 scoped_refptr<FakePicturePileImpl> active_pile = | 1973 scoped_refptr<FakePicturePileImpl> active_pile = |
1996 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( | 1974 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( |
1997 tile_size, layer_bounds); | 1975 tile_size, layer_bounds); |
1998 SetupTrees(pending_pile, active_pile); | |
1999 pending_layer_->set_fixed_tile_size(tile_size); | |
2000 active_layer_->set_fixed_tile_size(tile_size); | |
2001 | 1976 |
2002 CreateHighLowResAndSetAllTilesVisible(); | 1977 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); |
2003 | 1978 |
2004 // Active layer has tilings, but no tiles due to missing recordings. | 1979 // Active layer has tilings, but no tiles due to missing recordings. |
2005 EXPECT_TRUE(active_layer_->CanHaveTilings()); | 1980 EXPECT_TRUE(active_layer_->CanHaveTilings()); |
2006 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u); | 1981 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u); |
2007 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); | 1982 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); |
2008 | 1983 |
2009 // Since the active layer has no tiles at all, the pending layer doesn't | 1984 // Since the active layer has no tiles at all, the pending layer doesn't |
2010 // need content in order to activate. | 1985 // need content in order to activate. |
2011 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 1986 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
2012 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 1987 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
2013 | 1988 |
2014 AssertNoTilesRequired(pending_layer_->HighResTiling()); | 1989 AssertNoTilesRequired(pending_layer_->HighResTiling()); |
2015 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 1990 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
2016 } | 1991 } |
2017 | 1992 |
2018 TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) { | 1993 TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) { |
2019 gfx::Size layer_bounds(400, 400); | 1994 gfx::Size layer_bounds(400, 400); |
2020 gfx::Size tile_size(100, 100); | 1995 gfx::Size tile_size(100, 100); |
2021 | 1996 |
2022 host_impl_.SetViewportSize(layer_bounds); | |
2023 | |
2024 scoped_refptr<FakePicturePileImpl> pending_pile = | 1997 scoped_refptr<FakePicturePileImpl> pending_pile = |
2025 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1998 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
2026 scoped_refptr<FakePicturePileImpl> active_pile = | 1999 scoped_refptr<FakePicturePileImpl> active_pile = |
2027 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | 2000 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); |
2028 SetupTrees(pending_pile, active_pile); | 2001 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); |
2029 pending_layer_->set_fixed_tile_size(tile_size); | |
2030 active_layer_->set_fixed_tile_size(tile_size); | |
2031 | |
2032 CreateHighLowResAndSetAllTilesVisible(); | |
2033 | 2002 |
2034 // Active layer can't have tiles. | 2003 // Active layer can't have tiles. |
2035 EXPECT_FALSE(active_layer_->CanHaveTilings()); | 2004 EXPECT_FALSE(active_layer_->CanHaveTilings()); |
2036 | 2005 |
2037 // All high res tiles required. This should be considered identical | 2006 // All high res tiles required. This should be considered identical |
2038 // to the case where there is no active layer, to avoid flashing content. | 2007 // to the case where there is no active layer, to avoid flashing content. |
2039 // This can happen if a layer exists for a while and switches from | 2008 // This can happen if a layer exists for a while and switches from |
2040 // not being able to have content to having content. | 2009 // not being able to have content to having content. |
2041 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 2010 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
2042 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 2011 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
2043 | 2012 |
2044 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 2013 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
2045 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 2014 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
2046 } | 2015 } |
2047 | 2016 |
2048 TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveHasDifferentBounds) { | 2017 TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveHasDifferentBounds) { |
2049 gfx::Size layer_bounds(200, 200); | 2018 gfx::Size pending_layer_bounds(400, 400); |
| 2019 gfx::Size active_layer_bounds(200, 200); |
2050 gfx::Size tile_size(100, 100); | 2020 gfx::Size tile_size(100, 100); |
2051 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | |
2052 | 2021 |
2053 gfx::Size pending_layer_bounds(400, 400); | 2022 scoped_refptr<FakePicturePileImpl> pending_pile = |
2054 pending_layer_->SetBounds(pending_layer_bounds); | 2023 FakePicturePileImpl::CreateFilledPile(tile_size, pending_layer_bounds); |
| 2024 scoped_refptr<FakePicturePileImpl> active_pile = |
| 2025 FakePicturePileImpl::CreateFilledPile(tile_size, active_layer_bounds); |
2055 | 2026 |
2056 CreateHighLowResAndSetAllTilesVisible(); | 2027 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); |
2057 // TODO(vmpstr): This is confusing. Rework the test to create different bounds | |
2058 // on different trees instead of fudging tilings. | |
2059 pending_layer_->HighResTiling()->ComputeTilePriorityRects( | |
2060 gfx::Rect(pending_layer_bounds), 1.f, 1.f, Occlusion()); | |
2061 | |
2062 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | |
2063 active_layer_->SetAllTilesReady(); | |
2064 | 2028 |
2065 // Since the active layer has different bounds, the pending layer needs all | 2029 // Since the active layer has different bounds, the pending layer needs all |
2066 // high res tiles in order to activate. | 2030 // high res tiles in order to activate. |
2067 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 2031 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
2068 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 2032 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
2069 | 2033 |
2070 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 2034 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
2071 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 2035 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
2072 } | 2036 } |
2073 | 2037 |
(...skipping 27 matching lines...) Expand all Loading... |
2101 | 2065 |
2102 active_layer_ = static_cast<FakePictureLayerImpl*>( | 2066 active_layer_ = static_cast<FakePictureLayerImpl*>( |
2103 host_impl_.active_tree()->LayerById(id_)); | 2067 host_impl_.active_tree()->LayerById(id_)); |
2104 | 2068 |
2105 EXPECT_EQ(0u, active_layer_->num_tilings()); | 2069 EXPECT_EQ(0u, active_layer_->num_tilings()); |
2106 EXPECT_EQ(raster_page_scale, active_layer_->raster_page_scale()); | 2070 EXPECT_EQ(raster_page_scale, active_layer_->raster_page_scale()); |
2107 EXPECT_FALSE(active_layer_->needs_post_commit_initialization()); | 2071 EXPECT_FALSE(active_layer_->needs_post_commit_initialization()); |
2108 } | 2072 } |
2109 | 2073 |
2110 TEST_F(PictureLayerImplTest, ShareTilesOnNextFrame) { | 2074 TEST_F(PictureLayerImplTest, ShareTilesOnNextFrame) { |
2111 SetupDefaultTrees(gfx::Size(1500, 1500)); | 2075 gfx::Size layer_bounds(1500, 1500); |
| 2076 gfx::Size tile_size(100, 100); |
2112 | 2077 |
2113 PictureLayerTiling* tiling = pending_layer_->AddTiling(1.f); | 2078 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 2079 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2080 |
| 2081 SetupPendingTree(pending_pile); |
| 2082 |
| 2083 PictureLayerTiling* tiling = pending_layer_->HighResTiling(); |
2114 gfx::Rect first_invalidate = tiling->TilingDataForTesting().TileBounds(0, 0); | 2084 gfx::Rect first_invalidate = tiling->TilingDataForTesting().TileBounds(0, 0); |
2115 first_invalidate.Inset(tiling->TilingDataForTesting().border_texels(), | 2085 first_invalidate.Inset(tiling->TilingDataForTesting().border_texels(), |
2116 tiling->TilingDataForTesting().border_texels()); | 2086 tiling->TilingDataForTesting().border_texels()); |
2117 gfx::Rect second_invalidate = tiling->TilingDataForTesting().TileBounds(1, 1); | 2087 gfx::Rect second_invalidate = tiling->TilingDataForTesting().TileBounds(1, 1); |
2118 second_invalidate.Inset(tiling->TilingDataForTesting().border_texels(), | 2088 second_invalidate.Inset(tiling->TilingDataForTesting().border_texels(), |
2119 tiling->TilingDataForTesting().border_texels()); | 2089 tiling->TilingDataForTesting().border_texels()); |
2120 | 2090 |
| 2091 ActivateTree(); |
| 2092 |
2121 // Make a pending tree with an invalidated raster tile 0,0. | 2093 // Make a pending tree with an invalidated raster tile 0,0. |
2122 tiling->CreateAllTilesForTesting(); | 2094 SetupPendingTreeWithInvalidation(pending_pile, first_invalidate); |
2123 pending_layer_->set_invalidation(first_invalidate); | |
2124 | 2095 |
2125 // Activate and make a pending tree with an invalidated raster tile 1,1. | 2096 // Activate and make a pending tree with an invalidated raster tile 1,1. |
2126 ActivateTree(); | 2097 ActivateTree(); |
2127 | 2098 |
2128 host_impl_.CreatePendingTree(); | 2099 SetupPendingTreeWithInvalidation(pending_pile, second_invalidate); |
2129 pending_layer_ = static_cast<FakePictureLayerImpl*>( | |
2130 host_impl_.pending_tree()->root_layer()); | |
2131 pending_layer_->set_invalidation(second_invalidate); | |
2132 | 2100 |
2133 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); | 2101 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); |
2134 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); | 2102 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); |
2135 | 2103 |
2136 pending_tiling->CreateAllTilesForTesting(); | 2104 // pending_tiling->CreateAllTilesForTesting(); |
2137 | 2105 |
2138 // Tile 0,0 should be shared, but tile 1,1 should not be. | 2106 // Tile 0,0 should be shared, but tile 1,1 should not be. |
2139 EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); | 2107 EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); |
2140 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); | 2108 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); |
2141 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); | 2109 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); |
2142 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); | 2110 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); |
2143 EXPECT_TRUE(pending_tiling->TileAt(0, 0)->is_shared()); | 2111 EXPECT_TRUE(pending_tiling->TileAt(0, 0)->is_shared()); |
2144 EXPECT_TRUE(pending_tiling->TileAt(1, 0)->is_shared()); | 2112 EXPECT_TRUE(pending_tiling->TileAt(1, 0)->is_shared()); |
2145 EXPECT_TRUE(pending_tiling->TileAt(0, 1)->is_shared()); | 2113 EXPECT_TRUE(pending_tiling->TileAt(0, 1)->is_shared()); |
2146 EXPECT_FALSE(pending_tiling->TileAt(1, 1)->is_shared()); | 2114 EXPECT_FALSE(pending_tiling->TileAt(1, 1)->is_shared()); |
2147 | 2115 |
2148 // Drop the tiles on the active tree and recreate them. The same tiles | 2116 // Drop the tiles on the active tree and recreate them. The same tiles |
2149 // should be shared or not. | 2117 // should be shared or not. |
2150 active_tiling->ComputeTilePriorityRects(gfx::Rect(), 1.f, 1.0, Occlusion()); | 2118 active_tiling->ComputeTilePriorityRects(gfx::Rect(), 1.f, 1.0, Occlusion()); |
2151 EXPECT_TRUE(active_tiling->AllTilesForTesting().empty()); | 2119 EXPECT_TRUE(active_tiling->AllTilesForTesting().empty()); |
2152 active_tiling->CreateAllTilesForTesting(); | 2120 active_tiling->CreateAllTilesForTesting(); |
2153 | 2121 |
2154 // Tile 0,0 should be shared, but tile 1,1 should not be. | 2122 // Tile 0,0 should be shared, but tile 1,1 should not be. |
2155 EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); | 2123 EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); |
2156 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); | 2124 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); |
2157 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); | 2125 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); |
2158 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); | 2126 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); |
2159 EXPECT_TRUE(pending_tiling->TileAt(0, 0)->is_shared()); | 2127 EXPECT_TRUE(pending_tiling->TileAt(0, 0)->is_shared()); |
2160 EXPECT_TRUE(pending_tiling->TileAt(1, 0)->is_shared()); | 2128 EXPECT_TRUE(pending_tiling->TileAt(1, 0)->is_shared()); |
2161 EXPECT_TRUE(pending_tiling->TileAt(0, 1)->is_shared()); | 2129 EXPECT_TRUE(pending_tiling->TileAt(0, 1)->is_shared()); |
2162 EXPECT_FALSE(pending_tiling->TileAt(1, 1)->is_shared()); | 2130 EXPECT_FALSE(pending_tiling->TileAt(1, 1)->is_shared()); |
2163 } | 2131 } |
2164 | 2132 |
2165 TEST_F(PictureLayerImplTest, ShareTilesOnSync) { | 2133 TEST_F(PictureLayerImplTest, ShareTilesWithNoInvalidation) { |
2166 SetupDefaultTrees(gfx::Size(1500, 1500)); | 2134 SetupDefaultTrees(gfx::Size(1500, 1500)); |
2167 AddDefaultTilingsWithInvalidation(gfx::Rect()); | |
2168 | 2135 |
2169 host_impl_.ActivateSyncTree(); | 2136 EXPECT_GE(active_layer_->num_tilings(), 1u); |
2170 host_impl_.CreatePendingTree(); | 2137 EXPECT_GE(pending_layer_->num_tilings(), 1u); |
2171 active_layer_ = static_cast<FakePictureLayerImpl*>( | |
2172 host_impl_.active_tree()->LayerById(id_)); | |
2173 | 2138 |
2174 // Force the active tree to sync to the pending tree "post-commit". | 2139 // No invalidation, so all tiles are shared. |
2175 pending_layer_->DoPostCommitInitializationIfNeeded(); | 2140 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); |
| 2141 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); |
| 2142 ASSERT_TRUE(active_tiling); |
| 2143 ASSERT_TRUE(pending_tiling); |
2176 | 2144 |
2177 // Both invalidations should drop tiles from the pending tree. | 2145 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
2178 EXPECT_EQ(3u, active_layer_->num_tilings()); | 2146 EXPECT_TRUE(active_tiling->TileAt(1, 0)); |
2179 EXPECT_EQ(3u, pending_layer_->num_tilings()); | 2147 EXPECT_TRUE(active_tiling->TileAt(0, 1)); |
2180 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { | 2148 EXPECT_TRUE(active_tiling->TileAt(1, 1)); |
2181 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(i); | |
2182 PictureLayerTiling* pending_tiling = | |
2183 pending_layer_->tilings()->tiling_at(i); | |
2184 | 2149 |
2185 ASSERT_TRUE(active_tiling); | 2150 EXPECT_TRUE(pending_tiling->TileAt(0, 0)); |
2186 ASSERT_TRUE(pending_tiling); | 2151 EXPECT_TRUE(pending_tiling->TileAt(1, 0)); |
| 2152 EXPECT_TRUE(pending_tiling->TileAt(0, 1)); |
| 2153 EXPECT_TRUE(pending_tiling->TileAt(1, 1)); |
2187 | 2154 |
2188 EXPECT_TRUE(active_tiling->TileAt(0, 0)); | 2155 EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); |
2189 EXPECT_TRUE(active_tiling->TileAt(1, 0)); | 2156 EXPECT_TRUE(active_tiling->TileAt(0, 0)->is_shared()); |
2190 EXPECT_TRUE(active_tiling->TileAt(0, 1)); | 2157 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); |
2191 EXPECT_TRUE(active_tiling->TileAt(1, 1)); | 2158 EXPECT_TRUE(active_tiling->TileAt(1, 0)->is_shared()); |
2192 | 2159 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); |
2193 EXPECT_TRUE(pending_tiling->TileAt(0, 0)); | 2160 EXPECT_TRUE(active_tiling->TileAt(0, 1)->is_shared()); |
2194 EXPECT_TRUE(pending_tiling->TileAt(1, 0)); | 2161 EXPECT_EQ(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); |
2195 EXPECT_TRUE(pending_tiling->TileAt(0, 1)); | 2162 EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared()); |
2196 EXPECT_TRUE(pending_tiling->TileAt(1, 1)); | |
2197 | |
2198 EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); | |
2199 EXPECT_TRUE(active_tiling->TileAt(0, 0)->is_shared()); | |
2200 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); | |
2201 EXPECT_TRUE(active_tiling->TileAt(1, 0)->is_shared()); | |
2202 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); | |
2203 EXPECT_TRUE(active_tiling->TileAt(0, 1)->is_shared()); | |
2204 EXPECT_EQ(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); | |
2205 EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared()); | |
2206 } | |
2207 } | 2163 } |
2208 | 2164 |
2209 TEST_F(PictureLayerImplTest, ShareInvalidActiveTreeTilesOnSync) { | 2165 TEST_F(PictureLayerImplTest, ShareInvalidActiveTreeTiles) { |
2210 SetupDefaultTrees(gfx::Size(1500, 1500)); | 2166 gfx::Size tile_size(100, 100); |
2211 AddDefaultTilingsWithInvalidation(gfx::Rect(0, 0, 1, 1)); | 2167 gfx::Size layer_bounds(1500, 1500); |
2212 | 2168 |
2213 // This activates the 0,0,1,1 invalidation. | 2169 scoped_refptr<FakePicturePileImpl> pending_pile = |
2214 host_impl_.ActivateSyncTree(); | 2170 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
2215 host_impl_.CreatePendingTree(); | 2171 scoped_refptr<FakePicturePileImpl> active_pile = |
2216 active_layer_ = static_cast<FakePictureLayerImpl*>( | 2172 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
2217 host_impl_.active_tree()->LayerById(id_)); | 2173 SetupTreesWithInvalidation(pending_pile, active_pile, gfx::Rect(1, 1)); |
| 2174 // Activate the invalidation. |
| 2175 ActivateTree(); |
| 2176 // Make another pending tree without any invaliadtion in it. |
| 2177 scoped_refptr<FakePicturePileImpl> pending_pile2 = |
| 2178 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2179 SetupPendingTree(pending_pile2); |
2218 | 2180 |
2219 // Force the active tree to sync to the pending tree "post-commit". | 2181 EXPECT_GE(active_layer_->num_tilings(), 1u); |
2220 pending_layer_->DoPostCommitInitializationIfNeeded(); | 2182 EXPECT_GE(pending_layer_->num_tilings(), 1u); |
2221 | 2183 |
2222 // The active tree invalidation was handled by the active tiles, so they | 2184 // The active tree invalidation was handled by the active tiles, so they |
2223 // can be shared with the pending tree. | 2185 // can be shared with the pending tree. |
2224 EXPECT_EQ(3u, active_layer_->num_tilings()); | 2186 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); |
2225 EXPECT_EQ(3u, pending_layer_->num_tilings()); | 2187 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); |
2226 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { | 2188 ASSERT_TRUE(active_tiling); |
2227 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(i); | 2189 ASSERT_TRUE(pending_tiling); |
2228 PictureLayerTiling* pending_tiling = | |
2229 pending_layer_->tilings()->tiling_at(i); | |
2230 | 2190 |
2231 ASSERT_TRUE(active_tiling); | 2191 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
2232 ASSERT_TRUE(pending_tiling); | 2192 EXPECT_TRUE(active_tiling->TileAt(1, 0)); |
| 2193 EXPECT_TRUE(active_tiling->TileAt(0, 1)); |
| 2194 EXPECT_TRUE(active_tiling->TileAt(1, 1)); |
2233 | 2195 |
2234 EXPECT_TRUE(active_tiling->TileAt(0, 0)); | 2196 EXPECT_TRUE(pending_tiling->TileAt(0, 0)); |
2235 EXPECT_TRUE(active_tiling->TileAt(1, 0)); | 2197 EXPECT_TRUE(pending_tiling->TileAt(1, 0)); |
2236 EXPECT_TRUE(active_tiling->TileAt(0, 1)); | 2198 EXPECT_TRUE(pending_tiling->TileAt(0, 1)); |
2237 EXPECT_TRUE(active_tiling->TileAt(1, 1)); | 2199 EXPECT_TRUE(pending_tiling->TileAt(1, 1)); |
2238 | 2200 |
2239 EXPECT_TRUE(pending_tiling->TileAt(0, 0)); | 2201 EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); |
2240 EXPECT_TRUE(pending_tiling->TileAt(1, 0)); | 2202 EXPECT_TRUE(active_tiling->TileAt(0, 0)->is_shared()); |
2241 EXPECT_TRUE(pending_tiling->TileAt(0, 1)); | 2203 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); |
2242 EXPECT_TRUE(pending_tiling->TileAt(1, 1)); | 2204 EXPECT_TRUE(active_tiling->TileAt(1, 0)->is_shared()); |
2243 | 2205 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); |
2244 EXPECT_EQ(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); | 2206 EXPECT_TRUE(active_tiling->TileAt(0, 1)->is_shared()); |
2245 EXPECT_TRUE(active_tiling->TileAt(0, 0)->is_shared()); | 2207 EXPECT_EQ(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); |
2246 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); | 2208 EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared()); |
2247 EXPECT_TRUE(active_tiling->TileAt(1, 0)->is_shared()); | |
2248 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); | |
2249 EXPECT_TRUE(active_tiling->TileAt(0, 1)->is_shared()); | |
2250 EXPECT_EQ(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); | |
2251 EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared()); | |
2252 } | |
2253 } | 2209 } |
2254 | 2210 |
2255 TEST_F(PictureLayerImplTest, RemoveInvalidPendingTreeTilesOnSync) { | 2211 TEST_F(PictureLayerImplTest, RecreateInvalidPendingTreeTiles) { |
2256 SetupDefaultTrees(gfx::Size(1500, 1500)); | 2212 // Set some invalidation on the pending tree. We should replace raster tiles |
2257 AddDefaultTilingsWithInvalidation(gfx::Rect()); | 2213 // that touch this. |
| 2214 SetupDefaultTreesWithInvalidation(gfx::Size(1500, 1500), gfx::Rect(1, 1)); |
2258 | 2215 |
2259 host_impl_.ActivateSyncTree(); | 2216 EXPECT_GE(active_layer_->num_tilings(), 1u); |
2260 host_impl_.CreatePendingTree(); | 2217 EXPECT_GE(pending_layer_->num_tilings(), 1u); |
2261 active_layer_ = static_cast<FakePictureLayerImpl*>( | |
2262 host_impl_.active_tree()->LayerById(id_)); | |
2263 | |
2264 // Set some invalidation on the pending tree "during commit". We should | |
2265 // replace raster tiles that touch this. | |
2266 pending_layer_->set_invalidation(gfx::Rect(1, 1)); | |
2267 | |
2268 // Force the active tree to sync to the pending tree "post-commit". | |
2269 pending_layer_->DoPostCommitInitializationIfNeeded(); | |
2270 | 2218 |
2271 // The pending tree invalidation means tiles can not be shared with the | 2219 // The pending tree invalidation means tiles can not be shared with the |
2272 // active tree. | 2220 // active tree. |
2273 EXPECT_EQ(3u, active_layer_->num_tilings()); | 2221 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); |
2274 EXPECT_EQ(3u, pending_layer_->num_tilings()); | 2222 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); |
2275 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { | 2223 ASSERT_TRUE(active_tiling); |
2276 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(i); | 2224 ASSERT_TRUE(pending_tiling); |
2277 PictureLayerTiling* pending_tiling = | |
2278 pending_layer_->tilings()->tiling_at(i); | |
2279 | 2225 |
2280 ASSERT_TRUE(active_tiling); | 2226 EXPECT_TRUE(active_tiling->TileAt(0, 0)); |
2281 ASSERT_TRUE(pending_tiling); | 2227 EXPECT_TRUE(active_tiling->TileAt(1, 0)); |
| 2228 EXPECT_TRUE(active_tiling->TileAt(0, 1)); |
| 2229 EXPECT_TRUE(active_tiling->TileAt(1, 1)); |
2282 | 2230 |
2283 EXPECT_TRUE(active_tiling->TileAt(0, 0)); | 2231 EXPECT_TRUE(pending_tiling->TileAt(0, 0)); |
2284 EXPECT_TRUE(active_tiling->TileAt(1, 0)); | 2232 EXPECT_TRUE(pending_tiling->TileAt(1, 0)); |
2285 EXPECT_TRUE(active_tiling->TileAt(0, 1)); | 2233 EXPECT_TRUE(pending_tiling->TileAt(0, 1)); |
2286 EXPECT_TRUE(active_tiling->TileAt(1, 1)); | 2234 EXPECT_TRUE(pending_tiling->TileAt(1, 1)); |
2287 | 2235 |
2288 EXPECT_TRUE(pending_tiling->TileAt(0, 0)); | 2236 EXPECT_NE(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); |
2289 EXPECT_TRUE(pending_tiling->TileAt(1, 0)); | 2237 EXPECT_FALSE(active_tiling->TileAt(0, 0)->is_shared()); |
2290 EXPECT_TRUE(pending_tiling->TileAt(0, 1)); | 2238 EXPECT_FALSE(pending_tiling->TileAt(0, 0)->is_shared()); |
2291 EXPECT_TRUE(pending_tiling->TileAt(1, 1)); | 2239 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); |
2292 | 2240 EXPECT_TRUE(active_tiling->TileAt(1, 0)->is_shared()); |
2293 EXPECT_NE(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); | 2241 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); |
2294 EXPECT_FALSE(active_tiling->TileAt(0, 0)->is_shared()); | 2242 EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared()); |
2295 EXPECT_FALSE(pending_tiling->TileAt(0, 0)->is_shared()); | 2243 EXPECT_EQ(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); |
2296 EXPECT_EQ(active_tiling->TileAt(1, 0), pending_tiling->TileAt(1, 0)); | 2244 EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared()); |
2297 EXPECT_TRUE(active_tiling->TileAt(1, 0)->is_shared()); | |
2298 EXPECT_EQ(active_tiling->TileAt(0, 1), pending_tiling->TileAt(0, 1)); | |
2299 EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared()); | |
2300 EXPECT_EQ(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); | |
2301 EXPECT_TRUE(active_tiling->TileAt(1, 1)->is_shared()); | |
2302 } | |
2303 } | |
2304 | |
2305 TEST_F(PictureLayerImplTest, SyncTilingAfterReleaseResource) { | |
2306 SetupDefaultTrees(gfx::Size(10, 10)); | |
2307 host_impl_.active_tree()->UpdateDrawProperties(); | |
2308 EXPECT_FALSE(host_impl_.active_tree()->needs_update_draw_properties()); | |
2309 | |
2310 // Contrived unit test of a real crash. A layer is transparent during a | |
2311 // context loss, and later becomes opaque, causing active layer SyncTiling to | |
2312 // be called. | |
2313 float new_scale = 1.f; | |
2314 active_layer_->ReleaseResources(); | |
2315 pending_layer_->ReleaseResources(); | |
2316 EXPECT_FALSE(active_layer_->tilings()->FindTilingWithScale(new_scale)); | |
2317 pending_layer_->AddTiling(new_scale); | |
2318 EXPECT_TRUE(active_layer_->tilings()->FindTilingWithScale(new_scale)); | |
2319 | |
2320 // UpdateDrawProperties early-outs if the tree doesn't need it. It is also | |
2321 // responsible for calling ManageTilings. These checks verify that | |
2322 // ReleaseResources has set needs update draw properties so that the | |
2323 // new tiling gets the appropriate resolution set in ManageTilings. | |
2324 EXPECT_TRUE(host_impl_.active_tree()->needs_update_draw_properties()); | |
2325 host_impl_.active_tree()->UpdateDrawProperties(); | |
2326 PictureLayerTiling* high_res = | |
2327 active_layer_->tilings()->FindTilingWithScale(new_scale); | |
2328 ASSERT_TRUE(!!high_res); | |
2329 EXPECT_EQ(HIGH_RESOLUTION, high_res->resolution()); | |
2330 } | 2245 } |
2331 | 2246 |
2332 TEST_F(PictureLayerImplTest, SyncTilingAfterGpuRasterizationToggles) { | 2247 TEST_F(PictureLayerImplTest, SyncTilingAfterGpuRasterizationToggles) { |
2333 SetupDefaultTrees(gfx::Size(10, 10)); | 2248 base::TimeTicks time_ticks; |
| 2249 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 2250 host_impl_.SetCurrentBeginFrameArgs( |
| 2251 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
2334 | 2252 |
2335 const float kScale = 1.f; | 2253 gfx::Size tile_size(100, 100); |
2336 pending_layer_->AddTiling(kScale); | 2254 gfx::Size layer_bounds(10, 10); |
2337 EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(kScale)); | 2255 |
2338 EXPECT_TRUE(active_layer_->tilings()->FindTilingWithScale(kScale)); | 2256 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 2257 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2258 scoped_refptr<FakePicturePileImpl> active_pile = |
| 2259 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2260 |
| 2261 SetupTrees(pending_pile, active_pile); |
| 2262 |
| 2263 EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(1.f)); |
| 2264 EXPECT_TRUE(active_layer_->tilings()->FindTilingWithScale(1.f)); |
2339 | 2265 |
2340 // Gpu rasterization is disabled by default. | 2266 // Gpu rasterization is disabled by default. |
2341 EXPECT_FALSE(host_impl_.use_gpu_rasterization()); | 2267 EXPECT_FALSE(host_impl_.use_gpu_rasterization()); |
2342 // Toggling the gpu rasterization clears all tilings on both trees. | 2268 // Toggling the gpu rasterization clears all tilings on both trees. |
2343 host_impl_.SetUseGpuRasterization(true); | 2269 host_impl_.SetUseGpuRasterization(true); |
2344 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 2270 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
2345 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 2271 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
2346 | 2272 |
2347 // Make sure that we can still add tiling to the pending layer, | 2273 // Make sure that we can still add tiling to the pending layer, |
2348 // that gets synced to the active layer. | 2274 // that gets synced to the active layer. |
2349 pending_layer_->AddTiling(kScale); | 2275 time_ticks += base::TimeDelta::FromMilliseconds(1); |
2350 EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(kScale)); | 2276 host_impl_.SetCurrentBeginFrameArgs( |
2351 EXPECT_TRUE(active_layer_->tilings()->FindTilingWithScale(kScale)); | 2277 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 2278 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 2279 EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(1.f)); |
| 2280 |
| 2281 ActivateTree(); |
| 2282 EXPECT_TRUE(active_layer_->tilings()->FindTilingWithScale(1.f)); |
| 2283 |
| 2284 SetupPendingTree(pending_pile); |
| 2285 EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(1.f)); |
2352 | 2286 |
2353 // Toggling the gpu rasterization clears all tilings on both trees. | 2287 // Toggling the gpu rasterization clears all tilings on both trees. |
2354 EXPECT_TRUE(host_impl_.use_gpu_rasterization()); | 2288 EXPECT_TRUE(host_impl_.use_gpu_rasterization()); |
2355 host_impl_.SetUseGpuRasterization(false); | 2289 host_impl_.SetUseGpuRasterization(false); |
2356 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 2290 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
2357 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 2291 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
2358 } | 2292 } |
2359 | 2293 |
2360 TEST_F(PictureLayerImplTest, HighResCreatedWhenBoundsShrink) { | 2294 TEST_F(PictureLayerImplTest, HighResCreatedWhenBoundsShrink) { |
2361 gfx::Size tile_size(100, 100); | 2295 gfx::Size tile_size(100, 100); |
2362 | 2296 |
2363 scoped_refptr<FakePicturePileImpl> active_pile = | 2297 // Put 0.5 as high res. |
| 2298 host_impl_.SetDeviceScaleFactor(0.5f); |
| 2299 |
| 2300 scoped_refptr<FakePicturePileImpl> pending_pile = |
2364 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(10, 10)); | 2301 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(10, 10)); |
2365 SetupPendingTree(active_pile); | 2302 SetupPendingTree(pending_pile); |
2366 ActivateTree(); | |
2367 host_impl_.active_tree()->UpdateDrawProperties(); | |
2368 EXPECT_FALSE(host_impl_.active_tree()->needs_update_draw_properties()); | |
2369 | |
2370 SetupDrawPropertiesAndUpdateTiles( | |
2371 active_layer_, 0.5f, 0.5f, 0.5f, 0.5f, false); | |
2372 active_layer_->tilings()->RemoveAllTilings(); | |
2373 PictureLayerTiling* tiling = active_layer_->AddTiling(0.5f); | |
2374 active_layer_->AddTiling(1.5f); | |
2375 active_layer_->AddTiling(0.25f); | |
2376 tiling->set_resolution(HIGH_RESOLUTION); | |
2377 | 2303 |
2378 // Sanity checks. | 2304 // Sanity checks. |
2379 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); | 2305 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
2380 ASSERT_EQ(tiling, active_layer_->tilings()->FindTilingWithScale(0.5f)); | 2306 EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(0.5f)); |
2381 | 2307 |
2382 // Now, set the bounds to be 1x1 (so that minimum contents scale becomes | 2308 ActivateTree(); |
2383 // 1.0f). Note that we should also ensure that the pending layer needs post | 2309 |
2384 // commit initialization, since this is what would happen during commit. In | 2310 // Now, set the bounds to be 1x1, so that minimum contents scale becomes 1. |
2385 // other words we want the pending layer to sync from the active layer. | 2311 pending_pile = |
2386 scoped_refptr<FakePicturePileImpl> pending_pile = | |
2387 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1, 1)); | 2312 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1, 1)); |
2388 SetupPendingTree(pending_pile); | 2313 SetupPendingTree(pending_pile); |
2389 | 2314 |
2390 // Update the draw properties: sync from active tree should happen here. | 2315 // Another sanity check. |
2391 host_impl_.pending_tree()->UpdateDrawProperties(); | 2316 EXPECT_EQ(1.f, pending_layer_->MinimumContentsScale()); |
2392 EXPECT_FALSE(pending_layer_->needs_post_commit_initialization()); | |
2393 | 2317 |
2394 // Another sanity check. | 2318 // Since the MinContentsScale is 1, the 0.5 tiling should be replaced by a 1.0 |
2395 ASSERT_EQ(1.f, pending_layer_->MinimumContentsScale()); | 2319 // tiling. |
| 2320 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 0.5f, 1.f, 1.f, 1.f, false); |
2396 | 2321 |
2397 // Now we should've synced 1.5f tiling, since that's the only one that doesn't | 2322 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
2398 // violate minimum contents scale. At the same time, we should've created a | 2323 PictureLayerTiling* tiling = |
2399 // new high res tiling at scale 1.0f. | 2324 pending_layer_->tilings()->FindTilingWithScale(1.0f); |
| 2325 ASSERT_TRUE(tiling); |
| 2326 EXPECT_EQ(HIGH_RESOLUTION, tiling->resolution()); |
| 2327 } |
| 2328 |
| 2329 TEST_F(PictureLayerImplTest, LowResTilingWithoutGpuRasterization) { |
| 2330 gfx::Size default_tile_size(host_impl_.settings().default_tile_size); |
| 2331 gfx::Size layer_bounds(default_tile_size.width() * 4, |
| 2332 default_tile_size.height() * 4); |
| 2333 |
| 2334 host_impl_.SetUseGpuRasterization(false); |
| 2335 |
| 2336 SetupDefaultTrees(layer_bounds); |
| 2337 EXPECT_FALSE(host_impl_.use_gpu_rasterization()); |
| 2338 // Should have a low-res and a high-res tiling. |
2400 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 2339 EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
2401 ASSERT_TRUE(pending_layer_->tilings()->FindTilingWithScale(1.0f)); | |
2402 EXPECT_EQ(HIGH_RESOLUTION, | |
2403 pending_layer_->tilings()->FindTilingWithScale(1.0f)->resolution()); | |
2404 ASSERT_TRUE(pending_layer_->tilings()->FindTilingWithScale(1.5f)); | |
2405 EXPECT_EQ(NON_IDEAL_RESOLUTION, | |
2406 pending_layer_->tilings()->FindTilingWithScale(1.5f)->resolution()); | |
2407 } | 2340 } |
2408 | 2341 |
2409 TEST_F(PictureLayerImplTest, NoLowResTilingWithGpuRasterization) { | 2342 TEST_F(PictureLayerImplTest, NoLowResTilingWithGpuRasterization) { |
2410 gfx::Size default_tile_size(host_impl_.settings().default_tile_size); | 2343 gfx::Size default_tile_size(host_impl_.settings().default_tile_size); |
2411 gfx::Size layer_bounds(default_tile_size.width() * 4, | 2344 gfx::Size layer_bounds(default_tile_size.width() * 4, |
2412 default_tile_size.height() * 4); | 2345 default_tile_size.height() * 4); |
2413 | 2346 |
| 2347 host_impl_.SetUseGpuRasterization(true); |
| 2348 |
2414 SetupDefaultTrees(layer_bounds); | 2349 SetupDefaultTrees(layer_bounds); |
2415 EXPECT_FALSE(host_impl_.use_gpu_rasterization()); | |
2416 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | |
2417 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); | |
2418 // Should have a low-res and a high-res tiling. | |
2419 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | |
2420 | |
2421 ResetTilingsAndRasterScales(); | |
2422 | |
2423 host_impl_.SetUseGpuRasterization(true); | |
2424 EXPECT_TRUE(host_impl_.use_gpu_rasterization()); | 2350 EXPECT_TRUE(host_impl_.use_gpu_rasterization()); |
2425 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, false); | |
2426 | |
2427 // Should only have the high-res tiling. | 2351 // Should only have the high-res tiling. |
2428 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 2352 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
2429 } | 2353 } |
2430 | 2354 |
2431 TEST_F(PictureLayerImplTest, NoTilingIfDoesNotDrawContent) { | 2355 TEST_F(PictureLayerImplTest, NoTilingIfDoesNotDrawContent) { |
2432 // Set up layers with tilings. | 2356 // Set up layers with tilings. |
2433 SetupDefaultTrees(gfx::Size(10, 10)); | 2357 SetupDefaultTrees(gfx::Size(10, 10)); |
2434 SetContentsScaleOnBothLayers(1.f, 1.f, 1.f, 1.f, false); | 2358 SetContentsScaleOnBothLayers(1.f, 1.f, 1.f, 1.f, false); |
2435 pending_layer_->PushPropertiesTo(active_layer_); | 2359 pending_layer_->PushPropertiesTo(active_layer_); |
2436 EXPECT_TRUE(pending_layer_->DrawsContent()); | 2360 EXPECT_TRUE(pending_layer_->DrawsContent()); |
2437 EXPECT_TRUE(pending_layer_->CanHaveTilings()); | 2361 EXPECT_TRUE(pending_layer_->CanHaveTilings()); |
2438 EXPECT_GE(pending_layer_->num_tilings(), 0u); | 2362 EXPECT_GE(pending_layer_->num_tilings(), 0u); |
2439 EXPECT_GE(active_layer_->num_tilings(), 0u); | 2363 EXPECT_GE(active_layer_->num_tilings(), 0u); |
2440 | 2364 |
2441 // Set content to false, which should make CanHaveTilings return false. | 2365 // Set content to false, which should make CanHaveTilings return false. |
2442 pending_layer_->SetDrawsContent(false); | 2366 pending_layer_->SetDrawsContent(false); |
2443 EXPECT_FALSE(pending_layer_->DrawsContent()); | 2367 EXPECT_FALSE(pending_layer_->DrawsContent()); |
2444 EXPECT_FALSE(pending_layer_->CanHaveTilings()); | 2368 EXPECT_FALSE(pending_layer_->CanHaveTilings()); |
2445 | 2369 |
2446 // No tilings should be pushed to active layer. | 2370 // No tilings should be pushed to active layer. |
2447 pending_layer_->PushPropertiesTo(active_layer_); | 2371 pending_layer_->PushPropertiesTo(active_layer_); |
2448 EXPECT_EQ(0u, active_layer_->num_tilings()); | 2372 EXPECT_EQ(0u, active_layer_->num_tilings()); |
2449 } | 2373 } |
2450 | 2374 |
2451 TEST_F(PictureLayerImplTest, FirstTilingDuringPinch) { | 2375 TEST_F(PictureLayerImplTest, FirstTilingDuringPinch) { |
2452 SetupDefaultTrees(gfx::Size(10, 10)); | 2376 SetupDefaultTrees(gfx::Size(10, 10)); |
| 2377 |
| 2378 // We start with a tiling at scale 1. |
| 2379 EXPECT_EQ(1.f, pending_layer_->HighResTiling()->contents_scale()); |
| 2380 |
| 2381 // When we scale up by 2.3, we get a new tiling that is a power of 2, in this |
| 2382 // case 4. |
2453 host_impl_.PinchGestureBegin(); | 2383 host_impl_.PinchGestureBegin(); |
2454 float high_res_scale = 2.3f; | 2384 float high_res_scale = 2.3f; |
2455 SetContentsScaleOnBothLayers(high_res_scale, 1.f, 1.f, 1.f, false); | 2385 SetContentsScaleOnBothLayers(high_res_scale, 1.f, 1.f, 1.f, false); |
2456 | 2386 EXPECT_EQ(4.f, pending_layer_->HighResTiling()->contents_scale()); |
2457 ASSERT_GE(pending_layer_->num_tilings(), 0u); | |
2458 EXPECT_FLOAT_EQ(high_res_scale, | |
2459 pending_layer_->HighResTiling()->contents_scale()); | |
2460 } | |
2461 | |
2462 TEST_F(PictureLayerImplTest, FirstTilingTooSmall) { | |
2463 SetupDefaultTrees(gfx::Size(10, 10)); | |
2464 host_impl_.PinchGestureBegin(); | |
2465 float high_res_scale = 0.0001f; | |
2466 EXPECT_GT(pending_layer_->MinimumContentsScale(), high_res_scale); | |
2467 | |
2468 SetContentsScaleOnBothLayers(high_res_scale, 1.f, 1.f, 1.f, false); | |
2469 | |
2470 ASSERT_GE(pending_layer_->num_tilings(), 0u); | |
2471 EXPECT_FLOAT_EQ(pending_layer_->MinimumContentsScale(), | |
2472 pending_layer_->HighResTiling()->contents_scale()); | |
2473 } | 2387 } |
2474 | 2388 |
2475 TEST_F(PictureLayerImplTest, PinchingTooSmall) { | 2389 TEST_F(PictureLayerImplTest, PinchingTooSmall) { |
2476 SetupDefaultTrees(gfx::Size(10, 10)); | 2390 SetupDefaultTrees(gfx::Size(10, 10)); |
2477 | 2391 |
| 2392 // We start with a tiling at scale 1. |
| 2393 EXPECT_EQ(1.f, pending_layer_->HighResTiling()->contents_scale()); |
| 2394 |
| 2395 host_impl_.PinchGestureBegin(); |
| 2396 float high_res_scale = 0.0001f; |
| 2397 EXPECT_LT(high_res_scale, pending_layer_->MinimumContentsScale()); |
| 2398 |
| 2399 SetContentsScaleOnBothLayers(high_res_scale, 1.f, high_res_scale, 1.f, false); |
| 2400 EXPECT_FLOAT_EQ(pending_layer_->MinimumContentsScale(), |
| 2401 pending_layer_->HighResTiling()->contents_scale()); |
| 2402 } |
| 2403 |
| 2404 TEST_F(PictureLayerImplTest, PinchingTooSmallWithContentsScale) { |
| 2405 SetupDefaultTrees(gfx::Size(10, 10)); |
| 2406 |
| 2407 ResetTilingsAndRasterScales(); |
| 2408 |
2478 float contents_scale = 0.15f; | 2409 float contents_scale = 0.15f; |
2479 SetContentsScaleOnBothLayers(contents_scale, 1.f, 1.f, 1.f, false); | 2410 SetContentsScaleOnBothLayers(contents_scale, 1.f, 1.f, 1.f, false); |
2480 | 2411 |
2481 ASSERT_GE(pending_layer_->num_tilings(), 0u); | 2412 ASSERT_GE(pending_layer_->num_tilings(), 0u); |
2482 EXPECT_FLOAT_EQ(contents_scale, | 2413 EXPECT_FLOAT_EQ(contents_scale, |
2483 pending_layer_->HighResTiling()->contents_scale()); | 2414 pending_layer_->HighResTiling()->contents_scale()); |
2484 | 2415 |
2485 host_impl_.PinchGestureBegin(); | 2416 host_impl_.PinchGestureBegin(); |
2486 | 2417 |
2487 float page_scale = 0.0001f; | 2418 float page_scale = 0.0001f; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2535 ASSERT_TRUE(fake_output_surface->InitializeAndSetContext3d( | 2466 ASSERT_TRUE(fake_output_surface->InitializeAndSetContext3d( |
2536 TestContextProvider::Create())); | 2467 TestContextProvider::Create())); |
2537 | 2468 |
2538 // These will crash PictureLayerImpl if this is not true. | 2469 // These will crash PictureLayerImpl if this is not true. |
2539 ASSERT_TRUE(host_impl_.pending_tree()->needs_update_draw_properties()); | 2470 ASSERT_TRUE(host_impl_.pending_tree()->needs_update_draw_properties()); |
2540 ASSERT_TRUE(host_impl_.active_tree()->needs_update_draw_properties()); | 2471 ASSERT_TRUE(host_impl_.active_tree()->needs_update_draw_properties()); |
2541 host_impl_.active_tree()->UpdateDrawProperties(); | 2472 host_impl_.active_tree()->UpdateDrawProperties(); |
2542 } | 2473 } |
2543 | 2474 |
2544 TEST_F(PictureLayerImplTest, HighResTilingDuringAnimationForCpuRasterization) { | 2475 TEST_F(PictureLayerImplTest, HighResTilingDuringAnimationForCpuRasterization) { |
2545 gfx::Size layer_bounds(100, 100); | |
2546 gfx::Size viewport_size(1000, 1000); | 2476 gfx::Size viewport_size(1000, 1000); |
2547 SetupDefaultTrees(layer_bounds); | |
2548 host_impl_.SetViewportSize(viewport_size); | 2477 host_impl_.SetViewportSize(viewport_size); |
2549 | 2478 |
| 2479 gfx::Size layer_bounds(100, 100); |
| 2480 SetupDefaultTrees(layer_bounds); |
| 2481 |
2550 float contents_scale = 1.f; | 2482 float contents_scale = 1.f; |
2551 float device_scale = 1.3f; | 2483 float device_scale = 1.f; |
2552 float page_scale = 1.4f; | 2484 float page_scale = 1.f; |
2553 float maximum_animation_scale = 1.f; | 2485 float maximum_animation_scale = 1.f; |
2554 bool animating_transform = false; | 2486 bool animating_transform = false; |
2555 | 2487 |
2556 SetContentsScaleOnBothLayers(contents_scale, | |
2557 device_scale, | |
2558 page_scale, | |
2559 maximum_animation_scale, | |
2560 animating_transform); | |
2561 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 2488 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
2562 | 2489 |
2563 // Since we're CPU-rasterizing, starting an animation should cause tiling | 2490 // Since we're CPU-rasterizing, starting an animation should cause tiling |
2564 // resolution to get set to the maximum animation scale factor. | 2491 // resolution to get set to the maximum animation scale factor. |
2565 animating_transform = true; | 2492 animating_transform = true; |
2566 maximum_animation_scale = 3.f; | 2493 maximum_animation_scale = 3.f; |
2567 contents_scale = 2.f; | 2494 contents_scale = 2.f; |
2568 | 2495 |
2569 SetContentsScaleOnBothLayers(contents_scale, | 2496 SetContentsScaleOnBothLayers(contents_scale, |
2570 device_scale, | 2497 device_scale, |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2774 animating_transform); | 2701 animating_transform); |
2775 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f); | 2702 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f); |
2776 } | 2703 } |
2777 | 2704 |
2778 TEST_F(PictureLayerImplTest, LayerRasterTileIterator) { | 2705 TEST_F(PictureLayerImplTest, LayerRasterTileIterator) { |
2779 base::TimeTicks time_ticks; | 2706 base::TimeTicks time_ticks; |
2780 time_ticks += base::TimeDelta::FromMilliseconds(1); | 2707 time_ticks += base::TimeDelta::FromMilliseconds(1); |
2781 host_impl_.SetCurrentBeginFrameArgs( | 2708 host_impl_.SetCurrentBeginFrameArgs( |
2782 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 2709 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
2783 | 2710 |
| 2711 host_impl_.SetViewportSize(gfx::Size(500, 500)); |
| 2712 |
2784 gfx::Size tile_size(100, 100); | 2713 gfx::Size tile_size(100, 100); |
2785 gfx::Size layer_bounds(1000, 1000); | 2714 gfx::Size layer_bounds(1000, 1000); |
2786 | 2715 |
2787 scoped_refptr<FakePicturePileImpl> pending_pile = | 2716 scoped_refptr<FakePicturePileImpl> pending_pile = |
2788 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2717 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
2789 | 2718 |
2790 SetupPendingTree(pending_pile); | 2719 SetupPendingTree(pending_pile); |
| 2720 EXPECT_EQ(2u, pending_layer_->num_tilings()); |
2791 | 2721 |
2792 ASSERT_TRUE(pending_layer_->CanHaveTilings()); | |
2793 | |
2794 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | |
2795 | |
2796 // Empty iterator | |
2797 PictureLayerImpl::LayerRasterTileIterator it; | 2722 PictureLayerImpl::LayerRasterTileIterator it; |
2798 EXPECT_FALSE(it); | |
2799 | |
2800 // No tilings. | |
2801 it = PictureLayerImpl::LayerRasterTileIterator(pending_layer_, false); | |
2802 EXPECT_FALSE(it); | |
2803 | |
2804 pending_layer_->AddTiling(low_res_factor); | |
2805 pending_layer_->AddTiling(0.3f); | |
2806 pending_layer_->AddTiling(0.7f); | |
2807 PictureLayerTiling* high_res_tiling = pending_layer_->AddTiling(1.0f); | |
2808 pending_layer_->AddTiling(2.0f); | |
2809 | |
2810 host_impl_.SetViewportSize(gfx::Size(500, 500)); | |
2811 host_impl_.pending_tree()->UpdateDrawProperties(); | |
2812 | 2723 |
2813 std::set<Tile*> unique_tiles; | 2724 std::set<Tile*> unique_tiles; |
2814 bool reached_prepaint = false; | 2725 bool reached_prepaint = false; |
2815 size_t non_ideal_tile_count = 0u; | 2726 size_t non_ideal_tile_count = 0u; |
2816 size_t low_res_tile_count = 0u; | 2727 size_t low_res_tile_count = 0u; |
2817 size_t high_res_tile_count = 0u; | 2728 size_t high_res_tile_count = 0u; |
2818 for (it = PictureLayerImpl::LayerRasterTileIterator(pending_layer_, false); | 2729 for (it = PictureLayerImpl::LayerRasterTileIterator(pending_layer_, false); |
2819 it; | 2730 it; |
2820 ++it) { | 2731 ++it) { |
2821 Tile* tile = *it; | 2732 Tile* tile = *it; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2879 EXPECT_EQ(high_res_tile_count, unique_tiles.size()); | 2790 EXPECT_EQ(high_res_tile_count, unique_tiles.size()); |
2880 | 2791 |
2881 time_ticks += base::TimeDelta::FromMilliseconds(200); | 2792 time_ticks += base::TimeDelta::FromMilliseconds(200); |
2882 host_impl_.SetCurrentBeginFrameArgs( | 2793 host_impl_.SetCurrentBeginFrameArgs( |
2883 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 2794 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
2884 | 2795 |
2885 pending_layer_->draw_properties().visible_content_rect = | 2796 pending_layer_->draw_properties().visible_content_rect = |
2886 gfx::Rect(0, 0, 500, 500); | 2797 gfx::Rect(0, 0, 500, 500); |
2887 pending_layer_->UpdateTiles(Occlusion(), resourceless_software_draw); | 2798 pending_layer_->UpdateTiles(Occlusion(), resourceless_software_draw); |
2888 | 2799 |
2889 std::vector<Tile*> high_res_tiles = high_res_tiling->AllTilesForTesting(); | 2800 std::vector<Tile*> high_res_tiles = |
| 2801 pending_layer_->HighResTiling()->AllTilesForTesting(); |
2890 for (std::vector<Tile*>::iterator tile_it = high_res_tiles.begin(); | 2802 for (std::vector<Tile*>::iterator tile_it = high_res_tiles.begin(); |
2891 tile_it != high_res_tiles.end(); | 2803 tile_it != high_res_tiles.end(); |
2892 ++tile_it) { | 2804 ++tile_it) { |
2893 Tile* tile = *tile_it; | 2805 Tile* tile = *tile_it; |
2894 ManagedTileState::DrawInfo& draw_info = tile->draw_info(); | 2806 ManagedTileState::DrawInfo& draw_info = tile->draw_info(); |
2895 draw_info.SetSolidColorForTesting(SK_ColorRED); | 2807 draw_info.SetSolidColorForTesting(SK_ColorRED); |
2896 } | 2808 } |
2897 | 2809 |
2898 non_ideal_tile_count = 0; | 2810 non_ideal_tile_count = 0; |
2899 low_res_tile_count = 0; | 2811 low_res_tile_count = 0; |
(...skipping 11 matching lines...) Expand all Loading... |
2911 } | 2823 } |
2912 | 2824 |
2913 EXPECT_EQ(0u, non_ideal_tile_count); | 2825 EXPECT_EQ(0u, non_ideal_tile_count); |
2914 EXPECT_EQ(1u, low_res_tile_count); | 2826 EXPECT_EQ(1u, low_res_tile_count); |
2915 EXPECT_EQ(0u, high_res_tile_count); | 2827 EXPECT_EQ(0u, high_res_tile_count); |
2916 } | 2828 } |
2917 | 2829 |
2918 TEST_F(PictureLayerImplTest, TilingSetEvictionQueue) { | 2830 TEST_F(PictureLayerImplTest, TilingSetEvictionQueue) { |
2919 gfx::Size tile_size(100, 100); | 2831 gfx::Size tile_size(100, 100); |
2920 gfx::Size layer_bounds(1000, 1000); | 2832 gfx::Size layer_bounds(1000, 1000); |
| 2833 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
| 2834 |
| 2835 host_impl_.SetViewportSize(gfx::Size(500, 500)); |
2921 | 2836 |
2922 scoped_refptr<FakePicturePileImpl> pending_pile = | 2837 scoped_refptr<FakePicturePileImpl> pending_pile = |
2923 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2838 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
2924 | 2839 |
| 2840 // TODO(vmpstr): Add a test with tilings other than high/low res on the active |
| 2841 // tree. |
2925 SetupPendingTree(pending_pile); | 2842 SetupPendingTree(pending_pile); |
2926 | 2843 EXPECT_EQ(2u, pending_layer_->num_tilings()); |
2927 ASSERT_TRUE(pending_layer_->CanHaveTilings()); | |
2928 | |
2929 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | |
2930 | |
2931 std::vector<PictureLayerTiling*> tilings; | |
2932 tilings.push_back(pending_layer_->AddTiling(low_res_factor)); | |
2933 tilings.push_back(pending_layer_->AddTiling(0.3f)); | |
2934 tilings.push_back(pending_layer_->AddTiling(0.7f)); | |
2935 tilings.push_back(pending_layer_->AddTiling(1.0f)); | |
2936 tilings.push_back(pending_layer_->AddTiling(2.0f)); | |
2937 | |
2938 host_impl_.SetViewportSize(gfx::Size(500, 500)); | |
2939 host_impl_.pending_tree()->UpdateDrawProperties(); | |
2940 | 2844 |
2941 std::vector<Tile*> all_tiles; | 2845 std::vector<Tile*> all_tiles; |
2942 for (std::vector<PictureLayerTiling*>::iterator tiling_iterator = | 2846 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
2943 tilings.begin(); | 2847 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
2944 tiling_iterator != tilings.end(); | 2848 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
2945 ++tiling_iterator) { | 2849 all_tiles.insert(all_tiles.end(), tiles.begin(), tiles.end()); |
2946 std::vector<Tile*> tiles = (*tiling_iterator)->AllTilesForTesting(); | |
2947 std::copy(tiles.begin(), tiles.end(), std::back_inserter(all_tiles)); | |
2948 } | 2850 } |
2949 | 2851 |
2950 std::set<Tile*> all_tiles_set(all_tiles.begin(), all_tiles.end()); | 2852 std::set<Tile*> all_tiles_set(all_tiles.begin(), all_tiles.end()); |
2951 | 2853 |
2952 bool mark_required = false; | 2854 bool mark_required = false; |
2953 size_t number_of_marked_tiles = 0u; | 2855 size_t number_of_marked_tiles = 0u; |
2954 size_t number_of_unmarked_tiles = 0u; | 2856 size_t number_of_unmarked_tiles = 0u; |
2955 for (size_t i = 0; i < tilings.size(); ++i) { | 2857 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
2956 PictureLayerTiling* tiling = tilings.at(i); | 2858 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
2957 for (PictureLayerTiling::CoverageIterator iter( | 2859 for (PictureLayerTiling::CoverageIterator iter( |
2958 tiling, | 2860 tiling, |
2959 pending_layer_->contents_scale_x(), | 2861 pending_layer_->contents_scale_x(), |
2960 pending_layer_->visible_content_rect()); | 2862 pending_layer_->visible_content_rect()); |
2961 iter; | 2863 iter; |
2962 ++iter) { | 2864 ++iter) { |
2963 if (mark_required) { | 2865 if (mark_required) { |
2964 number_of_marked_tiles++; | 2866 number_of_marked_tiles++; |
2965 iter->set_required_for_activation(true); | 2867 iter->set_required_for_activation(true); |
2966 } else { | 2868 } else { |
2967 number_of_unmarked_tiles++; | 2869 number_of_unmarked_tiles++; |
2968 } | 2870 } |
2969 mark_required = !mark_required; | 2871 mark_required = !mark_required; |
2970 } | 2872 } |
2971 } | 2873 } |
2972 | 2874 |
2973 // Sanity checks. | 2875 // Sanity checks. |
2974 EXPECT_EQ(91u, all_tiles.size()); | 2876 EXPECT_EQ(17u, all_tiles.size()); |
2975 EXPECT_EQ(91u, all_tiles_set.size()); | 2877 EXPECT_EQ(17u, all_tiles_set.size()); |
2976 EXPECT_GT(number_of_marked_tiles, 1u); | 2878 EXPECT_GT(number_of_marked_tiles, 1u); |
2977 EXPECT_GT(number_of_unmarked_tiles, 1u); | 2879 EXPECT_GT(number_of_unmarked_tiles, 1u); |
2978 | 2880 |
2979 // Tiles don't have resources yet. | 2881 // Tiles don't have resources yet. |
2980 scoped_ptr<TilingSetEvictionQueue> queue = | 2882 scoped_ptr<TilingSetEvictionQueue> queue = |
2981 pending_layer_->CreateEvictionQueue(SAME_PRIORITY_FOR_BOTH_TREES); | 2883 pending_layer_->CreateEvictionQueue(SAME_PRIORITY_FOR_BOTH_TREES); |
2982 EXPECT_TRUE(queue->IsEmpty()); | 2884 EXPECT_TRUE(queue->IsEmpty()); |
2983 | 2885 |
2984 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); | 2886 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); |
2985 | 2887 |
2986 std::set<Tile*> unique_tiles; | 2888 std::set<Tile*> unique_tiles; |
2987 float expected_scales[] = {2.0f, 0.3f, 0.7f, low_res_factor, 1.0f}; | 2889 float expected_scales[] = {low_res_factor, 1.f}; |
2988 size_t scale_index = 0; | 2890 size_t scale_index = 0; |
2989 bool reached_visible = false; | 2891 bool reached_visible = false; |
2990 Tile* last_tile = nullptr; | 2892 Tile* last_tile = nullptr; |
2991 queue = pending_layer_->CreateEvictionQueue(SAME_PRIORITY_FOR_BOTH_TREES); | 2893 queue = pending_layer_->CreateEvictionQueue(SAME_PRIORITY_FOR_BOTH_TREES); |
2992 while (!queue->IsEmpty()) { | 2894 while (!queue->IsEmpty()) { |
2993 Tile* tile = queue->Top(); | 2895 Tile* tile = queue->Top(); |
2994 if (!last_tile) | 2896 if (!last_tile) |
2995 last_tile = tile; | 2897 last_tile = tile; |
2996 | 2898 |
2997 EXPECT_TRUE(tile); | 2899 EXPECT_TRUE(tile); |
(...skipping 26 matching lines...) Expand all Loading... |
3024 std::abs(tile->contents_scale() - last_tile->contents_scale()) < | 2926 std::abs(tile->contents_scale() - last_tile->contents_scale()) < |
3025 std::numeric_limits<float>::epsilon()) { | 2927 std::numeric_limits<float>::epsilon()) { |
3026 EXPECT_LE(priority.distance_to_visible, | 2928 EXPECT_LE(priority.distance_to_visible, |
3027 last_tile->priority(PENDING_TREE).distance_to_visible); | 2929 last_tile->priority(PENDING_TREE).distance_to_visible); |
3028 } | 2930 } |
3029 | 2931 |
3030 last_tile = tile; | 2932 last_tile = tile; |
3031 queue->Pop(); | 2933 queue->Pop(); |
3032 } | 2934 } |
3033 | 2935 |
| 2936 // 4 high res tiles are inside the viewport, the rest are evicted. |
3034 EXPECT_TRUE(reached_visible); | 2937 EXPECT_TRUE(reached_visible); |
3035 EXPECT_EQ(65u, unique_tiles.size()); | 2938 EXPECT_EQ(12u, unique_tiles.size()); |
3036 | 2939 |
3037 scale_index = 0; | 2940 scale_index = 0; |
3038 bool reached_required = false; | 2941 bool reached_required = false; |
3039 while (!queue->IsEmpty()) { | 2942 while (!queue->IsEmpty()) { |
3040 Tile* tile = queue->Top(); | 2943 Tile* tile = queue->Top(); |
3041 EXPECT_TRUE(tile); | 2944 EXPECT_TRUE(tile); |
3042 | 2945 |
3043 TilePriority priority = tile->priority(PENDING_TREE); | 2946 TilePriority priority = tile->priority(PENDING_TREE); |
3044 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); | 2947 EXPECT_EQ(TilePriority::NOW, priority.priority_bin); |
3045 | 2948 |
(...skipping 18 matching lines...) Expand all Loading... |
3064 EXPECT_TRUE(reached_required); | 2967 EXPECT_TRUE(reached_required); |
3065 EXPECT_EQ(all_tiles_set.size(), unique_tiles.size()); | 2968 EXPECT_EQ(all_tiles_set.size(), unique_tiles.size()); |
3066 } | 2969 } |
3067 | 2970 |
3068 TEST_F(PictureLayerImplTest, Occlusion) { | 2971 TEST_F(PictureLayerImplTest, Occlusion) { |
3069 gfx::Size tile_size(102, 102); | 2972 gfx::Size tile_size(102, 102); |
3070 gfx::Size layer_bounds(1000, 1000); | 2973 gfx::Size layer_bounds(1000, 1000); |
3071 gfx::Size viewport_size(1000, 1000); | 2974 gfx::Size viewport_size(1000, 1000); |
3072 | 2975 |
3073 LayerTestCommon::LayerImplTest impl; | 2976 LayerTestCommon::LayerImplTest impl; |
| 2977 host_impl_.SetViewportSize(viewport_size); |
3074 | 2978 |
3075 scoped_refptr<FakePicturePileImpl> pending_pile = | 2979 scoped_refptr<FakePicturePileImpl> pending_pile = |
3076 FakePicturePileImpl::CreateFilledPile(layer_bounds, layer_bounds); | 2980 FakePicturePileImpl::CreateFilledPile(layer_bounds, layer_bounds); |
3077 SetupPendingTree(pending_pile); | 2981 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); |
3078 pending_layer_->SetBounds(layer_bounds); | |
3079 ActivateTree(); | 2982 ActivateTree(); |
3080 active_layer_->set_fixed_tile_size(tile_size); | |
3081 | |
3082 host_impl_.SetViewportSize(viewport_size); | |
3083 host_impl_.active_tree()->UpdateDrawProperties(); | |
3084 | 2983 |
3085 std::vector<Tile*> tiles = | 2984 std::vector<Tile*> tiles = |
3086 active_layer_->HighResTiling()->AllTilesForTesting(); | 2985 active_layer_->HighResTiling()->AllTilesForTesting(); |
3087 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); | 2986 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); |
3088 | 2987 |
3089 { | 2988 { |
3090 SCOPED_TRACE("No occlusion"); | 2989 SCOPED_TRACE("No occlusion"); |
3091 gfx::Rect occluded; | 2990 gfx::Rect occluded; |
3092 impl.AppendQuadsWithOcclusion(active_layer_, occluded); | 2991 impl.AppendQuadsWithOcclusion(active_layer_, occluded); |
3093 | 2992 |
(...skipping 22 matching lines...) Expand all Loading... |
3116 // The layer outputs one quad, which is partially occluded. | 3015 // The layer outputs one quad, which is partially occluded. |
3117 EXPECT_EQ(100u - 10u, impl.quad_list().size()); | 3016 EXPECT_EQ(100u - 10u, impl.quad_list().size()); |
3118 EXPECT_EQ(10u + 10u, partially_occluded_count); | 3017 EXPECT_EQ(10u + 10u, partially_occluded_count); |
3119 } | 3018 } |
3120 } | 3019 } |
3121 | 3020 |
3122 TEST_F(PictureLayerImplTest, RasterScaleChangeWithoutAnimation) { | 3021 TEST_F(PictureLayerImplTest, RasterScaleChangeWithoutAnimation) { |
3123 gfx::Size tile_size(host_impl_.settings().default_tile_size); | 3022 gfx::Size tile_size(host_impl_.settings().default_tile_size); |
3124 SetupDefaultTrees(tile_size); | 3023 SetupDefaultTrees(tile_size); |
3125 | 3024 |
| 3025 ResetTilingsAndRasterScales(); |
| 3026 |
3126 float contents_scale = 2.f; | 3027 float contents_scale = 2.f; |
3127 float device_scale = 1.f; | 3028 float device_scale = 1.f; |
3128 float page_scale = 1.f; | 3029 float page_scale = 1.f; |
3129 float maximum_animation_scale = 1.f; | 3030 float maximum_animation_scale = 1.f; |
3130 bool animating_transform = false; | 3031 bool animating_transform = false; |
3131 | 3032 |
3132 SetContentsScaleOnBothLayers(contents_scale, | 3033 SetContentsScaleOnBothLayers(contents_scale, |
3133 device_scale, | 3034 device_scale, |
3134 page_scale, | 3035 page_scale, |
3135 maximum_animation_scale, | 3036 maximum_animation_scale, |
(...skipping 20 matching lines...) Expand all Loading... |
3156 page_scale, | 3057 page_scale, |
3157 maximum_animation_scale, | 3058 maximum_animation_scale, |
3158 animating_transform); | 3059 animating_transform); |
3159 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 3060 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
3160 } | 3061 } |
3161 | 3062 |
3162 TEST_F(PictureLayerImplTest, LowResReadyToDrawNotEnoughToActivate) { | 3063 TEST_F(PictureLayerImplTest, LowResReadyToDrawNotEnoughToActivate) { |
3163 gfx::Size tile_size(100, 100); | 3064 gfx::Size tile_size(100, 100); |
3164 gfx::Size layer_bounds(1000, 1000); | 3065 gfx::Size layer_bounds(1000, 1000); |
3165 | 3066 |
3166 host_impl_.SetViewportSize(layer_bounds); | |
3167 | |
3168 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | |
3169 | |
3170 // Make sure some tiles are not shared. | 3067 // Make sure some tiles are not shared. |
3171 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size)); | 3068 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); |
3172 | 3069 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); |
3173 CreateHighLowResAndSetAllTilesVisible(); | |
3174 active_layer_->SetAllTilesReady(); | |
3175 | 3070 |
3176 // All pending layer tiles required are not ready. | 3071 // All pending layer tiles required are not ready. |
3177 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 3072 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
3178 | 3073 |
3179 // Initialize all low-res tiles. | 3074 // Initialize all low-res tiles. |
3180 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); | 3075 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); |
3181 | 3076 |
3182 // Low-res tiles should not be enough. | 3077 // Low-res tiles should not be enough. |
3183 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 3078 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
3184 | 3079 |
3185 // Initialize remaining tiles. | 3080 // Initialize remaining tiles. |
3186 pending_layer_->SetAllTilesReady(); | 3081 pending_layer_->SetAllTilesReady(); |
3187 | 3082 |
3188 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 3083 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
3189 } | 3084 } |
3190 | 3085 |
3191 TEST_F(PictureLayerImplTest, HighResReadyToDrawEnoughToActivate) { | 3086 TEST_F(PictureLayerImplTest, HighResReadyToDrawEnoughToActivate) { |
3192 gfx::Size tile_size(100, 100); | 3087 gfx::Size tile_size(100, 100); |
3193 gfx::Size layer_bounds(1000, 1000); | 3088 gfx::Size layer_bounds(1000, 1000); |
3194 | 3089 |
3195 host_impl_.SetViewportSize(layer_bounds); | |
3196 | |
3197 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | |
3198 | |
3199 // Make sure some tiles are not shared. | 3090 // Make sure some tiles are not shared. |
3200 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size)); | 3091 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); |
3201 | 3092 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); |
3202 CreateHighLowResAndSetAllTilesVisible(); | |
3203 active_layer_->SetAllTilesReady(); | |
3204 | 3093 |
3205 // All pending layer tiles required are not ready. | 3094 // All pending layer tiles required are not ready. |
3206 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 3095 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
3207 | 3096 |
3208 // Initialize all high-res tiles. | 3097 // Initialize all high-res tiles. |
3209 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); | 3098 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); |
3210 | 3099 |
3211 // High-res tiles should be enough, since they cover everything visible. | 3100 // High-res tiles should be enough, since they cover everything visible. |
3212 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 3101 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
3213 } | 3102 } |
3214 | 3103 |
3215 TEST_F(PictureLayerImplTest, | 3104 TEST_F(PictureLayerImplTest, |
3216 SharedActiveHighResReadyAndPendingLowResReadyNotEnoughToActivate) { | 3105 SharedActiveHighResReadyAndPendingLowResReadyNotEnoughToActivate) { |
3217 gfx::Size tile_size(100, 100); | 3106 gfx::Size tile_size(100, 100); |
3218 gfx::Size layer_bounds(1000, 1000); | 3107 gfx::Size layer_bounds(1000, 1000); |
3219 | 3108 |
3220 host_impl_.SetViewportSize(layer_bounds); | |
3221 | |
3222 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | |
3223 | |
3224 // Make sure some tiles are not shared. | 3109 // Make sure some tiles are not shared. |
3225 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size)); | 3110 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); |
3226 | 3111 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); |
3227 CreateHighLowResAndSetAllTilesVisible(); | |
3228 | 3112 |
3229 // Initialize all high-res tiles in the active layer. | 3113 // Initialize all high-res tiles in the active layer. |
3230 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); | 3114 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); |
3231 // And all the low-res tiles in the pending layer. | 3115 // And all the low-res tiles in the pending layer. |
3232 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); | 3116 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling()); |
3233 | 3117 |
3234 // The unshared high-res tiles are not ready, so we cannot activate. | 3118 // The unshared high-res tiles are not ready, so we cannot activate. |
3235 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 3119 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
3236 | 3120 |
3237 // When the unshared pending high-res tiles are ready, we can activate. | 3121 // When the unshared pending high-res tiles are ready, we can activate. |
3238 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); | 3122 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); |
3239 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 3123 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
3240 } | 3124 } |
3241 | 3125 |
3242 TEST_F(PictureLayerImplTest, SharedActiveHighResReadyNotEnoughToActivate) { | 3126 TEST_F(PictureLayerImplTest, SharedActiveHighResReadyNotEnoughToActivate) { |
3243 gfx::Size tile_size(100, 100); | 3127 gfx::Size tile_size(100, 100); |
3244 gfx::Size layer_bounds(1000, 1000); | 3128 gfx::Size layer_bounds(1000, 1000); |
3245 | 3129 |
3246 host_impl_.SetViewportSize(layer_bounds); | |
3247 | |
3248 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | |
3249 | |
3250 // Make sure some tiles are not shared. | 3130 // Make sure some tiles are not shared. |
3251 pending_layer_->set_invalidation(gfx::Rect(gfx::Point(50, 50), tile_size)); | 3131 gfx::Rect invalidation(gfx::Point(50, 50), tile_size); |
3252 | 3132 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation); |
3253 CreateHighLowResAndSetAllTilesVisible(); | |
3254 | 3133 |
3255 // Initialize all high-res tiles in the active layer. | 3134 // Initialize all high-res tiles in the active layer. |
3256 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); | 3135 active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling()); |
3257 | 3136 |
3258 // The unshared high-res tiles are not ready, so we cannot activate. | 3137 // The unshared high-res tiles are not ready, so we cannot activate. |
3259 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 3138 EXPECT_FALSE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
3260 | 3139 |
3261 // When the unshared pending high-res tiles are ready, we can activate. | 3140 // When the unshared pending high-res tiles are ready, we can activate. |
3262 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); | 3141 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); |
3263 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); | 3142 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw()); |
3264 } | 3143 } |
3265 | 3144 |
3266 class NoLowResPictureLayerImplTest : public PictureLayerImplTest { | |
3267 public: | |
3268 NoLowResPictureLayerImplTest() | |
3269 : PictureLayerImplTest(NoLowResTilingsSettings()) {} | |
3270 }; | |
3271 | |
3272 TEST_F(NoLowResPictureLayerImplTest, ManageTilingsCreatesTilings) { | 3145 TEST_F(NoLowResPictureLayerImplTest, ManageTilingsCreatesTilings) { |
3273 gfx::Size tile_size(400, 400); | 3146 gfx::Size tile_size(400, 400); |
3274 gfx::Size layer_bounds(1300, 1900); | 3147 gfx::Size layer_bounds(1300, 1900); |
3275 | 3148 |
3276 scoped_refptr<FakePicturePileImpl> pending_pile = | 3149 scoped_refptr<FakePicturePileImpl> pending_pile = |
3277 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3150 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
3278 scoped_refptr<FakePicturePileImpl> active_pile = | 3151 scoped_refptr<FakePicturePileImpl> active_pile = |
3279 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3152 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
3280 | 3153 |
3281 SetupTrees(pending_pile, active_pile); | 3154 SetupTrees(pending_pile, active_pile); |
3282 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | |
3283 | 3155 |
3284 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 3156 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
3285 EXPECT_LT(low_res_factor, 1.f); | 3157 EXPECT_LT(low_res_factor, 1.f); |
3286 | 3158 |
| 3159 ResetTilingsAndRasterScales(); |
| 3160 |
| 3161 SetupDrawPropertiesAndUpdateTiles(active_layer_, |
| 3162 6.f, // ideal contents scale |
| 3163 3.f, // device scale |
| 3164 2.f, // page scale |
| 3165 1.f, // maximum animation scale |
| 3166 false); |
| 3167 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); |
| 3168 EXPECT_FLOAT_EQ(6.f, |
| 3169 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 3170 |
| 3171 // If we change the page scale factor, then we should get new tilings. |
| 3172 SetupDrawPropertiesAndUpdateTiles(active_layer_, |
| 3173 6.6f, // ideal contents scale |
| 3174 3.f, // device scale |
| 3175 2.2f, // page scale |
| 3176 1.f, // maximum animation scale |
| 3177 false); |
| 3178 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
| 3179 EXPECT_FLOAT_EQ(6.6f, |
| 3180 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 3181 |
| 3182 // If we change the device scale factor, then we should get new tilings. |
| 3183 SetupDrawPropertiesAndUpdateTiles(active_layer_, |
| 3184 7.26f, // ideal contents scale |
| 3185 3.3f, // device scale |
| 3186 2.2f, // page scale |
| 3187 1.f, // maximum animation scale |
| 3188 false); |
| 3189 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
| 3190 EXPECT_FLOAT_EQ(7.26f, |
| 3191 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 3192 |
| 3193 // If we change the device scale factor, but end up at the same total scale |
| 3194 // factor somehow, then we don't get new tilings. |
| 3195 SetupDrawPropertiesAndUpdateTiles(active_layer_, |
| 3196 7.26f, // ideal contents scale |
| 3197 2.2f, // device scale |
| 3198 3.3f, // page scale |
| 3199 1.f, // maximum animation scale |
| 3200 false); |
| 3201 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
| 3202 EXPECT_FLOAT_EQ(7.26f, |
| 3203 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 3204 } |
| 3205 |
| 3206 TEST_F(NoLowResPictureLayerImplTest, PendingLayerOnlyHasHighResTiling) { |
| 3207 gfx::Size tile_size(400, 400); |
| 3208 gfx::Size layer_bounds(1300, 1900); |
| 3209 |
| 3210 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 3211 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 3212 scoped_refptr<FakePicturePileImpl> active_pile = |
| 3213 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 3214 |
| 3215 SetupTrees(pending_pile, active_pile); |
| 3216 |
| 3217 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
| 3218 EXPECT_LT(low_res_factor, 1.f); |
| 3219 |
| 3220 ResetTilingsAndRasterScales(); |
| 3221 |
3287 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | 3222 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
3288 6.f, // ideal contents scale | 3223 6.f, // ideal contents scale |
3289 3.f, // device scale | 3224 3.f, // device scale |
3290 2.f, // page scale | 3225 2.f, // page scale |
3291 1.f, // maximum animation scale | 3226 1.f, // maximum animation scale |
3292 false); | 3227 false); |
3293 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 3228 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
3294 EXPECT_FLOAT_EQ(6.f, | 3229 EXPECT_FLOAT_EQ(6.f, |
3295 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 3230 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
3296 | 3231 |
3297 // If we change the page scale factor, then we should get new tilings. | 3232 // If we change the page scale factor, then we should get new tilings. |
3298 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | 3233 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
3299 6.6f, // ideal contents scale | 3234 6.6f, // ideal contents scale |
3300 3.f, // device scale | 3235 3.f, // device scale |
3301 2.2f, // page scale | 3236 2.2f, // page scale |
3302 1.f, // maximum animation scale | 3237 1.f, // maximum animation scale |
3303 false); | 3238 false); |
3304 ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); | 3239 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
3305 EXPECT_FLOAT_EQ(6.6f, | 3240 EXPECT_FLOAT_EQ(6.6f, |
3306 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 3241 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
3307 | 3242 |
3308 // If we change the device scale factor, then we should get new tilings. | 3243 // If we change the device scale factor, then we should get new tilings. |
3309 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | 3244 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
3310 7.26f, // ideal contents scale | 3245 7.26f, // ideal contents scale |
3311 3.3f, // device scale | 3246 3.3f, // device scale |
3312 2.2f, // page scale | 3247 2.2f, // page scale |
3313 1.f, // maximum animation scale | 3248 1.f, // maximum animation scale |
3314 false); | 3249 false); |
3315 ASSERT_EQ(3u, pending_layer_->tilings()->num_tilings()); | 3250 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
3316 EXPECT_FLOAT_EQ(7.26f, | 3251 EXPECT_FLOAT_EQ(7.26f, |
3317 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 3252 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
3318 | 3253 |
3319 // If we change the device scale factor, but end up at the same total scale | 3254 // If we change the device scale factor, but end up at the same total scale |
3320 // factor somehow, then we don't get new tilings. | 3255 // factor somehow, then we don't get new tilings. |
3321 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | 3256 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
3322 7.26f, // ideal contents scale | 3257 7.26f, // ideal contents scale |
3323 2.2f, // device scale | 3258 2.2f, // device scale |
3324 3.3f, // page scale | 3259 3.3f, // page scale |
3325 1.f, // maximum animation scale | 3260 1.f, // maximum animation scale |
3326 false); | 3261 false); |
3327 ASSERT_EQ(3u, pending_layer_->tilings()->num_tilings()); | 3262 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
3328 EXPECT_FLOAT_EQ(7.26f, | 3263 EXPECT_FLOAT_EQ(7.26f, |
3329 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | 3264 pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
3330 } | 3265 } |
3331 | 3266 |
3332 TEST_F(NoLowResPictureLayerImplTest, AllHighResRequiredEvenIfShared) { | 3267 TEST_F(NoLowResPictureLayerImplTest, AllHighResRequiredEvenIfShared) { |
3333 gfx::Size layer_bounds(400, 400); | 3268 gfx::Size layer_bounds(400, 400); |
3334 gfx::Size tile_size(100, 100); | 3269 gfx::Size tile_size(100, 100); |
3335 | 3270 |
3336 host_impl_.SetViewportSize(layer_bounds); | 3271 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
3337 | |
3338 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size); | |
3339 | |
3340 CreateHighLowResAndSetAllTilesVisible(); | |
3341 | 3272 |
3342 Tile* some_active_tile = | 3273 Tile* some_active_tile = |
3343 active_layer_->HighResTiling()->AllTilesForTesting()[0]; | 3274 active_layer_->HighResTiling()->AllTilesForTesting()[0]; |
3344 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); | 3275 EXPECT_FALSE(some_active_tile->IsReadyToDraw()); |
3345 | 3276 |
3346 // All tiles shared (no invalidation), so even though the active tree's | 3277 // All tiles shared (no invalidation), so even though the active tree's |
3347 // tiles aren't ready, there is nothing required. | 3278 // tiles aren't ready, there is nothing required. |
3348 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 3279 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
3349 if (host_impl_.settings().create_low_res_tiling) | 3280 if (host_impl_.settings().create_low_res_tiling) |
3350 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); | 3281 pending_layer_->LowResTiling()->UpdateAllTilePrioritiesForTesting(); |
3351 | 3282 |
3352 AssertAllTilesRequired(pending_layer_->HighResTiling()); | 3283 AssertAllTilesRequired(pending_layer_->HighResTiling()); |
3353 if (host_impl_.settings().create_low_res_tiling) | 3284 if (host_impl_.settings().create_low_res_tiling) |
3354 AssertNoTilesRequired(pending_layer_->LowResTiling()); | 3285 AssertNoTilesRequired(pending_layer_->LowResTiling()); |
3355 } | 3286 } |
3356 | 3287 |
3357 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { | 3288 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { |
3358 gfx::Size layer_bounds(400, 400); | 3289 gfx::Size layer_bounds(400, 400); |
3359 gfx::Size tile_size(100, 100); | 3290 gfx::Size tile_size(100, 100); |
| 3291 |
3360 scoped_refptr<FakePicturePileImpl> pending_pile = | 3292 scoped_refptr<FakePicturePileImpl> pending_pile = |
3361 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3293 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
3362 // This pile will create tilings, but has no recordings so will not create any | 3294 // This pile will create tilings, but has no recordings so will not create any |
3363 // tiles. This is attempting to simulate scrolling past the end of recorded | 3295 // tiles. This is attempting to simulate scrolling past the end of recorded |
3364 // content on the active layer, where the recordings are so far away that | 3296 // content on the active layer, where the recordings are so far away that |
3365 // no tiles are created. | 3297 // no tiles are created. |
3366 scoped_refptr<FakePicturePileImpl> active_pile = | 3298 scoped_refptr<FakePicturePileImpl> active_pile = |
3367 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( | 3299 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( |
3368 tile_size, layer_bounds); | 3300 tile_size, layer_bounds); |
3369 SetupTrees(pending_pile, active_pile); | |
3370 pending_layer_->set_fixed_tile_size(tile_size); | |
3371 active_layer_->set_fixed_tile_size(tile_size); | |
3372 | 3301 |
3373 CreateHighLowResAndSetAllTilesVisible(); | 3302 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); |
3374 | 3303 |
3375 // Active layer has tilings, but no tiles due to missing recordings. | 3304 // Active layer has tilings, but no tiles due to missing recordings. |
3376 EXPECT_TRUE(active_layer_->CanHaveTilings()); | 3305 EXPECT_TRUE(active_layer_->CanHaveTilings()); |
3377 EXPECT_EQ(active_layer_->tilings()->num_tilings(), | 3306 EXPECT_EQ(active_layer_->tilings()->num_tilings(), |
3378 host_impl_.settings().create_low_res_tiling ? 2u : 1u); | 3307 host_impl_.settings().create_low_res_tiling ? 2u : 1u); |
3379 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); | 3308 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); |
3380 | 3309 |
3381 // Since the active layer has no tiles at all, the pending layer doesn't | 3310 // Since the active layer has no tiles at all, the pending layer doesn't |
3382 // need content in order to activate. | 3311 // need content in order to activate. |
3383 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); | 3312 pending_layer_->HighResTiling()->UpdateAllTilePrioritiesForTesting(); |
(...skipping 12 matching lines...) Expand all Loading... |
3396 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 3325 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
3397 | 3326 |
3398 gfx::Size tile_size(100, 100); | 3327 gfx::Size tile_size(100, 100); |
3399 gfx::Size layer_bounds(400, 400); | 3328 gfx::Size layer_bounds(400, 400); |
3400 | 3329 |
3401 scoped_refptr<FakePicturePileImpl> pending_pile = | 3330 scoped_refptr<FakePicturePileImpl> pending_pile = |
3402 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3331 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
3403 scoped_refptr<FakePicturePileImpl> active_pile = | 3332 scoped_refptr<FakePicturePileImpl> active_pile = |
3404 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3333 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
3405 | 3334 |
3406 SetupTrees(pending_pile, active_pile); | 3335 SetupTreesWithInvalidation(pending_pile, active_pile, Region()); |
3407 | 3336 |
3408 Region invalidation; | |
3409 AddDefaultTilingsWithInvalidation(invalidation); | |
3410 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false); | 3337 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false); |
3411 | 3338 |
3412 // UpdateTiles with valid viewport. Should update tile viewport. | 3339 // UpdateTiles with valid viewport. Should update tile viewport. |
3413 // Note viewport is considered invalid if and only if in resourceless | 3340 // Note viewport is considered invalid if and only if in resourceless |
3414 // software draw. | 3341 // software draw. |
3415 bool resourceless_software_draw = false; | 3342 bool resourceless_software_draw = false; |
3416 gfx::Rect viewport = gfx::Rect(layer_bounds); | 3343 gfx::Rect viewport = gfx::Rect(layer_bounds); |
3417 gfx::Transform transform; | 3344 gfx::Transform transform; |
3418 host_impl_.SetExternalDrawConstraints(transform, | 3345 host_impl_.SetExternalDrawConstraints(transform, |
3419 viewport, | 3346 viewport, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3479 gfx::Size layer_bounds(1300, 1900); | 3406 gfx::Size layer_bounds(1300, 1900); |
3480 | 3407 |
3481 scoped_refptr<FakePicturePileImpl> pending_pile = | 3408 scoped_refptr<FakePicturePileImpl> pending_pile = |
3482 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3409 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
3483 scoped_refptr<FakePicturePileImpl> active_pile = | 3410 scoped_refptr<FakePicturePileImpl> active_pile = |
3484 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3411 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
3485 | 3412 |
3486 std::vector<PictureLayerTiling*> used_tilings; | 3413 std::vector<PictureLayerTiling*> used_tilings; |
3487 | 3414 |
3488 SetupTrees(pending_pile, active_pile); | 3415 SetupTrees(pending_pile, active_pile); |
3489 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | |
3490 | 3416 |
3491 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 3417 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
3492 EXPECT_LT(low_res_factor, 1.f); | 3418 EXPECT_LT(low_res_factor, 1.f); |
3493 | 3419 |
3494 float device_scale = 1.7f; | 3420 float device_scale = 1.7f; |
3495 float page_scale = 3.2f; | 3421 float page_scale = 3.2f; |
3496 float scale = 1.f; | 3422 float scale = 1.f; |
3497 | 3423 |
| 3424 ResetTilingsAndRasterScales(); |
| 3425 |
3498 SetContentsScaleOnBothLayers(scale, device_scale, page_scale, 1.f, false); | 3426 SetContentsScaleOnBothLayers(scale, device_scale, page_scale, 1.f, false); |
3499 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); | 3427 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); |
3500 | 3428 |
3501 // We only have ideal tilings, so they aren't removed. | 3429 // We only have ideal tilings, so they aren't removed. |
3502 used_tilings.clear(); | 3430 used_tilings.clear(); |
3503 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 3431 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
3504 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); | 3432 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); |
3505 | 3433 |
3506 host_impl_.PinchGestureBegin(); | 3434 host_impl_.PinchGestureBegin(); |
3507 | 3435 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3573 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 3501 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
3574 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); | 3502 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
3575 | 3503 |
3576 // If we remove it from our used tilings set, it is outside the range to keep | 3504 // If we remove it from our used tilings set, it is outside the range to keep |
3577 // so it is deleted. | 3505 // so it is deleted. |
3578 used_tilings.clear(); | 3506 used_tilings.clear(); |
3579 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | 3507 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); |
3580 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); | 3508 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); |
3581 } | 3509 } |
3582 | 3510 |
3583 TEST_F(PictureLayerImplTest, ScaleCollision) { | |
3584 gfx::Size tile_size(400, 400); | |
3585 gfx::Size layer_bounds(1300, 1900); | |
3586 | |
3587 scoped_refptr<FakePicturePileImpl> pending_pile = | |
3588 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | |
3589 scoped_refptr<FakePicturePileImpl> active_pile = | |
3590 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | |
3591 | |
3592 std::vector<PictureLayerTiling*> used_tilings; | |
3593 | |
3594 SetupTrees(pending_pile, active_pile); | |
3595 | |
3596 float pending_contents_scale = 1.f; | |
3597 float active_contents_scale = 2.f; | |
3598 float device_scale_factor = 1.f; | |
3599 float page_scale_factor = 1.f; | |
3600 float maximum_animation_contents_scale = 1.f; | |
3601 bool animating_transform = false; | |
3602 | |
3603 EXPECT_TRUE(host_impl_.settings().create_low_res_tiling); | |
3604 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | |
3605 EXPECT_LT(low_res_factor, 1.f); | |
3606 | |
3607 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | |
3608 pending_contents_scale, | |
3609 device_scale_factor, | |
3610 page_scale_factor, | |
3611 maximum_animation_contents_scale, | |
3612 animating_transform); | |
3613 SetupDrawPropertiesAndUpdateTiles(active_layer_, | |
3614 active_contents_scale, | |
3615 device_scale_factor, | |
3616 page_scale_factor, | |
3617 maximum_animation_contents_scale, | |
3618 animating_transform); | |
3619 | |
3620 ASSERT_EQ(4u, pending_layer_->tilings()->num_tilings()); | |
3621 ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); | |
3622 | |
3623 EXPECT_EQ(active_contents_scale, | |
3624 pending_layer_->tilings()->tiling_at(0)->contents_scale()); | |
3625 EXPECT_EQ(pending_contents_scale, | |
3626 pending_layer_->tilings()->tiling_at(1)->contents_scale()); | |
3627 EXPECT_EQ(active_contents_scale * low_res_factor, | |
3628 pending_layer_->tilings()->tiling_at(2)->contents_scale()); | |
3629 EXPECT_EQ(pending_contents_scale * low_res_factor, | |
3630 pending_layer_->tilings()->tiling_at(3)->contents_scale()); | |
3631 | |
3632 EXPECT_EQ(active_contents_scale, | |
3633 active_layer_->tilings()->tiling_at(0)->contents_scale()); | |
3634 EXPECT_EQ(pending_contents_scale, | |
3635 active_layer_->tilings()->tiling_at(1)->contents_scale()); | |
3636 EXPECT_EQ(active_contents_scale * low_res_factor, | |
3637 active_layer_->tilings()->tiling_at(2)->contents_scale()); | |
3638 EXPECT_EQ(pending_contents_scale * low_res_factor, | |
3639 active_layer_->tilings()->tiling_at(3)->contents_scale()); | |
3640 | |
3641 // The unused low res tiling from the pending tree must be kept or we may add | |
3642 // it again on the active tree and collide with the pending tree. | |
3643 used_tilings.push_back(active_layer_->tilings()->tiling_at(1)); | |
3644 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); | |
3645 ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); | |
3646 | |
3647 EXPECT_EQ(active_contents_scale, | |
3648 active_layer_->tilings()->tiling_at(0)->contents_scale()); | |
3649 EXPECT_EQ(pending_contents_scale, | |
3650 active_layer_->tilings()->tiling_at(1)->contents_scale()); | |
3651 EXPECT_EQ(active_contents_scale * low_res_factor, | |
3652 active_layer_->tilings()->tiling_at(2)->contents_scale()); | |
3653 EXPECT_EQ(pending_contents_scale * low_res_factor, | |
3654 active_layer_->tilings()->tiling_at(3)->contents_scale()); | |
3655 } | |
3656 | |
3657 TEST_F(NoLowResPictureLayerImplTest, ReleaseResources) { | 3511 TEST_F(NoLowResPictureLayerImplTest, ReleaseResources) { |
3658 gfx::Size tile_size(400, 400); | 3512 gfx::Size tile_size(400, 400); |
3659 gfx::Size layer_bounds(1300, 1900); | 3513 gfx::Size layer_bounds(1300, 1900); |
3660 | 3514 |
3661 scoped_refptr<FakePicturePileImpl> pending_pile = | 3515 scoped_refptr<FakePicturePileImpl> pending_pile = |
3662 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3516 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
3663 scoped_refptr<FakePicturePileImpl> active_pile = | 3517 scoped_refptr<FakePicturePileImpl> active_pile = |
3664 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3518 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
3665 | 3519 |
3666 SetupTrees(pending_pile, active_pile); | 3520 SetupTrees(pending_pile, active_pile); |
3667 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | |
3668 | |
3669 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | |
3670 1.3f, // ideal contents scale | |
3671 2.7f, // device scale | |
3672 3.2f, // page scale | |
3673 1.f, // maximum animation scale | |
3674 false); | |
3675 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 3521 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
| 3522 EXPECT_EQ(1u, active_layer_->tilings()->num_tilings()); |
3676 | 3523 |
3677 // All tilings should be removed when losing output surface. | 3524 // All tilings should be removed when losing output surface. |
3678 active_layer_->ReleaseResources(); | 3525 active_layer_->ReleaseResources(); |
3679 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 3526 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
3680 pending_layer_->ReleaseResources(); | 3527 pending_layer_->ReleaseResources(); |
3681 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); | 3528 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
3682 | 3529 |
3683 // This should create new tilings. | 3530 // This should create new tilings. |
3684 SetupDrawPropertiesAndUpdateTiles(pending_layer_, | 3531 SetupDrawPropertiesAndUpdateTiles(pending_layer_, |
3685 1.3f, // ideal contents scale | 3532 1.3f, // ideal contents scale |
3686 2.7f, // device scale | 3533 2.7f, // device scale |
3687 3.2f, // page scale | 3534 3.2f, // page scale |
3688 1.f, // maximum animation scale | 3535 1.f, // maximum animation scale |
3689 false); | 3536 false); |
3690 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); | 3537 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
3691 } | 3538 } |
3692 | 3539 |
3693 TEST_F(PictureLayerImplTest, SharedQuadStateContainsMaxTilingScale) { | 3540 TEST_F(PictureLayerImplTest, SharedQuadStateContainsMaxTilingScale) { |
3694 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 3541 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
3695 | 3542 |
3696 gfx::Size tile_size(400, 400); | 3543 gfx::Size tile_size(400, 400); |
3697 gfx::Size layer_bounds(1000, 2000); | 3544 gfx::Size layer_bounds(1000, 2000); |
3698 | 3545 |
3699 host_impl_.SetViewportSize(layer_bounds); | 3546 host_impl_.SetViewportSize(gfx::Size(10000, 20000)); |
3700 | 3547 |
3701 scoped_refptr<FakePicturePileImpl> pending_pile = | 3548 scoped_refptr<FakePicturePileImpl> pending_pile = |
3702 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3549 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
3703 scoped_refptr<FakePicturePileImpl> active_pile = | 3550 scoped_refptr<FakePicturePileImpl> active_pile = |
3704 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3551 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
3705 | 3552 |
3706 SetupTrees(pending_pile, active_pile); | 3553 SetupTrees(pending_pile, active_pile); |
3707 | 3554 |
3708 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 2.5f, 1.f, 1.f, 1.f, false); | 3555 ResetTilingsAndRasterScales(); |
3709 host_impl_.pending_tree()->UpdateDrawProperties(); | 3556 SetupDrawPropertiesAndUpdateTiles(active_layer_, 2.5f, 1.f, 1.f, 1.f, false); |
3710 | |
3711 active_layer_->draw_properties().visible_content_rect = | |
3712 gfx::Rect(layer_bounds); | |
3713 host_impl_.active_tree()->UpdateDrawProperties(); | |
3714 | 3557 |
3715 float max_contents_scale = active_layer_->MaximumTilingContentsScale(); | 3558 float max_contents_scale = active_layer_->MaximumTilingContentsScale(); |
| 3559 EXPECT_EQ(2.5f, max_contents_scale); |
| 3560 |
3716 gfx::Transform scaled_draw_transform = active_layer_->draw_transform(); | 3561 gfx::Transform scaled_draw_transform = active_layer_->draw_transform(); |
3717 scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale, | 3562 scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale, |
3718 SK_MScalar1 / max_contents_scale); | 3563 SK_MScalar1 / max_contents_scale); |
3719 | 3564 |
3720 AppendQuadsData data; | 3565 AppendQuadsData data; |
3721 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); | 3566 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); |
3722 | 3567 |
3723 // SharedQuadState should have be of size 1, as we are doing AppenQuad once. | 3568 // SharedQuadState should have be of size 1, as we are doing AppenQuad once. |
3724 EXPECT_EQ(1u, render_pass->shared_quad_state_list.size()); | 3569 EXPECT_EQ(1u, render_pass->shared_quad_state_list.size()); |
3725 // The content_to_target_transform should be scaled by the | 3570 // The content_to_target_transform should be scaled by the |
(...skipping 16 matching lines...) Expand all Loading... |
3742 TEST_F(PictureLayerImplTest, UpdateTilesForMasksWithNoVisibleContent) { | 3587 TEST_F(PictureLayerImplTest, UpdateTilesForMasksWithNoVisibleContent) { |
3743 gfx::Size tile_size(400, 400); | 3588 gfx::Size tile_size(400, 400); |
3744 gfx::Size bounds(100000, 100); | 3589 gfx::Size bounds(100000, 100); |
3745 | 3590 |
3746 host_impl_.CreatePendingTree(); | 3591 host_impl_.CreatePendingTree(); |
3747 | 3592 |
3748 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_.pending_tree(), 1); | 3593 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_.pending_tree(), 1); |
3749 | 3594 |
3750 scoped_ptr<FakePictureLayerImpl> layer_with_mask = | 3595 scoped_ptr<FakePictureLayerImpl> layer_with_mask = |
3751 FakePictureLayerImpl::Create(host_impl_.pending_tree(), 2); | 3596 FakePictureLayerImpl::Create(host_impl_.pending_tree(), 2); |
3752 | |
3753 layer_with_mask->SetBounds(bounds); | 3597 layer_with_mask->SetBounds(bounds); |
3754 layer_with_mask->SetContentBounds(bounds); | 3598 layer_with_mask->SetContentBounds(bounds); |
3755 | 3599 |
3756 scoped_refptr<FakePicturePileImpl> pending_pile = | 3600 scoped_refptr<FakePicturePileImpl> pending_pile = |
3757 FakePicturePileImpl::CreateFilledPile(tile_size, bounds); | 3601 FakePicturePileImpl::CreateFilledPile(tile_size, bounds); |
3758 scoped_ptr<FakePictureLayerImpl> mask = | 3602 scoped_ptr<FakePictureLayerImpl> mask = |
3759 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 3, | 3603 FakePictureLayerImpl::CreateMaskWithRasterSource( |
3760 pending_pile); | 3604 host_impl_.pending_tree(), 3, pending_pile); |
3761 mask->set_is_mask(true); | |
3762 | |
3763 mask->SetBounds(bounds); | 3605 mask->SetBounds(bounds); |
3764 mask->SetContentBounds(bounds); | 3606 mask->SetContentBounds(bounds); |
3765 mask->SetDrawsContent(true); | 3607 mask->SetDrawsContent(true); |
| 3608 layer_with_mask->SetMaskLayer(mask.Pass()); |
3766 | 3609 |
3767 FakePictureLayerImpl* pending_mask_content = mask.get(); | 3610 FakePictureLayerImpl* pending_mask = |
3768 layer_with_mask->SetMaskLayer(mask.Pass()); | 3611 static_cast<FakePictureLayerImpl*>(layer_with_mask->mask_layer()); |
3769 | 3612 |
3770 scoped_ptr<FakePictureLayerImpl> child_of_layer_with_mask = | 3613 scoped_ptr<FakePictureLayerImpl> child_of_layer_with_mask = |
3771 FakePictureLayerImpl::Create(host_impl_.pending_tree(), 4); | 3614 FakePictureLayerImpl::Create(host_impl_.pending_tree(), 4); |
3772 | |
3773 child_of_layer_with_mask->SetBounds(bounds); | 3615 child_of_layer_with_mask->SetBounds(bounds); |
3774 child_of_layer_with_mask->SetContentBounds(bounds); | 3616 child_of_layer_with_mask->SetContentBounds(bounds); |
3775 child_of_layer_with_mask->SetDrawsContent(true); | 3617 child_of_layer_with_mask->SetDrawsContent(true); |
3776 | |
3777 layer_with_mask->AddChild(child_of_layer_with_mask.Pass()); | 3618 layer_with_mask->AddChild(child_of_layer_with_mask.Pass()); |
3778 | |
3779 root->AddChild(layer_with_mask.Pass()); | 3619 root->AddChild(layer_with_mask.Pass()); |
3780 | 3620 |
3781 host_impl_.pending_tree()->SetRootLayer(root.Pass()); | 3621 host_impl_.pending_tree()->SetRootLayer(root.Pass()); |
3782 | 3622 |
3783 EXPECT_FALSE(pending_mask_content->tilings()); | 3623 EXPECT_EQ(0u, pending_mask->num_tilings()); |
3784 host_impl_.pending_tree()->UpdateDrawProperties(); | 3624 host_impl_.pending_tree()->UpdateDrawProperties(); |
3785 EXPECT_NE(0u, pending_mask_content->num_tilings()); | 3625 EXPECT_NE(0u, pending_mask->num_tilings()); |
3786 } | 3626 } |
3787 | 3627 |
3788 class PictureLayerImplTestWithDelegatingRenderer : public PictureLayerImplTest { | 3628 class PictureLayerImplTestWithDelegatingRenderer : public PictureLayerImplTest { |
3789 public: | 3629 public: |
3790 PictureLayerImplTestWithDelegatingRenderer() : PictureLayerImplTest() {} | 3630 PictureLayerImplTestWithDelegatingRenderer() : PictureLayerImplTest() {} |
3791 | 3631 |
3792 void InitializeRenderer() override { | 3632 void InitializeRenderer() override { |
3793 host_impl_.InitializeRenderer(FakeOutputSurface::CreateDelegating3d()); | 3633 host_impl_.InitializeRenderer(FakeOutputSurface::CreateDelegating3d()); |
3794 } | 3634 } |
3795 }; | 3635 }; |
3796 | 3636 |
3797 TEST_F(PictureLayerImplTestWithDelegatingRenderer, | 3637 TEST_F(PictureLayerImplTestWithDelegatingRenderer, |
3798 DelegatingRendererWithTileOOM) { | 3638 DelegatingRendererWithTileOOM) { |
3799 // This test is added for crbug.com/402321, where quad should be produced when | 3639 // This test is added for crbug.com/402321, where quad should be produced when |
3800 // raster on demand is not allowed and tile is OOM. | 3640 // raster on demand is not allowed and tile is OOM. |
3801 gfx::Size tile_size = host_impl_.settings().default_tile_size; | 3641 gfx::Size tile_size = host_impl_.settings().default_tile_size; |
3802 gfx::Size layer_bounds(1000, 1000); | 3642 gfx::Size layer_bounds(1000, 1000); |
3803 | 3643 |
3804 // Create tiles. | 3644 // Create tiles. |
3805 scoped_refptr<FakePicturePileImpl> pending_pile = | 3645 scoped_refptr<FakePicturePileImpl> pending_pile = |
3806 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3646 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
3807 SetupPendingTree(pending_pile); | 3647 SetupPendingTree(pending_pile); |
3808 pending_layer_->SetBounds(layer_bounds); | 3648 pending_layer_->SetBounds(layer_bounds); |
3809 host_impl_.SetViewportSize(layer_bounds); | |
3810 ActivateTree(); | 3649 ActivateTree(); |
3811 host_impl_.active_tree()->UpdateDrawProperties(); | 3650 host_impl_.active_tree()->UpdateDrawProperties(); |
3812 std::vector<Tile*> tiles = | 3651 std::vector<Tile*> tiles = |
3813 active_layer_->HighResTiling()->AllTilesForTesting(); | 3652 active_layer_->HighResTiling()->AllTilesForTesting(); |
3814 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); | 3653 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); |
3815 | 3654 |
3816 // Force tiles after max_tiles to be OOM. TileManager uses | 3655 // Force tiles after max_tiles to be OOM. TileManager uses |
3817 // GlobalStateThatImpactsTilesPriority from LayerTreeHostImpl, and we cannot | 3656 // GlobalStateThatImpactsTilesPriority from LayerTreeHostImpl, and we cannot |
3818 // directly set state to host_impl_, so we set policy that would change the | 3657 // directly set state to host_impl_, so we set policy that would change the |
3819 // state. We also need to update tree priority separately. | 3658 // state. We also need to update tree priority separately. |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3906 base::TimeTicks time_ticks; | 3745 base::TimeTicks time_ticks; |
3907 time_ticks += base::TimeDelta::FromMilliseconds(1); | 3746 time_ticks += base::TimeDelta::FromMilliseconds(1); |
3908 host_impl_.SetCurrentBeginFrameArgs( | 3747 host_impl_.SetCurrentBeginFrameArgs( |
3909 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 3748 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
3910 | 3749 |
3911 gfx::Size tile_size(102, 102); | 3750 gfx::Size tile_size(102, 102); |
3912 gfx::Size layer_bounds(1000, 1000); | 3751 gfx::Size layer_bounds(1000, 1000); |
3913 gfx::Size viewport_size(500, 500); | 3752 gfx::Size viewport_size(500, 500); |
3914 gfx::Point occluding_layer_position(310, 0); | 3753 gfx::Point occluding_layer_position(310, 0); |
3915 | 3754 |
| 3755 host_impl_.SetViewportSize(viewport_size); |
| 3756 |
3916 scoped_refptr<FakePicturePileImpl> pending_pile = | 3757 scoped_refptr<FakePicturePileImpl> pending_pile = |
3917 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3758 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
3918 SetupPendingTree(pending_pile); | 3759 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); |
3919 pending_layer_->set_fixed_tile_size(tile_size); | |
3920 | |
3921 host_impl_.SetViewportSize(viewport_size); | |
3922 host_impl_.pending_tree()->UpdateDrawProperties(); | |
3923 | 3760 |
3924 // No occlusion. | 3761 // No occlusion. |
3925 int unoccluded_tile_count = 0; | 3762 int unoccluded_tile_count = 0; |
3926 for (PictureLayerImpl::LayerRasterTileIterator it = | 3763 for (PictureLayerImpl::LayerRasterTileIterator it = |
3927 PictureLayerImpl::LayerRasterTileIterator(pending_layer_, false); | 3764 PictureLayerImpl::LayerRasterTileIterator(pending_layer_, false); |
3928 it; | 3765 it; |
3929 ++it) { | 3766 ++it) { |
3930 Tile* tile = *it; | 3767 Tile* tile = *it; |
3931 | 3768 |
3932 // Occluded tiles should not be iterated over. | 3769 // Occluded tiles should not be iterated over. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4001 base::TimeTicks time_ticks; | 3838 base::TimeTicks time_ticks; |
4002 time_ticks += base::TimeDelta::FromMilliseconds(1); | 3839 time_ticks += base::TimeDelta::FromMilliseconds(1); |
4003 host_impl_.SetCurrentBeginFrameArgs( | 3840 host_impl_.SetCurrentBeginFrameArgs( |
4004 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 3841 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
4005 | 3842 |
4006 gfx::Size tile_size(102, 102); | 3843 gfx::Size tile_size(102, 102); |
4007 gfx::Size layer_bounds(1000, 1000); | 3844 gfx::Size layer_bounds(1000, 1000); |
4008 gfx::Size viewport_size(500, 500); | 3845 gfx::Size viewport_size(500, 500); |
4009 gfx::Point occluding_layer_position(310, 0); | 3846 gfx::Point occluding_layer_position(310, 0); |
4010 | 3847 |
| 3848 host_impl_.SetViewportSize(viewport_size); |
| 3849 |
4011 scoped_refptr<FakePicturePileImpl> pending_pile = | 3850 scoped_refptr<FakePicturePileImpl> pending_pile = |
4012 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3851 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
4013 SetupPendingTree(pending_pile); | 3852 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); |
4014 pending_layer_->set_fixed_tile_size(tile_size); | |
4015 | |
4016 host_impl_.SetViewportSize(viewport_size); | |
4017 host_impl_.pending_tree()->UpdateDrawProperties(); | |
4018 | 3853 |
4019 // No occlusion. | 3854 // No occlusion. |
4020 int occluded_tile_count = 0; | 3855 int occluded_tile_count = 0; |
4021 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 3856 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
4022 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 3857 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
4023 | 3858 |
4024 occluded_tile_count = 0; | 3859 occluded_tile_count = 0; |
4025 for (PictureLayerTiling::CoverageIterator iter( | 3860 for (PictureLayerTiling::CoverageIterator iter( |
4026 tiling, | 3861 tiling, |
4027 pending_layer_->contents_scale_x(), | 3862 pending_layer_->contents_scale_x(), |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4122 case 1: | 3957 case 1: |
4123 EXPECT_EQ(4, occluded_tile_count); | 3958 EXPECT_EQ(4, occluded_tile_count); |
4124 break; | 3959 break; |
4125 default: | 3960 default: |
4126 NOTREACHED(); | 3961 NOTREACHED(); |
4127 } | 3962 } |
4128 } | 3963 } |
4129 } | 3964 } |
4130 | 3965 |
4131 TEST_F(OcclusionTrackingPictureLayerImplTest, OcclusionForDifferentScales) { | 3966 TEST_F(OcclusionTrackingPictureLayerImplTest, OcclusionForDifferentScales) { |
| 3967 base::TimeTicks time_ticks; |
| 3968 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 3969 host_impl_.SetCurrentBeginFrameArgs( |
| 3970 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 3971 |
4132 gfx::Size tile_size(102, 102); | 3972 gfx::Size tile_size(102, 102); |
4133 gfx::Size layer_bounds(1000, 1000); | 3973 gfx::Size layer_bounds(1000, 1000); |
4134 gfx::Size viewport_size(500, 500); | 3974 gfx::Size viewport_size(500, 500); |
4135 gfx::Point occluding_layer_position(310, 0); | 3975 gfx::Point occluding_layer_position(310, 0); |
4136 | 3976 |
4137 scoped_refptr<FakePicturePileImpl> pending_pile = | 3977 scoped_refptr<FakePicturePileImpl> pending_pile = |
4138 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3978 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
4139 SetupPendingTree(pending_pile); | |
4140 pending_layer_->set_fixed_tile_size(tile_size); | |
4141 | 3979 |
| 3980 host_impl_.SetViewportSize(viewport_size); |
| 3981 |
| 3982 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); |
4142 ASSERT_TRUE(pending_layer_->CanHaveTilings()); | 3983 ASSERT_TRUE(pending_layer_->CanHaveTilings()); |
4143 | 3984 |
4144 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | |
4145 | |
4146 std::vector<PictureLayerTiling*> tilings; | |
4147 tilings.push_back(pending_layer_->AddTiling(low_res_factor)); | |
4148 tilings.push_back(pending_layer_->AddTiling(0.3f)); | |
4149 tilings.push_back(pending_layer_->AddTiling(0.7f)); | |
4150 tilings.push_back(pending_layer_->AddTiling(1.0f)); | |
4151 tilings.push_back(pending_layer_->AddTiling(2.0f)); | |
4152 | |
4153 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); | 3985 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); |
4154 LayerImpl* layer1 = pending_layer_->children()[0]; | 3986 LayerImpl* layer1 = pending_layer_->children()[0]; |
4155 layer1->SetBounds(layer_bounds); | 3987 layer1->SetBounds(layer_bounds); |
4156 layer1->SetContentBounds(layer_bounds); | 3988 layer1->SetContentBounds(layer_bounds); |
4157 layer1->SetDrawsContent(true); | 3989 layer1->SetDrawsContent(true); |
4158 layer1->SetContentsOpaque(true); | 3990 layer1->SetContentsOpaque(true); |
4159 layer1->SetPosition(occluding_layer_position); | 3991 layer1->SetPosition(occluding_layer_position); |
4160 | 3992 |
4161 host_impl_.SetViewportSize(viewport_size); | 3993 pending_layer_->tilings()->RemoveAllTilings(); |
| 3994 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
| 3995 pending_layer_->AddTiling(low_res_factor); |
| 3996 pending_layer_->AddTiling(0.3f); |
| 3997 pending_layer_->AddTiling(0.7f); |
| 3998 pending_layer_->AddTiling(1.0f); |
| 3999 pending_layer_->AddTiling(2.0f); |
| 4000 |
| 4001 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 4002 host_impl_.SetCurrentBeginFrameArgs( |
| 4003 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 4004 // UpdateDrawProperties with the occluding layer. |
4162 host_impl_.pending_tree()->UpdateDrawProperties(); | 4005 host_impl_.pending_tree()->UpdateDrawProperties(); |
4163 | 4006 |
4164 int tiling_count = 0; | 4007 EXPECT_EQ(5u, pending_layer_->num_tilings()); |
| 4008 |
4165 int occluded_tile_count = 0; | 4009 int occluded_tile_count = 0; |
4166 for (std::vector<PictureLayerTiling*>::iterator tiling_iterator = | 4010 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
4167 tilings.begin(); | 4011 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
4168 tiling_iterator != tilings.end(); | 4012 tiling->UpdateAllTilePrioritiesForTesting(); |
4169 ++tiling_iterator) { | 4013 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
4170 (*tiling_iterator)->UpdateAllTilePrioritiesForTesting(); | |
4171 std::vector<Tile*> tiles = (*tiling_iterator)->AllTilesForTesting(); | |
4172 | 4014 |
4173 occluded_tile_count = 0; | 4015 occluded_tile_count = 0; |
4174 for (size_t i = 0; i < tiles.size(); ++i) { | 4016 for (size_t j = 0; j < tiles.size(); ++j) { |
4175 if (tiles[i]->is_occluded(PENDING_TREE)) { | 4017 if (tiles[j]->is_occluded(PENDING_TREE)) { |
4176 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( | 4018 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( |
4177 tiles[i]->content_rect(), 1.0f / tiles[i]->contents_scale()); | 4019 tiles[j]->content_rect(), 1.0f / tiles[j]->contents_scale()); |
4178 EXPECT_GE(scaled_content_rect.x(), occluding_layer_position.x()); | 4020 EXPECT_GE(scaled_content_rect.x(), occluding_layer_position.x()); |
4179 occluded_tile_count++; | 4021 occluded_tile_count++; |
4180 } | 4022 } |
4181 } | 4023 } |
4182 switch (tiling_count) { | 4024 |
| 4025 switch (i) { |
4183 case 0: | 4026 case 0: |
| 4027 EXPECT_EQ(occluded_tile_count, 30); |
| 4028 break; |
4184 case 1: | 4029 case 1: |
4185 EXPECT_EQ(occluded_tile_count, 2); | 4030 EXPECT_EQ(occluded_tile_count, 5); |
4186 break; | 4031 break; |
4187 case 2: | 4032 case 2: |
4188 EXPECT_EQ(occluded_tile_count, 4); | 4033 EXPECT_EQ(occluded_tile_count, 4); |
4189 break; | 4034 break; |
| 4035 case 4: |
4190 case 3: | 4036 case 3: |
4191 EXPECT_EQ(occluded_tile_count, 5); | 4037 EXPECT_EQ(occluded_tile_count, 2); |
4192 break; | |
4193 case 4: | |
4194 EXPECT_EQ(occluded_tile_count, 30); | |
4195 break; | 4038 break; |
4196 default: | 4039 default: |
4197 NOTREACHED(); | 4040 NOTREACHED(); |
4198 } | 4041 } |
4199 | |
4200 tiling_count++; | |
4201 } | 4042 } |
4202 | |
4203 EXPECT_EQ(tiling_count, 5); | |
4204 } | 4043 } |
4205 | 4044 |
4206 TEST_F(OcclusionTrackingPictureLayerImplTest, DifferentOcclusionOnTrees) { | 4045 TEST_F(OcclusionTrackingPictureLayerImplTest, DifferentOcclusionOnTrees) { |
4207 gfx::Size tile_size(102, 102); | 4046 gfx::Size tile_size(102, 102); |
4208 gfx::Size layer_bounds(1000, 1000); | 4047 gfx::Size layer_bounds(1000, 1000); |
4209 gfx::Size viewport_size(1000, 1000); | 4048 gfx::Size viewport_size(1000, 1000); |
4210 gfx::Point occluding_layer_position(310, 0); | 4049 gfx::Point occluding_layer_position(310, 0); |
4211 gfx::Rect invalidation_rect(230, 230, 102, 102); | 4050 gfx::Rect invalidation_rect(230, 230, 102, 102); |
4212 | 4051 |
4213 scoped_refptr<FakePicturePileImpl> pending_pile = | 4052 scoped_refptr<FakePicturePileImpl> pending_pile = |
4214 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 4053 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
4215 scoped_refptr<FakePicturePileImpl> active_pile = | 4054 scoped_refptr<FakePicturePileImpl> active_pile = |
4216 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 4055 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
4217 SetupTrees(pending_pile, active_pile); | 4056 |
| 4057 host_impl_.SetViewportSize(viewport_size); |
| 4058 SetupPendingTree(active_pile); |
4218 | 4059 |
4219 // Partially occlude the active layer. | 4060 // Partially occlude the active layer. |
4220 active_layer_->AddChild(LayerImpl::Create(host_impl_.active_tree(), 2)); | 4061 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 2)); |
4221 LayerImpl* layer1 = active_layer_->children()[0]; | 4062 LayerImpl* layer1 = pending_layer_->children()[0]; |
4222 layer1->SetBounds(layer_bounds); | 4063 layer1->SetBounds(layer_bounds); |
4223 layer1->SetContentBounds(layer_bounds); | 4064 layer1->SetContentBounds(layer_bounds); |
4224 layer1->SetDrawsContent(true); | 4065 layer1->SetDrawsContent(true); |
4225 layer1->SetContentsOpaque(true); | 4066 layer1->SetContentsOpaque(true); |
4226 layer1->SetPosition(occluding_layer_position); | 4067 layer1->SetPosition(occluding_layer_position); |
4227 | 4068 |
| 4069 ActivateTree(); |
| 4070 |
4228 // Partially invalidate the pending layer. | 4071 // Partially invalidate the pending layer. |
4229 pending_layer_->set_invalidation(invalidation_rect); | 4072 SetupPendingTreeWithInvalidation(pending_pile, invalidation_rect); |
4230 | |
4231 host_impl_.SetViewportSize(viewport_size); | |
4232 | |
4233 active_layer_->CreateDefaultTilingsAndTiles(); | |
4234 pending_layer_->CreateDefaultTilingsAndTiles(); | |
4235 | 4073 |
4236 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 4074 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
4237 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 4075 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
4238 tiling->UpdateAllTilePrioritiesForTesting(); | 4076 tiling->UpdateAllTilePrioritiesForTesting(); |
4239 | 4077 |
4240 for (PictureLayerTiling::CoverageIterator iter( | 4078 for (PictureLayerTiling::CoverageIterator iter( |
4241 tiling, | 4079 tiling, |
4242 pending_layer_->contents_scale_x(), | 4080 pending_layer_->contents_scale_x(), |
4243 gfx::Rect(layer_bounds)); | 4081 gfx::Rect(layer_bounds)); |
4244 iter; | 4082 iter; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4303 // the occluding layer. | 4141 // the occluding layer. |
4304 EXPECT_EQ(tile->is_occluded(ACTIVE_TREE), | 4142 EXPECT_EQ(tile->is_occluded(ACTIVE_TREE), |
4305 scaled_content_rect.x() >= occluding_layer_position.x()); | 4143 scaled_content_rect.x() >= occluding_layer_position.x()); |
4306 } | 4144 } |
4307 } | 4145 } |
4308 } | 4146 } |
4309 } | 4147 } |
4310 | 4148 |
4311 TEST_F(OcclusionTrackingPictureLayerImplTest, | 4149 TEST_F(OcclusionTrackingPictureLayerImplTest, |
4312 OccludedTilesConsideredDuringEviction) { | 4150 OccludedTilesConsideredDuringEviction) { |
| 4151 base::TimeTicks time_ticks; |
| 4152 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 4153 host_impl_.SetCurrentBeginFrameArgs( |
| 4154 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 4155 |
4313 gfx::Size tile_size(102, 102); | 4156 gfx::Size tile_size(102, 102); |
4314 gfx::Size layer_bounds(1000, 1000); | 4157 gfx::Size layer_bounds(1000, 1000); |
4315 gfx::Size viewport_size(500, 500); | 4158 gfx::Size viewport_size(1000, 1000); |
4316 gfx::Point pending_occluding_layer_position(310, 0); | 4159 gfx::Point pending_occluding_layer_position(310, 0); |
4317 gfx::Point active_occluding_layer_position(0, 310); | 4160 gfx::Point active_occluding_layer_position(0, 310); |
4318 gfx::Rect invalidation_rect(230, 230, 102, 102); | 4161 gfx::Rect invalidation_rect(230, 230, 102, 102); |
4319 | 4162 |
| 4163 host_impl_.SetViewportSize(viewport_size); |
| 4164 host_impl_.SetDeviceScaleFactor(2.f); |
| 4165 |
4320 scoped_refptr<FakePicturePileImpl> pending_pile = | 4166 scoped_refptr<FakePicturePileImpl> pending_pile = |
4321 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 4167 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
4322 scoped_refptr<FakePicturePileImpl> active_pile = | 4168 scoped_refptr<FakePicturePileImpl> active_pile = |
4323 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 4169 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
4324 SetupTrees(pending_pile, active_pile); | |
4325 | 4170 |
4326 pending_layer_->set_fixed_tile_size(tile_size); | 4171 SetupPendingTreeWithFixedTileSize(active_pile, tile_size, Region()); |
4327 active_layer_->set_fixed_tile_size(tile_size); | |
4328 | 4172 |
4329 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; | 4173 // Partially occlude the active layer. |
| 4174 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 2)); |
| 4175 LayerImpl* active_occluding_layer = pending_layer_->children()[0]; |
| 4176 active_occluding_layer->SetBounds(layer_bounds); |
| 4177 active_occluding_layer->SetContentBounds(layer_bounds); |
| 4178 active_occluding_layer->SetDrawsContent(true); |
| 4179 active_occluding_layer->SetContentsOpaque(true); |
| 4180 active_occluding_layer->SetPosition(active_occluding_layer_position); |
4330 | 4181 |
4331 std::vector<PictureLayerTiling*> tilings; | 4182 ActivateTree(); |
4332 tilings.push_back(pending_layer_->AddTiling(low_res_factor)); | |
4333 tilings.push_back(pending_layer_->AddTiling(0.3f)); | |
4334 tilings.push_back(pending_layer_->AddTiling(0.7f)); | |
4335 tilings.push_back(pending_layer_->AddTiling(1.0f)); | |
4336 tilings.push_back(pending_layer_->AddTiling(2.0f)); | |
4337 | 4183 |
4338 EXPECT_EQ(5u, pending_layer_->num_tilings()); | 4184 // Partially invalidate the pending layer. Tiles inside the invalidation rect |
4339 EXPECT_EQ(5u, active_layer_->num_tilings()); | 4185 // are not shared between trees. |
| 4186 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, invalidation_rect); |
4340 | 4187 |
4341 // Partially occlude the pending layer. | 4188 // Partially occlude the pending layer in a different way. |
4342 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); | 4189 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 3)); |
4343 LayerImpl* pending_occluding_layer = pending_layer_->children()[0]; | 4190 LayerImpl* pending_occluding_layer = pending_layer_->children()[0]; |
4344 pending_occluding_layer->SetBounds(layer_bounds); | 4191 pending_occluding_layer->SetBounds(layer_bounds); |
4345 pending_occluding_layer->SetContentBounds(layer_bounds); | 4192 pending_occluding_layer->SetContentBounds(layer_bounds); |
4346 pending_occluding_layer->SetDrawsContent(true); | 4193 pending_occluding_layer->SetDrawsContent(true); |
4347 pending_occluding_layer->SetContentsOpaque(true); | 4194 pending_occluding_layer->SetContentsOpaque(true); |
4348 pending_occluding_layer->SetPosition(pending_occluding_layer_position); | 4195 pending_occluding_layer->SetPosition(pending_occluding_layer_position); |
4349 | 4196 |
4350 // Partially occlude the active layer. | 4197 EXPECT_EQ(2u, pending_layer_->num_tilings()); |
4351 active_layer_->AddChild(LayerImpl::Create(host_impl_.active_tree(), 2)); | 4198 EXPECT_EQ(2u, active_layer_->num_tilings()); |
4352 LayerImpl* active_occluding_layer = active_layer_->children()[0]; | |
4353 active_occluding_layer->SetBounds(layer_bounds); | |
4354 active_occluding_layer->SetContentBounds(layer_bounds); | |
4355 active_occluding_layer->SetDrawsContent(true); | |
4356 active_occluding_layer->SetContentsOpaque(true); | |
4357 active_occluding_layer->SetPosition(active_occluding_layer_position); | |
4358 | 4199 |
4359 // Partially invalidate the pending layer. Tiles inside the invalidation rect | 4200 time_ticks += base::TimeDelta::FromMilliseconds(1); |
4360 // are not shared between trees. | 4201 host_impl_.SetCurrentBeginFrameArgs( |
4361 pending_layer_->set_invalidation(invalidation_rect); | 4202 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
4362 | 4203 // UpdateDrawProperties with the occluding layer. |
4363 host_impl_.SetViewportSize(viewport_size); | |
4364 host_impl_.active_tree()->UpdateDrawProperties(); | |
4365 host_impl_.pending_tree()->UpdateDrawProperties(); | 4204 host_impl_.pending_tree()->UpdateDrawProperties(); |
4366 | 4205 |
4367 // The expected number of occluded tiles on each of the 5 tilings for each of | 4206 // The expected number of occluded tiles on each of the 2 tilings for each of |
4368 // the 3 tree priorities. | 4207 // the 3 tree priorities. |
4369 size_t expected_occluded_tile_count_on_both[] = {9u, 1u, 1u, 1u, 1u}; | 4208 size_t expected_occluded_tile_count_on_both[] = {9u, 1u}; |
4370 size_t expected_occluded_tile_count_on_active[] = {30u, 5u, 4u, 2u, 2u}; | 4209 size_t expected_occluded_tile_count_on_active[] = {30u, 3u}; |
4371 size_t expected_occluded_tile_count_on_pending[] = {30u, 5u, 4u, 2u, 2u}; | 4210 size_t expected_occluded_tile_count_on_pending[] = {30u, 3u}; |
4372 | 4211 |
4373 // The total expected number of occluded tiles on all tilings for each of the | 4212 // The total expected number of occluded tiles on all tilings for each of the |
4374 // 3 tree priorities. | 4213 // 3 tree priorities. |
4375 size_t total_expected_occluded_tile_count[] = {13u, 43u, 43u}; | 4214 size_t total_expected_occluded_tile_count[] = {10u, 33u, 33u}; |
4376 | 4215 |
4377 ASSERT_EQ(arraysize(total_expected_occluded_tile_count), NUM_TREE_PRIORITIES); | 4216 ASSERT_EQ(arraysize(total_expected_occluded_tile_count), NUM_TREE_PRIORITIES); |
4378 | 4217 |
4379 // Verify number of occluded tiles on the pending layer for each tiling. | 4218 // Verify number of occluded tiles on the pending layer for each tiling. |
4380 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { | 4219 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
4381 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); | 4220 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
4382 tiling->CreateAllTilesForTesting(); | |
4383 tiling->UpdateAllTilePrioritiesForTesting(); | 4221 tiling->UpdateAllTilePrioritiesForTesting(); |
4384 | 4222 |
4385 size_t occluded_tile_count_on_pending = 0u; | 4223 size_t occluded_tile_count_on_pending = 0u; |
4386 size_t occluded_tile_count_on_active = 0u; | 4224 size_t occluded_tile_count_on_active = 0u; |
4387 size_t occluded_tile_count_on_both = 0u; | 4225 size_t occluded_tile_count_on_both = 0u; |
4388 for (PictureLayerTiling::CoverageIterator iter( | 4226 for (PictureLayerTiling::CoverageIterator iter(tiling, 1.f, |
4389 tiling, | 4227 gfx::Rect(layer_bounds)); |
4390 pending_layer_->contents_scale_x(), | 4228 iter; ++iter) { |
4391 gfx::Rect(layer_bounds)); | |
4392 iter; | |
4393 ++iter) { | |
4394 Tile* tile = *iter; | 4229 Tile* tile = *iter; |
4395 | 4230 |
| 4231 if (!tile) |
| 4232 continue; |
4396 if (tile->is_occluded(PENDING_TREE)) | 4233 if (tile->is_occluded(PENDING_TREE)) |
4397 occluded_tile_count_on_pending++; | 4234 occluded_tile_count_on_pending++; |
4398 if (tile->is_occluded(ACTIVE_TREE)) | 4235 if (tile->is_occluded(ACTIVE_TREE)) |
4399 occluded_tile_count_on_active++; | 4236 occluded_tile_count_on_active++; |
4400 if (tile->is_occluded(PENDING_TREE) && tile->is_occluded(ACTIVE_TREE)) | 4237 if (tile->is_occluded(PENDING_TREE) && tile->is_occluded(ACTIVE_TREE)) |
4401 occluded_tile_count_on_both++; | 4238 occluded_tile_count_on_both++; |
4402 } | 4239 } |
4403 EXPECT_EQ(expected_occluded_tile_count_on_pending[i], | 4240 EXPECT_EQ(expected_occluded_tile_count_on_pending[i], |
4404 occluded_tile_count_on_pending) | 4241 occluded_tile_count_on_pending) |
4405 << i; | 4242 << tiling->contents_scale(); |
4406 EXPECT_EQ(expected_occluded_tile_count_on_active[i], | 4243 EXPECT_EQ(expected_occluded_tile_count_on_active[i], |
4407 occluded_tile_count_on_active) | 4244 occluded_tile_count_on_active) |
4408 << i; | 4245 << tiling->contents_scale(); |
4409 EXPECT_EQ(expected_occluded_tile_count_on_both[i], | 4246 EXPECT_EQ(expected_occluded_tile_count_on_both[i], |
4410 occluded_tile_count_on_both) | 4247 occluded_tile_count_on_both) |
4411 << i; | 4248 << tiling->contents_scale(); |
4412 } | 4249 } |
4413 | 4250 |
4414 // Verify number of occluded tiles on the active layer for each tiling. | 4251 // Verify number of occluded tiles on the active layer for each tiling. |
4415 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { | 4252 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { |
4416 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); | 4253 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); |
4417 tiling->CreateAllTilesForTesting(); | |
4418 tiling->UpdateAllTilePrioritiesForTesting(); | 4254 tiling->UpdateAllTilePrioritiesForTesting(); |
4419 | 4255 |
4420 size_t occluded_tile_count_on_pending = 0u; | 4256 size_t occluded_tile_count_on_pending = 0u; |
4421 size_t occluded_tile_count_on_active = 0u; | 4257 size_t occluded_tile_count_on_active = 0u; |
4422 size_t occluded_tile_count_on_both = 0u; | 4258 size_t occluded_tile_count_on_both = 0u; |
4423 for (PictureLayerTiling::CoverageIterator iter( | 4259 for (PictureLayerTiling::CoverageIterator iter( |
4424 tiling, | 4260 tiling, |
4425 pending_layer_->contents_scale_x(), | 4261 pending_layer_->contents_scale_x(), |
4426 gfx::Rect(layer_bounds)); | 4262 gfx::Rect(layer_bounds)); |
4427 iter; | 4263 iter; |
4428 ++iter) { | 4264 ++iter) { |
4429 Tile* tile = *iter; | 4265 Tile* tile = *iter; |
4430 | 4266 |
| 4267 if (!tile) |
| 4268 continue; |
4431 if (tile->is_occluded(PENDING_TREE)) | 4269 if (tile->is_occluded(PENDING_TREE)) |
4432 occluded_tile_count_on_pending++; | 4270 occluded_tile_count_on_pending++; |
4433 if (tile->is_occluded(ACTIVE_TREE)) | 4271 if (tile->is_occluded(ACTIVE_TREE)) |
4434 occluded_tile_count_on_active++; | 4272 occluded_tile_count_on_active++; |
4435 if (tile->is_occluded(PENDING_TREE) && tile->is_occluded(ACTIVE_TREE)) | 4273 if (tile->is_occluded(PENDING_TREE) && tile->is_occluded(ACTIVE_TREE)) |
4436 occluded_tile_count_on_both++; | 4274 occluded_tile_count_on_both++; |
4437 } | 4275 } |
4438 EXPECT_EQ(expected_occluded_tile_count_on_pending[i], | 4276 EXPECT_EQ(expected_occluded_tile_count_on_pending[i], |
4439 occluded_tile_count_on_pending) | 4277 occluded_tile_count_on_pending) |
4440 << i; | 4278 << i; |
4441 EXPECT_EQ(expected_occluded_tile_count_on_active[i], | 4279 EXPECT_EQ(expected_occluded_tile_count_on_active[i], |
4442 occluded_tile_count_on_active) | 4280 occluded_tile_count_on_active) |
4443 << i; | 4281 << i; |
4444 EXPECT_EQ(expected_occluded_tile_count_on_both[i], | 4282 EXPECT_EQ(expected_occluded_tile_count_on_both[i], |
4445 occluded_tile_count_on_both) | 4283 occluded_tile_count_on_both) |
4446 << i; | 4284 << i; |
4447 } | 4285 } |
4448 | 4286 |
4449 std::vector<Tile*> all_tiles; | 4287 std::vector<Tile*> all_tiles; |
4450 for (std::vector<PictureLayerTiling*>::iterator tiling_iterator = | 4288 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { |
4451 tilings.begin(); | 4289 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); |
4452 tiling_iterator != tilings.end(); | 4290 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); |
4453 ++tiling_iterator) { | 4291 all_tiles.insert(all_tiles.end(), tiles.begin(), tiles.end()); |
4454 std::vector<Tile*> tiles = (*tiling_iterator)->AllTilesForTesting(); | |
4455 std::copy(tiles.begin(), tiles.end(), std::back_inserter(all_tiles)); | |
4456 } | 4292 } |
4457 | 4293 |
4458 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); | 4294 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); |
4459 | 4295 |
4460 VerifyEvictionConsidersOcclusion(pending_layer_, | 4296 VerifyEvictionConsidersOcclusion(pending_layer_, |
4461 total_expected_occluded_tile_count); | 4297 total_expected_occluded_tile_count); |
4462 VerifyEvictionConsidersOcclusion(active_layer_, | 4298 VerifyEvictionConsidersOcclusion(active_layer_, |
4463 total_expected_occluded_tile_count); | 4299 total_expected_occluded_tile_count); |
4464 } | 4300 } |
4465 | 4301 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4527 gfx::Size layer_bounds(200, 200); | 4363 gfx::Size layer_bounds(200, 200); |
4528 gfx::Rect layer_rect(layer_bounds); | 4364 gfx::Rect layer_rect(layer_bounds); |
4529 | 4365 |
4530 FakeContentLayerClient client; | 4366 FakeContentLayerClient client; |
4531 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); | 4367 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); |
4532 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); | 4368 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); |
4533 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&host_client); | 4369 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&host_client); |
4534 host->SetRootLayer(layer); | 4370 host->SetRootLayer(layer); |
4535 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); | 4371 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); |
4536 | 4372 |
4537 host_impl_.SetViewportSize(layer_bounds); | |
4538 | |
4539 int frame_number = 0; | 4373 int frame_number = 0; |
4540 | 4374 |
4541 client.set_fill_with_nonsolid_color(!test_for_solid); | 4375 client.set_fill_with_nonsolid_color(!test_for_solid); |
4542 | 4376 |
4543 Region invalidation(layer_rect); | 4377 Region invalidation(layer_rect); |
4544 recording_source->UpdateAndExpandInvalidation( | 4378 recording_source->UpdateAndExpandInvalidation( |
4545 &client, &invalidation, false, layer_bounds, layer_rect, frame_number++, | 4379 &client, &invalidation, false, layer_bounds, layer_rect, frame_number++, |
4546 Picture::RECORD_NORMALLY); | 4380 Picture::RECORD_NORMALLY); |
4547 | 4381 |
4548 scoped_refptr<RasterSource> pending_raster_source = | 4382 scoped_refptr<RasterSource> pending_raster_source = |
4549 recording_source->CreateRasterSource(); | 4383 recording_source->CreateRasterSource(); |
4550 | 4384 |
4551 SetupPendingTree(pending_raster_source); | 4385 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region()); |
4552 ActivateTree(); | 4386 ActivateTree(); |
4553 | 4387 |
4554 active_layer_->set_fixed_tile_size(tile_size); | |
4555 host_impl_.active_tree()->UpdateDrawProperties(); | |
4556 if (test_for_solid) { | 4388 if (test_for_solid) { |
4557 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 4389 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
4558 } else { | 4390 } else { |
4559 ASSERT_TRUE(active_layer_->tilings()); | 4391 ASSERT_TRUE(active_layer_->tilings()); |
4560 ASSERT_GT(active_layer_->tilings()->num_tilings(), 0u); | 4392 ASSERT_GT(active_layer_->tilings()->num_tilings(), 0u); |
4561 std::vector<Tile*> tiles = | 4393 std::vector<Tile*> tiles = |
4562 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); | 4394 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); |
4563 EXPECT_FALSE(tiles.empty()); | 4395 EXPECT_FALSE(tiles.empty()); |
4564 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); | 4396 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); |
4565 } | 4397 } |
(...skipping 28 matching lines...) Expand all Loading... |
4594 gfx::Size layer_bounds(200, 200); | 4426 gfx::Size layer_bounds(200, 200); |
4595 gfx::Rect layer_rect(layer_bounds); | 4427 gfx::Rect layer_rect(layer_bounds); |
4596 | 4428 |
4597 FakeContentLayerClient client; | 4429 FakeContentLayerClient client; |
4598 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); | 4430 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); |
4599 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); | 4431 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); |
4600 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&host_client); | 4432 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(&host_client); |
4601 host->SetRootLayer(layer); | 4433 host->SetRootLayer(layer); |
4602 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); | 4434 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); |
4603 | 4435 |
4604 host_impl_.SetViewportSize(layer_bounds); | |
4605 | |
4606 int frame_number = 0; | 4436 int frame_number = 0; |
4607 | 4437 |
4608 client.set_fill_with_nonsolid_color(true); | 4438 client.set_fill_with_nonsolid_color(true); |
4609 | 4439 |
4610 Region invalidation1(layer_rect); | 4440 Region invalidation1(layer_rect); |
4611 recording_source->UpdateAndExpandInvalidation( | 4441 recording_source->UpdateAndExpandInvalidation( |
4612 &client, &invalidation1, false, layer_bounds, layer_rect, frame_number++, | 4442 &client, &invalidation1, false, layer_bounds, layer_rect, frame_number++, |
4613 Picture::RECORD_NORMALLY); | 4443 Picture::RECORD_NORMALLY); |
4614 | 4444 |
4615 scoped_refptr<RasterSource> raster_source1 = | 4445 scoped_refptr<RasterSource> raster_source1 = |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4760 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 4590 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
4761 EXPECT_EQ(result.width(), 448); | 4591 EXPECT_EQ(result.width(), 448); |
4762 EXPECT_EQ(result.height(), 448); | 4592 EXPECT_EQ(result.height(), 448); |
4763 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 4593 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
4764 EXPECT_EQ(result.width(), 512); | 4594 EXPECT_EQ(result.width(), 512); |
4765 EXPECT_EQ(result.height(), 500 + 2); | 4595 EXPECT_EQ(result.height(), 500 + 2); |
4766 } | 4596 } |
4767 | 4597 |
4768 } // namespace | 4598 } // namespace |
4769 } // namespace cc | 4599 } // namespace cc |
OLD | NEW |