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

Side by Side Diff: cc/tile_manager.cc

Issue 11434033: Track the cost of impl-side painting. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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
« cc/tile_manager.h ('K') | « 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 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/threading/sequenced_worker_pool.h" 12 #include "base/threading/sequenced_worker_pool.h"
13 #include "cc/rendering_stats.h"
13 #include "cc/resource_pool.h" 14 #include "cc/resource_pool.h"
14 #include "cc/tile.h" 15 #include "cc/tile.h"
15 #include "third_party/skia/include/core/SkDevice.h" 16 #include "third_party/skia/include/core/SkDevice.h"
16 17
17 namespace { 18 namespace {
18 19
19 void RasterizeTile(cc::PicturePileImpl* picture_pile, 20 void RasterizeTile(cc::PicturePileImpl* picture_pile,
20 uint8_t* mapped_buffer, 21 uint8_t* mapped_buffer,
21 const gfx::Rect& rect) { 22 const gfx::Rect& rect) {
22 TRACE_EVENT0("cc", "RasterizeTile"); 23 TRACE_EVENT0("cc", "RasterizeTile");
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 } 56 }
56 57
57 TileManager::TileManager( 58 TileManager::TileManager(
58 TileManagerClient* client, ResourceProvider* resource_provider) 59 TileManagerClient* client, ResourceProvider* resource_provider)
59 : client_(client), 60 : client_(client),
60 resource_pool_(ResourcePool::Create(resource_provider, 61 resource_pool_(ResourcePool::Create(resource_provider,
61 Renderer::ImplPool)), 62 Renderer::ImplPool)),
62 manage_tiles_pending_(false), 63 manage_tiles_pending_(false),
63 pending_raster_tasks_(0), 64 pending_raster_tasks_(0),
64 worker_pool_(new base::SequencedWorkerPool(kMaxRasterThreads, 65 worker_pool_(new base::SequencedWorkerPool(kMaxRasterThreads,
65 kRasterThreadNamePrefix)) { 66 kRasterThreadNamePrefix)),
67 rasterize_time_in_seconds_(0) {
66 } 68 }
67 69
68 TileManager::~TileManager() { 70 TileManager::~TileManager() {
69 // Reset global state and manage. This should cause 71 // Reset global state and manage. This should cause
70 // our memory usage to drop to zero. 72 // our memory usage to drop to zero.
71 global_state_ = GlobalStateThatImpactsTilePriority(); 73 global_state_ = GlobalStateThatImpactsTilePriority();
72 ManageTiles(); 74 ManageTiles();
73 DCHECK(tiles_.size() == 0); 75 DCHECK(tiles_.size() == 0);
74 // This should finish all pending raster tasks and release any 76 // This should finish all pending raster tasks and release any
75 // uninitialized resources. 77 // uninitialized resources.
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 // Sort by bin. 210 // Sort by bin.
209 std::sort(tiles_.begin(), tiles_.end(), BinComparator()); 211 std::sort(tiles_.begin(), tiles_.end(), BinComparator());
210 212
211 // Assign gpu memory and determine what tiles need to be rasterized. 213 // Assign gpu memory and determine what tiles need to be rasterized.
212 AssignGpuMemoryToTiles(); 214 AssignGpuMemoryToTiles();
213 215
214 // Finally, kick the rasterizer. 216 // Finally, kick the rasterizer.
215 DispatchMoreRasterTasks(); 217 DispatchMoreRasterTasks();
216 } 218 }
217 219
220 void TileManager::renderingStats(RenderingStats* stats) {
221 stats->totalRasterizeTimeInSeconds += rasterize_time_in_seconds_;
222 rasterize_time_in_seconds_ = 0;
nduca 2012/11/29 18:16:30 we also need number of pixels rasterized
Tom Hudson 2012/11/29 20:30:31 Done.
223 }
224
225
218 void TileManager::AssignGpuMemoryToTiles() { 226 void TileManager::AssignGpuMemoryToTiles() {
219 TRACE_EVENT0("cc", "TileManager::AssignGpuMemoryToTiles"); 227 TRACE_EVENT0("cc", "TileManager::AssignGpuMemoryToTiles");
220 // Some memory cannot be released. Figure out which. 228 // Some memory cannot be released. Figure out which.
221 size_t unreleasable_bytes = 0; 229 size_t unreleasable_bytes = 0;
222 for (TileVector::iterator it = tiles_.begin(); it != tiles_.end(); ++it) { 230 for (TileVector::iterator it = tiles_.begin(); it != tiles_.end(); ++it) {
223 Tile* tile = *it; 231 Tile* tile = *it;
224 if (!tile->managed_state().can_be_freed) 232 if (!tile->managed_state().can_be_freed)
225 unreleasable_bytes += tile->bytes_consumed_if_allocated(); 233 unreleasable_bytes += tile->bytes_consumed_if_allocated();
226 } 234 }
227 235
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 cloned_picture_pile)); 323 cloned_picture_pile));
316 } 324 }
317 325
318 void TileManager::OnRasterTaskCompleted( 326 void TileManager::OnRasterTaskCompleted(
319 scoped_refptr<Tile> tile, 327 scoped_refptr<Tile> tile,
320 ResourceProvider::ResourceId resource_id, 328 ResourceProvider::ResourceId resource_id,
321 scoped_refptr<PicturePileImpl> cloned_picture_pile) { 329 scoped_refptr<PicturePileImpl> cloned_picture_pile) {
322 TRACE_EVENT0("cc", "TileManager::OnRasterTaskCompleted"); 330 TRACE_EVENT0("cc", "TileManager::OnRasterTaskCompleted");
323 --pending_raster_tasks_; 331 --pending_raster_tasks_;
324 332
333 rasterize_time_in_seconds_ += cloned_picture_pile->rasterizeTime();
334
325 // Release raster resources. 335 // Release raster resources.
326 resource_pool_->resource_provider()->unmapPixelBuffer(resource_id); 336 resource_pool_->resource_provider()->unmapPixelBuffer(resource_id);
327 337
328 ManagedTileState& managed_tile_state = tile->managed_state(); 338 ManagedTileState& managed_tile_state = tile->managed_state();
329 managed_tile_state.can_be_freed = true; 339 managed_tile_state.can_be_freed = true;
330 340
331 // Tile can be freed after the completion of the raster task. Call 341 // Tile can be freed after the completion of the raster task. Call
332 // AssignGpuMemoryToTiles() to re-assign gpu memory to highest priority 342 // AssignGpuMemoryToTiles() to re-assign gpu memory to highest priority
333 // tiles. The result of this could be that this tile is no longer 343 // tiles. The result of this could be that this tile is no longer
334 // allowed to use gpu memory and in that case we need to abort 344 // allowed to use gpu memory and in that case we need to abort
(...skipping 20 matching lines...) Expand all
355 Tile* tile, ResourceProvider::ResourceId resource_id) { 365 Tile* tile, ResourceProvider::ResourceId resource_id) {
356 ManagedTileState& managed_tile_state = tile->managed_state(); 366 ManagedTileState& managed_tile_state = tile->managed_state();
357 DCHECK(!managed_tile_state.resource_id); 367 DCHECK(!managed_tile_state.resource_id);
358 managed_tile_state.resource_id = resource_id; 368 managed_tile_state.resource_id = resource_id;
359 managed_tile_state.resource_id_is_being_initialized = false; 369 managed_tile_state.resource_id_is_being_initialized = false;
360 // TODO(qinmin): Make this conditional on managed_tile_state.bin == NOW_BIN. 370 // TODO(qinmin): Make this conditional on managed_tile_state.bin == NOW_BIN.
361 client_->ScheduleRedraw(); 371 client_->ScheduleRedraw();
362 } 372 }
363 373
364 } 374 }
OLDNEW
« cc/tile_manager.h ('K') | « cc/tile_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698