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

Side by Side Diff: cc/tile_manager.cc

Issue 11575015: adding render stats for deferred image decoding (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
« no previous file with comments | « cc/tile_manager.h ('k') | tools/perf/perf_tools/smoothness_benchmark.py » ('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/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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 base::Unretained(picture_pile), 62 base::Unretained(picture_pile),
63 mapped_buffer, 63 mapped_buffer,
64 rect, 64 rect,
65 contents_scale, 65 contents_scale,
66 stats), 66 stats),
67 base::Bind(&RasterThread::RunReply, base::Unretained(this), reply)); 67 base::Bind(&RasterThread::RunReply, base::Unretained(this), reply));
68 } 68 }
69 69
70 void PostImageDecodingTaskAndReply(const tracked_objects::Location& from_here, 70 void PostImageDecodingTaskAndReply(const tracked_objects::Location& from_here,
71 skia::LazyPixelRef* pixel_ref, 71 skia::LazyPixelRef* pixel_ref,
72 RenderingStats* stats,
72 const base::Closure& reply) { 73 const base::Closure& reply) {
73 ++num_pending_tasks_; 74 ++num_pending_tasks_;
74 message_loop_proxy()->PostTaskAndReply( 75 message_loop_proxy()->PostTaskAndReply(
75 from_here, 76 from_here,
76 base::Bind(&RunImageDecodeTask, base::Unretained(pixel_ref)), 77 base::Bind(&RunImageDecodeTask, pixel_ref, stats),
77 base::Bind(&RasterThread::RunReply, base::Unretained(this), reply)); 78 base::Bind(&RasterThread::RunReply, base::Unretained(this), reply));
78 } 79 }
79 80
80 private: 81 private:
81 static void RunRasterTask(PicturePileImpl* picture_pile, 82 static void RunRasterTask(PicturePileImpl* picture_pile,
82 uint8_t* mapped_buffer, 83 uint8_t* mapped_buffer,
83 const gfx::Rect& rect, 84 const gfx::Rect& rect,
84 float contents_scale, 85 float contents_scale,
85 RenderingStats* stats) { 86 RenderingStats* stats) {
86 TRACE_EVENT0("cc", "RasterThread::RunRasterTask"); 87 TRACE_EVENT0("cc", "RasterThread::RunRasterTask");
87 DCHECK(picture_pile); 88 DCHECK(picture_pile);
88 DCHECK(mapped_buffer); 89 DCHECK(mapped_buffer);
89 SkBitmap bitmap; 90 SkBitmap bitmap;
90 bitmap.setConfig(SkBitmap::kARGB_8888_Config, rect.width(), rect.height()); 91 bitmap.setConfig(SkBitmap::kARGB_8888_Config, rect.width(), rect.height());
91 bitmap.setPixels(mapped_buffer); 92 bitmap.setPixels(mapped_buffer);
92 SkDevice device(bitmap); 93 SkDevice device(bitmap);
93 SkCanvas canvas(&device); 94 SkCanvas canvas(&device);
94 picture_pile->Raster( 95 picture_pile->Raster(
95 &canvas, 96 &canvas,
96 rect, 97 rect,
97 contents_scale, 98 contents_scale,
98 stats); 99 stats);
99 } 100 }
100 101
101 static void RunImageDecodeTask(skia::LazyPixelRef* pixel_ref) { 102 static void RunImageDecodeTask(skia::LazyPixelRef* pixel_ref,
103 RenderingStats* stats) {
102 TRACE_EVENT0("cc", "RasterThread::RunImageDecodeTask"); 104 TRACE_EVENT0("cc", "RasterThread::RunImageDecodeTask");
105 base::TimeTicks decodeBeginTime = base::TimeTicks::Now();
103 pixel_ref->Decode(); 106 pixel_ref->Decode();
107 stats->totalDeferredImageDecodeTimeInSeconds +=
108 (base::TimeTicks::Now() - decodeBeginTime).InSecondsF();
104 } 109 }
105 110
106 void RunReply(const base::Closure& reply) { 111 void RunReply(const base::Closure& reply) {
107 --num_pending_tasks_; 112 --num_pending_tasks_;
108 reply.Run(); 113 reply.Run();
109 } 114 }
110 115
111 int num_pending_tasks_; 116 int num_pending_tasks_;
112 117
113 DISALLOW_COPY_AND_ASSIGN(RasterThread); 118 DISALLOW_COPY_AND_ASSIGN(RasterThread);
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 resource_pool_->resource_provider()->releasePixelBuffer( 327 resource_pool_->resource_provider()->releasePixelBuffer(
323 tile->managed_state().resource->id()); 328 tile->managed_state().resource->id());
324 329
325 DidFinishTileInitialization(tile); 330 DidFinishTileInitialization(tile);
326 tiles_with_pending_set_pixels_.pop(); 331 tiles_with_pending_set_pixels_.pop();
327 } 332 }
328 } 333 }
329 334
330 void TileManager::renderingStats(RenderingStats* stats) { 335 void TileManager::renderingStats(RenderingStats* stats) {
331 stats->totalRasterizeTimeInSeconds = 336 stats->totalRasterizeTimeInSeconds =
332 rendering_stats_.totalRasterizeTimeInSeconds; 337 rendering_stats_.totalRasterizeTimeInSeconds;
333 stats->totalPixelsRasterized = rendering_stats_.totalPixelsRasterized; 338 stats->totalPixelsRasterized = rendering_stats_.totalPixelsRasterized;
339 stats->totalDeferredImageDecodeCount =
340 rendering_stats_.totalDeferredImageDecodeCount;
341 stats->totalDeferredImageCacheHitCount =
342 rendering_stats_.totalDeferredImageCacheHitCount;
343 stats->totalPixelGatheringCount = rendering_stats_.totalPixelGatheringCount;
344 stats->totalDeferredImageDecodeTimeInSeconds =
345 rendering_stats_.totalDeferredImageDecodeTimeInSeconds;
346 stats->totalPixelGatheringTimeInSeconds =
347 rendering_stats_.totalPixelGatheringTimeInSeconds;
334 } 348 }
335 349
336 void TileManager::AssignGpuMemoryToTiles() { 350 void TileManager::AssignGpuMemoryToTiles() {
337 TRACE_EVENT0("cc", "TileManager::AssignGpuMemoryToTiles"); 351 TRACE_EVENT0("cc", "TileManager::AssignGpuMemoryToTiles");
338 // Some memory cannot be released. Figure out which. 352 // Some memory cannot be released. Figure out which.
339 size_t unreleasable_bytes = 0; 353 size_t unreleasable_bytes = 0;
340 for (TileVector::iterator it = tiles_.begin(); it != tiles_.end(); ++it) { 354 for (TileVector::iterator it = tiles_.begin(); it != tiles_.end(); ++it) {
341 Tile* tile = *it; 355 Tile* tile = *it;
342 if (!tile->managed_state().can_be_freed) 356 if (!tile->managed_state().can_be_freed)
343 unreleasable_bytes += tile->bytes_consumed_if_allocated(); 357 unreleasable_bytes += tile->bytes_consumed_if_allocated();
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 } 462 }
449 tiles_that_need_to_be_rasterized_.pop_back(); 463 tiles_that_need_to_be_rasterized_.pop_back();
450 } 464 }
451 } 465 }
452 466
453 void TileManager::DispatchImageDecodingTasksForTile(Tile* tile) { 467 void TileManager::DispatchImageDecodingTasksForTile(Tile* tile) {
454 ManagedTileState& managed_state = tile->managed_state(); 468 ManagedTileState& managed_state = tile->managed_state();
455 if (managed_state.need_to_gather_pixel_refs) { 469 if (managed_state.need_to_gather_pixel_refs) {
456 TRACE_EVENT0("cc", 470 TRACE_EVENT0("cc",
457 "TileManager::DispatchImageDecodingTaskForTile: Gather PixelRefs"); 471 "TileManager::DispatchImageDecodingTaskForTile: Gather PixelRefs");
472 base::TimeTicks gatherBeginTime = base::TimeTicks::Now();
458 const_cast<PicturePileImpl *>(tile->picture_pile())->GatherPixelRefs( 473 const_cast<PicturePileImpl *>(tile->picture_pile())->GatherPixelRefs(
459 tile->content_rect_, managed_state.pending_pixel_refs); 474 tile->content_rect_, managed_state.pending_pixel_refs);
475 rendering_stats_.totalPixelGatheringCount++;
476 rendering_stats_.totalPixelGatheringTimeInSeconds +=
477 (base::TimeTicks::Now() - gatherBeginTime).InSecondsF();
460 managed_state.need_to_gather_pixel_refs = false; 478 managed_state.need_to_gather_pixel_refs = false;
461 } 479 }
462 480
463 std::list<skia::LazyPixelRef*>& pending_pixel_refs = 481 std::list<skia::LazyPixelRef*>& pending_pixel_refs =
464 tile->managed_state().pending_pixel_refs; 482 tile->managed_state().pending_pixel_refs;
465 std::list<skia::LazyPixelRef*>::iterator it = pending_pixel_refs.begin(); 483 std::list<skia::LazyPixelRef*>::iterator it = pending_pixel_refs.begin();
466 while (it != pending_pixel_refs.end()) { 484 while (it != pending_pixel_refs.end()) {
467 if (pending_decode_tasks_.end() != pending_decode_tasks_.find( 485 if (pending_decode_tasks_.end() != pending_decode_tasks_.find(
468 (*it)->getGenerationID())) { 486 (*it)->getGenerationID())) {
469 ++it; 487 ++it;
470 continue; 488 continue;
471 } 489 }
472 // TODO(qinmin): passing correct image size to PrepareToDecode(). 490 // TODO(qinmin): passing correct image size to PrepareToDecode().
473 if ((*it)->PrepareToDecode(skia::LazyPixelRef::PrepareParams())) { 491 if ((*it)->PrepareToDecode(skia::LazyPixelRef::PrepareParams())) {
492 rendering_stats_.totalDeferredImageCacheHitCount++;
474 pending_pixel_refs.erase(it++); 493 pending_pixel_refs.erase(it++);
475 } else { 494 } else {
476 RasterThread* thread = GetFreeRasterThread(); 495 RasterThread* thread = GetFreeRasterThread();
477 if (thread) 496 if (!thread)
478 DispatchOneImageDecodingTask(thread, tile, *it); 497 return;
498 DispatchOneImageDecodingTask(thread, tile, *it);
479 ++it; 499 ++it;
480 } 500 }
481 } 501 }
482 } 502 }
483 503
484 void TileManager::DispatchOneImageDecodingTask(RasterThread* thread, 504 void TileManager::DispatchOneImageDecodingTask(RasterThread* thread,
485 scoped_refptr<Tile> tile, 505 scoped_refptr<Tile> tile,
486 skia::LazyPixelRef* pixel_ref) { 506 skia::LazyPixelRef* pixel_ref) {
487 TRACE_EVENT0("cc", "TileManager::DispatchOneImageDecodingTask"); 507 TRACE_EVENT0("cc", "TileManager::DispatchOneImageDecodingTask");
488 uint32_t pixel_ref_id = pixel_ref->getGenerationID(); 508 uint32_t pixel_ref_id = pixel_ref->getGenerationID();
489 DCHECK(pending_decode_tasks_.end() == 509 DCHECK(pending_decode_tasks_.end() ==
490 pending_decode_tasks_.find(pixel_ref_id)); 510 pending_decode_tasks_.find(pixel_ref_id));
491 pending_decode_tasks_[pixel_ref_id] = pixel_ref; 511 pending_decode_tasks_[pixel_ref_id] = pixel_ref;
512 RenderingStats* stats = new RenderingStats();
reveman 2012/12/13 20:55:13 you need to delete this instance in OnImageDecodin
qinmin 2012/12/13 21:09:25 ah...I forgot that.. Done. On 2012/12/13 20:55:13
492 513
493 thread->PostImageDecodingTaskAndReply( 514 thread->PostImageDecodingTaskAndReply(
494 FROM_HERE, 515 FROM_HERE,
495 pixel_ref, 516 pixel_ref,
517 stats,
496 base::Bind(&TileManager::OnImageDecodingTaskCompleted, 518 base::Bind(&TileManager::OnImageDecodingTaskCompleted,
497 base::Unretained(this), 519 base::Unretained(this),
498 tile, 520 tile,
499 pixel_ref_id)); 521 pixel_ref_id,
522 stats));
500 } 523 }
501 524
502 void TileManager::OnImageDecodingTaskCompleted(scoped_refptr<Tile> tile, 525 void TileManager::OnImageDecodingTaskCompleted(scoped_refptr<Tile> tile,
503 uint32_t pixel_ref_id) { 526 uint32_t pixel_ref_id,
527 RenderingStats* stats) {
504 TRACE_EVENT0("cc", "TileManager::OnImageDecoded"); 528 TRACE_EVENT0("cc", "TileManager::OnImageDecoded");
505 pending_decode_tasks_.erase(pixel_ref_id); 529 pending_decode_tasks_.erase(pixel_ref_id);
506 530 rendering_stats_.totalDeferredImageDecodeTimeInSeconds +=
531 stats->totalDeferredImageDecodeTimeInSeconds;
532 rendering_stats_.totalDeferredImageDecodeCount++;
507 for (TileList::iterator it = tiles_with_image_decoding_tasks_.begin(); 533 for (TileList::iterator it = tiles_with_image_decoding_tasks_.begin();
508 it != tiles_with_image_decoding_tasks_.end(); ++it) { 534 it != tiles_with_image_decoding_tasks_.end(); ++it) {
509 std::list<skia::LazyPixelRef*>& pixel_refs = 535 std::list<skia::LazyPixelRef*>& pixel_refs =
510 (*it)->managed_state().pending_pixel_refs; 536 (*it)->managed_state().pending_pixel_refs;
511 for (std::list<skia::LazyPixelRef*>::iterator pixel_it = 537 for (std::list<skia::LazyPixelRef*>::iterator pixel_it =
512 pixel_refs.begin(); pixel_it != pixel_refs.end(); ++pixel_it) { 538 pixel_refs.begin(); pixel_it != pixel_refs.end(); ++pixel_it) {
513 if (pixel_ref_id == (*pixel_it)->getGenerationID()) { 539 if (pixel_ref_id == (*pixel_it)->getGenerationID()) {
514 pixel_refs.erase(pixel_it); 540 pixel_refs.erase(pixel_it);
515 break; 541 break;
516 } 542 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 } 627 }
602 628
603 void TileManager::DidFinishTileInitialization(Tile* tile) { 629 void TileManager::DidFinishTileInitialization(Tile* tile) {
604 ManagedTileState& managed_tile_state = tile->managed_state(); 630 ManagedTileState& managed_tile_state = tile->managed_state();
605 DCHECK(managed_tile_state.resource); 631 DCHECK(managed_tile_state.resource);
606 managed_tile_state.resource_is_being_initialized = false; 632 managed_tile_state.resource_is_being_initialized = false;
607 managed_tile_state.can_be_freed = true; 633 managed_tile_state.can_be_freed = true;
608 } 634 }
609 635
610 } 636 }
OLDNEW
« no previous file with comments | « cc/tile_manager.h ('k') | tools/perf/perf_tools/smoothness_benchmark.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698