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

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

Issue 670183003: Update from chromium 62675d9fb31fb8cedc40f68e78e8445a74f362e7 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/resources/tile_manager.cc ('k') | cc/resources/tile_priority.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/resources/eviction_tile_priority_queue.h" 5 #include "cc/resources/eviction_tile_priority_queue.h"
6 #include "cc/resources/raster_tile_priority_queue.h" 6 #include "cc/resources/raster_tile_priority_queue.h"
7 #include "cc/resources/tile.h" 7 #include "cc/resources/tile.h"
8 #include "cc/resources/tile_priority.h" 8 #include "cc/resources/tile_priority.h"
9 #include "cc/test/fake_impl_proxy.h" 9 #include "cc/test/fake_impl_proxy.h"
10 #include "cc/test/fake_layer_tree_host_impl.h" 10 #include "cc/test/fake_layer_tree_host_impl.h"
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 queue.Pop(); 315 queue.Pop();
316 } 316 }
317 317
318 EXPECT_EQ(tile_count, new_content_tiles.size()); 318 EXPECT_EQ(tile_count, new_content_tiles.size());
319 EXPECT_EQ(high_res_tiles, new_content_tiles); 319 EXPECT_EQ(high_res_tiles, new_content_tiles);
320 // Since we don't guarantee increasing distance due to spiral iterator, we 320 // Since we don't guarantee increasing distance due to spiral iterator, we
321 // should check that we're _mostly_ right. 321 // should check that we're _mostly_ right.
322 EXPECT_GE(increasing_distance_tiles, 3 * tile_count / 4); 322 EXPECT_GE(increasing_distance_tiles, 3 * tile_count / 4);
323 } 323 }
324 324
325 TEST_F(TileManagerTilePriorityQueueTest, ActivationComesBeforeEventually) {
326 SetupDefaultTrees(gfx::Size(1000, 1000));
327
328 active_layer_->CreateDefaultTilingsAndTiles();
329 pending_layer_->CreateDefaultTilingsAndTiles();
330
331 // Create a pending child layer.
332 gfx::Size tile_size(256, 256);
333 scoped_refptr<FakePicturePileImpl> pending_pile =
334 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1000, 1000));
335 scoped_ptr<FakePictureLayerImpl> pending_child =
336 FakePictureLayerImpl::CreateWithPile(
337 host_impl_.pending_tree(), id_ + 1, pending_pile);
338 pending_layer_->AddChild(pending_child.Pass());
339 FakePictureLayerImpl* pending_child_raw = static_cast<FakePictureLayerImpl*>(
340 host_impl_.pending_tree()->LayerById(id_ + 1));
341 ASSERT_TRUE(pending_child_raw);
342
343 pending_child_raw->SetDrawsContent(true);
344 pending_child_raw->DoPostCommitInitializationIfNeeded();
345 pending_child_raw->CreateDefaultTilingsAndTiles();
346 ASSERT_TRUE(pending_child_raw->HighResTiling());
347
348 // Set a small viewport, so we have soon and eventually tiles.
349 gfx::Rect viewport(200, 200);
350 active_layer_->draw_properties().visible_content_rect = viewport;
351 active_layer_->UpdateTiles(Occlusion(), false);
352 pending_layer_->draw_properties().visible_content_rect = viewport;
353 pending_layer_->UpdateTiles(Occlusion(), false);
354 pending_child_raw->draw_properties().visible_content_rect = viewport;
355 pending_child_raw->UpdateTiles(Occlusion(), false);
356
357 RasterTilePriorityQueue queue;
358 host_impl_.SetRequiresHighResToDraw();
359 host_impl_.BuildRasterQueue(&queue, SMOOTHNESS_TAKES_PRIORITY);
360 EXPECT_FALSE(queue.IsEmpty());
361
362 // Get all the tiles that are NOW or SOON and make sure they are ready to
363 // draw.
364 std::vector<Tile*> all_tiles;
365 while (!queue.IsEmpty()) {
366 Tile* tile = queue.Top();
367 if (tile->combined_priority().priority_bin >= TilePriority::EVENTUALLY)
368 break;
369
370 all_tiles.push_back(tile);
371 queue.Pop();
372 }
373
374 tile_manager()->InitializeTilesWithResourcesForTesting(
375 std::vector<Tile*>(all_tiles.begin(), all_tiles.end()));
376
377 // Ensure we can activate.
378 EXPECT_TRUE(pending_layer_->AllTilesRequiredForActivationAreReadyToDraw());
379 EXPECT_TRUE(pending_child_raw->AllTilesRequiredForActivationAreReadyToDraw());
380 }
381
325 TEST_F(TileManagerTilePriorityQueueTest, EvictionTilePriorityQueue) { 382 TEST_F(TileManagerTilePriorityQueueTest, EvictionTilePriorityQueue) {
326 SetupDefaultTrees(gfx::Size(1000, 1000)); 383 SetupDefaultTrees(gfx::Size(1000, 1000));
327 384
328 active_layer_->CreateDefaultTilingsAndTiles(); 385 active_layer_->CreateDefaultTilingsAndTiles();
329 pending_layer_->CreateDefaultTilingsAndTiles(); 386 pending_layer_->CreateDefaultTilingsAndTiles();
330 387
331 EvictionTilePriorityQueue empty_queue; 388 EvictionTilePriorityQueue empty_queue;
332 host_impl_.BuildEvictionQueue(&empty_queue, SAME_PRIORITY_FOR_BOTH_TREES); 389 host_impl_.BuildEvictionQueue(&empty_queue, SAME_PRIORITY_FOR_BOTH_TREES);
333 EXPECT_TRUE(empty_queue.IsEmpty()); 390 EXPECT_TRUE(empty_queue.IsEmpty());
334 std::set<Tile*> all_tiles; 391 std::set<Tile*> all_tiles;
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 all_tiles.insert(queue.Top()); 749 all_tiles.insert(queue.Top());
693 ++tile_count; 750 ++tile_count;
694 queue.Pop(); 751 queue.Pop();
695 } 752 }
696 EXPECT_EQ(tile_count, all_tiles.size()); 753 EXPECT_EQ(tile_count, all_tiles.size());
697 EXPECT_EQ(16u, tile_count); 754 EXPECT_EQ(16u, tile_count);
698 } 755 }
699 756
700 } // namespace 757 } // namespace
701 } // namespace cc 758 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/tile_manager.cc ('k') | cc/resources/tile_priority.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698