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> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
11 #include "cc/base/util.h" | 11 #include "cc/base/util.h" |
12 #include "cc/debug/debug_colors.h" | 12 #include "cc/debug/debug_colors.h" |
13 #include "cc/layers/append_quads_data.h" | 13 #include "cc/layers/append_quads_data.h" |
14 #include "cc/layers/quad_sink.h" | 14 #include "cc/layers/quad_sink.h" |
15 #include "cc/quads/checkerboard_draw_quad.h" | 15 #include "cc/quads/checkerboard_draw_quad.h" |
16 #include "cc/quads/debug_border_draw_quad.h" | 16 #include "cc/quads/debug_border_draw_quad.h" |
| 17 #include "cc/quads/picture_draw_quad.h" |
17 #include "cc/quads/solid_color_draw_quad.h" | 18 #include "cc/quads/solid_color_draw_quad.h" |
18 #include "cc/quads/tile_draw_quad.h" | 19 #include "cc/quads/tile_draw_quad.h" |
19 #include "cc/trees/layer_tree_impl.h" | 20 #include "cc/trees/layer_tree_impl.h" |
20 #include "ui/gfx/quad_f.h" | 21 #include "ui/gfx/quad_f.h" |
21 #include "ui/gfx/rect_conversions.h" | 22 #include "ui/gfx/rect_conversions.h" |
22 #include "ui/gfx/size_conversions.h" | 23 #include "ui/gfx/size_conversions.h" |
23 | 24 |
24 namespace { | 25 namespace { |
25 const float kMaxScaleRatioDuringPinch = 2.0f; | 26 const float kMaxScaleRatioDuringPinch = 2.0f; |
26 } | 27 } |
(...skipping 85 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 if (quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data)) | 175 if (quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data)) |
172 append_quads_data->num_missing_tiles++; | 176 append_quads_data->num_missing_tiles++; |
173 } | 177 } |
174 | 178 |
175 append_quads_data->had_incomplete_tile = true; | 179 append_quads_data->had_incomplete_tile = true; |
176 continue; | 180 continue; |
177 } | 181 } |
178 | 182 |
179 const ManagedTileState::DrawingInfo& drawing_info = iter->drawing_info(); | 183 const ManagedTileState::DrawingInfo& drawing_info = iter->drawing_info(); |
180 switch (drawing_info.mode()) { | 184 switch (drawing_info.mode()) { |
181 case ManagedTileState::DrawingInfo::TEXTURE_MODE: { | 185 case ManagedTileState::DrawingInfo::RESOURCE_MODE: { |
182 if (iter->contents_scale() != ideal_contents_scale_) | |
183 append_quads_data->had_incomplete_tile = true; | |
184 | |
185 gfx::RectF texture_rect = iter.texture_rect(); | 186 gfx::RectF texture_rect = iter.texture_rect(); |
186 gfx::Rect opaque_rect = iter->opaque_rect(); | 187 gfx::Rect opaque_rect = iter->opaque_rect(); |
187 opaque_rect.Intersect(content_rect); | 188 opaque_rect.Intersect(content_rect); |
188 | 189 |
| 190 if (iter->contents_scale() != ideal_contents_scale_) |
| 191 append_quads_data->had_incomplete_tile = true; |
| 192 |
189 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create(); | 193 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create(); |
190 quad->SetNew(shared_quad_state, | 194 quad->SetNew(shared_quad_state, |
191 geometry_rect, | 195 geometry_rect, |
192 opaque_rect, | 196 opaque_rect, |
193 drawing_info.get_resource_id(), | 197 drawing_info.get_resource_id(), |
194 texture_rect, | 198 texture_rect, |
195 iter.texture_size(), | 199 iter.texture_size(), |
196 drawing_info.contents_swizzled()); | 200 drawing_info.contents_swizzled()); |
197 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); | 201 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
198 break; | 202 break; |
199 } | 203 } |
| 204 case ManagedTileState::DrawingInfo::PICTURE_PILE_MODE: { |
| 205 gfx::RectF texture_rect = iter.texture_rect(); |
| 206 gfx::Rect opaque_rect = iter->opaque_rect(); |
| 207 opaque_rect.Intersect(content_rect); |
| 208 |
| 209 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); |
| 210 quad->SetNew(shared_quad_state, |
| 211 geometry_rect, |
| 212 opaque_rect, |
| 213 texture_rect, |
| 214 iter.texture_size(), |
| 215 drawing_info.contents_swizzled(), |
| 216 iter->content_rect(), |
| 217 iter->contents_scale(), |
| 218 pile_); |
| 219 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
| 220 break; |
| 221 } |
200 case ManagedTileState::DrawingInfo::SOLID_COLOR_MODE: { | 222 case ManagedTileState::DrawingInfo::SOLID_COLOR_MODE: { |
201 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | 223 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
202 quad->SetNew(shared_quad_state, | 224 quad->SetNew(shared_quad_state, |
203 geometry_rect, | 225 geometry_rect, |
204 drawing_info.get_solid_color()); | 226 drawing_info.get_solid_color()); |
205 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); | 227 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
206 break; | 228 break; |
207 } | 229 } |
208 case ManagedTileState::DrawingInfo::TRANSPARENT_MODE: | 230 case ManagedTileState::DrawingInfo::TRANSPARENT_MODE: |
209 break; | 231 break; |
210 case ManagedTileState::DrawingInfo::PICTURE_PILE_MODE: | |
211 // TODO(leandrogarcia): crbug.com/173011 would fill this part in. | |
212 default: | 232 default: |
213 NOTREACHED(); | 233 NOTREACHED(); |
214 } | 234 } |
215 | 235 |
216 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling()) | 236 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling()) |
217 seen_tilings.push_back(iter.CurrentTiling()); | 237 seen_tilings.push_back(iter.CurrentTiling()); |
218 } | 238 } |
219 | 239 |
220 // 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 |
221 // 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { | 499 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { |
480 gfx::Rect content_rect(content_bounds()); | 500 gfx::Rect content_rect(content_bounds()); |
481 float scale = contents_scale_x(); | 501 float scale = contents_scale_x(); |
482 for (PictureLayerTilingSet::Iterator | 502 for (PictureLayerTilingSet::Iterator |
483 iter(tilings_.get(), scale, content_rect, ideal_contents_scale_); | 503 iter(tilings_.get(), scale, content_rect, ideal_contents_scale_); |
484 iter; | 504 iter; |
485 ++iter) { | 505 ++iter) { |
486 // Mask resource not ready yet. | 506 // Mask resource not ready yet. |
487 if (!*iter || | 507 if (!*iter || |
488 iter->drawing_info().mode() != | 508 iter->drawing_info().mode() != |
489 ManagedTileState::DrawingInfo::TEXTURE_MODE || | 509 ManagedTileState::DrawingInfo::RESOURCE_MODE || |
490 !iter->drawing_info().IsReadyToDraw()) | 510 !iter->drawing_info().IsReadyToDraw()) |
491 return 0; | 511 return 0; |
492 // Masks only supported if they fit on exactly one tile. | 512 // Masks only supported if they fit on exactly one tile. |
493 if (iter.geometry_rect() != content_rect) | 513 if (iter.geometry_rect() != content_rect) |
494 return 0; | 514 return 0; |
495 return iter->drawing_info().get_resource_id(); | 515 return iter->drawing_info().get_resource_id(); |
496 } | 516 } |
497 return 0; | 517 return 0; |
498 } | 518 } |
499 | 519 |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { | 861 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { |
842 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 862 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
843 LayerImpl::AsValueInto(state.get()); | 863 LayerImpl::AsValueInto(state.get()); |
844 | 864 |
845 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); | 865 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); |
846 state->Set("tilings", tilings_->AsValue().release()); | 866 state->Set("tilings", tilings_->AsValue().release()); |
847 return state.PassAs<base::Value>(); | 867 return state.PassAs<base::Value>(); |
848 } | 868 } |
849 | 869 |
850 } // namespace cc | 870 } // namespace cc |
OLD | NEW |