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

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

Issue 1814643002: cc: Add test for the fix in https://codereview.chromium.org/1808043002/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 | « no previous file | no next file » | 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/thread_task_runner_handle.h" 9 #include "base/thread_task_runner_handle.h"
10 #include "cc/playback/display_list_raster_source.h" 10 #include "cc/playback/display_list_raster_source.h"
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 all_actual_tiles.insert(queue->Top().tile()); 489 all_actual_tiles.insert(queue->Top().tile());
490 ++tile_count; 490 ++tile_count;
491 queue->Pop(); 491 queue->Pop();
492 } 492 }
493 493
494 EXPECT_EQ(tile_count, all_actual_tiles.size()); 494 EXPECT_EQ(tile_count, all_actual_tiles.size());
495 EXPECT_EQ(all_expected_tiles.size(), all_actual_tiles.size()); 495 EXPECT_EQ(all_expected_tiles.size(), all_actual_tiles.size());
496 EXPECT_EQ(all_expected_tiles, all_actual_tiles); 496 EXPECT_EQ(all_expected_tiles, all_actual_tiles);
497 } 497 }
498 498
499 TEST_F(TileManagerTilePriorityQueueTest,
500 RasterTilePriorityQueueHighLowTilings) {
501 const gfx::Size layer_bounds(1000, 1000);
502 const gfx::Size viewport(800, 800);
503 host_impl_.SetViewportSize(viewport);
504 SetupDefaultTrees(layer_bounds);
505
506 pending_layer_->tilings()->AddTiling(1.5f, pending_layer_->raster_source());
507 active_layer_->tilings()->AddTiling(1.5f, active_layer_->raster_source());
508 pending_layer_->tilings()->AddTiling(1.7f, pending_layer_->raster_source());
509 active_layer_->tilings()->AddTiling(1.7f, active_layer_->raster_source());
510
511 pending_layer_->tilings()->UpdateTilePriorities(gfx::Rect(viewport), 1.f, 5.0,
512 Occlusion(), true);
513 active_layer_->tilings()->UpdateTilePriorities(gfx::Rect(viewport), 1.f, 5.0,
514 Occlusion(), true);
515
516 std::set<Tile*> all_expected_tiles;
517 for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) {
518 PictureLayerTiling* tiling = pending_layer_->tilings()->tiling_at(i);
519 if (tiling->contents_scale() == 1.f) {
520 tiling->set_resolution(HIGH_RESOLUTION);
521 const auto& all_tiles = tiling->AllTilesForTesting();
522 all_expected_tiles.insert(all_tiles.begin(), all_tiles.end());
523 } else {
524 tiling->set_resolution(NON_IDEAL_RESOLUTION);
525 }
526 }
527
528 for (size_t i = 0; i < active_layer_->num_tilings(); ++i) {
529 PictureLayerTiling* tiling = active_layer_->tilings()->tiling_at(i);
530 if (tiling->contents_scale() == 1.5f) {
531 tiling->set_resolution(HIGH_RESOLUTION);
532 const auto& all_tiles = tiling->AllTilesForTesting();
533 all_expected_tiles.insert(all_tiles.begin(), all_tiles.end());
534 } else {
535 tiling->set_resolution(LOW_RESOLUTION);
536 // Low res tilings with a high res pending twin have to be processed
537 // because of possible activation tiles.
538 if (tiling->contents_scale() == 1.f) {
539 tiling->UpdateAndGetAllPrioritizedTilesForTesting();
540 const auto& all_tiles = tiling->AllTilesForTesting();
541 for (auto* tile : all_tiles)
542 EXPECT_TRUE(tile->required_for_activation());
543 all_expected_tiles.insert(all_tiles.begin(), all_tiles.end());
544 }
545 }
546 }
547
548 scoped_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue(
549 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL));
550 EXPECT_FALSE(queue->IsEmpty());
551
552 size_t tile_count = 0;
553 std::set<Tile*> all_actual_tiles;
554 while (!queue->IsEmpty()) {
555 EXPECT_TRUE(queue->Top().tile());
556 all_actual_tiles.insert(queue->Top().tile());
557 ++tile_count;
558 queue->Pop();
559 }
560
561 EXPECT_EQ(tile_count, all_actual_tiles.size());
562 EXPECT_EQ(all_expected_tiles.size(), all_actual_tiles.size());
563 EXPECT_EQ(all_expected_tiles, all_actual_tiles);
564 }
565
499 TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueueInvalidation) { 566 TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueueInvalidation) {
500 const gfx::Size layer_bounds(1000, 1000); 567 const gfx::Size layer_bounds(1000, 1000);
501 host_impl_.SetViewportSize(gfx::Size(500, 500)); 568 host_impl_.SetViewportSize(gfx::Size(500, 500));
502 SetupDefaultTrees(layer_bounds); 569 SetupDefaultTrees(layer_bounds);
503 570
504 // Use a tile's content rect as an invalidation. We should inset it a bit to 571 // Use a tile's content rect as an invalidation. We should inset it a bit to
505 // ensure that border math doesn't invalidate neighbouring tiles. 572 // ensure that border math doesn't invalidate neighbouring tiles.
506 gfx::Rect invalidation = 573 gfx::Rect invalidation =
507 active_layer_->HighResTiling()->TileAt(1, 0)->content_rect(); 574 active_layer_->HighResTiling()->TileAt(1, 0)->content_rect();
508 invalidation.Inset(2, 2); 575 invalidation.Inset(2, 2);
(...skipping 1444 matching lines...) Expand 10 before | Expand all | Expand 10 after
1953 2020
1954 // Ensures that the tile manager does not attempt to reuse tiles when partial 2021 // Ensures that the tile manager does not attempt to reuse tiles when partial
1955 // raster is disabled. 2022 // raster is disabled.
1956 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) { 2023 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) {
1957 RunPartialRasterCheck(std::move(host_impl_), 2024 RunPartialRasterCheck(std::move(host_impl_),
1958 false /* partial_raster_enabled */); 2025 false /* partial_raster_enabled */);
1959 } 2026 }
1960 2027
1961 } // namespace 2028 } // namespace
1962 } // namespace cc 2029 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698