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

Side by Side Diff: cc/resources/bitmap_skpicture_content_layer_updater.cc

Issue 12426024: cc: Switch RenderingStats collection in Layer::Update() to RenderingStatsInstrumentation (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase to 190965 Created 7 years, 9 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
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/resources/bitmap_skpicture_content_layer_updater.h" 5 #include "cc/resources/bitmap_skpicture_content_layer_updater.h"
6 6
7 #include "base/time.h" 7 #include "base/time.h"
8 #include "cc/debug/rendering_stats.h" 8 #include "cc/debug/rendering_stats_instrumentation.h"
9 #include "cc/resources/layer_painter.h" 9 #include "cc/resources/layer_painter.h"
10 #include "cc/resources/prioritized_resource.h" 10 #include "cc/resources/prioritized_resource.h"
11 #include "cc/resources/resource_update_queue.h" 11 #include "cc/resources/resource_update_queue.h"
12 #include "third_party/skia/include/core/SkCanvas.h" 12 #include "third_party/skia/include/core/SkCanvas.h"
13 #include "third_party/skia/include/core/SkDevice.h" 13 #include "third_party/skia/include/core/SkDevice.h"
14 14
15 namespace cc { 15 namespace cc {
16 16
17 BitmapSkPictureContentLayerUpdater::Resource::Resource( 17 BitmapSkPictureContentLayerUpdater::Resource::Resource(
18 BitmapSkPictureContentLayerUpdater* updater, 18 BitmapSkPictureContentLayerUpdater* updater,
19 scoped_ptr<PrioritizedResource> texture) 19 scoped_ptr<PrioritizedResource> texture)
20 : ContentLayerUpdater::Resource(texture.Pass()), updater_(updater) {} 20 : ContentLayerUpdater::Resource(texture.Pass()), updater_(updater) {}
21 21
22 void BitmapSkPictureContentLayerUpdater::Resource::Update( 22 void BitmapSkPictureContentLayerUpdater::Resource::Update(
23 ResourceUpdateQueue* queue, 23 ResourceUpdateQueue* queue,
24 gfx::Rect source_rect, 24 gfx::Rect source_rect,
25 gfx::Vector2d dest_offset, 25 gfx::Vector2d dest_offset,
26 bool partial_update, 26 bool partial_update) {
27 RenderingStats* stats) {
28 bitmap_.setConfig( 27 bitmap_.setConfig(
29 SkBitmap::kARGB_8888_Config, source_rect.width(), source_rect.height()); 28 SkBitmap::kARGB_8888_Config, source_rect.width(), source_rect.height());
30 bitmap_.allocPixels(); 29 bitmap_.allocPixels();
31 bitmap_.setIsOpaque(updater_->layer_is_opaque()); 30 bitmap_.setIsOpaque(updater_->layer_is_opaque());
32 SkDevice device(bitmap_); 31 SkDevice device(bitmap_);
33 SkCanvas canvas(&device); 32 SkCanvas canvas(&device);
34 base::TimeTicks paint_begin_time; 33
35 if (stats) 34 updater_->PaintContentsRect(&canvas, source_rect);
36 paint_begin_time = base::TimeTicks::Now();
37 updater_->PaintContentsRect(&canvas, source_rect, stats);
38 if (stats)
39 stats->total_paint_time += base::TimeTicks::Now() - paint_begin_time;
40 35
41 ResourceUpdate upload = ResourceUpdate::Create( 36 ResourceUpdate upload = ResourceUpdate::Create(
42 texture(), &bitmap_, source_rect, source_rect, dest_offset); 37 texture(), &bitmap_, source_rect, source_rect, dest_offset);
43 if (partial_update) 38 if (partial_update)
44 queue->AppendPartialUpload(upload); 39 queue->AppendPartialUpload(upload);
45 else 40 else
46 queue->AppendFullUpload(upload); 41 queue->AppendFullUpload(upload);
47 } 42 }
48 43
49 scoped_refptr<BitmapSkPictureContentLayerUpdater> 44 scoped_refptr<BitmapSkPictureContentLayerUpdater>
50 BitmapSkPictureContentLayerUpdater::Create(scoped_ptr<LayerPainter> painter) { 45 BitmapSkPictureContentLayerUpdater::Create(
46 scoped_ptr<LayerPainter> painter,
47 RenderingStatsInstrumentation* stats_instrumentation) {
51 return make_scoped_refptr( 48 return make_scoped_refptr(
52 new BitmapSkPictureContentLayerUpdater(painter.Pass())); 49 new BitmapSkPictureContentLayerUpdater(painter.Pass(),
50 stats_instrumentation));
53 } 51 }
54 52
55 BitmapSkPictureContentLayerUpdater::BitmapSkPictureContentLayerUpdater( 53 BitmapSkPictureContentLayerUpdater::BitmapSkPictureContentLayerUpdater(
56 scoped_ptr<LayerPainter> painter) 54 scoped_ptr<LayerPainter> painter,
57 : SkPictureContentLayerUpdater(painter.Pass()) {} 55 RenderingStatsInstrumentation* stats_instrumentation)
56 : SkPictureContentLayerUpdater(painter.Pass(), stats_instrumentation) {}
58 57
59 BitmapSkPictureContentLayerUpdater::~BitmapSkPictureContentLayerUpdater() {} 58 BitmapSkPictureContentLayerUpdater::~BitmapSkPictureContentLayerUpdater() {}
60 59
61 scoped_ptr<LayerUpdater::Resource> 60 scoped_ptr<LayerUpdater::Resource>
62 BitmapSkPictureContentLayerUpdater::CreateResource( 61 BitmapSkPictureContentLayerUpdater::CreateResource(
63 PrioritizedResourceManager* manager) { 62 PrioritizedResourceManager* manager) {
64 return scoped_ptr<LayerUpdater::Resource>( 63 return scoped_ptr<LayerUpdater::Resource>(
65 new Resource(this, PrioritizedResource::Create(manager))); 64 new Resource(this, PrioritizedResource::Create(manager)));
66 } 65 }
67 66
68 void BitmapSkPictureContentLayerUpdater::PaintContentsRect( 67 void BitmapSkPictureContentLayerUpdater::PaintContentsRect(
69 SkCanvas* canvas, 68 SkCanvas* canvas,
70 gfx::Rect source_rect, 69 gfx::Rect source_rect) {
71 RenderingStats* stats) {
72 // Translate the origin of content_rect to that of source_rect. 70 // Translate the origin of content_rect to that of source_rect.
73 canvas->translate(content_rect().x() - source_rect.x(), 71 canvas->translate(content_rect().x() - source_rect.x(),
74 content_rect().y() - source_rect.y()); 72 content_rect().y() - source_rect.y());
75 base::TimeTicks rasterize_begin_time; 73
76 if (stats) 74 base::TimeTicks start_time =
77 rasterize_begin_time = base::TimeTicks::Now(); 75 rendering_stats_instrumentation_->StartRecording();
76
78 DrawPicture(canvas); 77 DrawPicture(canvas);
79 if (stats) { 78
80 stats->total_rasterize_time += 79 base::TimeDelta duration =
81 base::TimeTicks::Now() - rasterize_begin_time; 80 rendering_stats_instrumentation_->EndRecording(start_time);
82 stats->total_pixels_rasterized += 81 rendering_stats_instrumentation_->AddRaster(
83 source_rect.width() * source_rect.height(); 82 duration,
84 } 83 source_rect.width() * source_rect.height(),
84 false);
85
86 // TODO: Clarify if this needs to be saved here. crbug.com/223693
87 rendering_stats_instrumentation_->AddPaint(duration, 0);
85 } 88 }
86 89
87 } // namespace cc 90 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/bitmap_skpicture_content_layer_updater.h ('k') | cc/resources/caching_bitmap_content_layer_updater.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698