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 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
11 #include "cc/base/math_util.h" | 11 #include "cc/base/math_util.h" |
12 #include "cc/base/util.h" | 12 #include "cc/base/util.h" |
13 #include "cc/debug/debug_colors.h" | 13 #include "cc/debug/debug_colors.h" |
14 #include "cc/debug/micro_benchmark_impl.h" | 14 #include "cc/debug/micro_benchmark_impl.h" |
15 #include "cc/debug/traced_value.h" | 15 #include "cc/debug/traced_value.h" |
16 #include "cc/layers/append_quads_data.h" | 16 #include "cc/layers/append_quads_data.h" |
17 #include "cc/layers/quad_sink.h" | |
18 #include "cc/quads/checkerboard_draw_quad.h" | 17 #include "cc/quads/checkerboard_draw_quad.h" |
19 #include "cc/quads/debug_border_draw_quad.h" | 18 #include "cc/quads/debug_border_draw_quad.h" |
20 #include "cc/quads/picture_draw_quad.h" | 19 #include "cc/quads/picture_draw_quad.h" |
21 #include "cc/quads/solid_color_draw_quad.h" | 20 #include "cc/quads/solid_color_draw_quad.h" |
22 #include "cc/quads/tile_draw_quad.h" | 21 #include "cc/quads/tile_draw_quad.h" |
23 #include "cc/resources/tile_manager.h" | 22 #include "cc/resources/tile_manager.h" |
24 #include "cc/trees/layer_tree_impl.h" | 23 #include "cc/trees/layer_tree_impl.h" |
| 24 #include "cc/trees/occlusion_tracker.h" |
25 #include "ui/gfx/quad_f.h" | 25 #include "ui/gfx/quad_f.h" |
26 #include "ui/gfx/rect_conversions.h" | 26 #include "ui/gfx/rect_conversions.h" |
27 #include "ui/gfx/size_conversions.h" | 27 #include "ui/gfx/size_conversions.h" |
28 | 28 |
29 namespace { | 29 namespace { |
30 const float kMaxScaleRatioDuringPinch = 2.0f; | 30 const float kMaxScaleRatioDuringPinch = 2.0f; |
31 | 31 |
32 // When creating a new tiling during pinch, snap to an existing | 32 // When creating a new tiling during pinch, snap to an existing |
33 // tiling's scale if the desired scale is within this ratio. | 33 // tiling's scale if the desired scale is within this ratio. |
34 const float kSnapToExistingTilingRatio = 1.2f; | 34 const float kSnapToExistingTilingRatio = 1.2f; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 // in case push properties is skipped. | 129 // in case push properties is skipped. |
130 layer_impl->invalidation_.Swap(&invalidation_); | 130 layer_impl->invalidation_.Swap(&invalidation_); |
131 invalidation_.Clear(); | 131 invalidation_.Clear(); |
132 needs_post_commit_initialization_ = true; | 132 needs_post_commit_initialization_ = true; |
133 | 133 |
134 // We always need to push properties. | 134 // We always need to push properties. |
135 // See http://crbug.com/303943 | 135 // See http://crbug.com/303943 |
136 needs_push_properties_ = true; | 136 needs_push_properties_ = true; |
137 } | 137 } |
138 | 138 |
139 void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, | 139 void PictureLayerImpl::AppendQuads( |
140 AppendQuadsData* append_quads_data) { | 140 RenderPass* render_pass, |
| 141 const OcclusionTracker<LayerImpl>& occlusion_tracker, |
| 142 AppendQuadsData* append_quads_data) { |
141 DCHECK(!needs_post_commit_initialization_); | 143 DCHECK(!needs_post_commit_initialization_); |
142 gfx::Rect rect(visible_content_rect()); | 144 gfx::Rect rect(visible_content_rect()); |
143 | 145 |
144 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); | 146 SharedQuadState* shared_quad_state = |
| 147 render_pass->CreateAndAppendSharedQuadState(); |
145 PopulateSharedQuadState(shared_quad_state); | 148 PopulateSharedQuadState(shared_quad_state); |
146 | 149 |
147 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) { | 150 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) { |
148 AppendDebugBorderQuad( | 151 AppendDebugBorderQuad( |
149 quad_sink, | 152 render_pass, |
150 shared_quad_state, | 153 shared_quad_state, |
151 append_quads_data, | 154 append_quads_data, |
152 DebugColors::DirectPictureBorderColor(), | 155 DebugColors::DirectPictureBorderColor(), |
153 DebugColors::DirectPictureBorderWidth(layer_tree_impl())); | 156 DebugColors::DirectPictureBorderWidth(layer_tree_impl())); |
154 | 157 |
155 gfx::Rect geometry_rect = rect; | 158 gfx::Rect geometry_rect = rect; |
156 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); | 159 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); |
157 gfx::Rect visible_geometry_rect = | 160 gfx::Rect visible_geometry_rect = occlusion_tracker.UnoccludedContentRect( |
158 quad_sink->UnoccludedContentRect(this, geometry_rect, draw_transform()); | 161 this->render_target(), geometry_rect, draw_transform()); |
159 if (visible_geometry_rect.IsEmpty()) | 162 if (visible_geometry_rect.IsEmpty()) |
160 return; | 163 return; |
161 | 164 |
162 gfx::Size texture_size = rect.size(); | 165 gfx::Size texture_size = rect.size(); |
163 gfx::RectF texture_rect = gfx::RectF(texture_size); | 166 gfx::RectF texture_rect = gfx::RectF(texture_size); |
164 gfx::Rect quad_content_rect = rect; | 167 gfx::Rect quad_content_rect = rect; |
165 float contents_scale = contents_scale_x(); | 168 float contents_scale = contents_scale_x(); |
166 | 169 |
167 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); | 170 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); |
168 quad->SetNew(shared_quad_state, | 171 quad->SetNew(shared_quad_state, |
169 geometry_rect, | 172 geometry_rect, |
170 opaque_rect, | 173 opaque_rect, |
171 visible_geometry_rect, | 174 visible_geometry_rect, |
172 texture_rect, | 175 texture_rect, |
173 texture_size, | 176 texture_size, |
174 RGBA_8888, | 177 RGBA_8888, |
175 quad_content_rect, | 178 quad_content_rect, |
176 contents_scale, | 179 contents_scale, |
177 pile_); | 180 pile_); |
178 quad_sink->Append(quad.PassAs<DrawQuad>()); | 181 render_pass->AppendDrawQuad(quad.PassAs<DrawQuad>()); |
179 append_quads_data->num_missing_tiles++; | 182 append_quads_data->num_missing_tiles++; |
180 return; | 183 return; |
181 } | 184 } |
182 | 185 |
183 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); | 186 AppendDebugBorderQuad(render_pass, shared_quad_state, append_quads_data); |
184 | 187 |
185 if (ShowDebugBorders()) { | 188 if (ShowDebugBorders()) { |
186 for (PictureLayerTilingSet::CoverageIterator iter( | 189 for (PictureLayerTilingSet::CoverageIterator iter( |
187 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); | 190 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); |
188 iter; | 191 iter; |
189 ++iter) { | 192 ++iter) { |
190 SkColor color; | 193 SkColor color; |
191 float width; | 194 float width; |
192 if (*iter && iter->IsReadyToDraw()) { | 195 if (*iter && iter->IsReadyToDraw()) { |
193 ManagedTileState::TileVersion::Mode mode = | 196 ManagedTileState::TileVersion::Mode mode = |
(...skipping 24 matching lines...) Expand all Loading... |
218 | 221 |
219 scoped_ptr<DebugBorderDrawQuad> debug_border_quad = | 222 scoped_ptr<DebugBorderDrawQuad> debug_border_quad = |
220 DebugBorderDrawQuad::Create(); | 223 DebugBorderDrawQuad::Create(); |
221 gfx::Rect geometry_rect = iter.geometry_rect(); | 224 gfx::Rect geometry_rect = iter.geometry_rect(); |
222 gfx::Rect visible_geometry_rect = geometry_rect; | 225 gfx::Rect visible_geometry_rect = geometry_rect; |
223 debug_border_quad->SetNew(shared_quad_state, | 226 debug_border_quad->SetNew(shared_quad_state, |
224 geometry_rect, | 227 geometry_rect, |
225 visible_geometry_rect, | 228 visible_geometry_rect, |
226 color, | 229 color, |
227 width); | 230 width); |
228 quad_sink->Append(debug_border_quad.PassAs<DrawQuad>()); | 231 render_pass->AppendDrawQuad(debug_border_quad.PassAs<DrawQuad>()); |
229 } | 232 } |
230 } | 233 } |
231 | 234 |
232 // Keep track of the tilings that were used so that tilings that are | 235 // Keep track of the tilings that were used so that tilings that are |
233 // unused can be considered for removal. | 236 // unused can be considered for removal. |
234 std::vector<PictureLayerTiling*> seen_tilings; | 237 std::vector<PictureLayerTiling*> seen_tilings; |
235 | 238 |
236 size_t missing_tile_count = 0u; | 239 size_t missing_tile_count = 0u; |
237 size_t on_demand_missing_tile_count = 0u; | 240 size_t on_demand_missing_tile_count = 0u; |
238 for (PictureLayerTilingSet::CoverageIterator iter( | 241 for (PictureLayerTilingSet::CoverageIterator iter( |
239 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); | 242 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); |
240 iter; | 243 iter; |
241 ++iter) { | 244 ++iter) { |
242 gfx::Rect geometry_rect = iter.geometry_rect(); | 245 gfx::Rect geometry_rect = iter.geometry_rect(); |
243 gfx::Rect visible_geometry_rect = | 246 gfx::Rect visible_geometry_rect = occlusion_tracker.UnoccludedContentRect( |
244 quad_sink->UnoccludedContentRect(this, geometry_rect, draw_transform()); | 247 this->render_target(), geometry_rect, draw_transform()); |
245 if (visible_geometry_rect.IsEmpty()) | 248 if (visible_geometry_rect.IsEmpty()) |
246 continue; | 249 continue; |
247 | 250 |
248 append_quads_data->visible_content_area += | 251 append_quads_data->visible_content_area += |
249 visible_geometry_rect.width() * visible_geometry_rect.height(); | 252 visible_geometry_rect.width() * visible_geometry_rect.height(); |
250 | 253 |
251 scoped_ptr<DrawQuad> draw_quad; | 254 scoped_ptr<DrawQuad> draw_quad; |
252 if (*iter && iter->IsReadyToDraw()) { | 255 if (*iter && iter->IsReadyToDraw()) { |
253 const ManagedTileState::TileVersion& tile_version = | 256 const ManagedTileState::TileVersion& tile_version = |
254 iter->GetTileVersionForDrawing(); | 257 iter->GetTileVersionForDrawing(); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 } | 318 } |
316 } | 319 } |
317 } | 320 } |
318 | 321 |
319 if (!draw_quad) { | 322 if (!draw_quad) { |
320 if (draw_checkerboard_for_missing_tiles()) { | 323 if (draw_checkerboard_for_missing_tiles()) { |
321 scoped_ptr<CheckerboardDrawQuad> quad = CheckerboardDrawQuad::Create(); | 324 scoped_ptr<CheckerboardDrawQuad> quad = CheckerboardDrawQuad::Create(); |
322 SkColor color = DebugColors::DefaultCheckerboardColor(); | 325 SkColor color = DebugColors::DefaultCheckerboardColor(); |
323 quad->SetNew( | 326 quad->SetNew( |
324 shared_quad_state, geometry_rect, visible_geometry_rect, color); | 327 shared_quad_state, geometry_rect, visible_geometry_rect, color); |
325 quad_sink->Append(quad.PassAs<DrawQuad>()); | 328 render_pass->AppendDrawQuad(quad.PassAs<DrawQuad>()); |
326 } else { | 329 } else { |
327 SkColor color = SafeOpaqueBackgroundColor(); | 330 SkColor color = SafeOpaqueBackgroundColor(); |
328 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | 331 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
329 quad->SetNew(shared_quad_state, | 332 quad->SetNew(shared_quad_state, |
330 geometry_rect, | 333 geometry_rect, |
331 visible_geometry_rect, | 334 visible_geometry_rect, |
332 color, | 335 color, |
333 false); | 336 false); |
334 quad_sink->Append(quad.PassAs<DrawQuad>()); | 337 render_pass->AppendDrawQuad(quad.PassAs<DrawQuad>()); |
335 } | 338 } |
336 | 339 |
337 append_quads_data->num_missing_tiles++; | 340 append_quads_data->num_missing_tiles++; |
338 append_quads_data->had_incomplete_tile = true; | 341 append_quads_data->had_incomplete_tile = true; |
339 append_quads_data->approximated_visible_content_area += | 342 append_quads_data->approximated_visible_content_area += |
340 visible_geometry_rect.width() * visible_geometry_rect.height(); | 343 visible_geometry_rect.width() * visible_geometry_rect.height(); |
341 ++missing_tile_count; | 344 ++missing_tile_count; |
342 continue; | 345 continue; |
343 } | 346 } |
344 | 347 |
345 quad_sink->Append(draw_quad.Pass()); | 348 render_pass->AppendDrawQuad(draw_quad.Pass()); |
346 | 349 |
347 if (iter->priority(ACTIVE_TREE).resolution != HIGH_RESOLUTION) { | 350 if (iter->priority(ACTIVE_TREE).resolution != HIGH_RESOLUTION) { |
348 append_quads_data->approximated_visible_content_area += | 351 append_quads_data->approximated_visible_content_area += |
349 visible_geometry_rect.width() * visible_geometry_rect.height(); | 352 visible_geometry_rect.width() * visible_geometry_rect.height(); |
350 } | 353 } |
351 | 354 |
352 if (seen_tilings.empty() || seen_tilings.back() != iter.CurrentTiling()) | 355 if (seen_tilings.empty() || seen_tilings.back() != iter.CurrentTiling()) |
353 seen_tilings.push_back(iter.CurrentTiling()); | 356 seen_tilings.push_back(iter.CurrentTiling()); |
354 } | 357 } |
355 | 358 |
(...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1614 return iterator_index_ < iterators_.size(); | 1617 return iterator_index_ < iterators_.size(); |
1615 } | 1618 } |
1616 | 1619 |
1617 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( | 1620 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( |
1618 PictureLayerTiling::TilingEvictionTileIterator* it) const { | 1621 PictureLayerTiling::TilingEvictionTileIterator* it) const { |
1619 return it->get_type() == iteration_stage_ && | 1622 return it->get_type() == iteration_stage_ && |
1620 (**it)->required_for_activation() == required_for_activation_; | 1623 (**it)->required_for_activation() == required_for_activation_; |
1621 } | 1624 } |
1622 | 1625 |
1623 } // namespace cc | 1626 } // namespace cc |
OLD | NEW |