OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
6 | 6 |
7 #include "base/time.h" | 7 #include "base/time.h" |
8 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
9 #include "cc/base/util.h" | 9 #include "cc/base/util.h" |
10 #include "cc/debug/debug_colors.h" | 10 #include "cc/debug/debug_colors.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 layer_impl->pile_ = pile_; | 77 layer_impl->pile_ = pile_; |
78 pile_ = PicturePileImpl::Create(is_using_lcd_text_); | 78 pile_ = PicturePileImpl::Create(is_using_lcd_text_); |
79 | 79 |
80 layer_impl->raster_page_scale_ = raster_page_scale_; | 80 layer_impl->raster_page_scale_ = raster_page_scale_; |
81 layer_impl->raster_device_scale_ = raster_device_scale_; | 81 layer_impl->raster_device_scale_ = raster_device_scale_; |
82 layer_impl->raster_source_scale_ = raster_source_scale_; | 82 layer_impl->raster_source_scale_ = raster_source_scale_; |
83 layer_impl->is_using_lcd_text_ = is_using_lcd_text_; | 83 layer_impl->is_using_lcd_text_ = is_using_lcd_text_; |
84 } | 84 } |
85 | 85 |
86 | 86 |
87 void PictureLayerImpl::AppendQuads(QuadSink* quadSink, | 87 void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, |
88 AppendQuadsData* appendQuadsData) { | 88 AppendQuadsData* append_quads_data) { |
89 const gfx::Rect& rect = visible_content_rect(); | 89 const gfx::Rect& rect = visible_content_rect(); |
90 gfx::Rect content_rect(content_bounds()); | 90 gfx::Rect content_rect(content_bounds()); |
91 | 91 |
92 SharedQuadState* sharedQuadState = | 92 SharedQuadState* shared_quad_state = |
93 quadSink->UseSharedQuadState(CreateSharedQuadState()); | 93 quad_sink->UseSharedQuadState(CreateSharedQuadState()); |
94 AppendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); | 94 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); |
95 | 95 |
96 bool clipped = false; | 96 bool clipped = false; |
97 gfx::QuadF target_quad = MathUtil::MapQuad( | 97 gfx::QuadF target_quad = MathUtil::MapQuad( |
98 draw_transform(), | 98 draw_transform(), |
99 gfx::QuadF(rect), | 99 gfx::QuadF(rect), |
100 &clipped); | 100 &clipped); |
101 if (ShowDebugBorders()) { | 101 if (ShowDebugBorders()) { |
102 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), | 102 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), |
103 contents_scale_x(), | 103 contents_scale_x(), |
104 rect, | 104 rect, |
(...skipping 19 matching lines...) Expand all Loading... |
124 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); | 124 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); |
125 } else { | 125 } else { |
126 color = DebugColors::ExtraLowResTileBorderColor(); | 126 color = DebugColors::ExtraLowResTileBorderColor(); |
127 width = DebugColors::ExtraLowResTileBorderWidth(layer_tree_impl()); | 127 width = DebugColors::ExtraLowResTileBorderWidth(layer_tree_impl()); |
128 } | 128 } |
129 } else { | 129 } else { |
130 color = DebugColors::MissingTileBorderColor(); | 130 color = DebugColors::MissingTileBorderColor(); |
131 width = DebugColors::MissingTileBorderWidth(layer_tree_impl()); | 131 width = DebugColors::MissingTileBorderWidth(layer_tree_impl()); |
132 } | 132 } |
133 | 133 |
134 scoped_ptr<DebugBorderDrawQuad> debugBorderQuad = | 134 scoped_ptr<DebugBorderDrawQuad> debug_border_quad = |
135 DebugBorderDrawQuad::Create(); | 135 DebugBorderDrawQuad::Create(); |
136 gfx::Rect geometry_rect = iter.geometry_rect(); | 136 gfx::Rect geometry_rect = iter.geometry_rect(); |
137 debugBorderQuad->SetNew(sharedQuadState, geometry_rect, color, width); | 137 debug_border_quad->SetNew(shared_quad_state, geometry_rect, color, width); |
138 quadSink->Append(debugBorderQuad.PassAs<DrawQuad>(), appendQuadsData); | 138 quad_sink->Append(debug_border_quad.PassAs<DrawQuad>(), |
| 139 append_quads_data); |
139 } | 140 } |
140 } | 141 } |
141 | 142 |
142 // Keep track of the tilings that were used so that tilings that are | 143 // Keep track of the tilings that were used so that tilings that are |
143 // unused can be considered for removal. | 144 // unused can be considered for removal. |
144 std::vector<PictureLayerTiling*> seen_tilings; | 145 std::vector<PictureLayerTiling*> seen_tilings; |
145 | 146 |
146 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), | 147 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), |
147 contents_scale_x(), | 148 contents_scale_x(), |
148 rect, | 149 rect, |
149 ideal_contents_scale_); | 150 ideal_contents_scale_); |
150 iter; | 151 iter; |
151 ++iter) { | 152 ++iter) { |
152 | 153 |
153 gfx::Rect geometry_rect = iter.geometry_rect(); | 154 gfx::Rect geometry_rect = iter.geometry_rect(); |
154 if (!*iter || !iter->drawing_info().IsReadyToDraw()) { | 155 if (!*iter || !iter->drawing_info().IsReadyToDraw()) { |
155 if (DrawCheckerboardForMissingTiles()) { | 156 if (DrawCheckerboardForMissingTiles()) { |
156 // TODO(enne): Figure out how to show debug "invalidated checker" color | 157 // TODO(enne): Figure out how to show debug "invalidated checker" color |
157 scoped_ptr<CheckerboardDrawQuad> quad = CheckerboardDrawQuad::Create(); | 158 scoped_ptr<CheckerboardDrawQuad> quad = CheckerboardDrawQuad::Create(); |
158 SkColor color = DebugColors::DefaultCheckerboardColor(); | 159 SkColor color = DebugColors::DefaultCheckerboardColor(); |
159 quad->SetNew(sharedQuadState, geometry_rect, color); | 160 quad->SetNew(shared_quad_state, geometry_rect, color); |
160 if (quadSink->Append(quad.PassAs<DrawQuad>(), appendQuadsData)) | 161 if (quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data)) |
161 appendQuadsData->numMissingTiles++; | 162 append_quads_data->numMissingTiles++; |
162 } else { | 163 } else { |
163 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | 164 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
164 quad->SetNew(sharedQuadState, geometry_rect, background_color()); | 165 quad->SetNew(shared_quad_state, geometry_rect, background_color()); |
165 if (quadSink->Append(quad.PassAs<DrawQuad>(), appendQuadsData)) | 166 if (quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data)) |
166 appendQuadsData->numMissingTiles++; | 167 append_quads_data->numMissingTiles++; |
167 } | 168 } |
168 | 169 |
169 appendQuadsData->hadIncompleteTile = true; | 170 append_quads_data->hadIncompleteTile = true; |
170 continue; | 171 continue; |
171 } | 172 } |
172 | 173 |
173 const ManagedTileState::DrawingInfo& drawing_info = iter->drawing_info(); | 174 const ManagedTileState::DrawingInfo& drawing_info = iter->drawing_info(); |
174 switch (drawing_info.mode()) { | 175 switch (drawing_info.mode()) { |
175 case ManagedTileState::DrawingInfo::TEXTURE_MODE: { | 176 case ManagedTileState::DrawingInfo::TEXTURE_MODE: { |
176 if (iter->contents_scale() != ideal_contents_scale_) | 177 if (iter->contents_scale() != ideal_contents_scale_) |
177 appendQuadsData->hadIncompleteTile = true; | 178 append_quads_data->hadIncompleteTile = true; |
178 | 179 |
179 gfx::RectF texture_rect = iter.texture_rect(); | 180 gfx::RectF texture_rect = iter.texture_rect(); |
180 gfx::Rect opaque_rect = iter->opaque_rect(); | 181 gfx::Rect opaque_rect = iter->opaque_rect(); |
181 opaque_rect.Intersect(content_rect); | 182 opaque_rect.Intersect(content_rect); |
182 | 183 |
183 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create(); | 184 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create(); |
184 quad->SetNew(sharedQuadState, | 185 quad->SetNew(shared_quad_state, |
185 geometry_rect, | 186 geometry_rect, |
186 opaque_rect, | 187 opaque_rect, |
187 drawing_info.get_resource_id(), | 188 drawing_info.get_resource_id(), |
188 texture_rect, | 189 texture_rect, |
189 iter.texture_size(), | 190 iter.texture_size(), |
190 drawing_info.contents_swizzled()); | 191 drawing_info.contents_swizzled()); |
191 quadSink->Append(quad.PassAs<DrawQuad>(), appendQuadsData); | 192 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
192 break; | 193 break; |
193 } | 194 } |
194 case ManagedTileState::DrawingInfo::SOLID_COLOR_MODE: { | 195 case ManagedTileState::DrawingInfo::SOLID_COLOR_MODE: { |
195 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | 196 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
196 quad->SetNew(sharedQuadState, | 197 quad->SetNew(shared_quad_state, |
197 geometry_rect, | 198 geometry_rect, |
198 drawing_info.get_solid_color()); | 199 drawing_info.get_solid_color()); |
199 quadSink->Append(quad.PassAs<DrawQuad>(), appendQuadsData); | 200 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
200 break; | 201 break; |
201 } | 202 } |
202 case ManagedTileState::DrawingInfo::TRANSPARENT_MODE: | 203 case ManagedTileState::DrawingInfo::TRANSPARENT_MODE: |
203 break; | 204 break; |
204 case ManagedTileState::DrawingInfo::PICTURE_PILE_MODE: | 205 case ManagedTileState::DrawingInfo::PICTURE_PILE_MODE: |
205 // TODO: crbug.com/173011 would fill this part in. | 206 // TODO: crbug.com/173011 would fill this part in. |
206 default: | 207 default: |
207 NOTREACHED(); | 208 NOTREACHED(); |
208 } | 209 } |
209 | 210 |
210 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling()) | 211 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling()) |
211 seen_tilings.push_back(iter.CurrentTiling()); | 212 seen_tilings.push_back(iter.CurrentTiling()); |
212 } | 213 } |
213 | 214 |
214 // Aggressively remove any tilings that are not seen to save memory. Note | 215 // Aggressively remove any tilings that are not seen to save memory. Note |
215 // that this is at the expense of doing cause more frequent re-painting. A | 216 // that this is at the expense of doing cause more frequent re-painting. A |
216 // better scheme would be to maintain a tighter visibleContentRect for the | 217 // better scheme would be to maintain a tighter visible_content_rect for the |
217 // finer tilings. | 218 // finer tilings. |
218 CleanUpTilingsOnActiveLayer(seen_tilings); | 219 CleanUpTilingsOnActiveLayer(seen_tilings); |
219 } | 220 } |
220 | 221 |
221 void PictureLayerImpl::DumpLayerProperties(std::string*, int indent) const { | 222 void PictureLayerImpl::DumpLayerProperties(std::string*, int indent) const { |
222 // TODO(enne): implement me | 223 // TODO(enne): implement me |
223 } | 224 } |
224 | 225 |
225 void PictureLayerImpl::UpdateTilePriorities() { | 226 void PictureLayerImpl::UpdateTilePriorities() { |
226 UpdateLCDTextStatus(); | 227 UpdateLCDTextStatus(); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 if (any_dimension_one_tile || !any_dimension_too_large) { | 373 if (any_dimension_one_tile || !any_dimension_too_large) { |
373 int width = | 374 int width = |
374 std::min(max_untiled_content_size.width(), content_bounds.width()); | 375 std::min(max_untiled_content_size.width(), content_bounds.width()); |
375 int height = | 376 int height = |
376 std::min(max_untiled_content_size.height(), content_bounds.height()); | 377 std::min(max_untiled_content_size.height(), content_bounds.height()); |
377 // Round width and height up to the closest multiple of 64, or 56 if | 378 // Round width and height up to the closest multiple of 64, or 56 if |
378 // we should avoid power-of-two textures. This helps reduce the number | 379 // we should avoid power-of-two textures. This helps reduce the number |
379 // of different textures sizes to help recycling, and also keeps all | 380 // of different textures sizes to help recycling, and also keeps all |
380 // textures multiple-of-eight, which is preferred on some drivers (IMG). | 381 // textures multiple-of-eight, which is preferred on some drivers (IMG). |
381 bool avoid_pow2 = | 382 bool avoid_pow2 = |
382 layer_tree_impl()->rendererCapabilities().avoid_pow2_textures; | 383 layer_tree_impl()->GetRendererCapabilities().avoid_pow2_textures; |
383 int round_up_to = avoid_pow2 ? 56 : 64; | 384 int round_up_to = avoid_pow2 ? 56 : 64; |
384 width = RoundUp(width, round_up_to); | 385 width = RoundUp(width, round_up_to); |
385 height = RoundUp(height, round_up_to); | 386 height = RoundUp(height, round_up_to); |
386 return gfx::Size(width, height); | 387 return gfx::Size(width, height); |
387 } | 388 } |
388 | 389 |
389 return default_tile_size; | 390 return default_tile_size; |
390 } | 391 } |
391 | 392 |
392 void PictureLayerImpl::SyncFromActiveLayer() { | 393 void PictureLayerImpl::SyncFromActiveLayer() { |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { | 846 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { |
846 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 847 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
847 LayerImpl::AsValueInto(state.get()); | 848 LayerImpl::AsValueInto(state.get()); |
848 | 849 |
849 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); | 850 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); |
850 state->Set("tilings", tilings_->AsValue().release()); | 851 state->Set("tilings", tilings_->AsValue().release()); |
851 return state.PassAs<base::Value>(); | 852 return state.PassAs<base::Value>(); |
852 } | 853 } |
853 | 854 |
854 } // namespace cc | 855 } // namespace cc |
OLD | NEW |