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

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

Issue 1351283003: Allow task pools to reason about transparency. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make StagingBuffer constructor non-explicit 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
« no previous file with comments | « cc/tiles/tile_manager.h ('k') | cc/tiles/tile_manager_perftest.cc » ('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 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 <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 10
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 520
521 DCHECK_IMPLIES(tile->draw_info().mode() != TileDrawInfo::OOM_MODE, 521 DCHECK_IMPLIES(tile->draw_info().mode() != TileDrawInfo::OOM_MODE,
522 !tile->draw_info().IsReadyToDraw()); 522 !tile->draw_info().IsReadyToDraw());
523 523
524 // If the tile already has a raster_task, then the memory used by it is 524 // If the tile already has a raster_task, then the memory used by it is
525 // already accounted for in memory_usage. Otherwise, we'll have to acquire 525 // already accounted for in memory_usage. Otherwise, we'll have to acquire
526 // more memory to create a raster task. 526 // more memory to create a raster task.
527 MemoryUsage memory_required_by_tile_to_be_scheduled; 527 MemoryUsage memory_required_by_tile_to_be_scheduled;
528 if (!tile->raster_task_.get()) { 528 if (!tile->raster_task_.get()) {
529 memory_required_by_tile_to_be_scheduled = MemoryUsage::FromConfig( 529 memory_required_by_tile_to_be_scheduled = MemoryUsage::FromConfig(
530 tile->desired_texture_size(), tile_task_runner_->GetResourceFormat()); 530 tile->desired_texture_size(), DetermineResourceFormat(tile));
531 } 531 }
532 532
533 bool tile_is_needed_now = priority.priority_bin == TilePriority::NOW; 533 bool tile_is_needed_now = priority.priority_bin == TilePriority::NOW;
534 534
535 // This is the memory limit that will be used by this tile. Depending on 535 // This is the memory limit that will be used by this tile. Depending on
536 // the tile priority, it will be one of hard_memory_limit or 536 // the tile priority, it will be one of hard_memory_limit or
537 // soft_memory_limit. 537 // soft_memory_limit.
538 MemoryUsage& tile_memory_limit = 538 MemoryUsage& tile_memory_limit =
539 tile_is_needed_now ? hard_memory_limit : soft_memory_limit; 539 tile_is_needed_now ? hard_memory_limit : soft_memory_limit;
540 540
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 uint64_t resource_content_id = 0; 660 uint64_t resource_content_id = 0;
661 Resource* resource = nullptr; 661 Resource* resource = nullptr;
662 if (tile->invalidated_id()) { 662 if (tile->invalidated_id()) {
663 // TODO(danakj): For resources that are in use, we should still grab them 663 // TODO(danakj): For resources that are in use, we should still grab them
664 // and copy from them instead of rastering everything. crbug.com/492754 664 // and copy from them instead of rastering everything. crbug.com/492754
665 resource = 665 resource =
666 resource_pool_->TryAcquireResourceWithContentId(tile->invalidated_id()); 666 resource_pool_->TryAcquireResourceWithContentId(tile->invalidated_id());
667 } 667 }
668 if (resource) { 668 if (resource) {
669 resource_content_id = tile->invalidated_id(); 669 resource_content_id = tile->invalidated_id();
670 DCHECK_EQ(tile_task_runner_->GetResourceFormat(), resource->format()); 670 DCHECK_EQ(DetermineResourceFormat(tile), resource->format());
671 DCHECK_EQ(tile->desired_texture_size().ToString(), 671 DCHECK_EQ(tile->desired_texture_size().ToString(),
672 resource->size().ToString()); 672 resource->size().ToString());
673 } else { 673 } else {
674 resource = resource_pool_->AcquireResource( 674 resource = resource_pool_->AcquireResource(tile->desired_texture_size(),
675 tile->desired_texture_size(), tile_task_runner_->GetResourceFormat()); 675 DetermineResourceFormat(tile));
676 } 676 }
677 677
678 // Create and queue all image decode tasks that this tile depends on. 678 // Create and queue all image decode tasks that this tile depends on.
679 ImageDecodeTask::Vector decode_tasks; 679 ImageDecodeTask::Vector decode_tasks;
680 std::vector<skia::PositionImage> images; 680 std::vector<skia::PositionImage> images;
681 prioritized_tile.raster_source()->GatherDiscardableImages( 681 prioritized_tile.raster_source()->GatherDiscardableImages(
682 tile->enclosing_layer_rect(), &images); 682 tile->enclosing_layer_rect(), &images);
683 for (const skia::PositionImage& image : images) { 683 for (const skia::PositionImage& image : images) {
684 decode_tasks.push_back(image_decode_controller_.GetTaskForImage( 684 decode_tasks.push_back(image_decode_controller_.GetTaskForImage(
685 image, tile->layer_id(), prepare_tiles_count_)); 685 image, tile->layer_id(), prepare_tiles_count_));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 draw_info.set_solid_color(analysis.solid_color); 730 draw_info.set_solid_color(analysis.solid_color);
731 if (resource) { 731 if (resource) {
732 // Pass the old tile id here because the tile is solid color so we did not 732 // Pass the old tile id here because the tile is solid color so we did not
733 // raster anything into the tile resource. 733 // raster anything into the tile resource.
734 resource_pool_->ReleaseResource(resource, tile->invalidated_id()); 734 resource_pool_->ReleaseResource(resource, tile->invalidated_id());
735 } 735 }
736 } else { 736 } else {
737 DCHECK(resource); 737 DCHECK(resource);
738 draw_info.set_use_resource(); 738 draw_info.set_use_resource();
739 draw_info.resource_ = resource; 739 draw_info.resource_ = resource;
740 draw_info.contents_swizzled_ = 740 draw_info.contents_swizzled_ = DetermineResourceRequiresSwizzle(tile);
741 tile_task_runner_->GetResourceRequiresSwizzle();
742 } 741 }
743 DCHECK(draw_info.IsReadyToDraw()); 742 DCHECK(draw_info.IsReadyToDraw());
744 draw_info.set_was_ever_ready_to_draw(); 743 draw_info.set_was_ever_ready_to_draw();
745 744
746 client_->NotifyTileStateChanged(tile); 745 client_->NotifyTileStateChanged(tile);
747 } 746 }
748 747
749 ScopedTilePtr TileManager::CreateTile(const Tile::CreateInfo& info, 748 ScopedTilePtr TileManager::CreateTile(const Tile::CreateInfo& info,
750 int layer_id, 749 int layer_id,
751 int source_frame_number, 750 int source_frame_number,
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 client_->NotifyTileStateChanged(tile); 911 client_->NotifyTileStateChanged(tile);
913 } 912 }
914 913
915 DCHECK(IsReadyToActivate()); 914 DCHECK(IsReadyToActivate());
916 // TODO(ericrk): Investigate why we need to schedule this (not just call it 915 // TODO(ericrk): Investigate why we need to schedule this (not just call it
917 // inline). http://crbug.com/498439 916 // inline). http://crbug.com/498439
918 signals_.ready_to_activate = true; 917 signals_.ready_to_activate = true;
919 signals_check_notifier_.Schedule(); 918 signals_check_notifier_.Schedule();
920 } 919 }
921 920
921 ResourceFormat TileManager::DetermineResourceFormat(const Tile* tile) const {
922 return tile_task_runner_->GetResourceFormat(!tile->is_opaque());
923 }
924
925 bool TileManager::DetermineResourceRequiresSwizzle(const Tile* tile) const {
926 return tile_task_runner_->GetResourceRequiresSwizzle(!tile->is_opaque());
927 }
928
922 TileManager::MemoryUsage::MemoryUsage() : memory_bytes_(0), resource_count_(0) { 929 TileManager::MemoryUsage::MemoryUsage() : memory_bytes_(0), resource_count_(0) {
923 } 930 }
924 931
925 TileManager::MemoryUsage::MemoryUsage(size_t memory_bytes, 932 TileManager::MemoryUsage::MemoryUsage(size_t memory_bytes,
926 size_t resource_count) 933 size_t resource_count)
927 : memory_bytes_(static_cast<int64>(memory_bytes)), 934 : memory_bytes_(static_cast<int64>(memory_bytes)),
928 resource_count_(static_cast<int>(resource_count)) { 935 resource_count_(static_cast<int>(resource_count)) {
929 // MemoryUsage is constructed using size_ts, since it deals with memory and 936 // MemoryUsage is constructed using size_ts, since it deals with memory and
930 // the inputs are typically size_t. However, during the course of usage (in 937 // the inputs are typically size_t. However, during the course of usage (in
931 // particular operator-=) can cause internal values to become negative. Thus, 938 // particular operator-=) can cause internal values to become negative. Thus,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 void TileManager::Signals::reset() { 996 void TileManager::Signals::reset() {
990 ready_to_activate = false; 997 ready_to_activate = false;
991 did_notify_ready_to_activate = false; 998 did_notify_ready_to_activate = false;
992 ready_to_draw = false; 999 ready_to_draw = false;
993 did_notify_ready_to_draw = false; 1000 did_notify_ready_to_draw = false;
994 all_tile_tasks_completed = false; 1001 all_tile_tasks_completed = false;
995 did_notify_all_tile_tasks_completed = false; 1002 did_notify_all_tile_tasks_completed = false;
996 } 1003 }
997 1004
998 } // namespace cc 1005 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/tile_manager.h ('k') | cc/tiles/tile_manager_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698