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

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

Issue 1362663002: cc: Remove PicturePile and PicturePileImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layers/picture_layer_impl.h" 5 #include "cc/layers/picture_layer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/thread_task_runner_handle.h" 13 #include "base/thread_task_runner_handle.h"
14 #include "cc/base/math_util.h" 14 #include "cc/base/math_util.h"
15 #include "cc/layers/append_quads_data.h" 15 #include "cc/layers/append_quads_data.h"
16 #include "cc/layers/picture_layer.h" 16 #include "cc/layers/picture_layer.h"
17 #include "cc/quads/draw_quad.h" 17 #include "cc/quads/draw_quad.h"
18 #include "cc/quads/tile_draw_quad.h" 18 #include "cc/quads/tile_draw_quad.h"
19 #include "cc/test/begin_frame_args_test.h" 19 #include "cc/test/begin_frame_args_test.h"
20 #include "cc/test/fake_content_layer_client.h" 20 #include "cc/test/fake_content_layer_client.h"
21 #include "cc/test/fake_display_list_raster_source.h"
22 #include "cc/test/fake_display_list_recording_source.h"
21 #include "cc/test/fake_impl_proxy.h" 23 #include "cc/test/fake_impl_proxy.h"
22 #include "cc/test/fake_layer_tree_host_impl.h" 24 #include "cc/test/fake_layer_tree_host_impl.h"
23 #include "cc/test/fake_output_surface.h" 25 #include "cc/test/fake_output_surface.h"
24 #include "cc/test/fake_picture_layer_impl.h" 26 #include "cc/test/fake_picture_layer_impl.h"
25 #include "cc/test/fake_picture_pile_impl.h"
26 #include "cc/test/geometry_test_utils.h" 27 #include "cc/test/geometry_test_utils.h"
27 #include "cc/test/gpu_rasterization_enabled_settings.h" 28 #include "cc/test/gpu_rasterization_enabled_settings.h"
28 #include "cc/test/layer_test_common.h" 29 #include "cc/test/layer_test_common.h"
29 #include "cc/test/test_shared_bitmap_manager.h" 30 #include "cc/test/test_shared_bitmap_manager.h"
30 #include "cc/test/test_task_graph_runner.h" 31 #include "cc/test/test_task_graph_runner.h"
31 #include "cc/test/test_web_graphics_context_3d.h" 32 #include "cc/test/test_web_graphics_context_3d.h"
32 #include "cc/tiles/tiling_set_raster_queue_all.h" 33 #include "cc/tiles/tiling_set_raster_queue_all.h"
33 #include "cc/tiles/tiling_set_raster_queue_required.h" 34 #include "cc/tiles/tiling_set_raster_queue_required.h"
34 #include "cc/trees/layer_tree_impl.h" 35 #include "cc/trees/layer_tree_impl.h"
35 #include "testing/gtest/include/gtest/gtest.h" 36 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 119
119 ~PictureLayerImplTest() override {} 120 ~PictureLayerImplTest() override {}
120 121
121 void SetUp() override { InitializeRenderer(); } 122 void SetUp() override { InitializeRenderer(); }
122 123
123 virtual void InitializeRenderer() { 124 virtual void InitializeRenderer() {
124 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d()); 125 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d());
125 } 126 }
126 127
127 void SetupDefaultTrees(const gfx::Size& layer_bounds) { 128 void SetupDefaultTrees(const gfx::Size& layer_bounds) {
128 gfx::Size tile_size(100, 100); 129 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
130 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
131 scoped_refptr<FakeDisplayListRasterSource> active_raster_source =
132 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
129 133
130 scoped_refptr<FakePicturePileImpl> pending_pile = 134 SetupTrees(pending_raster_source, active_raster_source);
131 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
132 scoped_refptr<FakePicturePileImpl> active_pile =
133 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
134
135 SetupTrees(pending_pile, active_pile);
136 } 135 }
137 136
138 void SetupDefaultTreesWithInvalidation(const gfx::Size& layer_bounds, 137 void SetupDefaultTreesWithInvalidation(const gfx::Size& layer_bounds,
139 const Region& invalidation) { 138 const Region& invalidation) {
140 gfx::Size tile_size(100, 100); 139 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
140 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
141 scoped_refptr<FakeDisplayListRasterSource> active_raster_source =
142 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
141 143
142 scoped_refptr<FakePicturePileImpl> pending_pile = 144 SetupTreesWithInvalidation(pending_raster_source, active_raster_source,
143 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 145 invalidation);
144 scoped_refptr<FakePicturePileImpl> active_pile =
145 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
146
147 SetupTreesWithInvalidation(pending_pile, active_pile, invalidation);
148 } 146 }
149 147
150 void ActivateTree() { 148 void ActivateTree() {
151 host_impl_.ActivateSyncTree(); 149 host_impl_.ActivateSyncTree();
152 CHECK(!host_impl_.pending_tree()); 150 CHECK(!host_impl_.pending_tree());
153 CHECK(host_impl_.recycle_tree()); 151 CHECK(host_impl_.recycle_tree());
154 old_pending_layer_ = pending_layer_; 152 old_pending_layer_ = pending_layer_;
155 pending_layer_ = nullptr; 153 pending_layer_ = nullptr;
156 active_layer_ = static_cast<FakePictureLayerImpl*>( 154 active_layer_ = static_cast<FakePictureLayerImpl*>(
157 host_impl_.active_tree()->LayerById(id_)); 155 host_impl_.active_tree()->LayerById(id_));
158 156
159 bool update_lcd_text = false; 157 bool update_lcd_text = false;
160 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); 158 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text);
161 } 159 }
162 160
163 void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds, 161 void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds,
164 const gfx::Size& tile_size, 162 const gfx::Size& tile_size,
165 const Region& invalidation) { 163 const Region& invalidation) {
166 gfx::Size pile_tile_size(100, 100); 164 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
165 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
166 scoped_refptr<FakeDisplayListRasterSource> active_raster_source =
167 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
167 168
168 scoped_refptr<FakePicturePileImpl> pending_pile = 169 SetupTreesWithFixedTileSize(pending_raster_source, active_raster_source,
169 FakePicturePileImpl::CreateFilledPile(pile_tile_size, layer_bounds); 170 tile_size, invalidation);
170 scoped_refptr<FakePicturePileImpl> active_pile =
171 FakePicturePileImpl::CreateFilledPile(pile_tile_size, layer_bounds);
172
173 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size,
174 invalidation);
175 } 171 }
176 172
177 void SetupTrees( 173 void SetupTrees(scoped_refptr<RasterSource> pending_raster_source,
178 scoped_refptr<PicturePileImpl> pending_pile, 174 scoped_refptr<RasterSource> active_raster_source) {
179 scoped_refptr<PicturePileImpl> active_pile) { 175 SetupPendingTree(active_raster_source);
180 SetupPendingTree(active_pile);
181 ActivateTree(); 176 ActivateTree();
182 SetupPendingTreeInternal(pending_pile, gfx::Size(), Region()); 177 SetupPendingTreeInternal(pending_raster_source, gfx::Size(), Region());
183 } 178 }
184 179
185 void SetupTreesWithInvalidation(scoped_refptr<PicturePileImpl> pending_pile, 180 void SetupTreesWithInvalidation(
186 scoped_refptr<PicturePileImpl> active_pile, 181 scoped_refptr<RasterSource> pending_raster_source,
187 const Region& pending_invalidation) { 182 scoped_refptr<RasterSource> active_raster_source,
188 SetupPendingTreeInternal(active_pile, gfx::Size(), Region()); 183 const Region& pending_invalidation) {
184 SetupPendingTreeInternal(active_raster_source, gfx::Size(), Region());
189 ActivateTree(); 185 ActivateTree();
190 SetupPendingTreeInternal(pending_pile, gfx::Size(), pending_invalidation); 186 SetupPendingTreeInternal(pending_raster_source, gfx::Size(),
187 pending_invalidation);
191 } 188 }
192 189
193 void SetupTreesWithFixedTileSize(scoped_refptr<PicturePileImpl> pending_pile, 190 void SetupTreesWithFixedTileSize(
194 scoped_refptr<PicturePileImpl> active_pile, 191 scoped_refptr<RasterSource> pending_raster_source,
195 const gfx::Size& tile_size, 192 scoped_refptr<RasterSource> active_raster_source,
196 const Region& pending_invalidation) { 193 const gfx::Size& tile_size,
197 SetupPendingTreeInternal(active_pile, tile_size, Region()); 194 const Region& pending_invalidation) {
195 SetupPendingTreeInternal(active_raster_source, tile_size, Region());
198 ActivateTree(); 196 ActivateTree();
199 SetupPendingTreeInternal(pending_pile, tile_size, pending_invalidation); 197 SetupPendingTreeInternal(pending_raster_source, tile_size,
198 pending_invalidation);
200 } 199 }
201 200
202 void SetupPendingTree(scoped_refptr<RasterSource> raster_source) { 201 void SetupPendingTree(scoped_refptr<RasterSource> raster_source) {
203 SetupPendingTreeInternal(raster_source, gfx::Size(), Region()); 202 SetupPendingTreeInternal(raster_source, gfx::Size(), Region());
204 } 203 }
205 204
206 void SetupPendingTreeWithInvalidation( 205 void SetupPendingTreeWithInvalidation(
207 scoped_refptr<RasterSource> raster_source, 206 scoped_refptr<RasterSource> raster_source,
208 const Region& invalidation) { 207 const Region& invalidation) {
209 SetupPendingTreeInternal(raster_source, gfx::Size(), invalidation); 208 SetupPendingTreeInternal(raster_source, gfx::Size(), invalidation);
(...skipping 24 matching lines...) Expand all
234 if (!tile_size.IsEmpty()) 233 if (!tile_size.IsEmpty())
235 pending_layer->set_fixed_tile_size(tile_size); 234 pending_layer->set_fixed_tile_size(tile_size);
236 pending_layer->SetDrawsContent(true); 235 pending_layer->SetDrawsContent(true);
237 } else { 236 } else {
238 pending_layer.reset(static_cast<FakePictureLayerImpl*>( 237 pending_layer.reset(static_cast<FakePictureLayerImpl*>(
239 pending_root->RemoveChild(pending_root->children()[0]).release())); 238 pending_root->RemoveChild(pending_root->children()[0]).release()));
240 if (!tile_size.IsEmpty()) 239 if (!tile_size.IsEmpty())
241 pending_layer->set_fixed_tile_size(tile_size); 240 pending_layer->set_fixed_tile_size(tile_size);
242 } 241 }
243 pending_root->SetHasRenderSurface(true); 242 pending_root->SetHasRenderSurface(true);
244 // The bounds() just mirror the pile size. 243 // The bounds() just mirror the raster source size.
245 pending_layer->SetBounds(raster_source->GetSize()); 244 pending_layer->SetBounds(raster_source->GetSize());
246 pending_layer->SetRasterSourceOnPending(raster_source, invalidation); 245 pending_layer->SetRasterSourceOnPending(raster_source, invalidation);
247 246
248 pending_root->AddChild(pending_layer.Pass()); 247 pending_root->AddChild(pending_layer.Pass());
249 pending_tree->SetRootLayer(pending_root.Pass()); 248 pending_tree->SetRootLayer(pending_root.Pass());
250 249
251 pending_layer_ = static_cast<FakePictureLayerImpl*>( 250 pending_layer_ = static_cast<FakePictureLayerImpl*>(
252 host_impl_.pending_tree()->LayerById(id_)); 251 host_impl_.pending_tree()->LayerById(id_));
253 252
254 // Add tilings/tiles for the layer. 253 // Add tilings/tiles for the layer.
(...skipping 18 matching lines...) Expand all
273 DCHECK_EQ(layer->GetIdealContentsScale(), ideal_contents_scale); 272 DCHECK_EQ(layer->GetIdealContentsScale(), ideal_contents_scale);
274 layer->draw_properties().maximum_animation_contents_scale = 273 layer->draw_properties().maximum_animation_contents_scale =
275 maximum_animation_contents_scale; 274 maximum_animation_contents_scale;
276 layer->draw_properties().starting_animation_contents_scale = 275 layer->draw_properties().starting_animation_contents_scale =
277 starting_animation_contents_scale; 276 starting_animation_contents_scale;
278 layer->draw_properties().screen_space_transform_is_animating = 277 layer->draw_properties().screen_space_transform_is_animating =
279 animating_transform_to_screen; 278 animating_transform_to_screen;
280 bool resourceless_software_draw = false; 279 bool resourceless_software_draw = false;
281 layer->UpdateTiles(resourceless_software_draw); 280 layer->UpdateTiles(resourceless_software_draw);
282 } 281 }
283 static void VerifyAllPrioritizedTilesExistAndHavePile( 282 static void VerifyAllPrioritizedTilesExistAndHaveRasterSource(
284 const PictureLayerTiling* tiling, 283 const PictureLayerTiling* tiling,
285 PicturePileImpl* pile) { 284 RasterSource* raster_source) {
286 auto prioritized_tiles = 285 auto prioritized_tiles =
287 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); 286 tiling->UpdateAndGetAllPrioritizedTilesForTesting();
288 for (PictureLayerTiling::CoverageIterator iter( 287 for (PictureLayerTiling::CoverageIterator iter(
289 tiling, 288 tiling,
290 tiling->contents_scale(), 289 tiling->contents_scale(),
291 gfx::Rect(tiling->tiling_size())); 290 gfx::Rect(tiling->tiling_size()));
292 iter; 291 iter;
293 ++iter) { 292 ++iter) {
294 EXPECT_TRUE(*iter); 293 EXPECT_TRUE(*iter);
295 EXPECT_EQ(pile, prioritized_tiles[*iter].raster_source()); 294 EXPECT_EQ(raster_source, prioritized_tiles[*iter].raster_source());
296 } 295 }
297 } 296 }
298 297
299 void SetContentsScaleOnBothLayers(float contents_scale, 298 void SetContentsScaleOnBothLayers(float contents_scale,
300 float device_scale_factor, 299 float device_scale_factor,
301 float page_scale_factor, 300 float page_scale_factor,
302 float maximum_animation_contents_scale, 301 float maximum_animation_contents_scale,
303 float starting_animation_contents_scale, 302 float starting_animation_contents_scale,
304 bool animating_transform) { 303 bool animating_transform) {
305 SetupDrawPropertiesAndUpdateTiles( 304 SetupDrawPropertiesAndUpdateTiles(
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 NoLowResPictureLayerImplTest() 375 NoLowResPictureLayerImplTest()
377 : PictureLayerImplTest(NoLowResTilingsSettings()) {} 376 : PictureLayerImplTest(NoLowResTilingsSettings()) {}
378 }; 377 };
379 378
380 TEST_F(PictureLayerImplTest, TileGridAlignment) { 379 TEST_F(PictureLayerImplTest, TileGridAlignment) {
381 // Layer to span 4 raster tiles in x and in y 380 // Layer to span 4 raster tiles in x and in y
382 LayerTreeSettings settings; 381 LayerTreeSettings settings;
383 gfx::Size layer_size(settings.default_tile_size.width() * 7 / 2, 382 gfx::Size layer_size(settings.default_tile_size.width() * 7 / 2,
384 settings.default_tile_size.height() * 7 / 2); 383 settings.default_tile_size.height() * 7 / 2);
385 384
386 scoped_refptr<FakePicturePileImpl> pending_pile = 385 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
387 FakePicturePileImpl::CreateFilledPile(layer_size, layer_size); 386 FakeDisplayListRasterSource::CreateFilled(layer_size);
388 387
389 scoped_ptr<FakePicturePile> active_recording = 388 // Create an active recording source, but make sure it's not solid.
danakj 2015/09/22 21:52:14 this says make sure it's solid but you then draw
vmpstr 2015/09/22 22:57:49 It says make sure it's not solid.
danakj 2015/09/22 23:04:06 Ya.. reading comprehension. All time low. Thanks :
390 FakePicturePile::CreateFilledPile(layer_size, layer_size); 389 scoped_ptr<FakeDisplayListRecordingSource> active_recording_source =
391 scoped_refptr<FakePicturePileImpl> active_pile = 390 FakeDisplayListRecordingSource::CreateFilledRecordingSource(layer_size);
392 FakePicturePileImpl::CreateFromPile(active_recording.get(), nullptr); 391 active_recording_source->add_draw_rect(gfx::Rect(layer_size));
392 active_recording_source->add_draw_rect(
393 gfx::Rect(0, 0, layer_size.width() - 1, layer_size.height() - 1));
394 active_recording_source->Rerecord();
395 scoped_refptr<FakeDisplayListRasterSource> active_raster_source =
396 FakeDisplayListRasterSource::CreateFromRecordingSource(
397 active_recording_source.get(), false);
393 398
394 SetupTrees(pending_pile, active_pile); 399 SetupTrees(pending_raster_source, active_raster_source);
395 400
396 // Add 1x1 rects at the centers of each tile, then re-record pile contents 401 // Add 1x1 rects at the centers of each tile, then re-record recording source
402 // contents.
397 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); 403 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting();
398 std::vector<Tile*> tiles = 404 std::vector<Tile*> tiles =
399 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); 405 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting();
400 EXPECT_EQ(16u, tiles.size()); 406 EXPECT_EQ(16u, tiles.size());
401 std::vector<SkRect> rects; 407 std::vector<SkRect> rects;
402 std::vector<Tile*>::const_iterator tile_iter; 408 std::vector<Tile*>::const_iterator tile_iter;
409 active_recording_source->reset_draws();
403 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) { 410 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) {
404 gfx::Point tile_center = (*tile_iter)->content_rect().CenterPoint(); 411 gfx::Point tile_center = (*tile_iter)->content_rect().CenterPoint();
405 gfx::Rect rect(tile_center.x(), tile_center.y(), 1, 1); 412 gfx::Rect rect(tile_center.x(), tile_center.y(), 1, 1);
406 active_recording->add_draw_rect(rect); 413 active_recording_source->add_draw_rect(rect);
407 rects.push_back(SkRect::MakeXYWH(rect.x(), rect.y(), 1, 1)); 414 rects.push_back(SkRect::MakeXYWH(rect.x(), rect.y(), 1, 1));
408 } 415 }
409 416
410 // Force re-raster with newly injected content 417 // Force re-raster with newly injected content
411 active_recording->RemoveRecordingAt(0, 0); 418 active_recording_source->Rerecord();
412 active_recording->AddRecordingAt(0, 0);
413 419
414 scoped_refptr<FakePicturePileImpl> updated_active_pile = 420 scoped_refptr<FakeDisplayListRasterSource> updated_active_raster_source =
415 FakePicturePileImpl::CreateFromPile(active_recording.get(), nullptr); 421 FakeDisplayListRasterSource::CreateFromRecordingSource(
422 active_recording_source.get(), false);
416 423
417 std::vector<SkRect>::const_iterator rect_iter = rects.begin(); 424 std::vector<SkRect>::const_iterator rect_iter = rects.begin();
418 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) { 425 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) {
419 MockCanvas mock_canvas(1000, 1000); 426 MockCanvas mock_canvas(1000, 1000);
420 updated_active_pile->PlaybackToSharedCanvas( 427 updated_active_raster_source->PlaybackToSharedCanvas(
421 &mock_canvas, (*tile_iter)->content_rect(), 1.0f); 428 &mock_canvas, (*tile_iter)->content_rect(), 1.0f);
422 429
423 // This test verifies that when drawing the contents of a specific tile 430 // This test verifies that when drawing the contents of a specific tile
424 // at content scale 1.0, the playback canvas never receives content from 431 // at content scale 1.0, the playback canvas never receives content from
425 // neighboring tiles which indicates that the tile grid embedded in 432 // neighboring tiles which indicates that the tile grid embedded in
426 // SkPicture is perfectly aligned with the compositor's tiles. 433 // SkPicture is perfectly aligned with the compositor's tiles.
427 EXPECT_EQ(1u, mock_canvas.rects_.size()); 434 EXPECT_EQ(1u, mock_canvas.rects_.size());
428 EXPECT_EQ(*rect_iter, mock_canvas.rects_[0]); 435 EXPECT_EQ(*rect_iter, mock_canvas.rects_[0]);
429 rect_iter++; 436 rect_iter++;
430 } 437 }
431 } 438 }
432 439
433 TEST_F(PictureLayerImplTest, CloneNoInvalidation) { 440 TEST_F(PictureLayerImplTest, CloneNoInvalidation) {
434 gfx::Size tile_size(100, 100);
435 gfx::Size layer_bounds(400, 400); 441 gfx::Size layer_bounds(400, 400);
436 442 SetupDefaultTrees(layer_bounds);
437 scoped_refptr<FakePicturePileImpl> pending_pile =
438 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
439 scoped_refptr<FakePicturePileImpl> active_pile =
440 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
441
442 SetupTreesWithInvalidation(pending_pile, active_pile, Region());
443 443
444 EXPECT_EQ(pending_layer_->tilings()->num_tilings(), 444 EXPECT_EQ(pending_layer_->tilings()->num_tilings(),
445 active_layer_->tilings()->num_tilings()); 445 active_layer_->tilings()->num_tilings());
446 446
447 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); 447 const PictureLayerTilingSet* tilings = pending_layer_->tilings();
448 EXPECT_GT(tilings->num_tilings(), 0u); 448 EXPECT_GT(tilings->num_tilings(), 0u);
449 for (size_t i = 0; i < tilings->num_tilings(); ++i) 449 for (size_t i = 0; i < tilings->num_tilings(); ++i)
450 EXPECT_TRUE(tilings->tiling_at(i)->AllTilesForTesting().empty()); 450 EXPECT_TRUE(tilings->tiling_at(i)->AllTilesForTesting().empty());
451 } 451 }
452 452
453 TEST_F(PictureLayerImplTest, ExternalViewportRectForPrioritizingTiles) { 453 TEST_F(PictureLayerImplTest, ExternalViewportRectForPrioritizingTiles) {
454 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 454 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
455 gfx::Size tile_size(100, 100);
456 gfx::Size layer_bounds(400, 400); 455 gfx::Size layer_bounds(400, 400);
457 456 SetupDefaultTrees(layer_bounds);
458 scoped_refptr<FakePicturePileImpl> pending_pile =
459 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
460 scoped_refptr<FakePicturePileImpl> active_pile =
461 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
462
463 SetupTreesWithInvalidation(pending_pile, active_pile, Region());
464 457
465 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, 458 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, 0.f,
466 false); 459 false);
467 460
468 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); 461 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200));
469 462
470 // Update tiles with viewport for tile priority as (0, 0, 100, 100) and the 463 // Update tiles with viewport for tile priority as (0, 0, 100, 100) and the
471 // identify transform for tile priority. 464 // identify transform for tile priority.
472 bool resourceless_software_draw = false; 465 bool resourceless_software_draw = false;
473 gfx::Rect viewport = gfx::Rect(layer_bounds), 466 gfx::Rect viewport = gfx::Rect(layer_bounds),
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 PictureLayerTiling* tiling = tilings->tiling_at(i); 527 PictureLayerTiling* tiling = tilings->tiling_at(i);
535 EXPECT_EQ( 528 EXPECT_EQ(
536 tiling->GetCurrentVisibleRectForTesting(), 529 tiling->GetCurrentVisibleRectForTesting(),
537 gfx::ScaleToEnclosingRect(viewport_rect_for_tile_priority_in_view_space, 530 gfx::ScaleToEnclosingRect(viewport_rect_for_tile_priority_in_view_space,
538 tiling->contents_scale())); 531 tiling->contents_scale()));
539 } 532 }
540 } 533 }
541 534
542 TEST_F(PictureLayerImplTest, InvalidViewportForPrioritizingTiles) { 535 TEST_F(PictureLayerImplTest, InvalidViewportForPrioritizingTiles) {
543 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 536 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
544
545 gfx::Size tile_size(100, 100);
546 gfx::Size layer_bounds(400, 400); 537 gfx::Size layer_bounds(400, 400);
547 538 SetupDefaultTrees(layer_bounds);
548 scoped_refptr<FakePicturePileImpl> pending_pile =
549 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
550 scoped_refptr<FakePicturePileImpl> active_pile =
551 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
552
553 SetupTreesWithInvalidation(pending_pile, active_pile, Region());
554 539
555 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, 540 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, 0.f,
556 false); 541 false);
557 542
558 // UpdateTiles with valid viewport. Should update tile viewport. 543 // UpdateTiles with valid viewport. Should update tile viewport.
559 // Note viewport is considered invalid if and only if in resourceless 544 // Note viewport is considered invalid if and only if in resourceless
560 // software draw. 545 // software draw.
561 bool resourceless_software_draw = false; 546 bool resourceless_software_draw = false;
562 gfx::Rect viewport = gfx::Rect(layer_bounds); 547 gfx::Rect viewport = gfx::Rect(layer_bounds);
563 gfx::Transform transform; 548 gfx::Transform transform;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 resourceless_software_draw); 596 resourceless_software_draw);
612 active_layer_->UpdateTiles(resourceless_software_draw); 597 active_layer_->UpdateTiles(resourceless_software_draw);
613 598
614 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, 599 EXPECT_TRANSFORMATION_MATRIX_EQ(transform,
615 active_layer_->screen_space_transform()); 600 active_layer_->screen_space_transform());
616 EXPECT_EQ(viewport, active_layer_->visible_rect_for_tile_priority()); 601 EXPECT_EQ(viewport, active_layer_->visible_rect_for_tile_priority());
617 } 602 }
618 603
619 TEST_F(PictureLayerImplTest, ViewportRectForTilePriorityIsCached) { 604 TEST_F(PictureLayerImplTest, ViewportRectForTilePriorityIsCached) {
620 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 605 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
621 gfx::Size tile_size(100, 100);
622 gfx::Size layer_bounds(400, 400); 606 gfx::Size layer_bounds(400, 400);
623 607 SetupDefaultTrees(layer_bounds);
624 scoped_refptr<FakePicturePileImpl> pending_pile =
625 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
626 scoped_refptr<FakePicturePileImpl> active_pile =
627 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
628
629 SetupTreesWithInvalidation(pending_pile, active_pile, Region());
630 608
631 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, 609 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, 0.f,
632 false); 610 false);
633 611
634 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200)); 612 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(200));
635 613
636 bool resourceless_software_draw = false; 614 bool resourceless_software_draw = false;
637 gfx::Rect viewport = gfx::Rect(layer_bounds); 615 gfx::Rect viewport = gfx::Rect(layer_bounds);
638 gfx::Rect viewport_rect_for_tile_priority(0, 0, 100, 100); 616 gfx::Rect viewport_rect_for_tile_priority(0, 0, 100, 100);
639 gfx::Transform transform, transform_for_tile_priority; 617 gfx::Transform transform, transform_for_tile_priority;
(...skipping 20 matching lines...) Expand all
660 active_layer_->viewport_rect_for_tile_priority_in_content_space()); 638 active_layer_->viewport_rect_for_tile_priority_in_content_space());
661 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); 639 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text);
662 640
663 // Now the UpdateDrawProperties is called. The viewport rect for tile 641 // Now the UpdateDrawProperties is called. The viewport rect for tile
664 // priority should be the latest value. 642 // priority should be the latest value.
665 EXPECT_EQ(another_viewport_rect_for_tile_priority, 643 EXPECT_EQ(another_viewport_rect_for_tile_priority,
666 active_layer_->viewport_rect_for_tile_priority_in_content_space()); 644 active_layer_->viewport_rect_for_tile_priority_in_content_space());
667 } 645 }
668 646
669 TEST_F(PictureLayerImplTest, ClonePartialInvalidation) { 647 TEST_F(PictureLayerImplTest, ClonePartialInvalidation) {
670 gfx::Size tile_size(100, 100);
671 gfx::Size layer_bounds(400, 400); 648 gfx::Size layer_bounds(400, 400);
672 gfx::Rect layer_invalidation(150, 200, 30, 180); 649 gfx::Rect layer_invalidation(150, 200, 30, 180);
673 650
674 scoped_refptr<FakePicturePileImpl> pending_pile = 651 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
675 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 652 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
676 scoped_refptr<FakePicturePileImpl> active_pile = 653 scoped_refptr<FakeDisplayListRasterSource> active_raster_source =
677 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 654 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
678 scoped_refptr<FakePicturePileImpl> lost_pile = 655 scoped_refptr<FakeDisplayListRasterSource> lost_raster_source =
679 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 656 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
680 657
681 SetupPendingTreeWithFixedTileSize(lost_pile, gfx::Size(50, 50), Region()); 658 SetupPendingTreeWithFixedTileSize(lost_raster_source, gfx::Size(50, 50),
659 Region());
682 ActivateTree(); 660 ActivateTree();
683 // Add a unique tiling on the active tree. 661 // Add a unique tiling on the active tree.
684 PictureLayerTiling* tiling = active_layer_->AddTiling(3.f); 662 PictureLayerTiling* tiling = active_layer_->AddTiling(3.f);
685 tiling->set_resolution(HIGH_RESOLUTION); 663 tiling->set_resolution(HIGH_RESOLUTION);
686 tiling->CreateAllTilesForTesting(); 664 tiling->CreateAllTilesForTesting();
687 665
688 // Ensure UpdateTiles won't remove any tilings. 666 // Ensure UpdateTiles won't remove any tilings.
689 active_layer_->MarkAllTilingsUsed(); 667 active_layer_->MarkAllTilingsUsed();
690 668
691 // Then setup a new pending tree and activate it. 669 // Then setup a new pending tree and activate it.
692 SetupTreesWithFixedTileSize(pending_pile, active_pile, gfx::Size(50, 50), 670 SetupTreesWithFixedTileSize(pending_raster_source, active_raster_source,
693 layer_invalidation); 671 gfx::Size(50, 50), layer_invalidation);
694 672
695 EXPECT_EQ(1u, pending_layer_->num_tilings()); 673 EXPECT_EQ(1u, pending_layer_->num_tilings());
696 EXPECT_EQ(3u, active_layer_->num_tilings()); 674 EXPECT_EQ(3u, active_layer_->num_tilings());
697 675
698 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); 676 const PictureLayerTilingSet* tilings = pending_layer_->tilings();
699 EXPECT_GT(tilings->num_tilings(), 0u); 677 EXPECT_GT(tilings->num_tilings(), 0u);
700 for (size_t i = 0; i < tilings->num_tilings(); ++i) { 678 for (size_t i = 0; i < tilings->num_tilings(); ++i) {
701 const PictureLayerTiling* tiling = tilings->tiling_at(i); 679 const PictureLayerTiling* tiling = tilings->tiling_at(i);
702 gfx::Rect content_invalidation = gfx::ScaleToEnclosingRect( 680 gfx::Rect content_invalidation = gfx::ScaleToEnclosingRect(
703 layer_invalidation, 681 layer_invalidation,
704 tiling->contents_scale()); 682 tiling->contents_scale());
705 auto prioritized_tiles = 683 auto prioritized_tiles =
706 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); 684 tiling->UpdateAndGetAllPrioritizedTilesForTesting();
707 for (PictureLayerTiling::CoverageIterator iter( 685 for (PictureLayerTiling::CoverageIterator iter(
708 tiling, 686 tiling,
709 tiling->contents_scale(), 687 tiling->contents_scale(),
710 gfx::Rect(tiling->tiling_size())); 688 gfx::Rect(tiling->tiling_size()));
711 iter; 689 iter;
712 ++iter) { 690 ++iter) {
713 // We don't always have a tile, but when we do it's because it was 691 // We don't always have a tile, but when we do it's because it was
714 // invalidated and it has the latest raster source. 692 // invalidated and it has the latest raster source.
715 if (*iter) { 693 if (*iter) {
716 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); 694 EXPECT_FALSE(iter.geometry_rect().IsEmpty());
717 EXPECT_EQ(pending_pile.get(), prioritized_tiles[*iter].raster_source()); 695 EXPECT_EQ(pending_raster_source.get(),
696 prioritized_tiles[*iter].raster_source());
718 EXPECT_TRUE(iter.geometry_rect().Intersects(content_invalidation)); 697 EXPECT_TRUE(iter.geometry_rect().Intersects(content_invalidation));
719 } else { 698 } else {
720 // We don't create tiles in non-invalidated regions. 699 // We don't create tiles in non-invalidated regions.
721 EXPECT_FALSE(iter.geometry_rect().Intersects(content_invalidation)); 700 EXPECT_FALSE(iter.geometry_rect().Intersects(content_invalidation));
722 } 701 }
723 } 702 }
724 } 703 }
725 704
726 tilings = active_layer_->tilings(); 705 tilings = active_layer_->tilings();
727 EXPECT_GT(tilings->num_tilings(), 0u); 706 EXPECT_GT(tilings->num_tilings(), 0u);
728 for (size_t i = 0; i < tilings->num_tilings(); ++i) { 707 for (size_t i = 0; i < tilings->num_tilings(); ++i) {
729 const PictureLayerTiling* tiling = tilings->tiling_at(i); 708 const PictureLayerTiling* tiling = tilings->tiling_at(i);
730 gfx::Rect content_invalidation = 709 gfx::Rect content_invalidation =
731 gfx::ScaleToEnclosingRect(layer_invalidation, tiling->contents_scale()); 710 gfx::ScaleToEnclosingRect(layer_invalidation, tiling->contents_scale());
732 auto prioritized_tiles = 711 auto prioritized_tiles =
733 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); 712 tiling->UpdateAndGetAllPrioritizedTilesForTesting();
734 for (PictureLayerTiling::CoverageIterator iter( 713 for (PictureLayerTiling::CoverageIterator iter(
735 tiling, 714 tiling,
736 tiling->contents_scale(), 715 tiling->contents_scale(),
737 gfx::Rect(tiling->tiling_size())); 716 gfx::Rect(tiling->tiling_size()));
738 iter; 717 iter;
739 ++iter) { 718 ++iter) {
740 EXPECT_TRUE(*iter); 719 EXPECT_TRUE(*iter);
741 EXPECT_FALSE(iter.geometry_rect().IsEmpty()); 720 EXPECT_FALSE(iter.geometry_rect().IsEmpty());
742 // Pile will be updated upon activation. 721 // Raster source will be updated upon activation.
743 EXPECT_EQ(active_pile.get(), prioritized_tiles[*iter].raster_source()); 722 EXPECT_EQ(active_raster_source.get(),
723 prioritized_tiles[*iter].raster_source());
744 } 724 }
745 } 725 }
746 } 726 }
747 727
748 TEST_F(PictureLayerImplTest, CloneFullInvalidation) { 728 TEST_F(PictureLayerImplTest, CloneFullInvalidation) {
749 gfx::Size tile_size(90, 80);
750 gfx::Size layer_bounds(300, 500); 729 gfx::Size layer_bounds(300, 500);
751 730
752 scoped_refptr<FakePicturePileImpl> pending_pile = 731 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
753 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 732 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
754 scoped_refptr<FakePicturePileImpl> active_pile = 733 scoped_refptr<FakeDisplayListRasterSource> active_raster_source =
755 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 734 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
756 735
757 SetupTreesWithInvalidation(pending_pile, active_pile, 736 SetupTreesWithInvalidation(pending_raster_source, active_raster_source,
758 gfx::Rect(layer_bounds)); 737 gfx::Rect(layer_bounds));
759 738
760 EXPECT_EQ(pending_layer_->tilings()->num_tilings(), 739 EXPECT_EQ(pending_layer_->tilings()->num_tilings(),
761 active_layer_->tilings()->num_tilings()); 740 active_layer_->tilings()->num_tilings());
762 741
763 const PictureLayerTilingSet* tilings = pending_layer_->tilings(); 742 const PictureLayerTilingSet* tilings = pending_layer_->tilings();
764 EXPECT_GT(tilings->num_tilings(), 0u); 743 EXPECT_GT(tilings->num_tilings(), 0u);
765 for (size_t i = 0; i < tilings->num_tilings(); ++i) 744 for (size_t i = 0; i < tilings->num_tilings(); ++i) {
766 VerifyAllPrioritizedTilesExistAndHavePile(tilings->tiling_at(i), 745 VerifyAllPrioritizedTilesExistAndHaveRasterSource(
767 pending_pile.get()); 746 tilings->tiling_at(i), pending_raster_source.get());
747 }
768 } 748 }
769 749
770 TEST_F(PictureLayerImplTest, UpdateTilesCreatesTilings) { 750 TEST_F(PictureLayerImplTest, UpdateTilesCreatesTilings) {
771 gfx::Size tile_size(400, 400);
772 gfx::Size layer_bounds(1300, 1900); 751 gfx::Size layer_bounds(1300, 1900);
773 752 SetupDefaultTrees(layer_bounds);
774 scoped_refptr<FakePicturePileImpl> pending_pile =
775 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
776 scoped_refptr<FakePicturePileImpl> active_pile =
777 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
778
779 SetupTrees(pending_pile, active_pile);
780 753
781 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; 754 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
782 EXPECT_LT(low_res_factor, 1.f); 755 EXPECT_LT(low_res_factor, 1.f);
783 756
784 active_layer_->ReleaseResources(); 757 active_layer_->ReleaseResources();
785 EXPECT_FALSE(active_layer_->tilings()); 758 EXPECT_FALSE(active_layer_->tilings());
786 active_layer_->RecreateResources(); 759 active_layer_->RecreateResources();
787 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); 760 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
788 761
789 SetupDrawPropertiesAndUpdateTiles(active_layer_, 762 SetupDrawPropertiesAndUpdateTiles(active_layer_,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 0.f, // starting animation scale 810 0.f, // starting animation scale
838 false); 811 false);
839 ASSERT_EQ(6u, active_layer_->tilings()->num_tilings()); 812 ASSERT_EQ(6u, active_layer_->tilings()->num_tilings());
840 EXPECT_FLOAT_EQ(7.26f, 813 EXPECT_FLOAT_EQ(7.26f,
841 active_layer_->tilings()->tiling_at(0)->contents_scale()); 814 active_layer_->tilings()->tiling_at(0)->contents_scale());
842 EXPECT_FLOAT_EQ(7.26f * low_res_factor, 815 EXPECT_FLOAT_EQ(7.26f * low_res_factor,
843 active_layer_->tilings()->tiling_at(3)->contents_scale()); 816 active_layer_->tilings()->tiling_at(3)->contents_scale());
844 } 817 }
845 818
846 TEST_F(PictureLayerImplTest, PendingLayerOnlyHasHighResTiling) { 819 TEST_F(PictureLayerImplTest, PendingLayerOnlyHasHighResTiling) {
847 gfx::Size tile_size(400, 400);
848 gfx::Size layer_bounds(1300, 1900); 820 gfx::Size layer_bounds(1300, 1900);
849 821 SetupDefaultTrees(layer_bounds);
850 scoped_refptr<FakePicturePileImpl> pending_pile =
851 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
852 scoped_refptr<FakePicturePileImpl> active_pile =
853 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
854
855 SetupTrees(pending_pile, active_pile);
856 822
857 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; 823 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
858 EXPECT_LT(low_res_factor, 1.f); 824 EXPECT_LT(low_res_factor, 1.f);
859 825
860 pending_layer_->ReleaseResources(); 826 pending_layer_->ReleaseResources();
861 EXPECT_FALSE(pending_layer_->tilings()); 827 EXPECT_FALSE(pending_layer_->tilings());
862 pending_layer_->RecreateResources(); 828 pending_layer_->RecreateResources();
863 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); 829 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings());
864 830
865 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 831 SetupDrawPropertiesAndUpdateTiles(pending_layer_,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 false); 874 false);
909 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); 875 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings());
910 EXPECT_FLOAT_EQ(7.26f, 876 EXPECT_FLOAT_EQ(7.26f,
911 pending_layer_->tilings()->tiling_at(0)->contents_scale()); 877 pending_layer_->tilings()->tiling_at(0)->contents_scale());
912 } 878 }
913 879
914 TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { 880 TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) {
915 // This test makes sure that if a layer can have tilings, then a commit makes 881 // This test makes sure that if a layer can have tilings, then a commit makes
916 // it not able to have tilings (empty size), and then a future commit that 882 // it not able to have tilings (empty size), and then a future commit that
917 // makes it valid again should be able to create tilings. 883 // makes it valid again should be able to create tilings.
918 gfx::Size tile_size(400, 400);
919 gfx::Size layer_bounds(1300, 1900); 884 gfx::Size layer_bounds(1300, 1900);
920 885
921 scoped_refptr<FakePicturePileImpl> empty_pile = 886 scoped_refptr<FakeDisplayListRasterSource> empty_raster_source =
922 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); 887 FakeDisplayListRasterSource::CreateEmpty(layer_bounds);
923 scoped_refptr<FakePicturePileImpl> valid_pile = 888 scoped_refptr<FakeDisplayListRasterSource> valid_raster_source =
924 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 889 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
925 890
926 SetupPendingTree(valid_pile); 891 SetupPendingTree(valid_raster_source);
927 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); 892 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings());
928 893
929 ActivateTree(); 894 ActivateTree();
930 SetupPendingTree(empty_pile); 895 SetupPendingTree(empty_raster_source);
931 EXPECT_FALSE(pending_layer_->CanHaveTilings()); 896 EXPECT_FALSE(pending_layer_->CanHaveTilings());
932 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); 897 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings());
933 ASSERT_EQ(0u, pending_layer_->tilings()->num_tilings()); 898 ASSERT_EQ(0u, pending_layer_->tilings()->num_tilings());
934 899
935 ActivateTree(); 900 ActivateTree();
936 EXPECT_FALSE(active_layer_->CanHaveTilings()); 901 EXPECT_FALSE(active_layer_->CanHaveTilings());
937 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); 902 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings());
938 903
939 SetupPendingTree(valid_pile); 904 SetupPendingTree(valid_raster_source);
940 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); 905 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings());
941 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); 906 ASSERT_EQ(0u, active_layer_->tilings()->num_tilings());
942 } 907 }
943 908
944 TEST_F(PictureLayerImplTest, LowResTilingStaysOnActiveTree) { 909 TEST_F(PictureLayerImplTest, LowResTilingStaysOnActiveTree) {
945 gfx::Size tile_size(400, 400);
946 gfx::Size layer_bounds(1300, 1900); 910 gfx::Size layer_bounds(1300, 1900);
947 911
948 scoped_refptr<FakePicturePileImpl> valid_pile = 912 scoped_refptr<FakeDisplayListRasterSource> valid_raster_source =
949 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 913 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
950 scoped_refptr<FakePicturePileImpl> other_valid_pile = 914 scoped_refptr<FakeDisplayListRasterSource> other_valid_raster_source =
951 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 915 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
952 916
953 SetupPendingTree(valid_pile); 917 SetupPendingTree(valid_raster_source);
954 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); 918 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings());
955 919
956 ActivateTree(); 920 ActivateTree();
957 SetupPendingTree(other_valid_pile); 921 SetupPendingTree(other_valid_raster_source);
958 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); 922 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings());
959 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); 923 ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings());
960 auto* low_res_tiling = 924 auto* low_res_tiling =
961 active_layer_->tilings()->FindTilingWithResolution(LOW_RESOLUTION); 925 active_layer_->tilings()->FindTilingWithResolution(LOW_RESOLUTION);
962 EXPECT_TRUE(low_res_tiling); 926 EXPECT_TRUE(low_res_tiling);
963 927
964 ActivateTree(); 928 ActivateTree();
965 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); 929 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings());
966 auto* other_low_res_tiling = 930 auto* other_low_res_tiling =
967 active_layer_->tilings()->FindTilingWithResolution(LOW_RESOLUTION); 931 active_layer_->tilings()->FindTilingWithResolution(LOW_RESOLUTION);
968 EXPECT_TRUE(other_low_res_tiling); 932 EXPECT_TRUE(other_low_res_tiling);
969 EXPECT_EQ(low_res_tiling, other_low_res_tiling); 933 EXPECT_EQ(low_res_tiling, other_low_res_tiling);
970 } 934 }
971 935
972 TEST_F(PictureLayerImplTest, ZoomOutCrash) { 936 TEST_F(PictureLayerImplTest, ZoomOutCrash) {
973 gfx::Size tile_size(400, 400);
974 gfx::Size layer_bounds(1300, 1900); 937 gfx::Size layer_bounds(1300, 1900);
975 938
976 // Set up the high and low res tilings before pinch zoom. 939 // Set up the high and low res tilings before pinch zoom.
977 scoped_refptr<FakePicturePileImpl> pending_pile = 940 SetupDefaultTrees(layer_bounds);
978 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
979 scoped_refptr<FakePicturePileImpl> active_pile =
980 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
981
982 SetupTrees(pending_pile, active_pile);
983 ResetTilingsAndRasterScales(); 941 ResetTilingsAndRasterScales();
984 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); 942 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
985 SetContentsScaleOnBothLayers(32.0f, 1.0f, 32.0f, 1.0f, 0.f, false); 943 SetContentsScaleOnBothLayers(32.0f, 1.0f, 32.0f, 1.0f, 0.f, false);
986 EXPECT_EQ(32.f, active_layer_->HighResTiling()->contents_scale()); 944 EXPECT_EQ(32.f, active_layer_->HighResTiling()->contents_scale());
987 host_impl_.PinchGestureBegin(); 945 host_impl_.PinchGestureBegin();
988 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, 0.f, false); 946 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, 0.f, false);
989 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, 0.f, false); 947 SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, 0.f, false);
990 EXPECT_EQ(active_layer_->tilings()->NumHighResTilings(), 1); 948 EXPECT_EQ(active_layer_->tilings()->NumHighResTilings(), 1);
991 } 949 }
992 950
993 TEST_F(PictureLayerImplTest, PinchGestureTilings) { 951 TEST_F(PictureLayerImplTest, PinchGestureTilings) {
994 gfx::Size tile_size(400, 400);
995 gfx::Size layer_bounds(1300, 1900); 952 gfx::Size layer_bounds(1300, 1900);
996 953
997 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; 954 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
998
999 scoped_refptr<FakePicturePileImpl> pending_pile =
1000 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1001 scoped_refptr<FakePicturePileImpl> active_pile =
1002 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1003
1004 // Set up the high and low res tilings before pinch zoom. 955 // Set up the high and low res tilings before pinch zoom.
1005 SetupTrees(pending_pile, active_pile); 956 SetupDefaultTrees(layer_bounds);
1006 ResetTilingsAndRasterScales(); 957 ResetTilingsAndRasterScales();
1007 958
1008 SetContentsScaleOnBothLayers(2.f, 1.0f, 2.f, 1.0f, 0.f, false); 959 SetContentsScaleOnBothLayers(2.f, 1.0f, 2.f, 1.0f, 0.f, false);
1009 EXPECT_EQ(active_layer_->num_tilings(), 2u); 960 EXPECT_EQ(active_layer_->num_tilings(), 2u);
1010 EXPECT_EQ(pending_layer_->num_tilings(), 1u); 961 EXPECT_EQ(pending_layer_->num_tilings(), 1u);
1011 EXPECT_EQ(active_layer_->tilings()->tiling_at(0)->contents_scale(), 2.f); 962 EXPECT_EQ(active_layer_->tilings()->tiling_at(0)->contents_scale(), 2.f);
1012 EXPECT_EQ(active_layer_->tilings()->tiling_at(1)->contents_scale(), 963 EXPECT_EQ(active_layer_->tilings()->tiling_at(1)->contents_scale(),
1013 2.f * low_res_factor); 964 2.f * low_res_factor);
1014 // One of the tilings has to be a low resolution one. 965 // One of the tilings has to be a low resolution one.
1015 EXPECT_EQ(LOW_RESOLUTION, 966 EXPECT_EQ(LOW_RESOLUTION,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 active_layer_->tilings()->tiling_at(0)->contents_scale()); 1024 active_layer_->tilings()->tiling_at(0)->contents_scale());
1074 // Now that we stopped pinching, the low resolution tiling that existed should 1025 // Now that we stopped pinching, the low resolution tiling that existed should
1075 // now be marked as low resolution. 1026 // now be marked as low resolution.
1076 low_res_tiling = 1027 low_res_tiling =
1077 active_layer_->tilings()->FindTilingWithScale(4.f * low_res_factor); 1028 active_layer_->tilings()->FindTilingWithScale(4.f * low_res_factor);
1078 EXPECT_TRUE(low_res_tiling); 1029 EXPECT_TRUE(low_res_tiling);
1079 EXPECT_EQ(LOW_RESOLUTION, low_res_tiling->resolution()); 1030 EXPECT_EQ(LOW_RESOLUTION, low_res_tiling->resolution());
1080 } 1031 }
1081 1032
1082 TEST_F(PictureLayerImplTest, SnappedTilingDuringZoom) { 1033 TEST_F(PictureLayerImplTest, SnappedTilingDuringZoom) {
1083 gfx::Size tile_size(300, 300);
1084 gfx::Size layer_bounds(2600, 3800); 1034 gfx::Size layer_bounds(2600, 3800);
1085 1035 SetupDefaultTrees(layer_bounds);
1086 scoped_refptr<FakePicturePileImpl> pending_pile =
1087 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1088 scoped_refptr<FakePicturePileImpl> active_pile =
1089 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1090
1091 SetupTrees(pending_pile, active_pile);
1092 1036
1093 ResetTilingsAndRasterScales(); 1037 ResetTilingsAndRasterScales();
1094 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); 1038 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
1095 1039
1096 // Set up the high and low res tilings before pinch zoom. 1040 // Set up the high and low res tilings before pinch zoom.
1097 SetContentsScaleOnBothLayers(0.24f, 1.0f, 0.24f, 1.0f, 0.f, false); 1041 SetContentsScaleOnBothLayers(0.24f, 1.0f, 0.24f, 1.0f, 0.f, false);
1098 EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); 1042 EXPECT_EQ(2u, active_layer_->tilings()->num_tilings());
1099 EXPECT_FLOAT_EQ(0.24f, 1043 EXPECT_FLOAT_EQ(0.24f,
1100 active_layer_->tilings()->tiling_at(0)->contents_scale()); 1044 active_layer_->tilings()->tiling_at(0)->contents_scale());
1101 EXPECT_FLOAT_EQ(0.0625f, 1045 EXPECT_FLOAT_EQ(0.0625f,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1133 1077
1134 // Zoom in a lot. Since we move in factors of two, we should get a scale that 1078 // Zoom in a lot. Since we move in factors of two, we should get a scale that
1135 // is a power of 2 times 0.24. 1079 // is a power of 2 times 0.24.
1136 SetContentsScaleOnBothLayers(1.f, 1.0f, 1.f, 1.0f, 0.f, false); 1080 SetContentsScaleOnBothLayers(1.f, 1.0f, 1.f, 1.0f, 0.f, false);
1137 EXPECT_EQ(4u, active_layer_->tilings()->num_tilings()); 1081 EXPECT_EQ(4u, active_layer_->tilings()->num_tilings());
1138 EXPECT_FLOAT_EQ(1.92f, 1082 EXPECT_FLOAT_EQ(1.92f,
1139 active_layer_->tilings()->tiling_at(0)->contents_scale()); 1083 active_layer_->tilings()->tiling_at(0)->contents_scale());
1140 } 1084 }
1141 1085
1142 TEST_F(PictureLayerImplTest, CleanUpTilings) { 1086 TEST_F(PictureLayerImplTest, CleanUpTilings) {
1143 gfx::Size tile_size(400, 400);
1144 gfx::Size layer_bounds(1300, 1900); 1087 gfx::Size layer_bounds(1300, 1900);
1145 1088
1146 scoped_refptr<FakePicturePileImpl> pending_pile =
1147 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1148 scoped_refptr<FakePicturePileImpl> active_pile =
1149 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1150
1151 std::vector<PictureLayerTiling*> used_tilings; 1089 std::vector<PictureLayerTiling*> used_tilings;
1152 1090
1153 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; 1091 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
1154 EXPECT_LT(low_res_factor, 1.f); 1092 EXPECT_LT(low_res_factor, 1.f);
1155 1093
1156 float scale = 1.f; 1094 float scale = 1.f;
1157 float page_scale = 1.f; 1095 float page_scale = 1.f;
1158 1096
1159 SetupTrees(pending_pile, active_pile); 1097 SetupDefaultTrees(layer_bounds);
1160 EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); 1098 EXPECT_EQ(2u, active_layer_->tilings()->num_tilings());
1161 EXPECT_EQ(1.f, active_layer_->HighResTiling()->contents_scale()); 1099 EXPECT_EQ(1.f, active_layer_->HighResTiling()->contents_scale());
1162 1100
1163 // Ensure UpdateTiles won't remove any tilings. Note this is unrelated to 1101 // Ensure UpdateTiles won't remove any tilings. Note this is unrelated to
1164 // |used_tilings| variable, and it's here only to ensure that active_layer_ 1102 // |used_tilings| variable, and it's here only to ensure that active_layer_
1165 // won't remove tilings before the test has a chance to verify behavior. 1103 // won't remove tilings before the test has a chance to verify behavior.
1166 active_layer_->MarkAllTilingsUsed(); 1104 active_layer_->MarkAllTilingsUsed();
1167 1105
1168 // We only have ideal tilings, so they aren't removed. 1106 // We only have ideal tilings, so they aren't removed.
1169 used_tilings.clear(); 1107 used_tilings.clear();
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 starting_animation_scale, animating_transform); 1254 starting_animation_scale, animating_transform);
1317 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); 1255 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f);
1318 EXPECT_EQ(active_layer_->LowResTiling()->contents_scale(), 1256 EXPECT_EQ(active_layer_->LowResTiling()->contents_scale(),
1319 2.f * low_res_factor); 1257 2.f * low_res_factor);
1320 EXPECT_EQ(4u, active_layer_->num_tilings()); 1258 EXPECT_EQ(4u, active_layer_->num_tilings());
1321 EXPECT_EQ(1u, pending_layer_->num_tilings()); 1259 EXPECT_EQ(1u, pending_layer_->num_tilings());
1322 } 1260 }
1323 1261
1324 TEST_F(PictureLayerImplTest, DontAddLowResForSmallLayers) { 1262 TEST_F(PictureLayerImplTest, DontAddLowResForSmallLayers) {
1325 gfx::Size layer_bounds(host_impl_.settings().default_tile_size); 1263 gfx::Size layer_bounds(host_impl_.settings().default_tile_size);
1326 gfx::Size tile_size(100, 100);
1327 1264
1328 scoped_refptr<FakePicturePileImpl> pending_pile = 1265 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
1329 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1266 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
1330 scoped_refptr<FakePicturePileImpl> active_pile = 1267 scoped_refptr<FakeDisplayListRasterSource> active_raster_source =
1331 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1268 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
1332 1269
1333 SetupTrees(pending_pile, active_pile); 1270 SetupTrees(pending_raster_source, active_raster_source);
1334 1271
1335 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; 1272 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
1336 float device_scale = 1.f; 1273 float device_scale = 1.f;
1337 float page_scale = 1.f; 1274 float page_scale = 1.f;
1338 float maximum_animation_scale = 1.f; 1275 float maximum_animation_scale = 1.f;
1339 float starting_animation_scale = 0.f; 1276 float starting_animation_scale = 0.f;
1340 bool animating_transform = false; 1277 bool animating_transform = false;
1341 1278
1342 // Contents exactly fit on one tile at scale 1, no low res. 1279 // Contents exactly fit on one tile at scale 1, no low res.
1343 float contents_scale = 1.f; 1280 float contents_scale = 1.f;
(...skipping 24 matching lines...) Expand all
1368 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); 1305 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale);
1369 EXPECT_EQ(active_layer_->LowResTiling()->contents_scale(), 1306 EXPECT_EQ(active_layer_->LowResTiling()->contents_scale(),
1370 contents_scale * low_res_factor); 1307 contents_scale * low_res_factor);
1371 EXPECT_FALSE(pending_layer_->LowResTiling()); 1308 EXPECT_FALSE(pending_layer_->LowResTiling());
1372 EXPECT_EQ(active_layer_->num_tilings(), 2u); 1309 EXPECT_EQ(active_layer_->num_tilings(), 2u);
1373 EXPECT_EQ(pending_layer_->num_tilings(), 1u); 1310 EXPECT_EQ(pending_layer_->num_tilings(), 1u);
1374 1311
1375 // Mask layers dont create low res since they always fit on one tile. 1312 // Mask layers dont create low res since they always fit on one tile.
1376 scoped_ptr<FakePictureLayerImpl> mask = 1313 scoped_ptr<FakePictureLayerImpl> mask =
1377 FakePictureLayerImpl::CreateMaskWithRasterSource( 1314 FakePictureLayerImpl::CreateMaskWithRasterSource(
1378 host_impl_.pending_tree(), 3, pending_pile); 1315 host_impl_.pending_tree(), 3, pending_raster_source);
1379 mask->SetBounds(layer_bounds); 1316 mask->SetBounds(layer_bounds);
1380 mask->SetDrawsContent(true); 1317 mask->SetDrawsContent(true);
1381 1318
1382 SetupDrawPropertiesAndUpdateTiles( 1319 SetupDrawPropertiesAndUpdateTiles(
1383 mask.get(), contents_scale, device_scale, page_scale, 1320 mask.get(), contents_scale, device_scale, page_scale,
1384 maximum_animation_scale, starting_animation_scale, animating_transform); 1321 maximum_animation_scale, starting_animation_scale, animating_transform);
1385 EXPECT_EQ(mask->HighResTiling()->contents_scale(), contents_scale); 1322 EXPECT_EQ(mask->HighResTiling()->contents_scale(), contents_scale);
1386 EXPECT_EQ(mask->num_tilings(), 1u); 1323 EXPECT_EQ(mask->num_tilings(), 1u);
1387 } 1324 }
1388 1325
1389 TEST_F(PictureLayerImplTest, HugeMasksGetScaledDown) { 1326 TEST_F(PictureLayerImplTest, HugeMasksGetScaledDown) {
1390 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 1327 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
1391 1328
1392 gfx::Size tile_size(100, 100);
1393 gfx::Size layer_bounds(1000, 1000); 1329 gfx::Size layer_bounds(1000, 1000);
1394 1330
1395 scoped_refptr<FakePicturePileImpl> valid_pile = 1331 scoped_refptr<FakeDisplayListRasterSource> valid_raster_source =
1396 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1332 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
1397 SetupPendingTree(valid_pile); 1333 SetupPendingTree(valid_raster_source);
1398 1334
1399 scoped_ptr<FakePictureLayerImpl> mask_ptr = 1335 scoped_ptr<FakePictureLayerImpl> mask_ptr =
1400 FakePictureLayerImpl::CreateMaskWithRasterSource( 1336 FakePictureLayerImpl::CreateMaskWithRasterSource(
1401 host_impl_.pending_tree(), 3, valid_pile); 1337 host_impl_.pending_tree(), 3, valid_raster_source);
1402 mask_ptr->SetBounds(layer_bounds); 1338 mask_ptr->SetBounds(layer_bounds);
1403 mask_ptr->SetDrawsContent(true); 1339 mask_ptr->SetDrawsContent(true);
1404 pending_layer_->SetMaskLayer(mask_ptr.Pass()); 1340 pending_layer_->SetMaskLayer(mask_ptr.Pass());
1405 pending_layer_->SetHasRenderSurface(true); 1341 pending_layer_->SetHasRenderSurface(true);
1406 1342
1407 host_impl_.pending_tree()->BuildPropertyTreesForTesting(); 1343 host_impl_.pending_tree()->BuildPropertyTreesForTesting();
1408 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 1344 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
1409 bool update_lcd_text = false; 1345 bool update_lcd_text = false;
1410 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); 1346 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text);
1411 1347
(...skipping 28 matching lines...) Expand all
1440 SetupDrawPropertiesAndUpdateTiles(active_mask, 1.f, 1.f, 1.f, 1.f, 0.f, 1376 SetupDrawPropertiesAndUpdateTiles(active_mask, 1.f, 1.f, 1.f, 1.f, 0.f,
1441 false); 1377 false);
1442 active_mask->HighResTiling()->CreateAllTilesForTesting(); 1378 active_mask->HighResTiling()->CreateAllTilesForTesting();
1443 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); 1379 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size());
1444 EXPECT_NE(0u, mask_resource_id); 1380 EXPECT_NE(0u, mask_resource_id);
1445 EXPECT_EQ(active_mask->bounds(), mask_texture_size); 1381 EXPECT_EQ(active_mask->bounds(), mask_texture_size);
1446 1382
1447 // Resize larger than the max texture size. 1383 // Resize larger than the max texture size.
1448 int max_texture_size = host_impl_.GetRendererCapabilities().max_texture_size; 1384 int max_texture_size = host_impl_.GetRendererCapabilities().max_texture_size;
1449 gfx::Size huge_bounds(max_texture_size + 1, 10); 1385 gfx::Size huge_bounds(max_texture_size + 1, 10);
1450 scoped_refptr<FakePicturePileImpl> huge_pile = 1386 scoped_refptr<FakeDisplayListRasterSource> huge_raster_source =
1451 FakePicturePileImpl::CreateFilledPile(tile_size, huge_bounds); 1387 FakeDisplayListRasterSource::CreateFilled(huge_bounds);
1452 1388
1453 SetupPendingTree(huge_pile); 1389 SetupPendingTree(huge_raster_source);
1454 pending_mask->SetBounds(huge_bounds); 1390 pending_mask->SetBounds(huge_bounds);
1455 pending_mask->SetRasterSourceOnPending(huge_pile, Region()); 1391 pending_mask->SetRasterSourceOnPending(huge_raster_source, Region());
1456 1392
1457 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 1393 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
1458 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); 1394 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text);
1459 1395
1460 // The mask tiling gets scaled down. 1396 // The mask tiling gets scaled down.
1461 EXPECT_LT(pending_mask->HighResTiling()->contents_scale(), 1.f); 1397 EXPECT_LT(pending_mask->HighResTiling()->contents_scale(), 1.f);
1462 EXPECT_EQ(1u, pending_mask->num_tilings()); 1398 EXPECT_EQ(1u, pending_mask->num_tilings());
1463 1399
1464 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( 1400 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(
1465 pending_mask->HighResTiling()->AllTilesForTesting()); 1401 pending_mask->HighResTiling()->AllTilesForTesting());
(...skipping 15 matching lines...) Expand all
1481 pending_mask->RecreateResources(); 1417 pending_mask->RecreateResources();
1482 active_mask->RecreateResources(); 1418 active_mask->RecreateResources();
1483 SetupDrawPropertiesAndUpdateTiles(active_mask, 1.f, 1.f, 1.f, 1.f, 0.f, 1419 SetupDrawPropertiesAndUpdateTiles(active_mask, 1.f, 1.f, 1.f, 1.f, 0.f,
1484 false); 1420 false);
1485 active_mask->HighResTiling()->CreateAllTilesForTesting(); 1421 active_mask->HighResTiling()->CreateAllTilesForTesting();
1486 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); 1422 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size());
1487 EXPECT_NE(0u, mask_resource_id); 1423 EXPECT_NE(0u, mask_resource_id);
1488 EXPECT_EQ(expected_size, mask_texture_size); 1424 EXPECT_EQ(expected_size, mask_texture_size);
1489 1425
1490 // Do another activate, the same holds. 1426 // Do another activate, the same holds.
1491 SetupPendingTree(huge_pile); 1427 SetupPendingTree(huge_raster_source);
1492 ActivateTree(); 1428 ActivateTree();
1493 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size()); 1429 EXPECT_EQ(1u, active_mask->HighResTiling()->AllTilesForTesting().size());
1494 active_layer_->GetContentsResourceId(&mask_resource_id, &mask_texture_size); 1430 active_layer_->GetContentsResourceId(&mask_resource_id, &mask_texture_size);
1495 EXPECT_EQ(expected_size, mask_texture_size); 1431 EXPECT_EQ(expected_size, mask_texture_size);
1496 EXPECT_EQ(0u, mask_resource_id); 1432 EXPECT_EQ(0u, mask_resource_id);
1497 1433
1498 // Resize even larger, so that the scale would be smaller than the minimum 1434 // Resize even larger, so that the scale would be smaller than the minimum
1499 // contents scale. Then the layer should no longer have any tiling. 1435 // contents scale. Then the layer should no longer have any tiling.
1500 float min_contents_scale = host_impl_.settings().minimum_contents_scale; 1436 float min_contents_scale = host_impl_.settings().minimum_contents_scale;
1501 gfx::Size extra_huge_bounds(max_texture_size / min_contents_scale + 1, 10); 1437 gfx::Size extra_huge_bounds(max_texture_size / min_contents_scale + 1, 10);
1502 scoped_refptr<FakePicturePileImpl> extra_huge_pile = 1438 scoped_refptr<FakeDisplayListRasterSource> extra_huge_raster_source =
1503 FakePicturePileImpl::CreateFilledPile(tile_size, extra_huge_bounds); 1439 FakeDisplayListRasterSource::CreateFilled(extra_huge_bounds);
1504 1440
1505 SetupPendingTree(extra_huge_pile); 1441 SetupPendingTree(extra_huge_raster_source);
1506 pending_mask->SetBounds(extra_huge_bounds); 1442 pending_mask->SetBounds(extra_huge_bounds);
1507 pending_mask->SetRasterSourceOnPending(extra_huge_pile, Region()); 1443 pending_mask->SetRasterSourceOnPending(extra_huge_raster_source, Region());
1508 1444
1509 EXPECT_FALSE(pending_mask->CanHaveTilings()); 1445 EXPECT_FALSE(pending_mask->CanHaveTilings());
1510 1446
1511 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 1447 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
1512 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); 1448 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text);
1513 1449
1514 EXPECT_EQ(0u, pending_mask->num_tilings()); 1450 EXPECT_EQ(0u, pending_mask->num_tilings());
1515 } 1451 }
1516 1452
1517 TEST_F(PictureLayerImplTest, ScaledMaskLayer) { 1453 TEST_F(PictureLayerImplTest, ScaledMaskLayer) {
1518 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 1454 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
1519 1455
1520 gfx::Size tile_size(100, 100);
1521 gfx::Size layer_bounds(1000, 1000); 1456 gfx::Size layer_bounds(1000, 1000);
1522 1457
1523 host_impl_.SetDeviceScaleFactor(1.3f); 1458 host_impl_.SetDeviceScaleFactor(1.3f);
1524 1459
1525 scoped_refptr<FakePicturePileImpl> valid_pile = 1460 scoped_refptr<FakeDisplayListRasterSource> valid_raster_source =
1526 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1461 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
1527 SetupPendingTree(valid_pile); 1462 SetupPendingTree(valid_raster_source);
1528 1463
1529 scoped_ptr<FakePictureLayerImpl> mask_ptr = 1464 scoped_ptr<FakePictureLayerImpl> mask_ptr =
1530 FakePictureLayerImpl::CreateMaskWithRasterSource( 1465 FakePictureLayerImpl::CreateMaskWithRasterSource(
1531 host_impl_.pending_tree(), 3, valid_pile); 1466 host_impl_.pending_tree(), 3, valid_raster_source);
1532 mask_ptr->SetBounds(layer_bounds); 1467 mask_ptr->SetBounds(layer_bounds);
1533 mask_ptr->SetDrawsContent(true); 1468 mask_ptr->SetDrawsContent(true);
1534 pending_layer_->SetMaskLayer(mask_ptr.Pass()); 1469 pending_layer_->SetMaskLayer(mask_ptr.Pass());
1535 pending_layer_->SetHasRenderSurface(true); 1470 pending_layer_->SetHasRenderSurface(true);
1536 1471
1537 host_impl_.pending_tree()->BuildPropertyTreesForTesting(); 1472 host_impl_.pending_tree()->BuildPropertyTreesForTesting();
1538 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 1473 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
1539 bool update_lcd_text = false; 1474 bool update_lcd_text = false;
1540 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); 1475 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text);
1541 1476
(...skipping 18 matching lines...) Expand all
1560 ResourceId mask_resource_id; 1495 ResourceId mask_resource_id;
1561 gfx::Size mask_texture_size; 1496 gfx::Size mask_texture_size;
1562 active_mask->GetContentsResourceId(&mask_resource_id, &mask_texture_size); 1497 active_mask->GetContentsResourceId(&mask_resource_id, &mask_texture_size);
1563 EXPECT_NE(0u, mask_resource_id); 1498 EXPECT_NE(0u, mask_resource_id);
1564 gfx::Size expected_mask_texture_size = 1499 gfx::Size expected_mask_texture_size =
1565 gfx::ToCeiledSize(gfx::ScaleSize(active_mask->bounds(), 1.3f)); 1500 gfx::ToCeiledSize(gfx::ScaleSize(active_mask->bounds(), 1.3f));
1566 EXPECT_EQ(mask_texture_size, expected_mask_texture_size); 1501 EXPECT_EQ(mask_texture_size, expected_mask_texture_size);
1567 } 1502 }
1568 1503
1569 TEST_F(PictureLayerImplTest, ReleaseResources) { 1504 TEST_F(PictureLayerImplTest, ReleaseResources) {
1570 gfx::Size tile_size(400, 400);
1571 gfx::Size layer_bounds(1300, 1900); 1505 gfx::Size layer_bounds(1300, 1900);
1572 1506 SetupDefaultTrees(layer_bounds);
1573 scoped_refptr<FakePicturePileImpl> pending_pile =
1574 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1575 scoped_refptr<FakePicturePileImpl> active_pile =
1576 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1577
1578 SetupTrees(pending_pile, active_pile);
1579 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); 1507 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings());
1580 1508
1581 // All tilings should be removed when losing output surface. 1509 // All tilings should be removed when losing output surface.
1582 active_layer_->ReleaseResources(); 1510 active_layer_->ReleaseResources();
1583 EXPECT_FALSE(active_layer_->tilings()); 1511 EXPECT_FALSE(active_layer_->tilings());
1584 active_layer_->RecreateResources(); 1512 active_layer_->RecreateResources();
1585 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); 1513 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
1586 pending_layer_->ReleaseResources(); 1514 pending_layer_->ReleaseResources();
1587 EXPECT_FALSE(pending_layer_->tilings()); 1515 EXPECT_FALSE(pending_layer_->tilings());
1588 pending_layer_->RecreateResources(); 1516 pending_layer_->RecreateResources();
1589 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); 1517 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings());
1590 1518
1591 // This should create new tilings. 1519 // This should create new tilings.
1592 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1520 SetupDrawPropertiesAndUpdateTiles(pending_layer_,
1593 1.f, // ideal contents scale 1521 1.f, // ideal contents scale
1594 1.f, // device scale 1522 1.f, // device scale
1595 1.f, // page scale 1523 1.f, // page scale
1596 1.f, // maximum animation scale 1524 1.f, // maximum animation scale
1597 0.f, // starting animation_scale 1525 0.f, // starting animation_scale
1598 false); 1526 false);
1599 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); 1527 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings());
1600 } 1528 }
1601 1529
1602 TEST_F(PictureLayerImplTest, ClampTilesToMaxTileSize) { 1530 TEST_F(PictureLayerImplTest, ClampTilesToMaxTileSize) {
1603 // The default max tile size is larger than 400x400.
1604 gfx::Size tile_size(400, 400);
1605 gfx::Size layer_bounds(5000, 5000); 1531 gfx::Size layer_bounds(5000, 5000);
1606 1532
1607 scoped_refptr<FakePicturePileImpl> pending_pile = 1533 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
1608 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1534 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
1609 1535
1610 SetupPendingTree(pending_pile); 1536 SetupPendingTree(pending_raster_source);
1611 EXPECT_GE(pending_layer_->tilings()->num_tilings(), 1u); 1537 EXPECT_GE(pending_layer_->tilings()->num_tilings(), 1u);
1612 1538
1613 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); 1539 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting();
1614 1540
1615 // The default value. 1541 // The default value.
1616 EXPECT_EQ(gfx::Size(256, 256).ToString(), 1542 EXPECT_EQ(gfx::Size(256, 256).ToString(),
1617 host_impl_.settings().default_tile_size.ToString()); 1543 host_impl_.settings().default_tile_size.ToString());
1618 1544
1619 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; 1545 Tile* tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0];
1620 EXPECT_EQ(gfx::Size(256, 256).ToString(), 1546 EXPECT_EQ(gfx::Size(256, 256).ToString(),
(...skipping 15 matching lines...) Expand all
1636 1562
1637 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); 1563 pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting();
1638 1564
1639 // Verify the tiles are not larger than the context's max texture size. 1565 // Verify the tiles are not larger than the context's max texture size.
1640 tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; 1566 tile = pending_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0];
1641 EXPECT_GE(140, tile->content_rect().width()); 1567 EXPECT_GE(140, tile->content_rect().width());
1642 EXPECT_GE(140, tile->content_rect().height()); 1568 EXPECT_GE(140, tile->content_rect().height());
1643 } 1569 }
1644 1570
1645 TEST_F(PictureLayerImplTest, ClampSingleTileToToMaxTileSize) { 1571 TEST_F(PictureLayerImplTest, ClampSingleTileToToMaxTileSize) {
1646 // The default max tile size is larger than 400x400.
1647 gfx::Size tile_size(400, 400);
1648 gfx::Size layer_bounds(500, 500); 1572 gfx::Size layer_bounds(500, 500);
1649 1573 SetupDefaultTrees(layer_bounds);
1650 scoped_refptr<FakePicturePileImpl> pending_pile =
1651 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1652 scoped_refptr<FakePicturePileImpl> active_pile =
1653 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1654
1655 SetupTrees(pending_pile, active_pile);
1656 EXPECT_GE(active_layer_->tilings()->num_tilings(), 1u); 1574 EXPECT_GE(active_layer_->tilings()->num_tilings(), 1u);
1657 1575
1658 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); 1576 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting();
1659 1577
1660 // The default value. The layer is smaller than this. 1578 // The default value. The layer is smaller than this.
1661 EXPECT_EQ(gfx::Size(512, 512).ToString(), 1579 EXPECT_EQ(gfx::Size(512, 512).ToString(),
1662 host_impl_.settings().max_untiled_layer_size.ToString()); 1580 host_impl_.settings().max_untiled_layer_size.ToString());
1663 1581
1664 // There should be a single tile since the layer is small. 1582 // There should be a single tile since the layer is small.
1665 PictureLayerTiling* high_res_tiling = active_layer_->tilings()->tiling_at(0); 1583 PictureLayerTiling* high_res_tiling = active_layer_->tilings()->tiling_at(0);
(...skipping 22 matching lines...) Expand all
1688 1606
1689 // Verify the tiles are not larger than the context's max texture size. 1607 // Verify the tiles are not larger than the context's max texture size.
1690 Tile* tile = active_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0]; 1608 Tile* tile = active_layer_->tilings()->tiling_at(0)->AllTilesForTesting()[0];
1691 EXPECT_GE(140, tile->content_rect().width()); 1609 EXPECT_GE(140, tile->content_rect().width());
1692 EXPECT_GE(140, tile->content_rect().height()); 1610 EXPECT_GE(140, tile->content_rect().height());
1693 } 1611 }
1694 1612
1695 TEST_F(PictureLayerImplTest, DisallowTileDrawQuads) { 1613 TEST_F(PictureLayerImplTest, DisallowTileDrawQuads) {
1696 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 1614 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
1697 1615
1698 gfx::Size tile_size(400, 400);
1699 gfx::Size layer_bounds(1300, 1900); 1616 gfx::Size layer_bounds(1300, 1900);
1700 gfx::Rect layer_rect(layer_bounds); 1617 gfx::Rect layer_rect(layer_bounds);
1701 1618
1702 scoped_refptr<FakePicturePileImpl> pending_pile =
1703 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1704 scoped_refptr<FakePicturePileImpl> active_pile =
1705 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1706
1707 gfx::Rect layer_invalidation(150, 200, 30, 180); 1619 gfx::Rect layer_invalidation(150, 200, 30, 180);
1708 SetupTreesWithInvalidation(pending_pile, active_pile, layer_invalidation); 1620 SetupDefaultTreesWithInvalidation(layer_bounds, layer_invalidation);
1709 1621
1710 active_layer_->SetContentsOpaque(true); 1622 active_layer_->SetContentsOpaque(true);
1711 active_layer_->draw_properties().visible_layer_rect = gfx::Rect(layer_bounds); 1623 active_layer_->draw_properties().visible_layer_rect = gfx::Rect(layer_bounds);
1712 1624
1713 AppendQuadsData data; 1625 AppendQuadsData data;
1714 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, nullptr); 1626 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, nullptr);
1715 active_layer_->AppendQuads(render_pass.get(), &data); 1627 active_layer_->AppendQuads(render_pass.get(), &data);
1716 active_layer_->DidDraw(nullptr); 1628 active_layer_->DidDraw(nullptr);
1717 1629
1718 ASSERT_EQ(1U, render_pass->quad_list.size()); 1630 ASSERT_EQ(1u, render_pass->quad_list.size());
1719 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, 1631 EXPECT_EQ(DrawQuad::PICTURE_CONTENT,
1720 render_pass->quad_list.front()->material); 1632 render_pass->quad_list.front()->material);
1721 EXPECT_EQ(render_pass->quad_list.front()->rect, layer_rect); 1633 EXPECT_EQ(render_pass->quad_list.front()->rect, layer_rect);
1722 EXPECT_EQ(render_pass->quad_list.front()->opaque_rect, layer_rect); 1634 EXPECT_EQ(render_pass->quad_list.front()->opaque_rect, layer_rect);
1723 EXPECT_EQ(render_pass->quad_list.front()->visible_rect, layer_rect); 1635 EXPECT_EQ(render_pass->quad_list.front()->visible_rect, layer_rect);
1724 } 1636 }
1725 1637
1726 TEST_F(PictureLayerImplTest, ResourcelessPartialRecording) { 1638 TEST_F(PictureLayerImplTest, ResourcelessPartialRecording) {
1727 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 1639 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
1728 1640
1729 gfx::Size tile_size(400, 400); 1641 gfx::Size tile_size(400, 400);
1730 gfx::Size layer_bounds(700, 650); 1642 gfx::Size layer_bounds(700, 650);
1731 gfx::Rect layer_rect(layer_bounds); 1643 gfx::Rect layer_rect(layer_bounds);
1732 host_impl_.SetDeviceScaleFactor(2.f); 1644 host_impl_.SetDeviceScaleFactor(2.f);
1733 1645
1734 gfx::Rect recorded_viewport(20, 30, 40, 50); 1646 gfx::Rect recorded_viewport(20, 30, 40, 50);
1735 bool is_filled = true; 1647 scoped_ptr<FakeDisplayListRecordingSource> active_recording_source =
1736 scoped_refptr<FakePicturePileImpl> active_pile = 1648 FakeDisplayListRecordingSource::CreateRecordingSource(recorded_viewport,
1737 FakePicturePileImpl::CreatePile(tile_size, layer_bounds, 1649 layer_bounds);
1738 recorded_viewport, is_filled); 1650 SkPaint green_paint;
1739 SetupPendingTree(active_pile); 1651 green_paint.setColor(SK_ColorGREEN);
danakj 2015/09/22 21:52:14 can you comment why is green important? maybe in c
vmpstr 2015/09/22 22:57:49 I changed this to use CreatePartiallyFilled
1652 active_recording_source->add_draw_rect_with_paint(recorded_viewport,
1653 green_paint);
1654 active_recording_source->Rerecord();
1655
1656 scoped_refptr<FakeDisplayListRasterSource> active_raster_source =
1657 FakeDisplayListRasterSource::CreateFromRecordingSource(
1658 active_recording_source.get(), true);
1659
1660 SetupPendingTree(active_raster_source);
1740 ActivateTree(); 1661 ActivateTree();
1741 1662
1742 active_layer_->SetContentsOpaque(true); 1663 active_layer_->SetContentsOpaque(true);
1743 gfx::Rect visible_rect(30, 35, 10, 5); 1664 gfx::Rect visible_rect(30, 35, 10, 5);
1744 active_layer_->draw_properties().visible_layer_rect = visible_rect; 1665 active_layer_->draw_properties().visible_layer_rect = visible_rect;
1745 1666
1746 AppendQuadsData data; 1667 AppendQuadsData data;
1747 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, nullptr); 1668 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, nullptr);
1748 active_layer_->AppendQuads(render_pass.get(), &data); 1669 active_layer_->AppendQuads(render_pass.get(), &data);
1749 active_layer_->DidDraw(nullptr); 1670 active_layer_->DidDraw(nullptr);
1750 1671
1751 gfx::Rect scaled_visible = gfx::ScaleToEnclosingRect(visible_rect, 2.f); 1672 gfx::Rect scaled_visible = gfx::ScaleToEnclosingRect(visible_rect, 2.f);
1752 gfx::Rect scaled_recorded = gfx::ScaleToEnclosingRect(recorded_viewport, 2.f); 1673 gfx::Rect scaled_recorded = gfx::ScaleToEnclosingRect(recorded_viewport, 2.f);
1753 gfx::Rect quad_visible = gfx::IntersectRects(scaled_visible, scaled_recorded); 1674 gfx::Rect quad_visible = gfx::IntersectRects(scaled_visible, scaled_recorded);
1754 1675
1755 ASSERT_EQ(1U, render_pass->quad_list.size()); 1676 ASSERT_EQ(1U, render_pass->quad_list.size());
1756 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, 1677 EXPECT_EQ(DrawQuad::PICTURE_CONTENT,
1757 render_pass->quad_list.front()->material); 1678 render_pass->quad_list.front()->material);
1758 const DrawQuad* quad = render_pass->quad_list.front(); 1679 const DrawQuad* quad = render_pass->quad_list.front();
1759 EXPECT_EQ(quad_visible, quad->rect); 1680 EXPECT_EQ(quad_visible, quad->rect);
1760 EXPECT_EQ(quad_visible, quad->opaque_rect); 1681 EXPECT_EQ(quad_visible, quad->opaque_rect);
1761 EXPECT_EQ(quad_visible, quad->visible_rect); 1682 EXPECT_EQ(quad_visible, quad->visible_rect);
1762 } 1683 }
1763 1684
1764 TEST_F(PictureLayerImplTest, ResourcelessEmptyRecording) { 1685 TEST_F(PictureLayerImplTest, ResourcelessEmptyRecording) {
1765 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 1686 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
1766 1687
1767 gfx::Size tile_size(400, 400);
1768 gfx::Size layer_bounds(700, 650); 1688 gfx::Size layer_bounds(700, 650);
1769 1689 scoped_refptr<FakeDisplayListRasterSource> active_raster_source =
1770 scoped_refptr<FakePicturePileImpl> active_pile = 1690 FakeDisplayListRasterSource::CreatePartiallyFilled(layer_bounds,
1771 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); 1691 gfx::Rect());
1772 SetupPendingTree(active_pile); 1692 SetupPendingTree(active_raster_source);
1773 ActivateTree(); 1693 ActivateTree();
1774 1694
1775 active_layer_->SetContentsOpaque(true); 1695 active_layer_->SetContentsOpaque(true);
1776 active_layer_->draw_properties().visible_layer_rect = gfx::Rect(layer_bounds); 1696 active_layer_->draw_properties().visible_layer_rect = gfx::Rect(layer_bounds);
1777 1697
1778 AppendQuadsData data; 1698 AppendQuadsData data;
1779 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, nullptr); 1699 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, nullptr);
1780 active_layer_->AppendQuads(render_pass.get(), &data); 1700 active_layer_->AppendQuads(render_pass.get(), &data);
1781 active_layer_->DidDraw(nullptr); 1701 active_layer_->DidDraw(nullptr);
1782 1702
1783 EXPECT_EQ(0U, render_pass->quad_list.size()); 1703 EXPECT_EQ(0U, render_pass->quad_list.size());
1784 } 1704 }
1785 1705
1786 TEST_F(PictureLayerImplTest, SolidColorLayerHasVisibleFullCoverage) { 1706 TEST_F(PictureLayerImplTest, SolidColorLayerHasVisibleFullCoverage) {
1787 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 1707 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
1788 1708
1789 gfx::Size tile_size(1000, 1000); 1709 gfx::Size tile_size(1000, 1000);
1790 gfx::Size layer_bounds(1500, 1500); 1710 gfx::Size layer_bounds(1500, 1500);
1791 gfx::Rect visible_rect(250, 250, 1000, 1000); 1711 gfx::Rect visible_rect(250, 250, 1000, 1000);
1792 1712
1793 scoped_ptr<FakePicturePile> empty_recording = 1713 scoped_ptr<FakeDisplayListRecordingSource> empty_recording =
1794 FakePicturePile::CreateEmptyPile(tile_size, layer_bounds); 1714 FakeDisplayListRecordingSource::CreateRecordingSource(
1795 empty_recording->SetIsSolidColor(true); 1715 gfx::Rect(layer_bounds), layer_bounds);
1716 SkPaint red_paint;
1717 red_paint.setColor(SK_ColorRED);
1718 empty_recording->add_draw_rect_with_paint(gfx::Rect(layer_bounds), red_paint);
danakj 2015/09/22 21:52:14 doesn't look so empty. solid_fill_recording?
vmpstr 2015/09/22 22:57:49 I changed this to use CreateFilledSolidColor
danakj 2015/09/22 23:04:06 Nice.
1719 empty_recording->Rerecord();
1796 1720
1797 scoped_refptr<FakePicturePileImpl> pending_pile = 1721 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
1798 FakePicturePileImpl::CreateFromPile(empty_recording.get(), nullptr); 1722 FakeDisplayListRasterSource::CreateFromRecordingSource(
1799 scoped_refptr<FakePicturePileImpl> active_pile = 1723 empty_recording.get(), false);
1800 FakePicturePileImpl::CreateFromPile(empty_recording.get(), nullptr); 1724 scoped_refptr<FakeDisplayListRasterSource> active_raster_source =
1725 FakeDisplayListRasterSource::CreateFromRecordingSource(
1726 empty_recording.get(), false);
1801 1727
1802 SetupTrees(pending_pile, active_pile); 1728 EXPECT_TRUE(pending_raster_source->IsSolidColor());
1729 EXPECT_TRUE(active_raster_source->IsSolidColor());
1730
1731 SetupTrees(pending_raster_source, active_raster_source);
1803 1732
1804 active_layer_->draw_properties().visible_layer_rect = visible_rect; 1733 active_layer_->draw_properties().visible_layer_rect = visible_rect;
1805 1734
1806 AppendQuadsData data; 1735 AppendQuadsData data;
1807 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); 1736 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr);
1808 active_layer_->AppendQuads(render_pass.get(), &data); 1737 active_layer_->AppendQuads(render_pass.get(), &data);
1809 active_layer_->DidDraw(nullptr); 1738 active_layer_->DidDraw(nullptr);
1810 1739
1811 Region remaining = visible_rect; 1740 Region remaining = visible_rect;
1812 for (const auto& quad : render_pass->quad_list) { 1741 for (const auto& quad : render_pass->quad_list) {
1813 EXPECT_TRUE(visible_rect.Contains(quad->rect)); 1742 EXPECT_TRUE(visible_rect.Contains(quad->rect));
1814 EXPECT_TRUE(remaining.Contains(quad->rect)); 1743 EXPECT_TRUE(remaining.Contains(quad->rect));
1815 remaining.Subtract(quad->rect); 1744 remaining.Subtract(quad->rect);
1816 } 1745 }
1817 1746
1818 EXPECT_TRUE(remaining.IsEmpty()); 1747 EXPECT_TRUE(remaining.IsEmpty());
1819 } 1748 }
1820 1749
1821 TEST_F(PictureLayerImplTest, TileScalesWithSolidColorPile) { 1750 TEST_F(PictureLayerImplTest, TileScalesWithSolidColorRasterSource) {
1822 gfx::Size layer_bounds(200, 200); 1751 gfx::Size layer_bounds(200, 200);
1823 gfx::Size tile_size(host_impl_.settings().default_tile_size); 1752 gfx::Size tile_size(host_impl_.settings().default_tile_size);
1824 scoped_refptr<FakePicturePileImpl> pending_pile = 1753 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
1825 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( 1754 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
1826 tile_size, layer_bounds, false); 1755 scoped_refptr<FakeDisplayListRasterSource> active_raster_source =
1827 scoped_refptr<FakePicturePileImpl> active_pile = 1756 FakeDisplayListRasterSource::CreateFilledSolidColor(layer_bounds);
1828 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings(
1829 tile_size, layer_bounds, true);
1830 1757
1831 SetupTrees(pending_pile, active_pile); 1758 SetupTrees(pending_raster_source, active_raster_source);
1832 // Solid color pile should not allow tilings at any scale. 1759 // Solid color raster source should not allow tilings at any scale.
1833 EXPECT_FALSE(active_layer_->CanHaveTilings()); 1760 EXPECT_FALSE(active_layer_->CanHaveTilings());
1834 EXPECT_EQ(0.f, active_layer_->ideal_contents_scale()); 1761 EXPECT_EQ(0.f, active_layer_->ideal_contents_scale());
1835 1762
1836 // Activate non-solid-color pending pile makes active layer can have tilings. 1763 // Activate non-solid-color pending raster source makes active layer can have
1764 // tilings.
1837 ActivateTree(); 1765 ActivateTree();
1838 EXPECT_TRUE(active_layer_->CanHaveTilings()); 1766 EXPECT_TRUE(active_layer_->CanHaveTilings());
1839 EXPECT_GT(active_layer_->ideal_contents_scale(), 0.f); 1767 EXPECT_GT(active_layer_->ideal_contents_scale(), 0.f);
1840 } 1768 }
1841 1769
1842 TEST_F(NoLowResPictureLayerImplTest, MarkRequiredOffscreenTiles) { 1770 TEST_F(NoLowResPictureLayerImplTest, MarkRequiredOffscreenTiles) {
1843 gfx::Size tile_size(100, 100);
1844 gfx::Size layer_bounds(200, 200); 1771 gfx::Size layer_bounds(200, 200);
1845 1772
1846 gfx::Transform transform; 1773 gfx::Transform transform;
1847 gfx::Transform transform_for_tile_priority; 1774 gfx::Transform transform_for_tile_priority;
1848 bool resourceless_software_draw = false; 1775 bool resourceless_software_draw = false;
1849 gfx::Rect viewport(0, 0, 100, 200); 1776 gfx::Rect viewport(0, 0, 100, 200);
1850 host_impl_.SetExternalDrawConstraints(transform, 1777 host_impl_.SetExternalDrawConstraints(transform,
1851 viewport, 1778 viewport,
1852 viewport, 1779 viewport,
1853 viewport, 1780 viewport,
1854 transform, 1781 transform,
1855 resourceless_software_draw); 1782 resourceless_software_draw);
1856 1783
1857 scoped_refptr<FakePicturePileImpl> pending_pile = 1784 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
1858 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1785 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
1859 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); 1786 SetupPendingTreeWithFixedTileSize(pending_raster_source, gfx::Size(100, 100),
1787 Region());
1860 1788
1861 EXPECT_EQ(1u, pending_layer_->num_tilings()); 1789 EXPECT_EQ(1u, pending_layer_->num_tilings());
1862 EXPECT_EQ(viewport, pending_layer_->visible_rect_for_tile_priority()); 1790 EXPECT_EQ(viewport, pending_layer_->visible_rect_for_tile_priority());
1863 1791
1864 base::TimeTicks time_ticks; 1792 base::TimeTicks time_ticks;
1865 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 1793 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
1866 pending_layer_->UpdateTiles(resourceless_software_draw); 1794 pending_layer_->UpdateTiles(resourceless_software_draw);
1867 1795
1868 int num_visible = 0; 1796 int num_visible = 0;
1869 int num_offscreen = 0; 1797 int num_offscreen = 0;
(...skipping 18 matching lines...) Expand all
1888 1816
1889 TEST_F(NoLowResPictureLayerImplTest, 1817 TEST_F(NoLowResPictureLayerImplTest,
1890 TileOutsideOfViewportForTilePriorityNotRequired) { 1818 TileOutsideOfViewportForTilePriorityNotRequired) {
1891 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 1819 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
1892 1820
1893 gfx::Size tile_size(100, 100); 1821 gfx::Size tile_size(100, 100);
1894 gfx::Size layer_bounds(400, 400); 1822 gfx::Size layer_bounds(400, 400);
1895 gfx::Rect external_viewport_for_tile_priority(400, 200); 1823 gfx::Rect external_viewport_for_tile_priority(400, 200);
1896 gfx::Rect visible_layer_rect(200, 400); 1824 gfx::Rect visible_layer_rect(200, 400);
1897 1825
1898 scoped_refptr<FakePicturePileImpl> active_pile = 1826 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region());
1899 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1900 scoped_refptr<FakePicturePileImpl> pending_pile =
1901 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1902 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region());
1903 1827
1904 ASSERT_EQ(1u, pending_layer_->num_tilings()); 1828 ASSERT_EQ(1u, pending_layer_->num_tilings());
1905 ASSERT_EQ(1.f, pending_layer_->HighResTiling()->contents_scale()); 1829 ASSERT_EQ(1.f, pending_layer_->HighResTiling()->contents_scale());
1906 1830
1907 // Set external viewport for tile priority. 1831 // Set external viewport for tile priority.
1908 gfx::Rect viewport = gfx::Rect(layer_bounds); 1832 gfx::Rect viewport = gfx::Rect(layer_bounds);
1909 gfx::Transform transform; 1833 gfx::Transform transform;
1910 gfx::Transform transform_for_tile_priority; 1834 gfx::Transform transform_for_tile_priority;
1911 bool resourceless_software_draw = false; 1835 bool resourceless_software_draw = false;
1912 host_impl_.SetExternalDrawConstraints(transform, 1836 host_impl_.SetExternalDrawConstraints(transform,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1971 EXPECT_EQ(0u, data.num_incomplete_tiles); 1895 EXPECT_EQ(0u, data.num_incomplete_tiles);
1972 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); 1896 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads());
1973 } 1897 }
1974 1898
1975 TEST_F(PictureLayerImplTest, HighResTileIsComplete) { 1899 TEST_F(PictureLayerImplTest, HighResTileIsComplete) {
1976 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 1900 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
1977 1901
1978 gfx::Size tile_size(100, 100); 1902 gfx::Size tile_size(100, 100);
1979 gfx::Size layer_bounds(200, 200); 1903 gfx::Size layer_bounds(200, 200);
1980 1904
1981 scoped_refptr<FakePicturePileImpl> pending_pile = 1905 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
1982 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1906 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
1983 1907
1984 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); 1908 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region());
1985 ActivateTree(); 1909 ActivateTree();
1986 1910
1987 // All high res tiles have resources. 1911 // All high res tiles have resources.
1988 std::vector<Tile*> tiles = 1912 std::vector<Tile*> tiles =
1989 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); 1913 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting();
1990 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); 1914 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles);
1991 1915
1992 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 1916 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
1993 AppendQuadsData data; 1917 AppendQuadsData data;
1994 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); 1918 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr);
1995 active_layer_->AppendQuads(render_pass.get(), &data); 1919 active_layer_->AppendQuads(render_pass.get(), &data);
1996 active_layer_->DidDraw(nullptr); 1920 active_layer_->DidDraw(nullptr);
1997 1921
1998 // All high res tiles drew, nothing was incomplete. 1922 // All high res tiles drew, nothing was incomplete.
1999 EXPECT_EQ(9u, render_pass->quad_list.size()); 1923 EXPECT_EQ(9u, render_pass->quad_list.size());
2000 EXPECT_EQ(0u, data.num_missing_tiles); 1924 EXPECT_EQ(0u, data.num_missing_tiles);
2001 EXPECT_EQ(0u, data.num_incomplete_tiles); 1925 EXPECT_EQ(0u, data.num_incomplete_tiles);
2002 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); 1926 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads());
2003 } 1927 }
2004 1928
2005 TEST_F(PictureLayerImplTest, HighResTileIsIncomplete) { 1929 TEST_F(PictureLayerImplTest, HighResTileIsIncomplete) {
2006 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 1930 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
2007 1931
2008 gfx::Size tile_size(100, 100); 1932 gfx::Size tile_size(100, 100);
2009 gfx::Size layer_bounds(200, 200); 1933 gfx::Size layer_bounds(200, 200);
2010 1934
2011 scoped_refptr<FakePicturePileImpl> pending_pile = 1935 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
2012 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1936 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
2013 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); 1937 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region());
2014 ActivateTree(); 1938 ActivateTree();
2015 1939
2016 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 1940 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
2017 AppendQuadsData data; 1941 AppendQuadsData data;
2018 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); 1942 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr);
2019 active_layer_->AppendQuads(render_pass.get(), &data); 1943 active_layer_->AppendQuads(render_pass.get(), &data);
2020 active_layer_->DidDraw(nullptr); 1944 active_layer_->DidDraw(nullptr);
2021 1945
2022 EXPECT_EQ(1u, render_pass->quad_list.size()); 1946 EXPECT_EQ(1u, render_pass->quad_list.size());
2023 EXPECT_EQ(1u, data.num_missing_tiles); 1947 EXPECT_EQ(1u, data.num_missing_tiles);
2024 EXPECT_EQ(0u, data.num_incomplete_tiles); 1948 EXPECT_EQ(0u, data.num_incomplete_tiles);
2025 EXPECT_TRUE(active_layer_->only_used_low_res_last_append_quads()); 1949 EXPECT_TRUE(active_layer_->only_used_low_res_last_append_quads());
2026 } 1950 }
2027 1951
2028 TEST_F(PictureLayerImplTest, HighResTileIsIncompleteLowResComplete) { 1952 TEST_F(PictureLayerImplTest, HighResTileIsIncompleteLowResComplete) {
2029 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 1953 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
2030 1954
2031 gfx::Size tile_size(100, 100); 1955 gfx::Size tile_size(100, 100);
2032 gfx::Size layer_bounds(200, 200); 1956 gfx::Size layer_bounds(200, 200);
2033 1957
2034 scoped_refptr<FakePicturePileImpl> pending_pile = 1958 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
2035 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1959 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
2036 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); 1960 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region());
2037 ActivateTree(); 1961 ActivateTree();
2038 1962
2039 std::vector<Tile*> low_tiles = 1963 std::vector<Tile*> low_tiles =
2040 active_layer_->tilings()->tiling_at(1)->AllTilesForTesting(); 1964 active_layer_->tilings()->tiling_at(1)->AllTilesForTesting();
2041 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(low_tiles); 1965 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(low_tiles);
2042 1966
2043 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 1967 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
2044 AppendQuadsData data; 1968 AppendQuadsData data;
2045 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); 1969 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr);
2046 active_layer_->AppendQuads(render_pass.get(), &data); 1970 active_layer_->AppendQuads(render_pass.get(), &data);
2047 active_layer_->DidDraw(nullptr); 1971 active_layer_->DidDraw(nullptr);
2048 1972
2049 EXPECT_EQ(1u, render_pass->quad_list.size()); 1973 EXPECT_EQ(1u, render_pass->quad_list.size());
2050 EXPECT_EQ(0u, data.num_missing_tiles); 1974 EXPECT_EQ(0u, data.num_missing_tiles);
2051 EXPECT_EQ(1u, data.num_incomplete_tiles); 1975 EXPECT_EQ(1u, data.num_incomplete_tiles);
2052 EXPECT_TRUE(active_layer_->only_used_low_res_last_append_quads()); 1976 EXPECT_TRUE(active_layer_->only_used_low_res_last_append_quads());
2053 } 1977 }
2054 1978
2055 TEST_F(PictureLayerImplTest, LowResTileIsIncomplete) { 1979 TEST_F(PictureLayerImplTest, LowResTileIsIncomplete) {
2056 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 1980 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
2057 1981
2058 gfx::Size tile_size(100, 100); 1982 gfx::Size tile_size(100, 100);
2059 gfx::Size layer_bounds(200, 200); 1983 gfx::Size layer_bounds(200, 200);
2060 1984
2061 scoped_refptr<FakePicturePileImpl> pending_pile = 1985 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
2062 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1986 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
2063 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); 1987 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region());
2064 ActivateTree(); 1988 ActivateTree();
2065 1989
2066 // All high res tiles have resources except one. 1990 // All high res tiles have resources except one.
2067 std::vector<Tile*> high_tiles = 1991 std::vector<Tile*> high_tiles =
2068 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); 1992 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting();
2069 high_tiles.erase(high_tiles.begin()); 1993 high_tiles.erase(high_tiles.begin());
2070 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(high_tiles); 1994 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(high_tiles);
2071 1995
2072 // All low res tiles have resources. 1996 // All low res tiles have resources.
2073 std::vector<Tile*> low_tiles = 1997 std::vector<Tile*> low_tiles =
(...skipping 17 matching lines...) Expand all
2091 HighResAndIdealResTileIsCompleteWhenRasterScaleIsNotIdeal) { 2015 HighResAndIdealResTileIsCompleteWhenRasterScaleIsNotIdeal) {
2092 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 2016 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
2093 2017
2094 gfx::Size tile_size(100, 100); 2018 gfx::Size tile_size(100, 100);
2095 gfx::Size layer_bounds(200, 200); 2019 gfx::Size layer_bounds(200, 200);
2096 gfx::Size viewport_size(400, 400); 2020 gfx::Size viewport_size(400, 400);
2097 2021
2098 host_impl_.SetViewportSize(viewport_size); 2022 host_impl_.SetViewportSize(viewport_size);
2099 host_impl_.SetDeviceScaleFactor(2.f); 2023 host_impl_.SetDeviceScaleFactor(2.f);
2100 2024
2101 scoped_refptr<FakePicturePileImpl> pending_pile = 2025 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region());
2102 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2103 scoped_refptr<FakePicturePileImpl> active_pile =
2104 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
2105 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region());
2106 2026
2107 // One ideal tile exists, this will get used when drawing. 2027 // One ideal tile exists, this will get used when drawing.
2108 std::vector<Tile*> ideal_tiles; 2028 std::vector<Tile*> ideal_tiles;
2109 EXPECT_EQ(2.f, active_layer_->HighResTiling()->contents_scale()); 2029 EXPECT_EQ(2.f, active_layer_->HighResTiling()->contents_scale());
2110 ideal_tiles.push_back(active_layer_->HighResTiling()->TileAt(0, 0)); 2030 ideal_tiles.push_back(active_layer_->HighResTiling()->TileAt(0, 0));
2111 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( 2031 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(
2112 ideal_tiles); 2032 ideal_tiles);
2113 2033
2114 // Due to layer scale throttling, the raster contents scale is changed to 1, 2034 // Due to layer scale throttling, the raster contents scale is changed to 1,
2115 // while the ideal is still 2. 2035 // while the ideal is still 2.
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
2237 active_layer_->LowResTiling()->UpdateAllRequiredStateForTesting(); 2157 active_layer_->LowResTiling()->UpdateAllRequiredStateForTesting();
2238 2158
2239 AssertNoTilesRequired(active_layer_->HighResTiling()); 2159 AssertNoTilesRequired(active_layer_->HighResTiling());
2240 AssertNoTilesRequired(active_layer_->LowResTiling()); 2160 AssertNoTilesRequired(active_layer_->LowResTiling());
2241 } 2161 }
2242 2162
2243 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { 2163 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) {
2244 gfx::Size layer_bounds(400, 400); 2164 gfx::Size layer_bounds(400, 400);
2245 gfx::Size tile_size(100, 100); 2165 gfx::Size tile_size(100, 100);
2246 2166
2247 scoped_refptr<FakePicturePileImpl> pending_pile = 2167 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
2248 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 2168 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
2249 // This pile will create tilings, but has no recordings so will not create any 2169 // This raster source will create tilings, but has no recordings so will not
2250 // tiles. This is attempting to simulate scrolling past the end of recorded 2170 // create any tiles. This is attempting to simulate scrolling past the end of
2251 // content on the active layer, where the recordings are so far away that 2171 // recorded content on the active layer, where the recordings are so far away
2252 // no tiles are created. 2172 // that no tiles are created.
2253 bool is_solid_color = false; 2173 scoped_refptr<FakeDisplayListRasterSource> active_raster_source =
2254 scoped_refptr<FakePicturePileImpl> active_pile = 2174 FakeDisplayListRasterSource::CreatePartiallyFilled(layer_bounds,
2255 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( 2175 gfx::Rect());
2256 tile_size, layer_bounds, is_solid_color);
2257 2176
2258 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); 2177 SetupTreesWithFixedTileSize(pending_raster_source, active_raster_source,
2178 tile_size, Region());
2259 2179
2260 // Active layer has tilings, but no tiles due to missing recordings. 2180 // Active layer has tilings, but no tiles due to missing recordings.
2261 EXPECT_TRUE(active_layer_->CanHaveTilings()); 2181 EXPECT_TRUE(active_layer_->CanHaveTilings());
2262 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u); 2182 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u);
2263 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); 2183 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u);
2264 2184
2265 // Since the active layer has no tiles at all, the pending layer doesn't 2185 // Since the active layer has no tiles at all, the pending layer doesn't
2266 // need content in order to activate. 2186 // need content in order to activate.
2267 pending_layer_->HighResTiling()->UpdateAllRequiredStateForTesting(); 2187 pending_layer_->HighResTiling()->UpdateAllRequiredStateForTesting();
2268 EXPECT_FALSE(pending_layer_->LowResTiling()); 2188 EXPECT_FALSE(pending_layer_->LowResTiling());
2269 2189
2270 AssertNoTilesRequired(pending_layer_->HighResTiling()); 2190 AssertNoTilesRequired(pending_layer_->HighResTiling());
2271 } 2191 }
2272 2192
2273 TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) { 2193 TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) {
2274 gfx::Size layer_bounds(400, 400); 2194 gfx::Size layer_bounds(400, 400);
2275 gfx::Size tile_size(100, 100); 2195 gfx::Size tile_size(100, 100);
2276 2196
2277 scoped_refptr<FakePicturePileImpl> pending_pile = 2197 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
2278 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 2198 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
2279 scoped_refptr<FakePicturePileImpl> active_pile = 2199 scoped_refptr<FakeDisplayListRasterSource> active_raster_source =
2280 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); 2200 FakeDisplayListRasterSource::CreateEmpty(layer_bounds);
2281 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); 2201 SetupTreesWithFixedTileSize(pending_raster_source, active_raster_source,
2202 tile_size, Region());
2282 2203
2283 // Active layer can't have tiles. 2204 // Active layer can't have tiles.
2284 EXPECT_FALSE(active_layer_->CanHaveTilings()); 2205 EXPECT_FALSE(active_layer_->CanHaveTilings());
2285 2206
2286 // All high res tiles required. This should be considered identical 2207 // All high res tiles required. This should be considered identical
2287 // to the case where there is no active layer, to avoid flashing content. 2208 // to the case where there is no active layer, to avoid flashing content.
2288 // This can happen if a layer exists for a while and switches from 2209 // This can happen if a layer exists for a while and switches from
2289 // not being able to have content to having content. 2210 // not being able to have content to having content.
2290 pending_layer_->HighResTiling()->UpdateAllRequiredStateForTesting(); 2211 pending_layer_->HighResTiling()->UpdateAllRequiredStateForTesting();
2291 EXPECT_FALSE(pending_layer_->LowResTiling()); 2212 EXPECT_FALSE(pending_layer_->LowResTiling());
2292 2213
2293 AssertAllTilesRequired(pending_layer_->HighResTiling()); 2214 AssertAllTilesRequired(pending_layer_->HighResTiling());
2294 } 2215 }
2295 2216
2296 TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveHasDifferentBounds) { 2217 TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveHasDifferentBounds) {
2297 gfx::Size pending_layer_bounds(400, 400); 2218 gfx::Size pending_layer_bounds(400, 400);
2298 gfx::Size active_layer_bounds(200, 200); 2219 gfx::Size active_layer_bounds(200, 200);
2299 gfx::Size tile_size(100, 100); 2220 gfx::Size tile_size(100, 100);
2300 2221
2301 scoped_refptr<FakePicturePileImpl> pending_pile = 2222 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
2302 FakePicturePileImpl::CreateFilledPile(tile_size, pending_layer_bounds); 2223 FakeDisplayListRasterSource::CreateFilled(pending_layer_bounds);
2303 scoped_refptr<FakePicturePileImpl> active_pile = 2224 scoped_refptr<FakeDisplayListRasterSource> active_raster_source =
2304 FakePicturePileImpl::CreateFilledPile(tile_size, active_layer_bounds); 2225 FakeDisplayListRasterSource::CreateFilled(active_layer_bounds);
2305 2226
2306 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); 2227 SetupTreesWithFixedTileSize(pending_raster_source, active_raster_source,
2228 tile_size, Region());
2307 2229
2308 // Since the active layer has different bounds, the pending layer needs all 2230 // Since the active layer has different bounds, the pending layer needs all
2309 // high res tiles in order to activate. 2231 // high res tiles in order to activate.
2310 pending_layer_->HighResTiling()->UpdateAllRequiredStateForTesting(); 2232 pending_layer_->HighResTiling()->UpdateAllRequiredStateForTesting();
2311 EXPECT_FALSE(pending_layer_->LowResTiling()); 2233 EXPECT_FALSE(pending_layer_->LowResTiling());
2312 active_layer_->HighResTiling()->UpdateAllRequiredStateForTesting(); 2234 active_layer_->HighResTiling()->UpdateAllRequiredStateForTesting();
2313 active_layer_->LowResTiling()->UpdateAllRequiredStateForTesting(); 2235 active_layer_->LowResTiling()->UpdateAllRequiredStateForTesting();
2314 2236
2315 AssertAllTilesRequired(pending_layer_->HighResTiling()); 2237 AssertAllTilesRequired(pending_layer_->HighResTiling());
2316 AssertAllTilesRequired(active_layer_->HighResTiling()); 2238 AssertAllTilesRequired(active_layer_->HighResTiling());
2317 AssertNoTilesRequired(active_layer_->LowResTiling()); 2239 AssertNoTilesRequired(active_layer_->LowResTiling());
2318 } 2240 }
2319 2241
2320 TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { 2242 TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) {
2321 gfx::Size tile_size(100, 100);
2322 gfx::Size layer_bounds(400, 400); 2243 gfx::Size layer_bounds(400, 400);
2323 scoped_refptr<FakePicturePileImpl> pending_pile = 2244 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
2324 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 2245 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
2325 2246
2326 host_impl_.CreatePendingTree(); 2247 host_impl_.CreatePendingTree();
2327 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); 2248 LayerTreeImpl* pending_tree = host_impl_.pending_tree();
2328 2249
2329 scoped_ptr<FakePictureLayerImpl> pending_layer = 2250 scoped_ptr<FakePictureLayerImpl> pending_layer =
2330 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id_, 2251 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id_,
2331 pending_pile); 2252 pending_raster_source);
2332 pending_layer->SetDrawsContent(true); 2253 pending_layer->SetDrawsContent(true);
2333 pending_tree->SetRootLayer(pending_layer.Pass()); 2254 pending_tree->SetRootLayer(pending_layer.Pass());
2334 2255
2335 pending_layer_ = static_cast<FakePictureLayerImpl*>( 2256 pending_layer_ = static_cast<FakePictureLayerImpl*>(
2336 host_impl_.pending_tree()->LayerById(id_)); 2257 host_impl_.pending_tree()->LayerById(id_));
2337 2258
2338 // Set some state on the pending layer, make sure it is not clobbered 2259 // Set some state on the pending layer, make sure it is not clobbered
2339 // by a sync from the active layer. This could happen because if the 2260 // by a sync from the active layer. This could happen because if the
2340 // pending layer has not been post-commit initialized it will attempt 2261 // pending layer has not been post-commit initialized it will attempt
2341 // to sync from the active layer. 2262 // to sync from the active layer.
2342 float raster_page_scale = 10.f * pending_layer_->raster_page_scale(); 2263 float raster_page_scale = 10.f * pending_layer_->raster_page_scale();
2343 pending_layer_->set_raster_page_scale(raster_page_scale); 2264 pending_layer_->set_raster_page_scale(raster_page_scale);
2344 2265
2345 host_impl_.ActivateSyncTree(); 2266 host_impl_.ActivateSyncTree();
2346 2267
2347 active_layer_ = static_cast<FakePictureLayerImpl*>( 2268 active_layer_ = static_cast<FakePictureLayerImpl*>(
2348 host_impl_.active_tree()->LayerById(id_)); 2269 host_impl_.active_tree()->LayerById(id_));
2349 2270
2350 EXPECT_EQ(0u, active_layer_->num_tilings()); 2271 EXPECT_EQ(0u, active_layer_->num_tilings());
2351 EXPECT_EQ(raster_page_scale, active_layer_->raster_page_scale()); 2272 EXPECT_EQ(raster_page_scale, active_layer_->raster_page_scale());
2352 } 2273 }
2353 2274
2354 TEST_F(PictureLayerImplTest, ShareTilesOnNextFrame) { 2275 TEST_F(PictureLayerImplTest, ShareTilesOnNextFrame) {
2355 gfx::Size layer_bounds(1500, 1500); 2276 gfx::Size layer_bounds(1500, 1500);
2356 gfx::Size tile_size(100, 100);
2357 2277
2358 scoped_refptr<FakePicturePileImpl> pending_pile = 2278 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
2359 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 2279 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
2360 2280
2361 SetupPendingTree(pending_pile); 2281 SetupPendingTree(pending_raster_source);
2362 2282
2363 PictureLayerTiling* tiling = pending_layer_->HighResTiling(); 2283 PictureLayerTiling* tiling = pending_layer_->HighResTiling();
2364 gfx::Rect first_invalidate = tiling->TilingDataForTesting().TileBounds(0, 0); 2284 gfx::Rect first_invalidate = tiling->TilingDataForTesting().TileBounds(0, 0);
2365 first_invalidate.Inset(tiling->TilingDataForTesting().border_texels(), 2285 first_invalidate.Inset(tiling->TilingDataForTesting().border_texels(),
2366 tiling->TilingDataForTesting().border_texels()); 2286 tiling->TilingDataForTesting().border_texels());
2367 gfx::Rect second_invalidate = tiling->TilingDataForTesting().TileBounds(1, 1); 2287 gfx::Rect second_invalidate = tiling->TilingDataForTesting().TileBounds(1, 1);
2368 second_invalidate.Inset(tiling->TilingDataForTesting().border_texels(), 2288 second_invalidate.Inset(tiling->TilingDataForTesting().border_texels(),
2369 tiling->TilingDataForTesting().border_texels()); 2289 tiling->TilingDataForTesting().border_texels());
2370 2290
2371 ActivateTree(); 2291 ActivateTree();
2372 2292
2373 // Make a pending tree with an invalidated raster tile 0,0. 2293 // Make a pending tree with an invalidated raster tile 0,0.
2374 SetupPendingTreeWithInvalidation(pending_pile, first_invalidate); 2294 SetupPendingTreeWithInvalidation(pending_raster_source, first_invalidate);
2375 2295
2376 // Activate and make a pending tree with an invalidated raster tile 1,1. 2296 // Activate and make a pending tree with an invalidated raster tile 1,1.
2377 ActivateTree(); 2297 ActivateTree();
2378 2298
2379 SetupPendingTreeWithInvalidation(pending_pile, second_invalidate); 2299 SetupPendingTreeWithInvalidation(pending_raster_source, second_invalidate);
2380 2300
2381 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); 2301 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0);
2382 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); 2302 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0);
2383 2303
2384 // pending_tiling->CreateAllTilesForTesting();
danakj 2015/09/22 21:52:14 heh oops *^_^*
2385
2386 // Tile 0,0 not exist on pending, but tile 1,1 should. 2304 // Tile 0,0 not exist on pending, but tile 1,1 should.
2387 EXPECT_TRUE(active_tiling->TileAt(0, 0)); 2305 EXPECT_TRUE(active_tiling->TileAt(0, 0));
2388 EXPECT_TRUE(active_tiling->TileAt(1, 0)); 2306 EXPECT_TRUE(active_tiling->TileAt(1, 0));
2389 EXPECT_TRUE(active_tiling->TileAt(0, 1)); 2307 EXPECT_TRUE(active_tiling->TileAt(0, 1));
2390 EXPECT_FALSE(pending_tiling->TileAt(0, 0)); 2308 EXPECT_FALSE(pending_tiling->TileAt(0, 0));
2391 EXPECT_FALSE(pending_tiling->TileAt(1, 0)); 2309 EXPECT_FALSE(pending_tiling->TileAt(1, 0));
2392 EXPECT_FALSE(pending_tiling->TileAt(0, 1)); 2310 EXPECT_FALSE(pending_tiling->TileAt(0, 1));
2393 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1)); 2311 EXPECT_NE(active_tiling->TileAt(1, 1), pending_tiling->TileAt(1, 1));
2394 EXPECT_TRUE(active_tiling->TileAt(1, 1)); 2312 EXPECT_TRUE(active_tiling->TileAt(1, 1));
2395 EXPECT_TRUE(pending_tiling->TileAt(1, 1)); 2313 EXPECT_TRUE(pending_tiling->TileAt(1, 1));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2428 EXPECT_TRUE(active_tiling->TileAt(0, 1)); 2346 EXPECT_TRUE(active_tiling->TileAt(0, 1));
2429 EXPECT_TRUE(active_tiling->TileAt(1, 1)); 2347 EXPECT_TRUE(active_tiling->TileAt(1, 1));
2430 2348
2431 EXPECT_FALSE(pending_tiling->TileAt(0, 0)); 2349 EXPECT_FALSE(pending_tiling->TileAt(0, 0));
2432 EXPECT_FALSE(pending_tiling->TileAt(1, 0)); 2350 EXPECT_FALSE(pending_tiling->TileAt(1, 0));
2433 EXPECT_FALSE(pending_tiling->TileAt(0, 1)); 2351 EXPECT_FALSE(pending_tiling->TileAt(0, 1));
2434 EXPECT_FALSE(pending_tiling->TileAt(1, 1)); 2352 EXPECT_FALSE(pending_tiling->TileAt(1, 1));
2435 } 2353 }
2436 2354
2437 TEST_F(PictureLayerImplTest, ShareInvalidActiveTreeTiles) { 2355 TEST_F(PictureLayerImplTest, ShareInvalidActiveTreeTiles) {
2438 gfx::Size tile_size(100, 100);
2439 gfx::Size layer_bounds(1500, 1500); 2356 gfx::Size layer_bounds(1500, 1500);
2440 2357
2441 scoped_refptr<FakePicturePileImpl> pending_pile = 2358 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
2442 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 2359 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
2443 scoped_refptr<FakePicturePileImpl> active_pile = 2360 scoped_refptr<FakeDisplayListRasterSource> active_raster_source =
2444 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 2361 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
2445 SetupTreesWithInvalidation(pending_pile, active_pile, gfx::Rect(1, 1)); 2362 SetupTreesWithInvalidation(pending_raster_source, active_raster_source,
2363 gfx::Rect(1, 1));
2446 // Activate the invalidation. 2364 // Activate the invalidation.
2447 ActivateTree(); 2365 ActivateTree();
2448 // Make another pending tree without any invalidation in it. 2366 // Make another pending tree without any invalidation in it.
2449 scoped_refptr<FakePicturePileImpl> pending_pile2 = 2367 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source2 =
2450 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 2368 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
2451 SetupPendingTree(pending_pile2); 2369 SetupPendingTree(pending_raster_source2);
2452 2370
2453 EXPECT_GE(active_layer_->num_tilings(), 1u); 2371 EXPECT_GE(active_layer_->num_tilings(), 1u);
2454 EXPECT_GE(pending_layer_->num_tilings(), 1u); 2372 EXPECT_GE(pending_layer_->num_tilings(), 1u);
2455 2373
2456 // The active tree invalidation was handled by the active tiles. 2374 // The active tree invalidation was handled by the active tiles.
2457 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0); 2375 PictureLayerTiling* active_tiling = active_layer_->tilings()->tiling_at(0);
2458 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0); 2376 PictureLayerTiling* pending_tiling = pending_layer_->tilings()->tiling_at(0);
2459 ASSERT_TRUE(active_tiling); 2377 ASSERT_TRUE(active_tiling);
2460 ASSERT_TRUE(pending_tiling); 2378 ASSERT_TRUE(pending_tiling);
2461 2379
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2493 EXPECT_FALSE(pending_tiling->TileAt(1, 0)); 2411 EXPECT_FALSE(pending_tiling->TileAt(1, 0));
2494 EXPECT_FALSE(pending_tiling->TileAt(0, 1)); 2412 EXPECT_FALSE(pending_tiling->TileAt(0, 1));
2495 EXPECT_FALSE(pending_tiling->TileAt(1, 1)); 2413 EXPECT_FALSE(pending_tiling->TileAt(1, 1));
2496 2414
2497 EXPECT_NE(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0)); 2415 EXPECT_NE(active_tiling->TileAt(0, 0), pending_tiling->TileAt(0, 0));
2498 } 2416 }
2499 2417
2500 TEST_F(PictureLayerImplTest, SyncTilingAfterGpuRasterizationToggles) { 2418 TEST_F(PictureLayerImplTest, SyncTilingAfterGpuRasterizationToggles) {
2501 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 2419 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
2502 2420
2503 gfx::Size tile_size(100, 100);
2504 gfx::Size layer_bounds(10, 10); 2421 gfx::Size layer_bounds(10, 10);
2505 2422
2506 scoped_refptr<FakePicturePileImpl> pending_pile = 2423 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
2507 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 2424 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
2508 scoped_refptr<FakePicturePileImpl> active_pile = 2425 scoped_refptr<FakeDisplayListRasterSource> active_raster_source =
2509 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 2426 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
2510 2427
2511 SetupTrees(pending_pile, active_pile); 2428 SetupTrees(pending_raster_source, active_raster_source);
2512 2429
2513 EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(1.f)); 2430 EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(1.f));
2514 EXPECT_TRUE(active_layer_->tilings()->FindTilingWithScale(1.f)); 2431 EXPECT_TRUE(active_layer_->tilings()->FindTilingWithScale(1.f));
2515 2432
2516 // Gpu rasterization is disabled by default. 2433 // Gpu rasterization is disabled by default.
2517 EXPECT_FALSE(host_impl_.use_gpu_rasterization()); 2434 EXPECT_FALSE(host_impl_.use_gpu_rasterization());
2518 // Toggling the gpu rasterization clears all tilings on both trees. 2435 // Toggling the gpu rasterization clears all tilings on both trees.
2519 host_impl_.SetHasGpuRasterizationTrigger(true); 2436 host_impl_.SetHasGpuRasterizationTrigger(true);
2520 host_impl_.SetContentIsSuitableForGpuRasterization(true); 2437 host_impl_.SetContentIsSuitableForGpuRasterization(true);
2521 host_impl_.UpdateTreeResourcesForGpuRasterizationIfNeeded(); 2438 host_impl_.UpdateTreeResourcesForGpuRasterizationIfNeeded();
2522 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); 2439 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings());
2523 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); 2440 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
2524 2441
2525 // Make sure that we can still add tiling to the pending layer, 2442 // Make sure that we can still add tiling to the pending layer,
2526 // that gets synced to the active layer. 2443 // that gets synced to the active layer.
2527 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 2444 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
2528 bool update_lcd_text = false; 2445 bool update_lcd_text = false;
2529 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); 2446 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text);
2530 EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(1.f)); 2447 EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(1.f));
2531 2448
2532 ActivateTree(); 2449 ActivateTree();
2533 EXPECT_TRUE(active_layer_->tilings()->FindTilingWithScale(1.f)); 2450 EXPECT_TRUE(active_layer_->tilings()->FindTilingWithScale(1.f));
2534 2451
2535 SetupPendingTree(pending_pile); 2452 SetupPendingTree(pending_raster_source);
2536 EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(1.f)); 2453 EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(1.f));
2537 2454
2538 // Toggling the gpu rasterization clears all tilings on both trees. 2455 // Toggling the gpu rasterization clears all tilings on both trees.
2539 EXPECT_TRUE(host_impl_.use_gpu_rasterization()); 2456 EXPECT_TRUE(host_impl_.use_gpu_rasterization());
2540 host_impl_.SetHasGpuRasterizationTrigger(false); 2457 host_impl_.SetHasGpuRasterizationTrigger(false);
2541 host_impl_.UpdateTreeResourcesForGpuRasterizationIfNeeded(); 2458 host_impl_.UpdateTreeResourcesForGpuRasterizationIfNeeded();
2542 EXPECT_EQ(GpuRasterizationStatus::OFF_VIEWPORT, 2459 EXPECT_EQ(GpuRasterizationStatus::OFF_VIEWPORT,
2543 host_impl_.gpu_rasterization_status()); 2460 host_impl_.gpu_rasterization_status());
2544 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); 2461 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings());
2545 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); 2462 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
2546 2463
2547 host_impl_.SetHasGpuRasterizationTrigger(true); 2464 host_impl_.SetHasGpuRasterizationTrigger(true);
2548 host_impl_.SetContentIsSuitableForGpuRasterization(false); 2465 host_impl_.SetContentIsSuitableForGpuRasterization(false);
2549 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT, 2466 EXPECT_EQ(GpuRasterizationStatus::OFF_CONTENT,
2550 host_impl_.gpu_rasterization_status()); 2467 host_impl_.gpu_rasterization_status());
2551 } 2468 }
2552 2469
2553 TEST_F(PictureLayerImplTest, HighResCreatedWhenBoundsShrink) { 2470 TEST_F(PictureLayerImplTest, HighResCreatedWhenBoundsShrink) {
2554 gfx::Size tile_size(100, 100);
2555
2556 // Put 0.5 as high res. 2471 // Put 0.5 as high res.
2557 host_impl_.SetDeviceScaleFactor(0.5f); 2472 host_impl_.SetDeviceScaleFactor(0.5f);
2558 2473
2559 scoped_refptr<FakePicturePileImpl> pending_pile = 2474 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
2560 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(10, 10)); 2475 FakeDisplayListRasterSource::CreateFilled(gfx::Size(10, 10));
2561 SetupPendingTree(pending_pile); 2476 SetupPendingTree(pending_raster_source);
2562 2477
2563 // Sanity checks. 2478 // Sanity checks.
2564 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); 2479 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings());
2565 EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(0.5f)); 2480 EXPECT_TRUE(pending_layer_->tilings()->FindTilingWithScale(0.5f));
2566 2481
2567 ActivateTree(); 2482 ActivateTree();
2568 2483
2569 // Now, set the bounds to be 1x1, so that minimum contents scale becomes 1. 2484 // Now, set the bounds to be 1x1, so that minimum contents scale becomes 1.
2570 pending_pile = 2485 pending_raster_source =
2571 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1, 1)); 2486 FakeDisplayListRasterSource::CreateFilled(gfx::Size(1, 1));
2572 SetupPendingTree(pending_pile); 2487 SetupPendingTree(pending_raster_source);
2573 2488
2574 // Another sanity check. 2489 // Another sanity check.
2575 EXPECT_EQ(1.f, pending_layer_->MinimumContentsScale()); 2490 EXPECT_EQ(1.f, pending_layer_->MinimumContentsScale());
2576 2491
2577 // Since the MinContentsScale is 1, the 0.5 tiling should have been replaced 2492 // Since the MinContentsScale is 1, the 0.5 tiling should have been replaced
2578 // by a 1.0 tiling during the UDP in SetupPendingTree. 2493 // by a 1.0 tiling during the UDP in SetupPendingTree.
2579 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); 2494 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings());
2580 PictureLayerTiling* tiling = 2495 PictureLayerTiling* tiling =
2581 pending_layer_->tilings()->FindTilingWithScale(1.0f); 2496 pending_layer_->tilings()->FindTilingWithScale(1.0f);
2582 ASSERT_TRUE(tiling); 2497 ASSERT_TRUE(tiling);
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
2975 maximum_animation_scale, 2890 maximum_animation_scale,
2976 starting_animation_scale, animating_transform); 2891 starting_animation_scale, animating_transform);
2977 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f); 2892 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f);
2978 } 2893 }
2979 2894
2980 TEST_F(PictureLayerImplTest, TilingSetRasterQueue) { 2895 TEST_F(PictureLayerImplTest, TilingSetRasterQueue) {
2981 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 2896 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
2982 2897
2983 host_impl_.SetViewportSize(gfx::Size(500, 500)); 2898 host_impl_.SetViewportSize(gfx::Size(500, 500));
2984 2899
2985 gfx::Size recording_tile_size(100, 100);
2986 gfx::Size layer_bounds(1000, 1000); 2900 gfx::Size layer_bounds(1000, 1000);
2987 2901
2988 scoped_refptr<FakePicturePileImpl> pending_pile = 2902 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
2989 FakePicturePileImpl::CreateFilledPile(recording_tile_size, layer_bounds); 2903 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
2990 2904
2991 SetupPendingTree(pending_pile); 2905 SetupPendingTree(pending_raster_source);
2992 EXPECT_EQ(1u, pending_layer_->num_tilings()); 2906 EXPECT_EQ(1u, pending_layer_->num_tilings());
2993 2907
2994 std::set<Tile*> unique_tiles; 2908 std::set<Tile*> unique_tiles;
2995 bool reached_prepaint = false; 2909 bool reached_prepaint = false;
2996 int non_ideal_tile_count = 0u; 2910 int non_ideal_tile_count = 0u;
2997 int low_res_tile_count = 0u; 2911 int low_res_tile_count = 0u;
2998 int high_res_tile_count = 0u; 2912 int high_res_tile_count = 0u;
2999 int high_res_now_tiles = 0u; 2913 int high_res_now_tiles = 0u;
3000 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( 2914 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll(
3001 pending_layer_->picture_layer_tiling_set(), false)); 2915 pending_layer_->picture_layer_tiling_set(), false));
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
3109 queue.reset(new TilingSetRasterQueueAll( 3023 queue.reset(new TilingSetRasterQueueAll(
3110 pending_layer_->picture_layer_tiling_set(), true)); 3024 pending_layer_->picture_layer_tiling_set(), true));
3111 EXPECT_TRUE(queue->IsEmpty()); 3025 EXPECT_TRUE(queue->IsEmpty());
3112 } 3026 }
3113 3027
3114 TEST_F(PictureLayerImplTest, TilingSetRasterQueueActiveTree) { 3028 TEST_F(PictureLayerImplTest, TilingSetRasterQueueActiveTree) {
3115 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 3029 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
3116 3030
3117 host_impl_.SetViewportSize(gfx::Size(500, 500)); 3031 host_impl_.SetViewportSize(gfx::Size(500, 500));
3118 3032
3119 gfx::Size tile_size(100, 100);
3120 gfx::Size layer_bounds(1000, 1000); 3033 gfx::Size layer_bounds(1000, 1000);
3121 3034
3122 scoped_refptr<FakePicturePileImpl> pending_pile = 3035 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
3123 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 3036 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
3124 3037
3125 SetupPendingTree(pending_pile); 3038 SetupPendingTree(pending_raster_source);
3126 ActivateTree(); 3039 ActivateTree();
3127 EXPECT_EQ(2u, active_layer_->num_tilings()); 3040 EXPECT_EQ(2u, active_layer_->num_tilings());
3128 3041
3129 scoped_ptr<TilingSetRasterQueueRequired> queue( 3042 scoped_ptr<TilingSetRasterQueueRequired> queue(
3130 new TilingSetRasterQueueRequired( 3043 new TilingSetRasterQueueRequired(
3131 active_layer_->picture_layer_tiling_set(), 3044 active_layer_->picture_layer_tiling_set(),
3132 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW)); 3045 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW));
3133 EXPECT_FALSE(queue->IsEmpty()); 3046 EXPECT_FALSE(queue->IsEmpty());
3134 while (!queue->IsEmpty()) { 3047 while (!queue->IsEmpty()) {
3135 PrioritizedTile prioritized_tile = queue->Top(); 3048 PrioritizedTile prioritized_tile = queue->Top();
3136 EXPECT_TRUE(prioritized_tile.tile()->required_for_draw()); 3049 EXPECT_TRUE(prioritized_tile.tile()->required_for_draw());
3137 EXPECT_FALSE(prioritized_tile.tile()->draw_info().IsReadyToDraw()); 3050 EXPECT_FALSE(prioritized_tile.tile()->draw_info().IsReadyToDraw());
3138 queue->Pop(); 3051 queue->Pop();
3139 } 3052 }
3140 3053
3141 queue.reset(new TilingSetRasterQueueRequired( 3054 queue.reset(new TilingSetRasterQueueRequired(
3142 active_layer_->picture_layer_tiling_set(), 3055 active_layer_->picture_layer_tiling_set(),
3143 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); 3056 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION));
3144 EXPECT_TRUE(queue->IsEmpty()); 3057 EXPECT_TRUE(queue->IsEmpty());
3145 } 3058 }
3146 3059
3147 TEST_F(PictureLayerImplTest, TilingSetRasterQueueRequiredNoHighRes) { 3060 TEST_F(PictureLayerImplTest, TilingSetRasterQueueRequiredNoHighRes) {
3148 scoped_ptr<FakePicturePile> empty_recording = 3061 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
3149 FakePicturePile::CreateEmptyPile(gfx::Size(256, 256), 3062 FakeDisplayListRasterSource::CreateFilledSolidColor(
3150 gfx::Size(1024, 1024)); 3063 gfx::Size(1024, 1024));
3151 empty_recording->SetIsSolidColor(true);
3152 3064
3153 scoped_refptr<FakePicturePileImpl> pending_pile = 3065 SetupPendingTree(pending_raster_source);
3154 FakePicturePileImpl::CreateFromPile(empty_recording.get(), nullptr);
3155
3156 SetupPendingTree(pending_pile);
3157 EXPECT_FALSE( 3066 EXPECT_FALSE(
3158 pending_layer_->picture_layer_tiling_set()->FindTilingWithResolution( 3067 pending_layer_->picture_layer_tiling_set()->FindTilingWithResolution(
3159 HIGH_RESOLUTION)); 3068 HIGH_RESOLUTION));
3160 3069
3161 scoped_ptr<TilingSetRasterQueueRequired> queue( 3070 scoped_ptr<TilingSetRasterQueueRequired> queue(
3162 new TilingSetRasterQueueRequired( 3071 new TilingSetRasterQueueRequired(
3163 pending_layer_->picture_layer_tiling_set(), 3072 pending_layer_->picture_layer_tiling_set(),
3164 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); 3073 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION));
3165 EXPECT_TRUE(queue->IsEmpty()); 3074 EXPECT_TRUE(queue->IsEmpty());
3166 } 3075 }
3167 3076
3168 TEST_F(PictureLayerImplTest, TilingSetEvictionQueue) { 3077 TEST_F(PictureLayerImplTest, TilingSetEvictionQueue) {
3169 gfx::Size tile_size(100, 100);
3170 gfx::Size layer_bounds(1000, 1000); 3078 gfx::Size layer_bounds(1000, 1000);
3171 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; 3079 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
3172 3080
3173 host_impl_.SetViewportSize(gfx::Size(500, 500)); 3081 host_impl_.SetViewportSize(gfx::Size(500, 500));
3174 3082
3175 scoped_refptr<FakePicturePileImpl> pending_pile = 3083 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
3176 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 3084 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
3177 3085
3178 // TODO(vmpstr): Add a test with tilings other than high res on the active 3086 // TODO(vmpstr): Add a test with tilings other than high res on the active
3179 // tree (crbug.com/519607). 3087 // tree (crbug.com/519607).
3180 SetupPendingTree(pending_pile); 3088 SetupPendingTree(pending_raster_source);
3181 EXPECT_EQ(1u, pending_layer_->num_tilings()); 3089 EXPECT_EQ(1u, pending_layer_->num_tilings());
3182 3090
3183 std::vector<Tile*> all_tiles; 3091 std::vector<Tile*> all_tiles;
3184 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { 3092 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) {
3185 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); 3093 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i);
3186 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); 3094 std::vector<Tile*> tiles = tiling->AllTilesForTesting();
3187 all_tiles.insert(all_tiles.end(), tiles.begin(), tiles.end()); 3095 all_tiles.insert(all_tiles.end(), tiles.begin(), tiles.end());
3188 } 3096 }
3189 3097
3190 std::set<Tile*> all_tiles_set(all_tiles.begin(), all_tiles.end()); 3098 std::set<Tile*> all_tiles_set(all_tiles.begin(), all_tiles.end());
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
3310 } 3218 }
3311 3219
3312 TEST_F(PictureLayerImplTest, Occlusion) { 3220 TEST_F(PictureLayerImplTest, Occlusion) {
3313 gfx::Size tile_size(102, 102); 3221 gfx::Size tile_size(102, 102);
3314 gfx::Size layer_bounds(1000, 1000); 3222 gfx::Size layer_bounds(1000, 1000);
3315 gfx::Size viewport_size(1000, 1000); 3223 gfx::Size viewport_size(1000, 1000);
3316 3224
3317 LayerTestCommon::LayerImplTest impl; 3225 LayerTestCommon::LayerImplTest impl;
3318 host_impl_.SetViewportSize(viewport_size); 3226 host_impl_.SetViewportSize(viewport_size);
3319 3227
3320 scoped_refptr<FakePicturePileImpl> pending_pile = 3228 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
3321 FakePicturePileImpl::CreateFilledPile(layer_bounds, layer_bounds); 3229 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
3322 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); 3230 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region());
3323 ActivateTree(); 3231 ActivateTree();
3324 3232
3325 std::vector<Tile*> tiles = 3233 std::vector<Tile*> tiles =
3326 active_layer_->HighResTiling()->AllTilesForTesting(); 3234 active_layer_->HighResTiling()->AllTilesForTesting();
3327 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); 3235 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles);
3328 3236
3329 { 3237 {
3330 SCOPED_TRACE("No occlusion"); 3238 SCOPED_TRACE("No occlusion");
3331 gfx::Rect occluded; 3239 gfx::Rect occluded;
3332 impl.AppendQuadsWithOcclusion(active_layer_, occluded); 3240 impl.AppendQuadsWithOcclusion(active_layer_, occluded);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
3453 3361
3454 // The pending high-res tiles are not ready, so we cannot activate. 3362 // The pending high-res tiles are not ready, so we cannot activate.
3455 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate()); 3363 EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate());
3456 3364
3457 // When the pending high-res tiles are ready, we can activate. 3365 // When the pending high-res tiles are ready, we can activate.
3458 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling()); 3366 pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling());
3459 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); 3367 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate());
3460 } 3368 }
3461 3369
3462 TEST_F(NoLowResPictureLayerImplTest, ManageTilingsCreatesTilings) { 3370 TEST_F(NoLowResPictureLayerImplTest, ManageTilingsCreatesTilings) {
3463 gfx::Size tile_size(400, 400);
3464 gfx::Size layer_bounds(1300, 1900); 3371 gfx::Size layer_bounds(1300, 1900);
3465 3372 SetupDefaultTrees(layer_bounds);
3466 scoped_refptr<FakePicturePileImpl> pending_pile =
3467 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
3468 scoped_refptr<FakePicturePileImpl> active_pile =
3469 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
3470
3471 SetupTrees(pending_pile, active_pile);
3472 3373
3473 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; 3374 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
3474 EXPECT_LT(low_res_factor, 1.f); 3375 EXPECT_LT(low_res_factor, 1.f);
3475 3376
3476 ResetTilingsAndRasterScales(); 3377 ResetTilingsAndRasterScales();
3477 3378
3478 SetupDrawPropertiesAndUpdateTiles(active_layer_, 3379 SetupDrawPropertiesAndUpdateTiles(active_layer_,
3479 6.f, // ideal contents scale 3380 6.f, // ideal contents scale
3480 3.f, // device scale 3381 3.f, // device scale
3481 2.f, // page scale 3382 2.f, // page scale
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3518 3.3f, // page scale 3419 3.3f, // page scale
3519 1.f, // maximum animation scale 3420 1.f, // maximum animation scale
3520 0.f, // starting animation scale 3421 0.f, // starting animation scale
3521 false); 3422 false);
3522 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); 3423 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings());
3523 EXPECT_FLOAT_EQ(7.26f, 3424 EXPECT_FLOAT_EQ(7.26f,
3524 active_layer_->tilings()->tiling_at(0)->contents_scale()); 3425 active_layer_->tilings()->tiling_at(0)->contents_scale());
3525 } 3426 }
3526 3427
3527 TEST_F(NoLowResPictureLayerImplTest, PendingLayerOnlyHasHighResTiling) { 3428 TEST_F(NoLowResPictureLayerImplTest, PendingLayerOnlyHasHighResTiling) {
3528 gfx::Size tile_size(400, 400);
3529 gfx::Size layer_bounds(1300, 1900); 3429 gfx::Size layer_bounds(1300, 1900);
3530 3430 SetupDefaultTrees(layer_bounds);
3531 scoped_refptr<FakePicturePileImpl> pending_pile =
3532 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
3533 scoped_refptr<FakePicturePileImpl> active_pile =
3534 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
3535
3536 SetupTrees(pending_pile, active_pile);
3537 3431
3538 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; 3432 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
3539 EXPECT_LT(low_res_factor, 1.f); 3433 EXPECT_LT(low_res_factor, 1.f);
3540 3434
3541 ResetTilingsAndRasterScales(); 3435 ResetTilingsAndRasterScales();
3542 3436
3543 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 3437 SetupDrawPropertiesAndUpdateTiles(pending_layer_,
3544 6.f, // ideal contents scale 3438 6.f, // ideal contents scale
3545 3.f, // device scale 3439 3.f, // device scale
3546 2.f, // page scale 3440 2.f, // page scale
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
3610 3504
3611 AssertAllTilesRequired(active_layer_->HighResTiling()); 3505 AssertAllTilesRequired(active_layer_->HighResTiling());
3612 if (host_impl_.settings().create_low_res_tiling) 3506 if (host_impl_.settings().create_low_res_tiling)
3613 AssertNoTilesRequired(active_layer_->LowResTiling()); 3507 AssertNoTilesRequired(active_layer_->LowResTiling());
3614 } 3508 }
3615 3509
3616 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { 3510 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) {
3617 gfx::Size layer_bounds(400, 400); 3511 gfx::Size layer_bounds(400, 400);
3618 gfx::Size tile_size(100, 100); 3512 gfx::Size tile_size(100, 100);
3619 3513
3620 scoped_refptr<FakePicturePileImpl> pending_pile = 3514 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
3621 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 3515 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
3622 // This pile will create tilings, but has no recordings so will not create any 3516 // This raster source will create tilings, but has no recordings so will not
3623 // tiles. This is attempting to simulate scrolling past the end of recorded 3517 // create any tiles. This is attempting to simulate scrolling past the end of
3624 // content on the active layer, where the recordings are so far away that 3518 // recorded content on the active layer, where the recordings are so far away
3625 // no tiles are created. 3519 // that no tiles are created.
3626 bool is_solid_color = false; 3520 scoped_refptr<FakeDisplayListRasterSource> active_raster_source =
3627 scoped_refptr<FakePicturePileImpl> active_pile = 3521 FakeDisplayListRasterSource::CreatePartiallyFilled(layer_bounds,
3628 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( 3522 gfx::Rect());
3629 tile_size, layer_bounds, is_solid_color);
3630 3523
3631 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); 3524 SetupTreesWithFixedTileSize(pending_raster_source, active_raster_source,
3525 tile_size, Region());
3632 3526
3633 // Active layer has tilings, but no tiles due to missing recordings. 3527 // Active layer has tilings, but no tiles due to missing recordings.
3634 EXPECT_TRUE(active_layer_->CanHaveTilings()); 3528 EXPECT_TRUE(active_layer_->CanHaveTilings());
3635 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 3529 EXPECT_EQ(active_layer_->tilings()->num_tilings(),
3636 host_impl_.settings().create_low_res_tiling ? 2u : 1u); 3530 host_impl_.settings().create_low_res_tiling ? 2u : 1u);
3637 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); 3531 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u);
3638 3532
3639 // Since the active layer has no tiles at all, the pending layer doesn't 3533 // Since the active layer has no tiles at all, the pending layer doesn't
3640 // need content in order to activate. 3534 // need content in order to activate.
3641 pending_layer_->HighResTiling()->UpdateAllRequiredStateForTesting(); 3535 pending_layer_->HighResTiling()->UpdateAllRequiredStateForTesting();
3642 if (host_impl_.settings().create_low_res_tiling) 3536 if (host_impl_.settings().create_low_res_tiling)
3643 pending_layer_->LowResTiling()->UpdateAllRequiredStateForTesting(); 3537 pending_layer_->LowResTiling()->UpdateAllRequiredStateForTesting();
3644 3538
3645 AssertNoTilesRequired(pending_layer_->HighResTiling()); 3539 AssertNoTilesRequired(pending_layer_->HighResTiling());
3646 if (host_impl_.settings().create_low_res_tiling) 3540 if (host_impl_.settings().create_low_res_tiling)
3647 AssertNoTilesRequired(pending_layer_->LowResTiling()); 3541 AssertNoTilesRequired(pending_layer_->LowResTiling());
3648 } 3542 }
3649 3543
3650 TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) { 3544 TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) {
3651 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 3545 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
3652
3653 gfx::Size tile_size(100, 100);
3654 gfx::Size layer_bounds(400, 400); 3546 gfx::Size layer_bounds(400, 400);
3655 3547 SetupDefaultTrees(layer_bounds);
3656 scoped_refptr<FakePicturePileImpl> pending_pile =
3657 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
3658 scoped_refptr<FakePicturePileImpl> active_pile =
3659 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
3660
3661 SetupTreesWithInvalidation(pending_pile, active_pile, Region());
3662 3548
3663 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, 0.f, 3549 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, 0.f,
3664 false); 3550 false);
3665 3551
3666 // UpdateTiles with valid viewport. Should update tile viewport. 3552 // UpdateTiles with valid viewport. Should update tile viewport.
3667 // Note viewport is considered invalid if and only if in resourceless 3553 // Note viewport is considered invalid if and only if in resourceless
3668 // software draw. 3554 // software draw.
3669 bool resourceless_software_draw = false; 3555 bool resourceless_software_draw = false;
3670 gfx::Rect viewport = gfx::Rect(layer_bounds); 3556 gfx::Rect viewport = gfx::Rect(layer_bounds);
3671 gfx::Transform transform; 3557 gfx::Transform transform;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
3718 transform, 3604 transform,
3719 resourceless_software_draw); 3605 resourceless_software_draw);
3720 active_layer_->UpdateTiles(resourceless_software_draw); 3606 active_layer_->UpdateTiles(resourceless_software_draw);
3721 3607
3722 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, 3608 EXPECT_TRANSFORMATION_MATRIX_EQ(transform,
3723 active_layer_->screen_space_transform()); 3609 active_layer_->screen_space_transform());
3724 EXPECT_EQ(viewport, active_layer_->visible_rect_for_tile_priority()); 3610 EXPECT_EQ(viewport, active_layer_->visible_rect_for_tile_priority());
3725 } 3611 }
3726 3612
3727 TEST_F(NoLowResPictureLayerImplTest, CleanUpTilings) { 3613 TEST_F(NoLowResPictureLayerImplTest, CleanUpTilings) {
3728 gfx::Size tile_size(400, 400);
3729 gfx::Size layer_bounds(1300, 1900); 3614 gfx::Size layer_bounds(1300, 1900);
3730
3731 scoped_refptr<FakePicturePileImpl> pending_pile =
3732 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
3733 scoped_refptr<FakePicturePileImpl> active_pile =
3734 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
3735
3736 std::vector<PictureLayerTiling*> used_tilings; 3615 std::vector<PictureLayerTiling*> used_tilings;
3737 3616 SetupDefaultTrees(layer_bounds);
3738 SetupTrees(pending_pile, active_pile);
3739 3617
3740 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; 3618 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
3741 EXPECT_LT(low_res_factor, 1.f); 3619 EXPECT_LT(low_res_factor, 1.f);
3742 3620
3743 float device_scale = 1.7f; 3621 float device_scale = 1.7f;
3744 float page_scale = 3.2f; 3622 float page_scale = 3.2f;
3745 float scale = 1.f; 3623 float scale = 1.f;
3746 3624
3747 ResetTilingsAndRasterScales(); 3625 ResetTilingsAndRasterScales();
3748 3626
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
3835 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); 3713 ASSERT_EQ(2u, active_layer_->tilings()->num_tilings());
3836 3714
3837 // If we remove it from our used tilings set, it is outside the range to keep 3715 // If we remove it from our used tilings set, it is outside the range to keep
3838 // so it is deleted. 3716 // so it is deleted.
3839 used_tilings.clear(); 3717 used_tilings.clear();
3840 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings); 3718 active_layer_->CleanUpTilingsOnActiveLayer(used_tilings);
3841 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings()); 3719 ASSERT_EQ(1u, active_layer_->tilings()->num_tilings());
3842 } 3720 }
3843 3721
3844 TEST_F(NoLowResPictureLayerImplTest, ReleaseResources) { 3722 TEST_F(NoLowResPictureLayerImplTest, ReleaseResources) {
3845 gfx::Size tile_size(400, 400);
3846 gfx::Size layer_bounds(1300, 1900); 3723 gfx::Size layer_bounds(1300, 1900);
3847 3724 SetupDefaultTrees(layer_bounds);
3848 scoped_refptr<FakePicturePileImpl> pending_pile =
3849 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
3850 scoped_refptr<FakePicturePileImpl> active_pile =
3851 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
3852
3853 SetupTrees(pending_pile, active_pile);
3854 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); 3725 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings());
3855 EXPECT_EQ(1u, active_layer_->tilings()->num_tilings()); 3726 EXPECT_EQ(1u, active_layer_->tilings()->num_tilings());
3856 3727
3857 // All tilings should be removed when losing output surface. 3728 // All tilings should be removed when losing output surface.
3858 active_layer_->ReleaseResources(); 3729 active_layer_->ReleaseResources();
3859 EXPECT_FALSE(active_layer_->tilings()); 3730 EXPECT_FALSE(active_layer_->tilings());
3860 active_layer_->RecreateResources(); 3731 active_layer_->RecreateResources();
3861 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); 3732 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
3862 pending_layer_->ReleaseResources(); 3733 pending_layer_->ReleaseResources();
3863 EXPECT_FALSE(pending_layer_->tilings()); 3734 EXPECT_FALSE(pending_layer_->tilings());
3864 pending_layer_->RecreateResources(); 3735 pending_layer_->RecreateResources();
3865 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); 3736 EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings());
3866 3737
3867 // This should create new tilings. 3738 // This should create new tilings.
3868 SetupDrawPropertiesAndUpdateTiles(pending_layer_, 3739 SetupDrawPropertiesAndUpdateTiles(pending_layer_,
3869 1.3f, // ideal contents scale 3740 1.3f, // ideal contents scale
3870 2.7f, // device scale 3741 2.7f, // device scale
3871 3.2f, // page scale 3742 3.2f, // page scale
3872 1.f, // maximum animation scale 3743 1.f, // maximum animation scale
3873 0.f, // starting animation scale 3744 0.f, // starting animation scale
3874 false); 3745 false);
3875 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); 3746 EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings());
3876 } 3747 }
3877 3748
3878 TEST_F(PictureLayerImplTest, SharedQuadStateContainsMaxTilingScale) { 3749 TEST_F(PictureLayerImplTest, SharedQuadStateContainsMaxTilingScale) {
3879 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 3750 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
3880 3751
3881 gfx::Size tile_size(400, 400);
3882 gfx::Size layer_bounds(1000, 2000); 3752 gfx::Size layer_bounds(1000, 2000);
3883
3884 host_impl_.SetViewportSize(gfx::Size(10000, 20000)); 3753 host_impl_.SetViewportSize(gfx::Size(10000, 20000));
3885 3754 SetupDefaultTrees(layer_bounds);
3886 scoped_refptr<FakePicturePileImpl> pending_pile =
3887 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
3888 scoped_refptr<FakePicturePileImpl> active_pile =
3889 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
3890
3891 SetupTrees(pending_pile, active_pile);
3892 3755
3893 ResetTilingsAndRasterScales(); 3756 ResetTilingsAndRasterScales();
3894 SetupDrawPropertiesAndUpdateTiles(active_layer_, 2.5f, 1.f, 1.f, 1.f, 0.f, 3757 SetupDrawPropertiesAndUpdateTiles(active_layer_, 2.5f, 1.f, 1.f, 1.f, 0.f,
3895 false); 3758 false);
3896 3759
3897 float max_contents_scale = active_layer_->MaximumTilingContentsScale(); 3760 float max_contents_scale = active_layer_->MaximumTilingContentsScale();
3898 EXPECT_EQ(2.5f, max_contents_scale); 3761 EXPECT_EQ(2.5f, max_contents_scale);
3899 3762
3900 gfx::Transform scaled_draw_transform = active_layer_->draw_transform(); 3763 gfx::Transform scaled_draw_transform = active_layer_->draw_transform();
3901 scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale, 3764 scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale,
(...skipping 27 matching lines...) Expand all
3929 3792
3930 void InitializeRenderer() override { 3793 void InitializeRenderer() override {
3931 host_impl_.InitializeRenderer(FakeOutputSurface::CreateDelegating3d()); 3794 host_impl_.InitializeRenderer(FakeOutputSurface::CreateDelegating3d());
3932 } 3795 }
3933 }; 3796 };
3934 3797
3935 TEST_F(PictureLayerImplTestWithDelegatingRenderer, 3798 TEST_F(PictureLayerImplTestWithDelegatingRenderer,
3936 DelegatingRendererWithTileOOM) { 3799 DelegatingRendererWithTileOOM) {
3937 // This test is added for crbug.com/402321, where quad should be produced when 3800 // This test is added for crbug.com/402321, where quad should be produced when
3938 // raster on demand is not allowed and tile is OOM. 3801 // raster on demand is not allowed and tile is OOM.
3939 gfx::Size tile_size = host_impl_.settings().default_tile_size;
3940 gfx::Size layer_bounds(1000, 1000); 3802 gfx::Size layer_bounds(1000, 1000);
3941 3803
3942 // Create tiles. 3804 // Create tiles.
3943 scoped_refptr<FakePicturePileImpl> pending_pile = 3805 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
3944 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 3806 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
3945 SetupPendingTree(pending_pile); 3807 SetupPendingTree(pending_raster_source);
3946 pending_layer_->SetBounds(layer_bounds); 3808 pending_layer_->SetBounds(layer_bounds);
3947 ActivateTree(); 3809 ActivateTree();
3948 bool update_lcd_text = false; 3810 bool update_lcd_text = false;
3949 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); 3811 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text);
3950 std::vector<Tile*> tiles = 3812 std::vector<Tile*> tiles =
3951 active_layer_->HighResTiling()->AllTilesForTesting(); 3813 active_layer_->HighResTiling()->AllTilesForTesting();
3952 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); 3814 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles);
3953 3815
3954 // Force tiles after max_tiles to be OOM. TileManager uses 3816 // Force tiles after max_tiles to be OOM. TileManager uses
3955 // GlobalStateThatImpactsTilesPriority from LayerTreeHostImpl, and we cannot 3817 // GlobalStateThatImpactsTilesPriority from LayerTreeHostImpl, and we cannot
3956 // directly set state to host_impl_, so we set policy that would change the 3818 // directly set state to host_impl_, so we set policy that would change the
3957 // state. We also need to update tree priority separately. 3819 // state. We also need to update tree priority separately.
3958 GlobalStateThatImpactsTilePriority state; 3820 GlobalStateThatImpactsTilePriority state;
3959 size_t max_tiles = 1; 3821 size_t max_tiles = 1;
3822 gfx::Size tile_size(host_impl_.settings().default_tile_size);
3960 size_t memory_limit = max_tiles * 4 * tile_size.width() * tile_size.height(); 3823 size_t memory_limit = max_tiles * 4 * tile_size.width() * tile_size.height();
3961 size_t resource_limit = max_tiles; 3824 size_t resource_limit = max_tiles;
3962 ManagedMemoryPolicy policy(memory_limit, 3825 ManagedMemoryPolicy policy(memory_limit,
3963 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, 3826 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING,
3964 resource_limit); 3827 resource_limit);
3965 host_impl_.SetMemoryPolicy(policy); 3828 host_impl_.SetMemoryPolicy(policy);
3966 host_impl_.SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); 3829 host_impl_.SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES);
3967 host_impl_.PrepareTiles(); 3830 host_impl_.PrepareTiles();
3968 3831
3969 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 3832 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
4039 OccludedTilesSkippedDuringRasterization) { 3902 OccludedTilesSkippedDuringRasterization) {
4040 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 3903 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
4041 3904
4042 gfx::Size tile_size(102, 102); 3905 gfx::Size tile_size(102, 102);
4043 gfx::Size layer_bounds(1000, 1000); 3906 gfx::Size layer_bounds(1000, 1000);
4044 gfx::Size viewport_size(500, 500); 3907 gfx::Size viewport_size(500, 500);
4045 gfx::Point occluding_layer_position(310, 0); 3908 gfx::Point occluding_layer_position(310, 0);
4046 3909
4047 host_impl_.SetViewportSize(viewport_size); 3910 host_impl_.SetViewportSize(viewport_size);
4048 3911
4049 scoped_refptr<FakePicturePileImpl> pending_pile = 3912 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
4050 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 3913 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
4051 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); 3914 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region());
4052 3915
4053 // No occlusion. 3916 // No occlusion.
4054 int unoccluded_tile_count = 0; 3917 int unoccluded_tile_count = 0;
4055 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( 3918 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll(
4056 pending_layer_->picture_layer_tiling_set(), false)); 3919 pending_layer_->picture_layer_tiling_set(), false));
4057 while (!queue->IsEmpty()) { 3920 while (!queue->IsEmpty()) {
4058 PrioritizedTile prioritized_tile = queue->Top(); 3921 PrioritizedTile prioritized_tile = queue->Top();
4059 Tile* tile = prioritized_tile.tile(); 3922 Tile* tile = prioritized_tile.tile();
4060 3923
4061 // Occluded tiles should not be iterated over. 3924 // Occluded tiles should not be iterated over.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
4128 OccludedTilesNotMarkedAsRequired) { 3991 OccludedTilesNotMarkedAsRequired) {
4129 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 3992 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
4130 3993
4131 gfx::Size tile_size(102, 102); 3994 gfx::Size tile_size(102, 102);
4132 gfx::Size layer_bounds(1000, 1000); 3995 gfx::Size layer_bounds(1000, 1000);
4133 gfx::Size viewport_size(500, 500); 3996 gfx::Size viewport_size(500, 500);
4134 gfx::Point occluding_layer_position(310, 0); 3997 gfx::Point occluding_layer_position(310, 0);
4135 3998
4136 host_impl_.SetViewportSize(viewport_size); 3999 host_impl_.SetViewportSize(viewport_size);
4137 4000
4138 scoped_refptr<FakePicturePileImpl> pending_pile = 4001 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
4139 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 4002 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
4140 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); 4003 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region());
4141 4004
4142 // No occlusion. 4005 // No occlusion.
4143 int occluded_tile_count = 0; 4006 int occluded_tile_count = 0;
4144 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) { 4007 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) {
4145 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i); 4008 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i);
4146 auto prioritized_tiles = 4009 auto prioritized_tiles =
4147 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); 4010 tiling->UpdateAndGetAllPrioritizedTilesForTesting();
4148 4011
4149 occluded_tile_count = 0; 4012 occluded_tile_count = 0;
4150 for (PictureLayerTiling::CoverageIterator iter(tiling, 1.f, 4013 for (PictureLayerTiling::CoverageIterator iter(tiling, 1.f,
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
4243 } 4106 }
4244 4107
4245 TEST_F(OcclusionTrackingPictureLayerImplTest, OcclusionForDifferentScales) { 4108 TEST_F(OcclusionTrackingPictureLayerImplTest, OcclusionForDifferentScales) {
4246 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 4109 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
4247 4110
4248 gfx::Size tile_size(102, 102); 4111 gfx::Size tile_size(102, 102);
4249 gfx::Size layer_bounds(1000, 1000); 4112 gfx::Size layer_bounds(1000, 1000);
4250 gfx::Size viewport_size(500, 500); 4113 gfx::Size viewport_size(500, 500);
4251 gfx::Point occluding_layer_position(310, 0); 4114 gfx::Point occluding_layer_position(310, 0);
4252 4115
4253 scoped_refptr<FakePicturePileImpl> pending_pile = 4116 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
4254 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 4117 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
4255 4118
4256 host_impl_.SetViewportSize(viewport_size); 4119 host_impl_.SetViewportSize(viewport_size);
4257 4120
4258 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); 4121 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region());
4259 ASSERT_TRUE(pending_layer_->CanHaveTilings()); 4122 ASSERT_TRUE(pending_layer_->CanHaveTilings());
4260 4123
4261 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1)); 4124 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 1));
4262 LayerImpl* layer1 = pending_layer_->children()[0]; 4125 LayerImpl* layer1 = pending_layer_->children()[0];
4263 layer1->SetBounds(layer_bounds); 4126 layer1->SetBounds(layer_bounds);
4264 layer1->SetDrawsContent(true); 4127 layer1->SetDrawsContent(true);
4265 layer1->SetContentsOpaque(true); 4128 layer1->SetContentsOpaque(true);
4266 layer1->SetPosition(occluding_layer_position); 4129 layer1->SetPosition(occluding_layer_position);
4267 4130
4268 pending_layer_->tilings()->RemoveAllTilings(); 4131 pending_layer_->tilings()->RemoveAllTilings();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
4317 } 4180 }
4318 } 4181 }
4319 4182
4320 TEST_F(OcclusionTrackingPictureLayerImplTest, DifferentOcclusionOnTrees) { 4183 TEST_F(OcclusionTrackingPictureLayerImplTest, DifferentOcclusionOnTrees) {
4321 gfx::Size tile_size(102, 102); 4184 gfx::Size tile_size(102, 102);
4322 gfx::Size layer_bounds(1000, 1000); 4185 gfx::Size layer_bounds(1000, 1000);
4323 gfx::Size viewport_size(1000, 1000); 4186 gfx::Size viewport_size(1000, 1000);
4324 gfx::Point occluding_layer_position(310, 0); 4187 gfx::Point occluding_layer_position(310, 0);
4325 gfx::Rect invalidation_rect(230, 230, 102, 102); 4188 gfx::Rect invalidation_rect(230, 230, 102, 102);
4326 4189
4327 scoped_refptr<FakePicturePileImpl> pending_pile = 4190 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
4328 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 4191 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
4329 scoped_refptr<FakePicturePileImpl> active_pile = 4192 scoped_refptr<FakeDisplayListRasterSource> active_raster_source =
4330 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 4193 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
4331 4194
4332 host_impl_.SetViewportSize(viewport_size); 4195 host_impl_.SetViewportSize(viewport_size);
4333 SetupPendingTree(active_pile); 4196 SetupPendingTree(active_raster_source);
4334 4197
4335 // Partially occlude the active layer. 4198 // Partially occlude the active layer.
4336 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 2)); 4199 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 2));
4337 LayerImpl* layer1 = pending_layer_->children()[0]; 4200 LayerImpl* layer1 = pending_layer_->children()[0];
4338 layer1->SetBounds(layer_bounds); 4201 layer1->SetBounds(layer_bounds);
4339 layer1->SetDrawsContent(true); 4202 layer1->SetDrawsContent(true);
4340 layer1->SetContentsOpaque(true); 4203 layer1->SetContentsOpaque(true);
4341 layer1->SetPosition(occluding_layer_position); 4204 layer1->SetPosition(occluding_layer_position);
4342 4205
4343 ActivateTree(); 4206 ActivateTree();
(...skipping 13 matching lines...) Expand all
4357 gfx::Rect scaled_content_rect = ScaleToEnclosingRect( 4220 gfx::Rect scaled_content_rect = ScaleToEnclosingRect(
4358 tile->content_rect(), 1.0f / tile->contents_scale()); 4221 tile->content_rect(), 1.0f / tile->contents_scale());
4359 // Tiles are occluded on the active tree iff they lie beneath the 4222 // Tiles are occluded on the active tree iff they lie beneath the
4360 // occluding layer. 4223 // occluding layer.
4361 EXPECT_EQ(prioritized_tiles[tile].is_occluded(), 4224 EXPECT_EQ(prioritized_tiles[tile].is_occluded(),
4362 scaled_content_rect.x() >= occluding_layer_position.x()); 4225 scaled_content_rect.x() >= occluding_layer_position.x());
4363 } 4226 }
4364 } 4227 }
4365 4228
4366 // Partially invalidate the pending layer. 4229 // Partially invalidate the pending layer.
4367 SetupPendingTreeWithInvalidation(pending_pile, invalidation_rect); 4230 SetupPendingTreeWithInvalidation(pending_raster_source, invalidation_rect);
4368 4231
4369 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) { 4232 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) {
4370 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i); 4233 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i);
4371 auto prioritized_tiles = 4234 auto prioritized_tiles =
4372 tiling->UpdateAndGetAllPrioritizedTilesForTesting(); 4235 tiling->UpdateAndGetAllPrioritizedTilesForTesting();
4373 4236
4374 for (PictureLayerTiling::CoverageIterator iter(tiling, 1.f, 4237 for (PictureLayerTiling::CoverageIterator iter(tiling, 1.f,
4375 gfx::Rect(layer_bounds)); 4238 gfx::Rect(layer_bounds));
4376 iter; ++iter) { 4239 iter; ++iter) {
4377 if (!*iter) 4240 if (!*iter)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
4411 gfx::Size tile_size(102, 102); 4274 gfx::Size tile_size(102, 102);
4412 gfx::Size layer_bounds(1000, 1000); 4275 gfx::Size layer_bounds(1000, 1000);
4413 gfx::Size viewport_size(1000, 1000); 4276 gfx::Size viewport_size(1000, 1000);
4414 gfx::Point pending_occluding_layer_position(310, 0); 4277 gfx::Point pending_occluding_layer_position(310, 0);
4415 gfx::Point active_occluding_layer_position(0, 310); 4278 gfx::Point active_occluding_layer_position(0, 310);
4416 gfx::Rect invalidation_rect(230, 230, 152, 152); 4279 gfx::Rect invalidation_rect(230, 230, 152, 152);
4417 4280
4418 host_impl_.SetViewportSize(viewport_size); 4281 host_impl_.SetViewportSize(viewport_size);
4419 host_impl_.SetDeviceScaleFactor(2.f); 4282 host_impl_.SetDeviceScaleFactor(2.f);
4420 4283
4421 scoped_refptr<FakePicturePileImpl> pending_pile = 4284 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
4422 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 4285 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
4423 scoped_refptr<FakePicturePileImpl> active_pile = 4286 scoped_refptr<FakeDisplayListRasterSource> active_raster_source =
4424 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 4287 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
4425 4288
4426 SetupPendingTreeWithFixedTileSize(active_pile, tile_size, Region()); 4289 SetupPendingTreeWithFixedTileSize(active_raster_source, tile_size, Region());
4427 4290
4428 // Partially occlude the active layer. 4291 // Partially occlude the active layer.
4429 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 2)); 4292 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 2));
4430 LayerImpl* active_occluding_layer = pending_layer_->children()[0]; 4293 LayerImpl* active_occluding_layer = pending_layer_->children()[0];
4431 active_occluding_layer->SetBounds(layer_bounds); 4294 active_occluding_layer->SetBounds(layer_bounds);
4432 active_occluding_layer->SetDrawsContent(true); 4295 active_occluding_layer->SetDrawsContent(true);
4433 active_occluding_layer->SetContentsOpaque(true); 4296 active_occluding_layer->SetContentsOpaque(true);
4434 active_occluding_layer->SetPosition(active_occluding_layer_position); 4297 active_occluding_layer->SetPosition(active_occluding_layer_position);
4435 4298
4436 ActivateTree(); 4299 ActivateTree();
4437 4300
4438 // Partially invalidate the pending layer. Tiles inside the invalidation rect 4301 // Partially invalidate the pending layer. Tiles inside the invalidation rect
4439 // are created. 4302 // are created.
4440 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, invalidation_rect); 4303 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size,
4304 invalidation_rect);
4441 4305
4442 // Partially occlude the pending layer in a different way. 4306 // Partially occlude the pending layer in a different way.
4443 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 3)); 4307 pending_layer_->AddChild(LayerImpl::Create(host_impl_.pending_tree(), 3));
4444 LayerImpl* pending_occluding_layer = pending_layer_->children()[0]; 4308 LayerImpl* pending_occluding_layer = pending_layer_->children()[0];
4445 pending_occluding_layer->SetBounds(layer_bounds); 4309 pending_occluding_layer->SetBounds(layer_bounds);
4446 pending_occluding_layer->SetDrawsContent(true); 4310 pending_occluding_layer->SetDrawsContent(true);
4447 pending_occluding_layer->SetContentsOpaque(true); 4311 pending_occluding_layer->SetContentsOpaque(true);
4448 pending_occluding_layer->SetPosition(pending_occluding_layer_position); 4312 pending_occluding_layer->SetPosition(pending_occluding_layer_position);
4449 4313
4450 EXPECT_EQ(1u, pending_layer_->num_tilings()); 4314 EXPECT_EQ(1u, pending_layer_->num_tilings());
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
4546 VerifyEvictionConsidersOcclusion( 4410 VerifyEvictionConsidersOcclusion(
4547 active_layer_, ACTIVE_TREE, 4411 active_layer_, ACTIVE_TREE,
4548 total_expected_occluded_tile_count_on_trees[ACTIVE_TREE], __LINE__); 4412 total_expected_occluded_tile_count_on_trees[ACTIVE_TREE], __LINE__);
4549 VerifyEvictionConsidersOcclusion( 4413 VerifyEvictionConsidersOcclusion(
4550 pending_layer_, PENDING_TREE, 4414 pending_layer_, PENDING_TREE,
4551 total_expected_occluded_tile_count_on_trees[PENDING_TREE], __LINE__); 4415 total_expected_occluded_tile_count_on_trees[PENDING_TREE], __LINE__);
4552 pending_layer_->set_has_valid_tile_priorities(true); 4416 pending_layer_->set_has_valid_tile_priorities(true);
4553 } 4417 }
4554 4418
4555 TEST_F(PictureLayerImplTest, PendingOrActiveTwinLayer) { 4419 TEST_F(PictureLayerImplTest, PendingOrActiveTwinLayer) {
4556 gfx::Size tile_size(102, 102);
4557 gfx::Size layer_bounds(1000, 1000); 4420 gfx::Size layer_bounds(1000, 1000);
4558 4421
4559 scoped_refptr<FakePicturePileImpl> pile = 4422 scoped_refptr<FakeDisplayListRasterSource> raster_source =
4560 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 4423 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
4561 SetupPendingTree(pile); 4424 SetupPendingTree(raster_source);
4562 EXPECT_FALSE(pending_layer_->GetPendingOrActiveTwinLayer()); 4425 EXPECT_FALSE(pending_layer_->GetPendingOrActiveTwinLayer());
4563 4426
4564 ActivateTree(); 4427 ActivateTree();
4565 EXPECT_FALSE(active_layer_->GetPendingOrActiveTwinLayer()); 4428 EXPECT_FALSE(active_layer_->GetPendingOrActiveTwinLayer());
4566 4429
4567 SetupPendingTree(pile); 4430 SetupPendingTree(raster_source);
4568 EXPECT_TRUE(pending_layer_->GetPendingOrActiveTwinLayer()); 4431 EXPECT_TRUE(pending_layer_->GetPendingOrActiveTwinLayer());
4569 EXPECT_TRUE(active_layer_->GetPendingOrActiveTwinLayer()); 4432 EXPECT_TRUE(active_layer_->GetPendingOrActiveTwinLayer());
4570 EXPECT_EQ(pending_layer_, active_layer_->GetPendingOrActiveTwinLayer()); 4433 EXPECT_EQ(pending_layer_, active_layer_->GetPendingOrActiveTwinLayer());
4571 EXPECT_EQ(active_layer_, pending_layer_->GetPendingOrActiveTwinLayer()); 4434 EXPECT_EQ(active_layer_, pending_layer_->GetPendingOrActiveTwinLayer());
4572 4435
4573 ActivateTree(); 4436 ActivateTree();
4574 EXPECT_FALSE(active_layer_->GetPendingOrActiveTwinLayer()); 4437 EXPECT_FALSE(active_layer_->GetPendingOrActiveTwinLayer());
4575 4438
4576 // Make an empty pending tree. 4439 // Make an empty pending tree.
4577 host_impl_.CreatePendingTree(); 4440 host_impl_.CreatePendingTree();
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
4694 ActivateTree(); 4557 ActivateTree();
4695 4558
4696 // We've switched to a solid color, so we should end up with no tilings. 4559 // We've switched to a solid color, so we should end up with no tilings.
4697 ASSERT_TRUE(active_layer_->tilings()); 4560 ASSERT_TRUE(active_layer_->tilings());
4698 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); 4561 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
4699 } 4562 }
4700 4563
4701 TEST_F(PictureLayerImplTest, ChangeInViewportAllowsTilingUpdates) { 4564 TEST_F(PictureLayerImplTest, ChangeInViewportAllowsTilingUpdates) {
4702 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 4565 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
4703 4566
4704 gfx::Size tile_size(100, 100);
4705 gfx::Size layer_bounds(400, 4000); 4567 gfx::Size layer_bounds(400, 4000);
4706 4568 SetupDefaultTrees(layer_bounds);
4707 scoped_refptr<FakePicturePileImpl> pending_pile =
4708 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
4709 scoped_refptr<FakePicturePileImpl> active_pile =
4710 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
4711
4712 SetupTrees(pending_pile, active_pile);
4713 4569
4714 Region invalidation; 4570 Region invalidation;
4715 gfx::Rect viewport = gfx::Rect(0, 0, 100, 100); 4571 gfx::Rect viewport = gfx::Rect(0, 0, 100, 100);
4716 gfx::Transform transform; 4572 gfx::Transform transform;
4717 4573
4718 host_impl_.SetRequiresHighResToDraw(); 4574 host_impl_.SetRequiresHighResToDraw();
4719 4575
4720 // Update tiles. 4576 // Update tiles.
4721 pending_layer_->draw_properties().visible_layer_rect = viewport; 4577 pending_layer_->draw_properties().visible_layer_rect = viewport;
4722 pending_layer_->draw_properties().screen_space_transform = transform; 4578 pending_layer_->draw_properties().screen_space_transform = transform;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
4760 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); 4616 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles);
4761 4617
4762 // Ensure we can activate. 4618 // Ensure we can activate.
4763 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); 4619 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate());
4764 } 4620 }
4765 4621
4766 TEST_F(PictureLayerImplTest, CloneMissingRecordings) { 4622 TEST_F(PictureLayerImplTest, CloneMissingRecordings) {
4767 gfx::Size tile_size(100, 100); 4623 gfx::Size tile_size(100, 100);
4768 gfx::Size layer_bounds(400, 400); 4624 gfx::Size layer_bounds(400, 400);
4769 4625
4770 scoped_refptr<FakePicturePileImpl> filled_pile = 4626 scoped_refptr<FakeDisplayListRasterSource> filled_raster_source =
4771 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 4627 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
4772 4628
4773 scoped_ptr<FakePicturePile> partial_recording = 4629 // scoped_ptr<FakeDisplayListRecordingSource> partial_recording =
danakj 2015/09/22 21:52:14 commented out code
vmpstr 2015/09/22 22:57:49 Removed.
4774 FakePicturePile::CreateEmptyPile(tile_size, layer_bounds); 4630 // FakeDisplayListRecordingSource::CreateRecordingSource(
4775 for (int i = 1; i < partial_recording->tiling().num_tiles_x(); ++i) { 4631 // gfx::Rect(250, 250, 150, 150), layer_bounds);
4776 for (int j = 1; j < partial_recording->tiling().num_tiles_y(); ++j) 4632 scoped_refptr<FakeDisplayListRasterSource> partial_raster_source =
4777 partial_recording->AddRecordingAt(i, j); 4633 FakeDisplayListRasterSource::CreatePartiallyFilled(
4778 } 4634 layer_bounds, gfx::Rect(100, 100, 300, 300));
4779 scoped_refptr<FakePicturePileImpl> partial_pile =
4780 FakePicturePileImpl::CreateFromPile(partial_recording.get(), nullptr);
4781 4635
4782 SetupPendingTreeWithFixedTileSize(filled_pile, tile_size, Region()); 4636 SetupPendingTreeWithFixedTileSize(filled_raster_source, tile_size, Region());
4783 ActivateTree(); 4637 ActivateTree();
4784 4638
4785 PictureLayerTiling* pending_tiling = old_pending_layer_->HighResTiling(); 4639 PictureLayerTiling* pending_tiling = old_pending_layer_->HighResTiling();
4786 PictureLayerTiling* active_tiling = active_layer_->HighResTiling(); 4640 PictureLayerTiling* active_tiling = active_layer_->HighResTiling();
4787 4641
4788 // We should have all tiles on active, and none on pending. 4642 // We should have all tiles on active, and none on pending.
4789 EXPECT_EQ(0u, pending_tiling->AllTilesForTesting().size()); 4643 EXPECT_EQ(0u, pending_tiling->AllTilesForTesting().size());
4790 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); 4644 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size());
4791 4645
4792 // Now put a partially-recorded pile on the pending tree (and invalidate 4646 // Now put a partially-recorded raster source on the pending tree (and
4793 // everything, since the main thread PicturePile will invalidate dropped 4647 // invalidate everything, since the main thread recording will invalidate
4794 // recordings). This will cause us to be missing some tiles. 4648 // dropped recordings). This will cause us to be missing some tiles.
4795 SetupPendingTreeWithFixedTileSize(partial_pile, tile_size, 4649 SetupPendingTreeWithFixedTileSize(partial_raster_source, tile_size,
4796 Region(gfx::Rect(layer_bounds))); 4650 Region(gfx::Rect(layer_bounds)));
4797 EXPECT_EQ(3u * 3u, pending_tiling->AllTilesForTesting().size()); 4651 EXPECT_EQ(3u * 3u, pending_tiling->AllTilesForTesting().size());
4798 EXPECT_FALSE(pending_tiling->TileAt(0, 0)); 4652 EXPECT_FALSE(pending_tiling->TileAt(0, 0));
4799 EXPECT_FALSE(pending_tiling->TileAt(1, 1)); 4653 EXPECT_FALSE(pending_tiling->TileAt(1, 1));
4800 EXPECT_TRUE(pending_tiling->TileAt(2, 2)); 4654 EXPECT_TRUE(pending_tiling->TileAt(2, 2));
4801 4655
4802 // Active is not affected yet. 4656 // Active is not affected yet.
4803 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); 4657 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size());
4804 4658
4805 // Activate the tree. The same tiles go missing on the active tree. 4659 // Activate the tree. The same tiles go missing on the active tree.
4806 ActivateTree(); 4660 ActivateTree();
4807 EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size()); 4661 EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size());
4808 EXPECT_FALSE(active_tiling->TileAt(0, 0)); 4662 EXPECT_FALSE(active_tiling->TileAt(0, 0));
4809 EXPECT_FALSE(active_tiling->TileAt(1, 1)); 4663 EXPECT_FALSE(active_tiling->TileAt(1, 1));
4810 EXPECT_TRUE(active_tiling->TileAt(2, 2)); 4664 EXPECT_TRUE(active_tiling->TileAt(2, 2));
4811 4665
4812 // Now put a full recording on the pending tree again. We'll get all our tiles 4666 // Now put a full recording on the pending tree again. We'll get all our tiles
4813 // back. 4667 // back.
4814 SetupPendingTreeWithFixedTileSize(filled_pile, tile_size, 4668 SetupPendingTreeWithFixedTileSize(filled_raster_source, tile_size,
4815 Region(gfx::Rect(layer_bounds))); 4669 Region(gfx::Rect(layer_bounds)));
4816 EXPECT_EQ(5u * 5u, pending_tiling->AllTilesForTesting().size()); 4670 EXPECT_EQ(5u * 5u, pending_tiling->AllTilesForTesting().size());
4817 Tile* tile00 = pending_tiling->TileAt(0, 0); 4671 Tile* tile00 = pending_tiling->TileAt(0, 0);
4818 Tile* tile11 = pending_tiling->TileAt(1, 1); 4672 Tile* tile11 = pending_tiling->TileAt(1, 1);
4819 Tile* tile22 = pending_tiling->TileAt(2, 2); 4673 Tile* tile22 = pending_tiling->TileAt(2, 2);
4820 4674
4821 // Active is not affected yet. 4675 // Active is not affected yet.
4822 EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size()); 4676 EXPECT_EQ(3u * 3u, active_tiling->AllTilesForTesting().size());
4823 4677
4824 // Activate the tree. The tiles are moved to the active tree. 4678 // Activate the tree. The tiles are moved to the active tree.
4825 ActivateTree(); 4679 ActivateTree();
4826 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); 4680 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size());
4827 EXPECT_EQ(tile00, active_tiling->TileAt(0, 0)); 4681 EXPECT_EQ(tile00, active_tiling->TileAt(0, 0));
4828 EXPECT_EQ(tile11, active_tiling->TileAt(1, 1)); 4682 EXPECT_EQ(tile11, active_tiling->TileAt(1, 1));
4829 EXPECT_EQ(tile22, active_tiling->TileAt(2, 2)); 4683 EXPECT_EQ(tile22, active_tiling->TileAt(2, 2));
4830 } 4684 }
4831 4685
4832 TEST_F(PictureLayerImplTest, ScrollPastLiveTilesRectAndBack) { 4686 TEST_F(PictureLayerImplTest, ScrollPastLiveTilesRectAndBack) {
4833 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 4687 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
4834 4688
4835 gfx::Size tile_size(102, 102); 4689 gfx::Size tile_size(102, 102);
4836 gfx::Size layer_bounds(100, 100); 4690 gfx::Size layer_bounds(100, 100);
4837 gfx::Size viewport_size(100, 100); 4691 gfx::Size viewport_size(100, 100);
4838 4692
4839 host_impl_.SetViewportSize(viewport_size); 4693 host_impl_.SetViewportSize(viewport_size);
4840 host_impl_.SetDeviceScaleFactor(1.f); 4694 host_impl_.SetDeviceScaleFactor(1.f);
4841 4695
4842 scoped_refptr<FakePicturePileImpl> pending_pile = 4696 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
4843 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 4697 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
4844 scoped_refptr<FakePicturePileImpl> active_pile = 4698 scoped_refptr<FakeDisplayListRasterSource> active_raster_source =
4845 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 4699 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
4846 4700
4847 SetupPendingTreeWithFixedTileSize(active_pile, tile_size, Region()); 4701 SetupPendingTreeWithFixedTileSize(active_raster_source, tile_size, Region());
4848 4702
4849 ActivateTree(); 4703 ActivateTree();
4850 EXPECT_TRUE(active_layer_->HighResTiling()->has_tiles()); 4704 EXPECT_TRUE(active_layer_->HighResTiling()->has_tiles());
4851 4705
4852 host_impl_.SetExternalDrawConstraints( 4706 host_impl_.SetExternalDrawConstraints(
4853 gfx::Transform(), // transform 4707 gfx::Transform(), // transform
4854 gfx::Rect(), // clip 4708 gfx::Rect(), // clip
4855 gfx::Rect(), // viewport 4709 gfx::Rect(), // viewport
4856 gfx::Rect(0, 5000, 100, 100), // viewport_rect_for_tile_priority 4710 gfx::Rect(0, 5000, 100, 100), // viewport_rect_for_tile_priority
4857 gfx::Transform(), // transform_for_tile_priority 4711 gfx::Transform(), // transform_for_tile_priority
4858 false); 4712 false);
4859 4713
4860 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, gfx::Rect()); 4714 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size,
4715 gfx::Rect());
4861 4716
4862 EXPECT_FALSE(pending_layer_->HighResTiling()->has_tiles()); 4717 EXPECT_FALSE(pending_layer_->HighResTiling()->has_tiles());
4863 EXPECT_TRUE(pending_layer_->HighResTiling()->live_tiles_rect().IsEmpty()); 4718 EXPECT_TRUE(pending_layer_->HighResTiling()->live_tiles_rect().IsEmpty());
4864 ActivateTree(); 4719 ActivateTree();
4865 EXPECT_FALSE(active_layer_->HighResTiling()->has_tiles()); 4720 EXPECT_FALSE(active_layer_->HighResTiling()->has_tiles());
4866 EXPECT_TRUE(active_layer_->HighResTiling()->live_tiles_rect().IsEmpty()); 4721 EXPECT_TRUE(active_layer_->HighResTiling()->live_tiles_rect().IsEmpty());
4867 4722
4868 host_impl_.SetExternalDrawConstraints( 4723 host_impl_.SetExternalDrawConstraints(
4869 gfx::Transform(), // transform 4724 gfx::Transform(), // transform
4870 gfx::Rect(), // clip 4725 gfx::Rect(), // clip
4871 gfx::Rect(), // viewport 4726 gfx::Rect(), // viewport
4872 gfx::Rect(0, 110, 100, 100), // viewport_rect_for_tile_priority 4727 gfx::Rect(0, 110, 100, 100), // viewport_rect_for_tile_priority
4873 gfx::Transform(), // transform_for_tile_priority 4728 gfx::Transform(), // transform_for_tile_priority
4874 false); 4729 false);
4875 4730
4876 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, gfx::Rect()); 4731 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size,
4732 gfx::Rect());
4877 4733
4878 EXPECT_FALSE(pending_layer_->HighResTiling()->has_tiles()); 4734 EXPECT_FALSE(pending_layer_->HighResTiling()->has_tiles());
4879 EXPECT_FALSE(pending_layer_->HighResTiling()->live_tiles_rect().IsEmpty()); 4735 EXPECT_FALSE(pending_layer_->HighResTiling()->live_tiles_rect().IsEmpty());
4880 ActivateTree(); 4736 ActivateTree();
4881 EXPECT_TRUE(active_layer_->HighResTiling()->has_tiles()); 4737 EXPECT_TRUE(active_layer_->HighResTiling()->has_tiles());
4882 EXPECT_FALSE(active_layer_->HighResTiling()->live_tiles_rect().IsEmpty()); 4738 EXPECT_FALSE(active_layer_->HighResTiling()->live_tiles_rect().IsEmpty());
4883 } 4739 }
4884 4740
4885 TEST_F(PictureLayerImplTest, ScrollPropagatesToPending) { 4741 TEST_F(PictureLayerImplTest, ScrollPropagatesToPending) {
4886 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 4742 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
4887 4743
4888 gfx::Size tile_size(102, 102);
4889 gfx::Size layer_bounds(1000, 1000); 4744 gfx::Size layer_bounds(1000, 1000);
4890 gfx::Size viewport_size(100, 100); 4745 gfx::Size viewport_size(100, 100);
4891 4746
4892 host_impl_.SetViewportSize(viewport_size); 4747 host_impl_.SetViewportSize(viewport_size);
4893 host_impl_.SetDeviceScaleFactor(1.f); 4748 host_impl_.SetDeviceScaleFactor(1.f);
4894 4749
4895 scoped_refptr<FakePicturePileImpl> pending_pile = 4750 SetupDefaultTrees(layer_bounds);
4896 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
4897 scoped_refptr<FakePicturePileImpl> active_pile =
4898 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
4899
4900 SetupTrees(pending_pile, active_pile);
4901 4751
4902 active_layer_->SetCurrentScrollOffset(gfx::ScrollOffset(0.0, 50.0)); 4752 active_layer_->SetCurrentScrollOffset(gfx::ScrollOffset(0.0, 50.0));
4903 host_impl_.active_tree()->UpdateDrawProperties(false); 4753 host_impl_.active_tree()->UpdateDrawProperties(false);
4904 EXPECT_EQ("0,50 100x100", active_layer_->HighResTiling() 4754 EXPECT_EQ("0,50 100x100", active_layer_->HighResTiling()
4905 ->GetCurrentVisibleRectForTesting() 4755 ->GetCurrentVisibleRectForTesting()
4906 .ToString()); 4756 .ToString());
4907 4757
4908 EXPECT_EQ("0,0 100x100", pending_layer_->HighResTiling() 4758 EXPECT_EQ("0,0 100x100", pending_layer_->HighResTiling()
4909 ->GetCurrentVisibleRectForTesting() 4759 ->GetCurrentVisibleRectForTesting()
4910 .ToString()); 4760 .ToString());
4911 host_impl_.pending_tree()->UpdateDrawProperties(false); 4761 host_impl_.pending_tree()->UpdateDrawProperties(false);
4912 EXPECT_EQ("0,50 100x100", pending_layer_->HighResTiling() 4762 EXPECT_EQ("0,50 100x100", pending_layer_->HighResTiling()
4913 ->GetCurrentVisibleRectForTesting() 4763 ->GetCurrentVisibleRectForTesting()
4914 .ToString()); 4764 .ToString());
4915 } 4765 }
4916 4766
4917 TEST_F(PictureLayerImplTest, UpdateLCDInvalidatesPendingTree) { 4767 TEST_F(PictureLayerImplTest, UpdateLCDInvalidatesPendingTree) {
4918 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); 4768 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
4919 4769
4920 gfx::Size tile_size(102, 102); 4770 gfx::Size tile_size(102, 102);
4921 gfx::Size layer_bounds(100, 100); 4771 gfx::Size layer_bounds(100, 100);
4922 gfx::Size viewport_size(100, 100); 4772 gfx::Size viewport_size(100, 100);
4923 4773
4924 host_impl_.SetViewportSize(viewport_size); 4774 host_impl_.SetViewportSize(viewport_size);
4925 host_impl_.SetDeviceScaleFactor(1.f); 4775 host_impl_.SetDeviceScaleFactor(1.f);
4926 4776
4927 scoped_refptr<FakePicturePileImpl> pending_pile = 4777 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
4928 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 4778 FakeDisplayListRasterSource::CreateFilledLCD(layer_bounds);
4929 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); 4779 SetupPendingTreeWithFixedTileSize(pending_raster_source, tile_size, Region());
4930 4780
4931 EXPECT_TRUE(pending_layer_->RasterSourceUsesLCDText()); 4781 EXPECT_TRUE(pending_layer_->RasterSourceUsesLCDText());
4932 EXPECT_TRUE(pending_layer_->HighResTiling()->has_tiles()); 4782 EXPECT_TRUE(pending_layer_->HighResTiling()->has_tiles());
4933 std::vector<Tile*> tiles = 4783 std::vector<Tile*> tiles =
4934 pending_layer_->HighResTiling()->AllTilesForTesting(); 4784 pending_layer_->HighResTiling()->AllTilesForTesting();
4935 auto prioritized_tiles = pending_layer_->HighResTiling() 4785 auto prioritized_tiles = pending_layer_->HighResTiling()
4936 ->UpdateAndGetAllPrioritizedTilesForTesting(); 4786 ->UpdateAndGetAllPrioritizedTilesForTesting();
4937 4787
4938 for (Tile* tile : tiles) 4788 for (Tile* tile : tiles)
4939 EXPECT_EQ(pending_layer_->raster_source(), 4789 EXPECT_EQ(pending_layer_->raster_source(),
4940 prioritized_tiles[tile].raster_source()); 4790 prioritized_tiles[tile].raster_source());
4941 4791
4942 pending_layer_->draw_properties().can_use_lcd_text = false; 4792 pending_layer_->draw_properties().can_use_lcd_text = false;
4943 pending_layer_->UpdateCanUseLCDTextAfterCommit(); 4793 pending_layer_->UpdateCanUseLCDTextAfterCommit();
4944 4794
4945 EXPECT_FALSE(pending_layer_->RasterSourceUsesLCDText()); 4795 EXPECT_FALSE(pending_layer_->RasterSourceUsesLCDText());
4946 EXPECT_NE(pending_pile.get(), pending_layer_->raster_source()); 4796 EXPECT_NE(pending_raster_source.get(), pending_layer_->raster_source());
4947 EXPECT_TRUE(pending_layer_->HighResTiling()->has_tiles()); 4797 EXPECT_TRUE(pending_layer_->HighResTiling()->has_tiles());
4948 tiles = pending_layer_->HighResTiling()->AllTilesForTesting(); 4798 tiles = pending_layer_->HighResTiling()->AllTilesForTesting();
4949 prioritized_tiles = pending_layer_->HighResTiling() 4799 prioritized_tiles = pending_layer_->HighResTiling()
4950 ->UpdateAndGetAllPrioritizedTilesForTesting(); 4800 ->UpdateAndGetAllPrioritizedTilesForTesting();
4951 for (Tile* tile : tiles) 4801 for (Tile* tile : tiles)
4952 EXPECT_EQ(pending_layer_->raster_source(), 4802 EXPECT_EQ(pending_layer_->raster_source(),
4953 prioritized_tiles[tile].raster_source()); 4803 prioritized_tiles[tile].raster_source());
4954 } 4804 }
4955 4805
4956 TEST_F(PictureLayerImplTest, TilingAllTilesDone) { 4806 TEST_F(PictureLayerImplTest, TilingAllTilesDone) {
4957 gfx::Size tile_size = host_impl_.settings().default_tile_size; 4807 gfx::Size tile_size = host_impl_.settings().default_tile_size;
4958 size_t tile_mem = 4 * tile_size.width() * tile_size.height(); 4808 size_t tile_mem = 4 * tile_size.width() * tile_size.height();
4959 gfx::Size layer_bounds(1000, 1000); 4809 gfx::Size layer_bounds(1000, 1000);
4960 4810
4961 // Create tiles. 4811 // Create tiles.
4962 scoped_refptr<FakePicturePileImpl> pending_pile = 4812 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source =
4963 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 4813 FakeDisplayListRasterSource::CreateFilled(layer_bounds);
4964 SetupPendingTree(pending_pile); 4814 SetupPendingTree(pending_raster_source);
4965 pending_layer_->SetBounds(layer_bounds); 4815 pending_layer_->SetBounds(layer_bounds);
4966 ActivateTree(); 4816 ActivateTree();
4967 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( 4817 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(
4968 active_layer_->HighResTiling()->AllTilesForTesting()); 4818 active_layer_->HighResTiling()->AllTilesForTesting());
4969 host_impl_.SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); 4819 host_impl_.SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES);
4970 4820
4971 EXPECT_FALSE(active_layer_->HighResTiling()->all_tiles_done()); 4821 EXPECT_FALSE(active_layer_->HighResTiling()->all_tiles_done());
4972 4822
4973 { 4823 {
4974 // Set a memory policy that will fit all tiles. 4824 // Set a memory policy that will fit all tiles.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
5063 // 50% of viewport in height. 4913 // 50% of viewport in height.
5064 result = layer->CalculateTileSize(gfx::Size(447, 400)); 4914 result = layer->CalculateTileSize(gfx::Size(447, 400));
5065 EXPECT_EQ(result.width(), 448); 4915 EXPECT_EQ(result.width(), 448);
5066 EXPECT_EQ(result.height(), 448); 4916 EXPECT_EQ(result.height(), 448);
5067 result = layer->CalculateTileSize(gfx::Size(500, 499)); 4917 result = layer->CalculateTileSize(gfx::Size(500, 499));
5068 EXPECT_EQ(result.width(), 512); 4918 EXPECT_EQ(result.width(), 512);
5069 EXPECT_EQ(result.height(), 500 + 2); 4919 EXPECT_EQ(result.height(), 500 + 2);
5070 } 4920 }
5071 4921
5072 TEST_F(NoLowResPictureLayerImplTest, LowResWasHighResCollision) { 4922 TEST_F(NoLowResPictureLayerImplTest, LowResWasHighResCollision) {
5073 gfx::Size tile_size(400, 400);
5074 gfx::Size layer_bounds(1300, 1900); 4923 gfx::Size layer_bounds(1300, 1900);
5075 4924
5076 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; 4925 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
5077 4926 SetupDefaultTrees(layer_bounds);
5078 scoped_refptr<FakePicturePileImpl> pending_pile =
5079 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
5080 scoped_refptr<FakePicturePileImpl> active_pile =
5081 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
5082
5083 // Set up the high and low res tilings before pinch zoom.
5084 SetupTrees(pending_pile, active_pile);
5085 ResetTilingsAndRasterScales(); 4927 ResetTilingsAndRasterScales();
5086 4928
5087 float page_scale = 2.f; 4929 float page_scale = 2.f;
5088 SetContentsScaleOnBothLayers(page_scale, 1.0f, page_scale, 1.0f, 0.f, false); 4930 SetContentsScaleOnBothLayers(page_scale, 1.0f, page_scale, 1.0f, 0.f, false);
5089 EXPECT_BOTH_EQ(num_tilings(), 1u); 4931 EXPECT_BOTH_EQ(num_tilings(), 1u);
5090 EXPECT_BOTH_EQ(tilings()->tiling_at(0)->contents_scale(), page_scale); 4932 EXPECT_BOTH_EQ(tilings()->tiling_at(0)->contents_scale(), page_scale);
5091 4933
5092 host_impl_.PinchGestureBegin(); 4934 host_impl_.PinchGestureBegin();
5093 4935
5094 // Zoom out to exactly the low res factor so that the previous high res 4936 // Zoom out to exactly the low res factor so that the previous high res
5095 // would be equal to the current low res (if it were possible to have one). 4937 // would be equal to the current low res (if it were possible to have one).
5096 float zoomed = page_scale / low_res_factor; 4938 float zoomed = page_scale / low_res_factor;
5097 SetContentsScaleOnBothLayers(zoomed, 1.0f, zoomed, 1.0f, 0.f, false); 4939 SetContentsScaleOnBothLayers(zoomed, 1.0f, zoomed, 1.0f, 0.f, false);
5098 EXPECT_EQ(1u, pending_layer_->num_tilings()); 4940 EXPECT_EQ(1u, pending_layer_->num_tilings());
5099 EXPECT_EQ(zoomed, pending_layer_->tilings()->tiling_at(0)->contents_scale()); 4941 EXPECT_EQ(zoomed, pending_layer_->tilings()->tiling_at(0)->contents_scale());
5100 } 4942 }
5101 4943
5102 TEST_F(PictureLayerImplTest, HighResWasLowResCollision) { 4944 TEST_F(PictureLayerImplTest, HighResWasLowResCollision) {
5103 gfx::Size tile_size(400, 400);
5104 gfx::Size layer_bounds(1300, 1900); 4945 gfx::Size layer_bounds(1300, 1900);
5105 4946
5106 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; 4947 float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
5107 4948
5108 scoped_refptr<FakePicturePileImpl> pending_pile = 4949 SetupDefaultTrees(layer_bounds);
5109 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
5110 scoped_refptr<FakePicturePileImpl> active_pile =
5111 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
5112
5113 // Set up the high and low res tilings before pinch zoom.
5114 SetupTrees(pending_pile, active_pile);
5115 ResetTilingsAndRasterScales(); 4950 ResetTilingsAndRasterScales();
5116 4951
5117 float page_scale = 4.f; 4952 float page_scale = 4.f;
5118 float low_res = page_scale * low_res_factor; 4953 float low_res = page_scale * low_res_factor;
5119 float extra_low_res = low_res * low_res_factor; 4954 float extra_low_res = low_res * low_res_factor;
5120 SetupDrawPropertiesAndUpdateTiles(active_layer_, page_scale, 1.0f, page_scale, 4955 SetupDrawPropertiesAndUpdateTiles(active_layer_, page_scale, 1.0f, page_scale,
5121 1.0f, 0.f, false); 4956 1.0f, 0.f, false);
5122 EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); 4957 EXPECT_EQ(2u, active_layer_->tilings()->num_tilings());
5123 EXPECT_EQ(page_scale, 4958 EXPECT_EQ(page_scale,
5124 active_layer_->tilings()->tiling_at(0)->contents_scale()); 4959 active_layer_->tilings()->tiling_at(0)->contents_scale());
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
5163 // New low res tiling. 4998 // New low res tiling.
5164 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles()); 4999 EXPECT_TRUE(tilings->tiling_at(2)->may_contain_low_resolution_tiles());
5165 5000
5166 // This tiling will be high res now, it won't contain low res content since it 5001 // This tiling will be high res now, it won't contain low res content since it
5167 // was all destroyed. 5002 // was all destroyed.
5168 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles()); 5003 EXPECT_FALSE(tilings->tiling_at(1)->may_contain_low_resolution_tiles());
5169 } 5004 }
5170 5005
5171 } // namespace 5006 } // namespace
5172 } // namespace cc 5007 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698