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 <algorithm> |
| 8 |
7 #include "base/time.h" | 9 #include "base/time.h" |
8 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
9 #include "cc/base/util.h" | 11 #include "cc/base/util.h" |
10 #include "cc/debug/debug_colors.h" | 12 #include "cc/debug/debug_colors.h" |
11 #include "cc/layers/append_quads_data.h" | 13 #include "cc/layers/append_quads_data.h" |
12 #include "cc/layers/quad_sink.h" | 14 #include "cc/layers/quad_sink.h" |
13 #include "cc/quads/checkerboard_draw_quad.h" | 15 #include "cc/quads/checkerboard_draw_quad.h" |
14 #include "cc/quads/debug_border_draw_quad.h" | 16 #include "cc/quads/debug_border_draw_quad.h" |
15 #include "cc/quads/solid_color_draw_quad.h" | 17 #include "cc/quads/solid_color_draw_quad.h" |
16 #include "cc/quads/tile_draw_quad.h" | 18 #include "cc/quads/tile_draw_quad.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 // Keep track of the tilings that were used so that tilings that are | 149 // Keep track of the tilings that were used so that tilings that are |
148 // unused can be considered for removal. | 150 // unused can be considered for removal. |
149 std::vector<PictureLayerTiling*> seen_tilings; | 151 std::vector<PictureLayerTiling*> seen_tilings; |
150 | 152 |
151 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), | 153 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), |
152 contents_scale_x(), | 154 contents_scale_x(), |
153 rect, | 155 rect, |
154 ideal_contents_scale_); | 156 ideal_contents_scale_); |
155 iter; | 157 iter; |
156 ++iter) { | 158 ++iter) { |
157 | |
158 gfx::Rect geometry_rect = iter.geometry_rect(); | 159 gfx::Rect geometry_rect = iter.geometry_rect(); |
159 if (!*iter || !iter->drawing_info().IsReadyToDraw()) { | 160 if (!*iter || !iter->drawing_info().IsReadyToDraw()) { |
160 if (DrawCheckerboardForMissingTiles()) { | 161 if (DrawCheckerboardForMissingTiles()) { |
161 // TODO(enne): Figure out how to show debug "invalidated checker" color | 162 // TODO(enne): Figure out how to show debug "invalidated checker" color |
162 scoped_ptr<CheckerboardDrawQuad> quad = CheckerboardDrawQuad::Create(); | 163 scoped_ptr<CheckerboardDrawQuad> quad = CheckerboardDrawQuad::Create(); |
163 SkColor color = DebugColors::DefaultCheckerboardColor(); | 164 SkColor color = DebugColors::DefaultCheckerboardColor(); |
164 quad->SetNew(shared_quad_state, geometry_rect, color); | 165 quad->SetNew(shared_quad_state, geometry_rect, color); |
165 if (quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data)) | 166 if (quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data)) |
166 append_quads_data->num_missing_tiles++; | 167 append_quads_data->num_missing_tiles++; |
167 } else { | 168 } else { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | 201 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
201 quad->SetNew(shared_quad_state, | 202 quad->SetNew(shared_quad_state, |
202 geometry_rect, | 203 geometry_rect, |
203 drawing_info.get_solid_color()); | 204 drawing_info.get_solid_color()); |
204 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); | 205 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
205 break; | 206 break; |
206 } | 207 } |
207 case ManagedTileState::DrawingInfo::TRANSPARENT_MODE: | 208 case ManagedTileState::DrawingInfo::TRANSPARENT_MODE: |
208 break; | 209 break; |
209 case ManagedTileState::DrawingInfo::PICTURE_PILE_MODE: | 210 case ManagedTileState::DrawingInfo::PICTURE_PILE_MODE: |
210 // TODO: crbug.com/173011 would fill this part in. | 211 // TODO(leandrogarcia): crbug.com/173011 would fill this part in. |
211 default: | 212 default: |
212 NOTREACHED(); | 213 NOTREACHED(); |
213 } | 214 } |
214 | 215 |
215 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling()) | 216 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling()) |
216 seen_tilings.push_back(iter.CurrentTiling()); | 217 seen_tilings.push_back(iter.CurrentTiling()); |
217 } | 218 } |
218 | 219 |
219 // Aggressively remove any tilings that are not seen to save memory. Note | 220 // Aggressively remove any tilings that are not seen to save memory. Note |
220 // that this is at the expense of doing cause more frequent re-painting. A | 221 // that this is at the expense of doing cause more frequent re-painting. A |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 if (tiling->contents_scale() == contents_scale) { | 570 if (tiling->contents_scale() == contents_scale) { |
570 tilings_->Remove(tiling); | 571 tilings_->Remove(tiling); |
571 break; | 572 break; |
572 } | 573 } |
573 } | 574 } |
574 } | 575 } |
575 | 576 |
576 namespace { | 577 namespace { |
577 | 578 |
578 inline float PositiveRatio(float float1, float float2) { | 579 inline float PositiveRatio(float float1, float float2) { |
579 DCHECK(float1 > 0); | 580 DCHECK_GT(float1, 0); |
580 DCHECK(float2 > 0); | 581 DCHECK_GT(float2, 0); |
581 return float1 > float2 ? float1 / float2 : float2 / float1; | 582 return float1 > float2 ? float1 / float2 : float2 / float1; |
582 } | 583 } |
583 | 584 |
584 inline bool IsCloserToThan( | 585 inline bool IsCloserToThan( |
585 PictureLayerTiling* layer1, | 586 PictureLayerTiling* layer1, |
586 PictureLayerTiling* layer2, | 587 PictureLayerTiling* layer2, |
587 float contents_scale) { | 588 float contents_scale) { |
588 // Absolute value for ratios. | 589 // Absolute value for ratios. |
589 float ratio1 = PositiveRatio(layer1->contents_scale(), contents_scale); | 590 float ratio1 = PositiveRatio(layer1->contents_scale(), contents_scale); |
590 float ratio2 = PositiveRatio(layer2->contents_scale(), contents_scale); | 591 float ratio2 = PositiveRatio(layer2->contents_scale(), contents_scale); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { | 841 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { |
841 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 842 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
842 LayerImpl::AsValueInto(state.get()); | 843 LayerImpl::AsValueInto(state.get()); |
843 | 844 |
844 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); | 845 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); |
845 state->Set("tilings", tilings_->AsValue().release()); | 846 state->Set("tilings", tilings_->AsValue().release()); |
846 return state.PassAs<base::Value>(); | 847 return state.PassAs<base::Value>(); |
847 } | 848 } |
848 | 849 |
849 } // namespace cc | 850 } // namespace cc |
OLD | NEW |