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/picture_layer_impl.h" | 5 #include "cc/picture_layer_impl.h" |
6 | 6 |
7 #include "base/time.h" | 7 #include "base/time.h" |
8 #include "cc/append_quads_data.h" | 8 #include "cc/append_quads_data.h" |
9 #include "cc/checkerboard_draw_quad.h" | 9 #include "cc/checkerboard_draw_quad.h" |
10 #include "cc/debug_border_draw_quad.h" | 10 #include "cc/debug_border_draw_quad.h" |
11 #include "cc/debug_colors.h" | 11 #include "cc/debug_colors.h" |
12 #include "cc/layer_tree_impl.h" | 12 #include "cc/layer_tree_impl.h" |
13 #include "cc/math_util.h" | 13 #include "cc/math_util.h" |
14 #include "cc/picture_draw_quad.h" | |
14 #include "cc/quad_sink.h" | 15 #include "cc/quad_sink.h" |
15 #include "cc/solid_color_draw_quad.h" | 16 #include "cc/solid_color_draw_quad.h" |
16 #include "cc/tile_draw_quad.h" | 17 #include "cc/tile_draw_quad.h" |
17 #include "cc/util.h" | 18 #include "cc/util.h" |
18 #include "ui/gfx/quad_f.h" | 19 #include "ui/gfx/quad_f.h" |
19 #include "ui/gfx/rect_conversions.h" | 20 #include "ui/gfx/rect_conversions.h" |
20 #include "ui/gfx/size_conversions.h" | 21 #include "ui/gfx/size_conversions.h" |
21 | 22 |
22 namespace { | 23 namespace { |
23 const float kMaxScaleRatioDuringPinch = 2.0f; | 24 const float kMaxScaleRatioDuringPinch = 2.0f; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 iter; | 113 iter; |
113 ++iter) { | 114 ++iter) { |
114 SkColor color; | 115 SkColor color; |
115 float width; | 116 float width; |
116 if (*iter && iter->drawing_info().IsReadyToDraw()) { | 117 if (*iter && iter->drawing_info().IsReadyToDraw()) { |
117 ManagedTileState::DrawingInfo::Mode mode = iter->drawing_info().mode(); | 118 ManagedTileState::DrawingInfo::Mode mode = iter->drawing_info().mode(); |
118 if (mode == ManagedTileState::DrawingInfo::SOLID_COLOR_MODE || | 119 if (mode == ManagedTileState::DrawingInfo::SOLID_COLOR_MODE || |
119 mode == ManagedTileState::DrawingInfo::TRANSPARENT_MODE) { | 120 mode == ManagedTileState::DrawingInfo::TRANSPARENT_MODE) { |
120 color = DebugColors::SolidColorTileBorderColor(); | 121 color = DebugColors::SolidColorTileBorderColor(); |
121 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); | 122 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); |
123 } else if (mode == ManagedTileState::DrawingInfo::PICTURE_PILE_MODE) { | |
124 color = DebugColors::PictureTileBorderColor(); | |
125 width = DebugColors::PictureTileBorderWidth(layer_tree_impl()); | |
122 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { | 126 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { |
123 color = DebugColors::HighResTileBorderColor(); | 127 color = DebugColors::HighResTileBorderColor(); |
124 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); | 128 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); |
125 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { | 129 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { |
126 color = DebugColors::LowResTileBorderColor(); | 130 color = DebugColors::LowResTileBorderColor(); |
127 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); | 131 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); |
128 } else if (iter->contents_scale() > contents_scale_x()) { | 132 } else if (iter->contents_scale() > contents_scale_x()) { |
129 color = DebugColors::ExtraHighResTileBorderColor(); | 133 color = DebugColors::ExtraHighResTileBorderColor(); |
130 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); | 134 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); |
131 } else { | 135 } else { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 if (quadSink->append(quad.PassAs<DrawQuad>(), appendQuadsData)) | 177 if (quadSink->append(quad.PassAs<DrawQuad>(), appendQuadsData)) |
174 appendQuadsData->numMissingTiles++; | 178 appendQuadsData->numMissingTiles++; |
175 } | 179 } |
176 | 180 |
177 appendQuadsData->hadIncompleteTile = true; | 181 appendQuadsData->hadIncompleteTile = true; |
178 continue; | 182 continue; |
179 } | 183 } |
180 | 184 |
181 const ManagedTileState::DrawingInfo& drawing_info = iter->drawing_info(); | 185 const ManagedTileState::DrawingInfo& drawing_info = iter->drawing_info(); |
182 switch (drawing_info.mode()) { | 186 switch (drawing_info.mode()) { |
183 case ManagedTileState::DrawingInfo::TEXTURE_MODE: { | 187 case ManagedTileState::DrawingInfo::TEXTURE_MODE: |
188 case ManagedTileState::DrawingInfo::PICTURE_PILE_MODE: { | |
vmpstr
2013/03/13 21:03:08
I not sure if it's worth combining the two cases,
Leandro GraciĆ” Gil
2013/03/19 17:30:07
The point is that if we add more code here for TEX
| |
184 if (iter->contents_scale() != ideal_contents_scale_) | 189 if (iter->contents_scale() != ideal_contents_scale_) |
185 appendQuadsData->hadIncompleteTile = true; | 190 appendQuadsData->hadIncompleteTile = true; |
186 | 191 |
187 gfx::RectF texture_rect = iter.texture_rect(); | 192 gfx::RectF texture_rect = iter.texture_rect(); |
188 gfx::Rect opaque_rect = iter->opaque_rect(); | 193 gfx::Rect opaque_rect = iter->opaque_rect(); |
189 opaque_rect.Intersect(content_rect); | 194 opaque_rect.Intersect(content_rect); |
190 | 195 |
191 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create(); | 196 if (drawing_info.mode() == |
192 quad->SetNew(sharedQuadState, | 197 ManagedTileState::DrawingInfo::TEXTURE_MODE) { |
193 geometry_rect, | 198 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create(); |
194 opaque_rect, | 199 quad->SetNew(sharedQuadState, |
195 drawing_info.get_resource_id(), | 200 geometry_rect, |
196 texture_rect, | 201 opaque_rect, |
197 iter.texture_size(), | 202 drawing_info.get_resource_id(), |
198 drawing_info.contents_swizzled()); | 203 texture_rect, |
199 quadSink->append(quad.PassAs<DrawQuad>(), appendQuadsData); | 204 iter.texture_size(), |
205 drawing_info.contents_swizzled()); | |
206 quadSink->append(quad.PassAs<DrawQuad>(), appendQuadsData); | |
207 } else { | |
208 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); | |
209 quad->SetNew(sharedQuadState, | |
210 geometry_rect, | |
211 opaque_rect, | |
212 texture_rect, | |
213 iter.texture_size(), | |
214 drawing_info.contents_swizzled(), | |
215 iter->content_rect(), | |
216 iter->contents_scale(), | |
217 pile_); | |
218 quadSink->append(quad.PassAs<DrawQuad>(), appendQuadsData); | |
219 } | |
200 break; | 220 break; |
201 } | 221 } |
202 case ManagedTileState::DrawingInfo::SOLID_COLOR_MODE: { | 222 case ManagedTileState::DrawingInfo::SOLID_COLOR_MODE: { |
203 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | 223 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
204 quad->SetNew(sharedQuadState, | 224 quad->SetNew(sharedQuadState, |
205 geometry_rect, | 225 geometry_rect, |
206 drawing_info.get_solid_color()); | 226 drawing_info.get_solid_color()); |
207 quadSink->append(quad.PassAs<DrawQuad>(), appendQuadsData); | 227 quadSink->append(quad.PassAs<DrawQuad>(), appendQuadsData); |
208 break; | 228 break; |
209 } | 229 } |
210 case ManagedTileState::DrawingInfo::TRANSPARENT_MODE: | 230 case ManagedTileState::DrawingInfo::TRANSPARENT_MODE: |
211 break; | 231 break; |
212 case ManagedTileState::DrawingInfo::PICTURE_PILE_MODE: | |
213 // TODO: crbug.com/173011 would fill this part in. | |
214 default: | 232 default: |
215 NOTREACHED(); | 233 NOTREACHED(); |
216 } | 234 } |
217 | 235 |
218 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling()) | 236 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling()) |
219 seen_tilings.push_back(iter.CurrentTiling()); | 237 seen_tilings.push_back(iter.CurrentTiling()); |
220 } | 238 } |
221 | 239 |
222 // Aggressively remove any tilings that are not seen to save memory. Note | 240 // Aggressively remove any tilings that are not seen to save memory. Note |
223 // that this is at the expense of doing cause more frequent re-painting. A | 241 // that this is at the expense of doing cause more frequent re-painting. A |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
803 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { | 821 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { |
804 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 822 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
805 LayerImpl::AsValueInto(state.get()); | 823 LayerImpl::AsValueInto(state.get()); |
806 | 824 |
807 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); | 825 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); |
808 state->Set("tilings", tilings_->AsValue().release()); | 826 state->Set("tilings", tilings_->AsValue().release()); |
809 return state.PassAs<base::Value>(); | 827 return state.PassAs<base::Value>(); |
810 } | 828 } |
811 | 829 |
812 } // namespace cc | 830 } // namespace cc |
OLD | NEW |