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

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

Issue 2948033005: cc: Drop locked decodes from checker image tracker on cache switch. (Closed)
Patch Set: tested Created 3 years, 6 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/tiles/tile_manager.cc ('k') | 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 <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 2341 matching lines...) Expand 10 before | Expand all | Expand 10 after
2352 return base::MakeUnique<SynchronousTaskGraphRunner>(); 2352 return base::MakeUnique<SynchronousTaskGraphRunner>();
2353 } 2353 }
2354 2354
2355 void FlushDecodeTasks() { 2355 void FlushDecodeTasks() {
2356 while (task_runner_->HasPendingTask()) { 2356 while (task_runner_->HasPendingTask()) {
2357 task_runner_->RunUntilIdle(); 2357 task_runner_->RunUntilIdle();
2358 base::RunLoop().RunUntilIdle(); 2358 base::RunLoop().RunUntilIdle();
2359 } 2359 }
2360 } 2360 }
2361 2361
2362 void CleanUpTileManager() {
2363 task_runner_->set_run_tasks_synchronously(true);
2364 host_impl()->tile_manager()->FinishTasksAndCleanUp();
2365 task_runner_->set_run_tasks_synchronously(false);
2366 }
2367
2362 private: 2368 private:
2363 scoped_refptr<SynchronousSimpleTaskRunner> task_runner_; 2369 scoped_refptr<SynchronousSimpleTaskRunner> task_runner_;
2364 }; 2370 };
2365 2371
2366 TEST_F(CheckerImagingTileManagerTest, 2372 TEST_F(CheckerImagingTileManagerTest,
2367 NoImageDecodeDependencyForCheckeredTiles) { 2373 NoImageDecodeDependencyForCheckeredTiles) {
2368 const gfx::Size layer_bounds(512, 512); 2374 const gfx::Size layer_bounds(512, 512);
2369 SetupDefaultTrees(layer_bounds); 2375 SetupDefaultTrees(layer_bounds);
2370 2376
2371 std::unique_ptr<FakeRecordingSource> recording_source = 2377 std::unique_ptr<FakeRecordingSource> recording_source =
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
2557 gfx::Rect(layer_bounds), // Visible rect. 2563 gfx::Rect(layer_bounds), // Visible rect.
2558 gfx::Rect(layer_bounds), // Skewport rect. 2564 gfx::Rect(layer_bounds), // Skewport rect.
2559 gfx::Rect(layer_bounds), // Soon rect. 2565 gfx::Rect(layer_bounds), // Soon rect.
2560 gfx::Rect(layer_bounds)); // Eventually rect. 2566 gfx::Rect(layer_bounds)); // Eventually rect.
2561 host_impl()->SetVisible(false); 2567 host_impl()->SetVisible(false);
2562 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); 2568 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state());
2563 FlushDecodeTasks(); 2569 FlushDecodeTasks();
2564 EXPECT_FALSE(host_impl()->client()->did_request_impl_side_invalidation()); 2570 EXPECT_FALSE(host_impl()->client()->did_request_impl_side_invalidation());
2565 } 2571 }
2566 2572
2573 TEST_F(CheckerImagingTileManagerTest,
2574 TileManagerCleanupClearsCheckerImagedDecodes) {
2575 const gfx::Size layer_bounds(512, 512);
2576 SetupDefaultTrees(layer_bounds);
2577
2578 std::unique_ptr<FakeRecordingSource> recording_source =
2579 FakeRecordingSource::CreateFilledRecordingSource(layer_bounds);
2580 recording_source->set_fill_with_nonsolid_color(true);
2581 sk_sp<SkImage> image = CreateDiscardableImage(gfx::Size(512, 512));
2582 recording_source->add_draw_image(image, gfx::Point(0, 0));
2583 recording_source->Rerecord();
2584 scoped_refptr<RasterSource> raster_source =
2585 RasterSource::CreateFromRecordingSource(recording_source.get(), false);
2586
2587 std::unique_ptr<PictureLayerImpl> layer_impl = PictureLayerImpl::Create(
2588 host_impl()->active_tree(), 1, Layer::LayerMaskType::NOT_MASK);
2589 layer_impl->set_contributes_to_drawn_render_surface(true);
2590 PictureLayerTilingSet* tiling_set = layer_impl->picture_layer_tiling_set();
2591
2592 PictureLayerTiling* tiling =
2593 tiling_set->AddTiling(gfx::AxisTransform2d(), raster_source);
2594 tiling->set_resolution(HIGH_RESOLUTION);
2595 tiling->CreateAllTilesForTesting();
2596 tiling->SetTilePriorityRectsForTesting(
2597 gfx::Rect(layer_bounds), // Visible rect.
2598 gfx::Rect(layer_bounds), // Skewport rect.
2599 gfx::Rect(layer_bounds), // Soon rect.
2600 gfx::Rect(layer_bounds)); // Eventually rect.
2601
2602 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state());
2603 FlushDecodeTasks();
2604 EXPECT_TRUE(host_impl()
2605 ->tile_manager()
2606 ->checker_image_tracker()
2607 .has_locked_decodes_for_testing());
2608 CleanUpTileManager();
2609 EXPECT_FALSE(host_impl()
2610 ->tile_manager()
2611 ->checker_image_tracker()
2612 .has_locked_decodes_for_testing());
2613 EXPECT_TRUE(
2614 host_impl()->tile_manager()->TakeImagesToInvalidateOnSyncTree().empty());
2615 }
2616
2567 class CheckerImagingTileManagerMemoryTest 2617 class CheckerImagingTileManagerMemoryTest
2568 : public CheckerImagingTileManagerTest { 2618 : public CheckerImagingTileManagerTest {
2569 public: 2619 public:
2570 std::unique_ptr<FakeLayerTreeHostImpl> CreateHostImpl( 2620 std::unique_ptr<FakeLayerTreeHostImpl> CreateHostImpl(
2571 const LayerTreeSettings& settings, 2621 const LayerTreeSettings& settings,
2572 TaskRunnerProvider* task_runner_provider, 2622 TaskRunnerProvider* task_runner_provider,
2573 TaskGraphRunner* task_graph_runner) override { 2623 TaskGraphRunner* task_graph_runner) override {
2574 LayerTreeSettings new_settings = settings; 2624 LayerTreeSettings new_settings = settings;
2575 new_settings.gpu_memory_policy.num_resources_limit = 4; 2625 new_settings.gpu_memory_policy.num_resources_limit = 4;
2576 return CheckerImagingTileManagerTest::CreateHostImpl( 2626 return CheckerImagingTileManagerTest::CreateHostImpl(
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
2648 EXPECT_TRUE(tile); 2698 EXPECT_TRUE(tile);
2649 else 2699 else
2650 EXPECT_FALSE(tile); 2700 EXPECT_FALSE(tile);
2651 } 2701 }
2652 } 2702 }
2653 host_impl()->client()->reset_did_request_impl_side_invalidation(); 2703 host_impl()->client()->reset_did_request_impl_side_invalidation();
2654 } 2704 }
2655 2705
2656 } // namespace 2706 } // namespace
2657 } // namespace cc 2707 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/tile_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698