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

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

Issue 2822493003: cc: Create raster tasks in AssignGpuMemoryToTiles. (Closed)
Patch Set: disabled-by-default Created 3 years, 8 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/tiles/tile_manager.h" 5 #include "cc/tiles/tile_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 all_tiles_that_need_to_be_rasterized_are_scheduled_ = true; 632 all_tiles_that_need_to_be_rasterized_are_scheduled_ = true;
633 bool had_enough_memory_to_schedule_tiles_needed_now = true; 633 bool had_enough_memory_to_schedule_tiles_needed_now = true;
634 634
635 MemoryUsage hard_memory_limit(global_state_.hard_memory_limit_in_bytes, 635 MemoryUsage hard_memory_limit(global_state_.hard_memory_limit_in_bytes,
636 global_state_.num_resources_limit); 636 global_state_.num_resources_limit);
637 MemoryUsage soft_memory_limit(global_state_.soft_memory_limit_in_bytes, 637 MemoryUsage soft_memory_limit(global_state_.soft_memory_limit_in_bytes,
638 global_state_.num_resources_limit); 638 global_state_.num_resources_limit);
639 MemoryUsage memory_usage(resource_pool_->memory_usage_bytes(), 639 MemoryUsage memory_usage(resource_pool_->memory_usage_bytes(),
640 resource_pool_->resource_count()); 640 resource_pool_->resource_count());
641 641
642 gfx::ColorSpace raster_color_space = client_->GetRasterColorSpace();
643
642 std::unique_ptr<RasterTilePriorityQueue> raster_priority_queue( 644 std::unique_ptr<RasterTilePriorityQueue> raster_priority_queue(
643 client_->BuildRasterQueue(global_state_.tree_priority, 645 client_->BuildRasterQueue(global_state_.tree_priority,
644 RasterTilePriorityQueue::Type::ALL)); 646 RasterTilePriorityQueue::Type::ALL));
645 std::unique_ptr<EvictionTilePriorityQueue> eviction_priority_queue; 647 std::unique_ptr<EvictionTilePriorityQueue> eviction_priority_queue;
646 PrioritizedWorkToSchedule work_to_schedule; 648 PrioritizedWorkToSchedule work_to_schedule;
647 for (; !raster_priority_queue->IsEmpty(); raster_priority_queue->Pop()) { 649 for (; !raster_priority_queue->IsEmpty(); raster_priority_queue->Pop()) {
648 const PrioritizedTile& prioritized_tile = raster_priority_queue->Top(); 650 const PrioritizedTile& prioritized_tile = raster_priority_queue->Top();
649 Tile* tile = prioritized_tile.tile(); 651 Tile* tile = prioritized_tile.tile();
650 TilePriority priority = prioritized_tile.priority(); 652 TilePriority priority = prioritized_tile.priority();
651 653
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 724
723 // If we couldn't fit the tile into our current memory limit, then we're 725 // If we couldn't fit the tile into our current memory limit, then we're
724 // done. 726 // done.
725 if (!memory_usage_is_within_limit) { 727 if (!memory_usage_is_within_limit) {
726 if (tile_is_needed_now) 728 if (tile_is_needed_now)
727 had_enough_memory_to_schedule_tiles_needed_now = false; 729 had_enough_memory_to_schedule_tiles_needed_now = false;
728 all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; 730 all_tiles_that_need_to_be_rasterized_are_scheduled_ = false;
729 break; 731 break;
730 } 732 }
731 733
734 // If we were able to assign memory to this tile, create a raster task if
735 // necessary.
736 if (!tile->raster_task_) {
737 tile->raster_task_ =
738 CreateRasterTask(prioritized_tile, raster_color_space);
739 }
740
732 memory_usage += memory_required_by_tile_to_be_scheduled; 741 memory_usage += memory_required_by_tile_to_be_scheduled;
733 work_to_schedule.tiles_to_raster.push_back(prioritized_tile); 742 work_to_schedule.tiles_to_raster.push_back(prioritized_tile);
734 } 743 }
735 744
736 // Note that we should try and further reduce memory in case the above loop 745 // Note that we should try and further reduce memory in case the above loop
737 // didn't reduce memory. This ensures that we always release as many resources 746 // didn't reduce memory. This ensures that we always release as many resources
738 // as possible to stay within the memory limit. 747 // as possible to stay within the memory limit.
739 eviction_priority_queue = FreeTileResourcesUntilUsageIsWithinLimit( 748 eviction_priority_queue = FreeTileResourcesUntilUsageIsWithinLimit(
740 std::move(eviction_priority_queue), hard_memory_limit, &memory_usage); 749 std::move(eviction_priority_queue), hard_memory_limit, &memory_usage);
741 750
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 scoped_refptr<TileTask> all_done_task = 825 scoped_refptr<TileTask> all_done_task =
817 CreateTaskSetFinishedTask(&TileManager::DidFinishRunningAllTileTasks); 826 CreateTaskSetFinishedTask(&TileManager::DidFinishRunningAllTileTasks);
818 827
819 // Build a new task queue containing all task currently needed. Tasks 828 // Build a new task queue containing all task currently needed. Tasks
820 // are added in order of priority, highest priority task first. 829 // are added in order of priority, highest priority task first.
821 for (auto& prioritized_tile : tiles_that_need_to_be_rasterized) { 830 for (auto& prioritized_tile : tiles_that_need_to_be_rasterized) {
822 Tile* tile = prioritized_tile.tile(); 831 Tile* tile = prioritized_tile.tile();
823 832
824 DCHECK(tile->draw_info().requires_resource()); 833 DCHECK(tile->draw_info().requires_resource());
825 DCHECK(!tile->draw_info().resource()); 834 DCHECK(!tile->draw_info().resource());
826 835 DCHECK(tile->HasRasterTask());
827 if (!tile->raster_task_) {
828 tile->raster_task_ =
829 CreateRasterTask(prioritized_tile, raster_color_space);
830 }
831 836
832 TileTask* task = tile->raster_task_.get(); 837 TileTask* task = tile->raster_task_.get();
833 838
834 DCHECK(!task->HasCompleted()); 839 DCHECK(!task->HasCompleted());
835 840
836 if (tile->required_for_activation()) { 841 if (tile->required_for_activation()) {
837 required_for_activate_count++; 842 required_for_activate_count++;
838 graph_.edges.push_back( 843 graph_.edges.push_back(
839 TaskGraph::Edge(task, required_for_activation_done_task.get())); 844 TaskGraph::Edge(task, required_for_activation_done_task.get()));
840 } 845 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 936
932 did_check_for_completed_tasks_since_last_schedule_tasks_ = false; 937 did_check_for_completed_tasks_since_last_schedule_tasks_ = false;
933 938
934 TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state", 939 TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state",
935 ScheduledTasksStateAsValue()); 940 ScheduledTasksStateAsValue());
936 } 941 }
937 942
938 scoped_refptr<TileTask> TileManager::CreateRasterTask( 943 scoped_refptr<TileTask> TileManager::CreateRasterTask(
939 const PrioritizedTile& prioritized_tile, 944 const PrioritizedTile& prioritized_tile,
940 const gfx::ColorSpace& color_space) { 945 const gfx::ColorSpace& color_space) {
946 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
947 "TileManager::CreateRasterTask");
948
941 Tile* tile = prioritized_tile.tile(); 949 Tile* tile = prioritized_tile.tile();
942 950
943 // Get the resource. 951 // Get the resource.
944 uint64_t resource_content_id = 0; 952 uint64_t resource_content_id = 0;
945 Resource* resource = nullptr; 953 Resource* resource = nullptr;
946 gfx::Rect invalidated_rect = tile->invalidated_content_rect(); 954 gfx::Rect invalidated_rect = tile->invalidated_content_rect();
947 if (UsePartialRaster() && tile->invalidated_id()) { 955 if (UsePartialRaster() && tile->invalidated_id()) {
948 resource = resource_pool_->TryAcquireResourceForPartialRaster( 956 resource = resource_pool_->TryAcquireResourceForPartialRaster(
949 tile->id(), tile->invalidated_content_rect(), tile->invalidated_id(), 957 tile->id(), tile->invalidated_content_rect(), tile->invalidated_id(),
950 &invalidated_rect); 958 &invalidated_rect);
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
1498 all_tile_tasks_completed = false; 1506 all_tile_tasks_completed = false;
1499 did_notify_all_tile_tasks_completed = false; 1507 did_notify_all_tile_tasks_completed = false;
1500 } 1508 }
1501 1509
1502 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; 1510 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default;
1503 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( 1511 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule(
1504 PrioritizedWorkToSchedule&& other) = default; 1512 PrioritizedWorkToSchedule&& other) = default;
1505 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; 1513 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default;
1506 1514
1507 } // namespace cc 1515 } // 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