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

Side by Side Diff: cc/tile_manager.cc

Issue 11557017: cc: Reduce time spent in AssignGpuMemoryToTiles(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « cc/tile_manager.h ('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 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/tile_manager.h" 5 #include "cc/tile_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 } 127 }
128 128
129 TileManager::TileManager( 129 TileManager::TileManager(
130 TileManagerClient* client, 130 TileManagerClient* client,
131 ResourceProvider* resource_provider, 131 ResourceProvider* resource_provider,
132 size_t num_raster_threads) 132 size_t num_raster_threads)
133 : client_(client), 133 : client_(client),
134 resource_pool_(ResourcePool::Create(resource_provider, 134 resource_pool_(ResourcePool::Create(resource_provider,
135 Renderer::ImplPool)), 135 Renderer::ImplPool)),
136 manage_tiles_pending_(false), 136 manage_tiles_pending_(false),
137 manage_tiles_call_count_(0),
137 check_for_completed_set_pixels_pending_(false) { 138 check_for_completed_set_pixels_pending_(false) {
138 // Initialize all threads. 139 // Initialize all threads.
139 const std::string thread_name_prefix = kRasterThreadNamePrefix; 140 const std::string thread_name_prefix = kRasterThreadNamePrefix;
140 while (raster_threads_.size() < num_raster_threads) { 141 while (raster_threads_.size() < num_raster_threads) {
141 int thread_number = raster_threads_.size() + 1; 142 int thread_number = raster_threads_.size() + 1;
142 scoped_ptr<RasterThread> thread = make_scoped_ptr( 143 scoped_ptr<RasterThread> thread = make_scoped_ptr(
143 new RasterThread(thread_name_prefix + 144 new RasterThread(thread_name_prefix +
144 StringPrintf("Worker%d", thread_number).c_str())); 145 StringPrintf("Worker%d", thread_number).c_str()));
145 raster_threads_.append(thread.Pass()); 146 raster_threads_.append(thread.Pass());
146 } 147 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 228
228 return 229 return
229 ams.time_to_needed_in_seconds < 230 ams.time_to_needed_in_seconds <
230 bms.time_to_needed_in_seconds; 231 bms.time_to_needed_in_seconds;
231 } 232 }
232 }; 233 };
233 234
234 void TileManager::ManageTiles() { 235 void TileManager::ManageTiles() {
235 TRACE_EVENT0("cc", "TileManager::ManageTiles"); 236 TRACE_EVENT0("cc", "TileManager::ManageTiles");
236 manage_tiles_pending_ = false; 237 manage_tiles_pending_ = false;
238 ++manage_tiles_call_count_;
237 239
238 // The amount of time for which we want to have prepainting coverage. 240 // The amount of time for which we want to have prepainting coverage.
239 const double prepainting_window_time_seconds = 1.0; 241 const double prepainting_window_time_seconds = 1.0;
240 const double backfling_guard_distance_pixels = 314.0; 242 const double backfling_guard_distance_pixels = 314.0;
241 243
242 const bool smoothness_takes_priority = global_state_.smoothness_takes_priority ; 244 const bool smoothness_takes_priority = global_state_.smoothness_takes_priority ;
243 245
244 // Bin into three categories of tiles: things we need now, things we need soon , and eventually 246 // Bin into three categories of tiles: things we need now, things we need soon , and eventually
245 for (TileVector::iterator it = tiles_.begin(); it != tiles_.end(); ++it) { 247 for (TileVector::iterator it = tiles_.begin(); it != tiles_.end(); ++it) {
246 Tile* tile = *it; 248 Tile* tile = *it;
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 picture_pile_clone.get(), 557 picture_pile_clone.get(),
556 resource_pool_->resource_provider()->mapPixelBuffer(resource_id), 558 resource_pool_->resource_provider()->mapPixelBuffer(resource_id),
557 tile->content_rect_, 559 tile->content_rect_,
558 tile->contents_scale(), 560 tile->contents_scale(),
559 stats, 561 stats,
560 base::Bind(&TileManager::OnRasterTaskCompleted, 562 base::Bind(&TileManager::OnRasterTaskCompleted,
561 base::Unretained(this), 563 base::Unretained(this),
562 tile, 564 tile,
563 base::Passed(&resource), 565 base::Passed(&resource),
564 picture_pile_clone, 566 picture_pile_clone,
567 manage_tiles_call_count_,
565 stats)); 568 stats));
566 } 569 }
567 570
568 void TileManager::OnRasterTaskCompleted( 571 void TileManager::OnRasterTaskCompleted(
569 scoped_refptr<Tile> tile, 572 scoped_refptr<Tile> tile,
570 scoped_ptr<ResourcePool::Resource> resource, 573 scoped_ptr<ResourcePool::Resource> resource,
571 scoped_refptr<PicturePileImpl> picture_pile_clone, 574 scoped_refptr<PicturePileImpl> picture_pile_clone,
575 int manage_tiles_call_count_when_dispatched,
572 RenderingStats* stats) { 576 RenderingStats* stats) {
573 TRACE_EVENT0("cc", "TileManager::OnRasterTaskCompleted"); 577 TRACE_EVENT0("cc", "TileManager::OnRasterTaskCompleted");
574 rendering_stats_.totalRasterizeTimeInSeconds += 578 rendering_stats_.totalRasterizeTimeInSeconds +=
575 stats->totalRasterizeTimeInSeconds; 579 stats->totalRasterizeTimeInSeconds;
576 rendering_stats_.totalPixelsRasterized += stats->totalPixelsRasterized; 580 rendering_stats_.totalPixelsRasterized += stats->totalPixelsRasterized;
577 delete stats; 581 delete stats;
578 582
579 // Release raster resources. 583 // Release raster resources.
580 resource_pool_->resource_provider()->unmapPixelBuffer(resource->id()); 584 resource_pool_->resource_provider()->unmapPixelBuffer(resource->id());
581 585
582 ManagedTileState& managed_tile_state = tile->managed_state(); 586 ManagedTileState& managed_tile_state = tile->managed_state();
583 managed_tile_state.can_be_freed = true; 587 managed_tile_state.can_be_freed = true;
584 588
585 // Tile can be freed after the completion of the raster task. Call 589 // Tile can be freed after the completion of the raster task. Call
586 // AssignGpuMemoryToTiles() to re-assign gpu memory to highest priority 590 // AssignGpuMemoryToTiles() to re-assign gpu memory to highest priority
587 // tiles. The result of this could be that this tile is no longer 591 // tiles if ManageTiles() was called since task was dispatched. The result
588 // allowed to use gpu memory and in that case we need to abort 592 // of this could be that this tile is no longer allowed to use gpu
589 // initialization and free all associated resources before calling 593 // memory and in that case we need to abort initialization and free all
590 // DispatchMoreTasks(). 594 // associated resources before calling DispatchMoreTasks().
591 AssignGpuMemoryToTiles(); 595 if (manage_tiles_call_count_when_dispatched != manage_tiles_call_count_)
596 AssignGpuMemoryToTiles();
592 597
593 // Finish resource initialization if |can_use_gpu_memory| is true. 598 // Finish resource initialization if |can_use_gpu_memory| is true.
594 if (managed_tile_state.can_use_gpu_memory) { 599 if (managed_tile_state.can_use_gpu_memory) {
595 // The component order may be bgra if we're uploading bgra pixels to rgba 600 // The component order may be bgra if we're uploading bgra pixels to rgba
596 // texture. Mark contents as swizzled if image component order is 601 // texture. Mark contents as swizzled if image component order is
597 // different than texture format. 602 // different than texture format.
598 managed_tile_state.contents_swizzled = 603 managed_tile_state.contents_swizzled =
599 !PlatformColor::sameComponentOrder(tile->format_); 604 !PlatformColor::sameComponentOrder(tile->format_);
600 605
601 // Tile resources can't be freed until upload has completed. 606 // Tile resources can't be freed until upload has completed.
(...skipping 13 matching lines...) Expand all
615 } 620 }
616 621
617 void TileManager::DidFinishTileInitialization(Tile* tile) { 622 void TileManager::DidFinishTileInitialization(Tile* tile) {
618 ManagedTileState& managed_tile_state = tile->managed_state(); 623 ManagedTileState& managed_tile_state = tile->managed_state();
619 DCHECK(managed_tile_state.resource); 624 DCHECK(managed_tile_state.resource);
620 managed_tile_state.resource_is_being_initialized = false; 625 managed_tile_state.resource_is_being_initialized = false;
621 managed_tile_state.can_be_freed = true; 626 managed_tile_state.can_be_freed = true;
622 } 627 }
623 628
624 } 629 }
OLDNEW
« no previous file with comments | « cc/tile_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698