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

Side by Side Diff: cc/resources/bitmap_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: 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_content_layer_updater.h" 5 #include "cc/resources/bitmap_content_layer_updater.h"
6 6
7 #include "cc/debug/rendering_stats.h" 7 #include "cc/debug/rendering_stats_instrumentation.h"
8 #include "cc/resources/layer_painter.h" 8 #include "cc/resources/layer_painter.h"
9 #include "cc/resources/prioritized_resource.h" 9 #include "cc/resources/prioritized_resource.h"
10 #include "cc/resources/resource_update.h" 10 #include "cc/resources/resource_update.h"
11 #include "cc/resources/resource_update_queue.h" 11 #include "cc/resources/resource_update_queue.h"
12 #include "skia/ext/platform_canvas.h" 12 #include "skia/ext/platform_canvas.h"
13 13
14 namespace cc { 14 namespace cc {
15 15
16 BitmapContentLayerUpdater::Resource::Resource( 16 BitmapContentLayerUpdater::Resource::Resource(
17 BitmapContentLayerUpdater* updater, 17 BitmapContentLayerUpdater* updater,
18 scoped_ptr<PrioritizedResource> texture) 18 scoped_ptr<PrioritizedResource> texture)
19 : LayerUpdater::Resource(texture.Pass()), updater_(updater) {} 19 : LayerUpdater::Resource(texture.Pass()), updater_(updater) {}
20 20
21 BitmapContentLayerUpdater::Resource::~Resource() {} 21 BitmapContentLayerUpdater::Resource::~Resource() {}
22 22
23 void BitmapContentLayerUpdater::Resource::Update(ResourceUpdateQueue* queue, 23 void BitmapContentLayerUpdater::Resource::Update(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 updater_->UpdateTexture( 27 updater_->UpdateTexture(
29 queue, texture(), source_rect, dest_offset, partial_update); 28 queue, texture(), source_rect, dest_offset, partial_update);
30 } 29 }
31 30
32 scoped_refptr<BitmapContentLayerUpdater> BitmapContentLayerUpdater::Create( 31 scoped_refptr<BitmapContentLayerUpdater> BitmapContentLayerUpdater::Create(
33 scoped_ptr<LayerPainter> painter) { 32 scoped_ptr<LayerPainter> painter,
34 return make_scoped_refptr(new BitmapContentLayerUpdater(painter.Pass())); 33 RenderingStatsInstrumentation* stats_instrumentation) {
34 return make_scoped_refptr(
35 new BitmapContentLayerUpdater(painter.Pass(), stats_instrumentation));
35 } 36 }
36 37
37 BitmapContentLayerUpdater::BitmapContentLayerUpdater( 38 BitmapContentLayerUpdater::BitmapContentLayerUpdater(
38 scoped_ptr<LayerPainter> painter) 39 scoped_ptr<LayerPainter> painter,
39 : ContentLayerUpdater(painter.Pass()), opaque_(false) {} 40 RenderingStatsInstrumentation* stats_instrumentation)
41 : ContentLayerUpdater(painter.Pass(), stats_instrumentation),
42 opaque_(false) {}
40 43
41 BitmapContentLayerUpdater::~BitmapContentLayerUpdater() {} 44 BitmapContentLayerUpdater::~BitmapContentLayerUpdater() {}
42 45
43 scoped_ptr<LayerUpdater::Resource> BitmapContentLayerUpdater::CreateResource( 46 scoped_ptr<LayerUpdater::Resource> BitmapContentLayerUpdater::CreateResource(
44 PrioritizedResourceManager* manager) { 47 PrioritizedResourceManager* manager) {
45 return scoped_ptr<LayerUpdater::Resource>( 48 return scoped_ptr<LayerUpdater::Resource>(
46 new Resource(this, PrioritizedResource::Create(manager))); 49 new Resource(this, PrioritizedResource::Create(manager)));
47 } 50 }
48 51
49 void BitmapContentLayerUpdater::PrepareToUpdate( 52 void BitmapContentLayerUpdater::PrepareToUpdate(
50 gfx::Rect content_rect, 53 gfx::Rect content_rect,
51 gfx::Size tile_size, 54 gfx::Size tile_size,
52 float contents_width_scale, 55 float contents_width_scale,
53 float contents_height_scale, 56 float contents_height_scale,
54 gfx::Rect* resulting_opaque_rect, 57 gfx::Rect* resulting_opaque_rect) {
55 RenderingStats* stats) {
56 if (canvas_size_ != content_rect.size()) { 58 if (canvas_size_ != content_rect.size()) {
57 canvas_size_ = content_rect.size(); 59 canvas_size_ = content_rect.size();
58 canvas_ = make_scoped_ptr(skia::CreateBitmapCanvas( 60 canvas_ = make_scoped_ptr(skia::CreateBitmapCanvas(
59 canvas_size_.width(), canvas_size_.height(), opaque_)); 61 canvas_size_.width(), canvas_size_.height(), opaque_));
60 } 62 }
61 63
62 if (stats) { 64 rendering_stats_instrumentation_->AddRaster(
63 stats->totalPixelsRasterized += 65 base::TimeDelta(),
egraether 2013/03/23 00:15:40 No rasterize time saved here, should we change tha
danakj 2013/03/23 01:56:32 It will be equal to the paint time, and I think th
egraether 2013/03/25 21:07:44 Had a chat with hartmanng, he was not sure what's
danakj 2013/03/26 18:47:50 Ok, can you add a TODO that points to the crbug in
64 content_rect.width() * content_rect.height(); 66 content_rect.width() * content_rect.height(),
65 } 67 false);
66 68
67 PaintContents(canvas_.get(), 69 PaintContents(canvas_.get(),
68 content_rect, 70 content_rect,
69 contents_width_scale, 71 contents_width_scale,
70 contents_height_scale, 72 contents_height_scale,
71 resulting_opaque_rect, 73 resulting_opaque_rect);
72 stats);
73 } 74 }
74 75
75 void BitmapContentLayerUpdater::UpdateTexture(ResourceUpdateQueue* queue, 76 void BitmapContentLayerUpdater::UpdateTexture(ResourceUpdateQueue* queue,
76 PrioritizedResource* texture, 77 PrioritizedResource* texture,
77 gfx::Rect source_rect, 78 gfx::Rect source_rect,
78 gfx::Vector2d dest_offset, 79 gfx::Vector2d dest_offset,
79 bool partial_update) { 80 bool partial_update) {
80 ResourceUpdate upload = 81 ResourceUpdate upload =
81 ResourceUpdate::Create(texture, 82 ResourceUpdate::Create(texture,
82 &canvas_->getDevice()->accessBitmap(false), 83 &canvas_->getDevice()->accessBitmap(false),
83 content_rect(), 84 content_rect(),
84 source_rect, 85 source_rect,
85 dest_offset); 86 dest_offset);
86 if (partial_update) 87 if (partial_update)
87 queue->AppendPartialUpload(upload); 88 queue->AppendPartialUpload(upload);
88 else 89 else
89 queue->AppendFullUpload(upload); 90 queue->AppendFullUpload(upload);
90 } 91 }
91 92
92 void BitmapContentLayerUpdater::SetOpaque(bool opaque) { 93 void BitmapContentLayerUpdater::SetOpaque(bool opaque) {
93 if (opaque != opaque_) { 94 if (opaque != opaque_) {
94 canvas_.reset(); 95 canvas_.reset();
95 canvas_size_ = gfx::Size(); 96 canvas_size_ = gfx::Size();
96 } 97 }
97 opaque_ = opaque; 98 opaque_ = opaque;
98 } 99 }
99 100
100 } // namespace cc 101 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698