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

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: 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_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 // TODO: Clarify if this needs to be saved here. crbug.com/223693
63 stats->total_pixels_rasterized += 65 rendering_stats_instrumentation_->AddRaster(
64 content_rect.width() * content_rect.height(); 66 base::TimeDelta(),
65 } 67 content_rect.width() * content_rect.height(),
68 false);
66 69
67 PaintContents(canvas_.get(), 70 PaintContents(canvas_.get(),
68 content_rect, 71 content_rect,
69 contents_width_scale, 72 contents_width_scale,
70 contents_height_scale, 73 contents_height_scale,
71 resulting_opaque_rect, 74 resulting_opaque_rect);
72 stats);
73 } 75 }
74 76
75 void BitmapContentLayerUpdater::UpdateTexture(ResourceUpdateQueue* queue, 77 void BitmapContentLayerUpdater::UpdateTexture(ResourceUpdateQueue* queue,
76 PrioritizedResource* texture, 78 PrioritizedResource* texture,
77 gfx::Rect source_rect, 79 gfx::Rect source_rect,
78 gfx::Vector2d dest_offset, 80 gfx::Vector2d dest_offset,
79 bool partial_update) { 81 bool partial_update) {
80 ResourceUpdate upload = 82 ResourceUpdate upload =
81 ResourceUpdate::Create(texture, 83 ResourceUpdate::Create(texture,
82 &canvas_->getDevice()->accessBitmap(false), 84 &canvas_->getDevice()->accessBitmap(false),
83 content_rect(), 85 content_rect(),
84 source_rect, 86 source_rect,
85 dest_offset); 87 dest_offset);
86 if (partial_update) 88 if (partial_update)
87 queue->AppendPartialUpload(upload); 89 queue->AppendPartialUpload(upload);
88 else 90 else
89 queue->AppendFullUpload(upload); 91 queue->AppendFullUpload(upload);
90 } 92 }
91 93
92 void BitmapContentLayerUpdater::SetOpaque(bool opaque) { 94 void BitmapContentLayerUpdater::SetOpaque(bool opaque) {
93 if (opaque != opaque_) { 95 if (opaque != opaque_) {
94 canvas_.reset(); 96 canvas_.reset();
95 canvas_size_ = gfx::Size(); 97 canvas_size_ = gfx::Size();
96 } 98 }
97 opaque_ = opaque; 99 opaque_ = opaque;
98 } 100 }
99 101
100 } // namespace cc 102 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/bitmap_content_layer_updater.h ('k') | cc/resources/bitmap_skpicture_content_layer_updater.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698