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( |
25 const gfx::Rect& source_rect, | 25 ResourceUpdateQueue* queue, |
26 gfx::Vector2d dest_offset, | 26 const gfx::Rect& source_rect, |
27 bool partial_update) { | 27 const gfx::Vector2d& dest_offset, |
| 28 bool partial_update) { |
28 updater_->UpdateTexture( | 29 updater_->UpdateTexture( |
29 queue, texture(), source_rect, dest_offset, partial_update); | 30 queue, texture(), source_rect, dest_offset, partial_update); |
30 } | 31 } |
31 | 32 |
32 scoped_refptr<BitmapContentLayerUpdater> BitmapContentLayerUpdater::Create( | 33 scoped_refptr<BitmapContentLayerUpdater> BitmapContentLayerUpdater::Create( |
33 scoped_ptr<LayerPainter> painter, | 34 scoped_ptr<LayerPainter> painter, |
34 RenderingStatsInstrumentation* stats_instrumentation, | 35 RenderingStatsInstrumentation* stats_instrumentation, |
35 int layer_id) { | 36 int layer_id) { |
36 return make_scoped_refptr( | 37 return make_scoped_refptr( |
37 new BitmapContentLayerUpdater(painter.Pass(), | 38 new BitmapContentLayerUpdater(painter.Pass(), |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 base::TimeDelta duration = | 82 base::TimeDelta duration = |
82 rendering_stats_instrumentation_->EndRecording(start_time); | 83 rendering_stats_instrumentation_->EndRecording(start_time); |
83 rendering_stats_instrumentation_->AddPaint( | 84 rendering_stats_instrumentation_->AddPaint( |
84 duration, | 85 duration, |
85 content_rect.width() * content_rect.height()); | 86 content_rect.width() * content_rect.height()); |
86 } | 87 } |
87 | 88 |
88 void BitmapContentLayerUpdater::UpdateTexture(ResourceUpdateQueue* queue, | 89 void BitmapContentLayerUpdater::UpdateTexture(ResourceUpdateQueue* queue, |
89 PrioritizedResource* texture, | 90 PrioritizedResource* texture, |
90 const gfx::Rect& source_rect, | 91 const gfx::Rect& source_rect, |
91 gfx::Vector2d dest_offset, | 92 const gfx::Vector2d& dest_offset, |
92 bool partial_update) { | 93 bool partial_update) { |
93 CHECK(canvas_); | 94 CHECK(canvas_); |
94 ResourceUpdate upload = ResourceUpdate::Create(texture, | 95 ResourceUpdate upload = ResourceUpdate::Create(texture, |
95 &bitmap_backing_, | 96 &bitmap_backing_, |
96 content_rect(), | 97 content_rect(), |
97 source_rect, | 98 source_rect, |
98 dest_offset); | 99 dest_offset); |
99 if (partial_update) | 100 if (partial_update) |
100 queue->AppendPartialUpload(upload); | 101 queue->AppendPartialUpload(upload); |
101 else | 102 else |
102 queue->AppendFullUpload(upload); | 103 queue->AppendFullUpload(upload); |
103 } | 104 } |
104 | 105 |
105 void BitmapContentLayerUpdater::ReduceMemoryUsage() { | 106 void BitmapContentLayerUpdater::ReduceMemoryUsage() { |
106 canvas_.clear(); | 107 canvas_.clear(); |
107 canvas_size_ = gfx::Size(); | 108 canvas_size_ = gfx::Size(); |
108 } | 109 } |
109 | 110 |
110 void BitmapContentLayerUpdater::SetOpaque(bool opaque) { | 111 void BitmapContentLayerUpdater::SetOpaque(bool opaque) { |
111 if (opaque != layer_is_opaque_) { | 112 if (opaque != layer_is_opaque_) { |
112 canvas_.clear(); | 113 canvas_.clear(); |
113 canvas_size_ = gfx::Size(); | 114 canvas_size_ = gfx::Size(); |
114 } | 115 } |
115 | 116 |
116 ContentLayerUpdater::SetOpaque(opaque); | 117 ContentLayerUpdater::SetOpaque(opaque); |
117 } | 118 } |
118 | 119 |
119 } // namespace cc | 120 } // namespace cc |
OLD | NEW |