OLD | NEW |
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/devtools_instrumentation.h" | 7 #include "cc/debug/devtools_instrumentation.h" |
8 #include "cc/debug/rendering_stats_instrumentation.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.h" | 11 #include "cc/resources/resource_update.h" |
12 #include "cc/resources/resource_update_queue.h" | 12 #include "cc/resources/resource_update_queue.h" |
13 #include "skia/ext/platform_canvas.h" | 13 #include "skia/ext/platform_canvas.h" |
14 | 14 |
15 namespace cc { | 15 namespace cc { |
16 | 16 |
17 BitmapContentLayerUpdater::Resource::Resource( | 17 BitmapContentLayerUpdater::Resource::Resource( |
18 BitmapContentLayerUpdater* updater, | 18 BitmapContentLayerUpdater* updater, |
19 scoped_ptr<PrioritizedResource> texture) | 19 scoped_ptr<PrioritizedResource> texture) |
20 : LayerUpdater::Resource(texture.Pass()), updater_(updater) {} | 20 : LayerUpdater::Resource(texture.Pass()), updater_(updater) {} |
21 | 21 |
22 BitmapContentLayerUpdater::Resource::~Resource() {} | 22 BitmapContentLayerUpdater::Resource::~Resource() {} |
23 | 23 |
24 void BitmapContentLayerUpdater::Resource::Update(ResourceUpdateQueue* queue, | 24 void BitmapContentLayerUpdater::Resource::Update(ResourceUpdateQueue* queue, |
25 gfx::Rect source_rect, | 25 gfx::Rect source_rect, |
26 gfx::Vector2d dest_offset, | 26 gfx::Vector2d dest_offset, |
27 bool partial_update, | 27 bool partial_update) { |
28 RenderingStats* stats) { | |
29 updater_->UpdateTexture( | 28 updater_->UpdateTexture( |
30 queue, texture(), source_rect, dest_offset, partial_update); | 29 queue, texture(), source_rect, dest_offset, partial_update); |
31 } | 30 } |
32 | 31 |
33 scoped_refptr<BitmapContentLayerUpdater> BitmapContentLayerUpdater::Create( | 32 scoped_refptr<BitmapContentLayerUpdater> BitmapContentLayerUpdater::Create( |
34 scoped_ptr<LayerPainter> painter, | 33 scoped_ptr<LayerPainter> painter, |
35 RenderingStatsInstrumentation* stats_instrumentation, | 34 RenderingStatsInstrumentation* stats_instrumentation, |
36 int layer_id) { | 35 int layer_id) { |
37 return make_scoped_refptr( | 36 return make_scoped_refptr( |
38 new BitmapContentLayerUpdater(painter.Pass(), | 37 new BitmapContentLayerUpdater(painter.Pass(), |
(...skipping 14 matching lines...) Expand all Loading... |
53 PrioritizedResourceManager* manager) { | 52 PrioritizedResourceManager* manager) { |
54 return scoped_ptr<LayerUpdater::Resource>( | 53 return scoped_ptr<LayerUpdater::Resource>( |
55 new Resource(this, PrioritizedResource::Create(manager))); | 54 new Resource(this, PrioritizedResource::Create(manager))); |
56 } | 55 } |
57 | 56 |
58 void BitmapContentLayerUpdater::PrepareToUpdate( | 57 void BitmapContentLayerUpdater::PrepareToUpdate( |
59 gfx::Rect content_rect, | 58 gfx::Rect content_rect, |
60 gfx::Size tile_size, | 59 gfx::Size tile_size, |
61 float contents_width_scale, | 60 float contents_width_scale, |
62 float contents_height_scale, | 61 float contents_height_scale, |
63 gfx::Rect* resulting_opaque_rect, | 62 gfx::Rect* resulting_opaque_rect) { |
64 RenderingStats* stats) { | |
65 devtools_instrumentation::ScopedLayerTask paint_layer( | 63 devtools_instrumentation::ScopedLayerTask paint_layer( |
66 devtools_instrumentation::kPaintLayer, layer_id_); | 64 devtools_instrumentation::kPaintLayer, layer_id_); |
67 if (canvas_size_ != content_rect.size()) { | 65 if (canvas_size_ != content_rect.size()) { |
68 devtools_instrumentation::ScopedLayerTask paint_setup( | 66 devtools_instrumentation::ScopedLayerTask paint_setup( |
69 devtools_instrumentation::kPaintSetup, layer_id_); | 67 devtools_instrumentation::kPaintSetup, layer_id_); |
70 canvas_size_ = content_rect.size(); | 68 canvas_size_ = content_rect.size(); |
71 canvas_ = skia::AdoptRef(skia::CreateBitmapCanvas( | 69 canvas_ = skia::AdoptRef(skia::CreateBitmapCanvas( |
72 canvas_size_.width(), canvas_size_.height(), opaque_)); | 70 canvas_size_.width(), canvas_size_.height(), opaque_)); |
73 } | 71 } |
74 | 72 |
75 base::TimeTicks start_time = | 73 base::TimeTicks start_time = |
76 rendering_stats_instrumentation_->StartRecording(); | 74 rendering_stats_instrumentation_->StartRecording(); |
77 PaintContents(canvas_.get(), | 75 PaintContents(canvas_.get(), |
78 content_rect, | 76 content_rect, |
79 contents_width_scale, | 77 contents_width_scale, |
80 contents_height_scale, | 78 contents_height_scale, |
81 resulting_opaque_rect, | 79 resulting_opaque_rect); |
82 stats); | |
83 base::TimeDelta duration = | 80 base::TimeDelta duration = |
84 rendering_stats_instrumentation_->EndRecording(start_time); | 81 rendering_stats_instrumentation_->EndRecording(start_time); |
85 rendering_stats_instrumentation_->AddPaint( | 82 rendering_stats_instrumentation_->AddPaint( |
86 duration, | 83 duration, |
87 content_rect.width() * content_rect.height()); | 84 content_rect.width() * content_rect.height()); |
88 } | 85 } |
89 | 86 |
90 void BitmapContentLayerUpdater::UpdateTexture(ResourceUpdateQueue* queue, | 87 void BitmapContentLayerUpdater::UpdateTexture(ResourceUpdateQueue* queue, |
91 PrioritizedResource* texture, | 88 PrioritizedResource* texture, |
92 gfx::Rect source_rect, | 89 gfx::Rect source_rect, |
(...skipping 19 matching lines...) Expand all Loading... |
112 | 109 |
113 void BitmapContentLayerUpdater::SetOpaque(bool opaque) { | 110 void BitmapContentLayerUpdater::SetOpaque(bool opaque) { |
114 if (opaque != opaque_) { | 111 if (opaque != opaque_) { |
115 canvas_.clear(); | 112 canvas_.clear(); |
116 canvas_size_ = gfx::Size(); | 113 canvas_size_ = gfx::Size(); |
117 } | 114 } |
118 opaque_ = opaque; | 115 opaque_ = opaque; |
119 } | 116 } |
120 | 117 |
121 } // namespace cc | 118 } // namespace cc |
OLD | NEW |