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 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 PictureLayerImpl* pending_layer) | 64 PictureLayerImpl* pending_layer) |
65 : active(active_layer), pending(pending_layer) { | 65 : active(active_layer), pending(pending_layer) { |
66 } | 66 } |
67 | 67 |
68 PictureLayerImpl::Pair::~Pair() { | 68 PictureLayerImpl::Pair::~Pair() { |
69 } | 69 } |
70 | 70 |
71 PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl, int id) | 71 PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl, int id) |
72 : LayerImpl(tree_impl, id), | 72 : LayerImpl(tree_impl, id), |
73 twin_layer_(nullptr), | 73 twin_layer_(nullptr), |
74 pile_(PicturePileImpl::Create()), | 74 raster_source_(PicturePileImpl::Create()), |
75 ideal_page_scale_(0.f), | 75 ideal_page_scale_(0.f), |
76 ideal_device_scale_(0.f), | 76 ideal_device_scale_(0.f), |
77 ideal_source_scale_(0.f), | 77 ideal_source_scale_(0.f), |
78 ideal_contents_scale_(0.f), | 78 ideal_contents_scale_(0.f), |
79 raster_page_scale_(0.f), | 79 raster_page_scale_(0.f), |
80 raster_device_scale_(0.f), | 80 raster_device_scale_(0.f), |
81 raster_source_scale_(0.f), | 81 raster_source_scale_(0.f), |
82 raster_contents_scale_(0.f), | 82 raster_contents_scale_(0.f), |
83 low_res_raster_contents_scale_(0.f), | 83 low_res_raster_contents_scale_(0.f), |
84 raster_source_scale_is_fixed_(false), | 84 raster_source_scale_is_fixed_(false), |
(...skipping 30 matching lines...) Expand all Loading... |
115 // Twin relationships should never change once established. | 115 // Twin relationships should never change once established. |
116 DCHECK_IMPLIES(twin_layer_, twin_layer_ == layer_impl); | 116 DCHECK_IMPLIES(twin_layer_, twin_layer_ == layer_impl); |
117 DCHECK_IMPLIES(twin_layer_, layer_impl->twin_layer_ == this); | 117 DCHECK_IMPLIES(twin_layer_, layer_impl->twin_layer_ == this); |
118 // The twin relationship does not need to exist before the first | 118 // The twin relationship does not need to exist before the first |
119 // PushPropertiesTo from pending to active layer since before that the active | 119 // PushPropertiesTo from pending to active layer since before that the active |
120 // layer can not have a pile or tilings, it has only been created and inserted | 120 // layer can not have a pile or tilings, it has only been created and inserted |
121 // into the tree at that point. | 121 // into the tree at that point. |
122 twin_layer_ = layer_impl; | 122 twin_layer_ = layer_impl; |
123 layer_impl->twin_layer_ = this; | 123 layer_impl->twin_layer_ = this; |
124 | 124 |
125 layer_impl->UpdatePile(pile_); | 125 layer_impl->UpdateRasterSource(raster_source_); |
126 | 126 |
127 DCHECK(!pile_->is_solid_color() || !tilings_->num_tilings()); | 127 DCHECK(!raster_source_->IsSolidColor() || !tilings_->num_tilings()); |
128 // Tilings would be expensive to push, so we swap. | 128 // Tilings would be expensive to push, so we swap. |
129 layer_impl->tilings_.swap(tilings_); | 129 layer_impl->tilings_.swap(tilings_); |
130 layer_impl->tilings_->SetClient(layer_impl); | 130 layer_impl->tilings_->SetClient(layer_impl); |
131 if (tilings_) | 131 if (tilings_) |
132 tilings_->SetClient(this); | 132 tilings_->SetClient(this); |
133 | 133 |
134 // Ensure that the recycle tree doesn't have any unshared tiles. | 134 // Ensure that the recycle tree doesn't have any unshared tiles. |
135 if (tilings_ && pile_->is_solid_color()) | 135 if (tilings_ && raster_source_->IsSolidColor()) |
136 tilings_->RemoveAllTilings(); | 136 tilings_->RemoveAllTilings(); |
137 | 137 |
138 // Remove invalidated tiles from what will become a recycle tree. | 138 // Remove invalidated tiles from what will become a recycle tree. |
139 if (tilings_) | 139 if (tilings_) |
140 tilings_->RemoveTilesInRegion(invalidation_); | 140 tilings_->RemoveTilesInRegion(invalidation_); |
141 | 141 |
142 layer_impl->raster_page_scale_ = raster_page_scale_; | 142 layer_impl->raster_page_scale_ = raster_page_scale_; |
143 layer_impl->raster_device_scale_ = raster_device_scale_; | 143 layer_impl->raster_device_scale_ = raster_device_scale_; |
144 layer_impl->raster_source_scale_ = raster_source_scale_; | 144 layer_impl->raster_source_scale_ = raster_source_scale_; |
145 layer_impl->raster_contents_scale_ = raster_contents_scale_; | 145 layer_impl->raster_contents_scale_ = raster_contents_scale_; |
146 layer_impl->low_res_raster_contents_scale_ = low_res_raster_contents_scale_; | 146 layer_impl->low_res_raster_contents_scale_ = low_res_raster_contents_scale_; |
147 layer_impl->needs_post_commit_initialization_ = false; | 147 layer_impl->needs_post_commit_initialization_ = false; |
148 | 148 |
149 // The invalidation on this soon-to-be-recycled layer must be cleared to | 149 // The invalidation on this soon-to-be-recycled layer must be cleared to |
150 // mirror clearing the invalidation in PictureLayer's version of this function | 150 // mirror clearing the invalidation in PictureLayer's version of this function |
151 // in case push properties is skipped. | 151 // in case push properties is skipped. |
152 layer_impl->invalidation_.Swap(&invalidation_); | 152 layer_impl->invalidation_.Swap(&invalidation_); |
153 invalidation_.Clear(); | 153 invalidation_.Clear(); |
154 needs_post_commit_initialization_ = true; | 154 needs_post_commit_initialization_ = true; |
155 | 155 |
156 // We always need to push properties. | 156 // We always need to push properties. |
157 // See http://crbug.com/303943 | 157 // See http://crbug.com/303943 |
158 needs_push_properties_ = true; | 158 needs_push_properties_ = true; |
159 } | 159 } |
160 | 160 |
161 void PictureLayerImpl::UpdatePile(scoped_refptr<PicturePileImpl> pile) { | 161 void PictureLayerImpl::UpdateRasterSource( |
| 162 scoped_refptr<RasterSource> raster_source) { |
162 bool could_have_tilings = CanHaveTilings(); | 163 bool could_have_tilings = CanHaveTilings(); |
163 pile_.swap(pile); | 164 raster_source_.swap(raster_source); |
164 | 165 |
165 // Need to call UpdateTiles again if CanHaveTilings changed. | 166 // Need to call UpdateTiles again if CanHaveTilings changed. |
166 if (could_have_tilings != CanHaveTilings()) { | 167 if (could_have_tilings != CanHaveTilings()) { |
167 layer_tree_impl()->set_needs_update_draw_properties(); | 168 layer_tree_impl()->set_needs_update_draw_properties(); |
168 } | 169 } |
169 } | 170 } |
170 | 171 |
171 void PictureLayerImpl::AppendQuads(RenderPass* render_pass, | 172 void PictureLayerImpl::AppendQuads(RenderPass* render_pass, |
172 const Occlusion& occlusion_in_content_space, | 173 const Occlusion& occlusion_in_content_space, |
173 AppendQuadsData* append_quads_data) { | 174 AppendQuadsData* append_quads_data) { |
174 DCHECK(!needs_post_commit_initialization_); | 175 DCHECK(!needs_post_commit_initialization_); |
175 // The bounds and the pile size may differ if the pile wasn't updated (ie. | 176 // The bounds and the pile size may differ if the pile wasn't updated (ie. |
176 // PictureLayer::Update didn't happen). In that case the pile will be empty. | 177 // PictureLayer::Update didn't happen). In that case the pile will be empty. |
177 DCHECK_IMPLIES(!pile_->tiling_size().IsEmpty(), | 178 DCHECK_IMPLIES(!raster_source_->GetSize().IsEmpty(), |
178 bounds() == pile_->tiling_size()) | 179 bounds() == raster_source_->GetSize()) |
179 << " bounds " << bounds().ToString() << " pile " | 180 << " bounds " << bounds().ToString() << " pile " |
180 << pile_->tiling_size().ToString(); | 181 << raster_source_->GetSize().ToString(); |
181 | 182 |
182 SharedQuadState* shared_quad_state = | 183 SharedQuadState* shared_quad_state = |
183 render_pass->CreateAndAppendSharedQuadState(); | 184 render_pass->CreateAndAppendSharedQuadState(); |
184 | 185 |
185 if (pile_->is_solid_color()) { | 186 if (raster_source_->IsSolidColor()) { |
186 PopulateSharedQuadState(shared_quad_state); | 187 PopulateSharedQuadState(shared_quad_state); |
187 | 188 |
188 AppendDebugBorderQuad( | 189 AppendDebugBorderQuad( |
189 render_pass, bounds(), shared_quad_state, append_quads_data); | 190 render_pass, bounds(), shared_quad_state, append_quads_data); |
190 | 191 |
191 SolidColorLayerImpl::AppendSolidQuads(render_pass, | 192 SolidColorLayerImpl::AppendSolidQuads( |
192 occlusion_in_content_space, | 193 render_pass, occlusion_in_content_space, shared_quad_state, |
193 shared_quad_state, | 194 visible_content_rect(), raster_source_->GetSolidColor(), |
194 visible_content_rect(), | 195 append_quads_data); |
195 pile_->solid_color(), | |
196 append_quads_data); | |
197 return; | 196 return; |
198 } | 197 } |
199 | 198 |
200 float max_contents_scale = MaximumTilingContentsScale(); | 199 float max_contents_scale = MaximumTilingContentsScale(); |
201 gfx::Transform scaled_draw_transform = draw_transform(); | 200 gfx::Transform scaled_draw_transform = draw_transform(); |
202 scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale, | 201 scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale, |
203 SK_MScalar1 / max_contents_scale); | 202 SK_MScalar1 / max_contents_scale); |
204 gfx::Size scaled_content_bounds = | 203 gfx::Size scaled_content_bounds = |
205 gfx::ToCeiledSize(gfx::ScaleSize(bounds(), max_contents_scale)); | 204 gfx::ToCeiledSize(gfx::ScaleSize(bounds(), max_contents_scale)); |
206 gfx::Rect scaled_visible_content_rect = | 205 gfx::Rect scaled_visible_content_rect = |
207 gfx::ScaleToEnclosingRect(visible_content_rect(), max_contents_scale); | 206 gfx::ScaleToEnclosingRect(visible_content_rect(), max_contents_scale); |
208 scaled_visible_content_rect.Intersect(gfx::Rect(scaled_content_bounds)); | 207 scaled_visible_content_rect.Intersect(gfx::Rect(scaled_content_bounds)); |
209 Occlusion scaled_occlusion = | 208 Occlusion scaled_occlusion = |
210 occlusion_in_content_space.GetOcclusionWithGivenDrawTransform( | 209 occlusion_in_content_space.GetOcclusionWithGivenDrawTransform( |
211 scaled_draw_transform); | 210 scaled_draw_transform); |
212 | 211 |
213 shared_quad_state->SetAll(scaled_draw_transform, | 212 shared_quad_state->SetAll( |
214 scaled_content_bounds, | 213 scaled_draw_transform, scaled_content_bounds, scaled_visible_content_rect, |
215 scaled_visible_content_rect, | 214 draw_properties().clip_rect, draw_properties().is_clipped, |
216 draw_properties().clip_rect, | 215 draw_properties().opacity, draw_properties().blend_mode, |
217 draw_properties().is_clipped, | 216 sorting_context_id_); |
218 draw_properties().opacity, | |
219 blend_mode(), | |
220 sorting_context_id_); | |
221 | 217 |
222 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) { | 218 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) { |
223 AppendDebugBorderQuad( | 219 AppendDebugBorderQuad( |
224 render_pass, | 220 render_pass, |
225 scaled_content_bounds, | 221 scaled_content_bounds, |
226 shared_quad_state, | 222 shared_quad_state, |
227 append_quads_data, | 223 append_quads_data, |
228 DebugColors::DirectPictureBorderColor(), | 224 DebugColors::DirectPictureBorderColor(), |
229 DebugColors::DirectPictureBorderWidth(layer_tree_impl())); | 225 DebugColors::DirectPictureBorderWidth(layer_tree_impl())); |
230 | 226 |
231 gfx::Rect geometry_rect = scaled_visible_content_rect; | 227 gfx::Rect geometry_rect = scaled_visible_content_rect; |
232 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); | 228 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); |
233 gfx::Rect visible_geometry_rect = | 229 gfx::Rect visible_geometry_rect = |
234 scaled_occlusion.GetUnoccludedContentRect(geometry_rect); | 230 scaled_occlusion.GetUnoccludedContentRect(geometry_rect); |
235 if (visible_geometry_rect.IsEmpty()) | 231 if (visible_geometry_rect.IsEmpty()) |
236 return; | 232 return; |
237 | 233 |
238 gfx::Size texture_size = scaled_visible_content_rect.size(); | 234 gfx::Size texture_size = scaled_visible_content_rect.size(); |
239 gfx::RectF texture_rect = gfx::RectF(texture_size); | 235 gfx::RectF texture_rect = gfx::RectF(texture_size); |
240 gfx::Rect quad_content_rect = scaled_visible_content_rect; | 236 gfx::Rect quad_content_rect = scaled_visible_content_rect; |
241 | 237 |
242 PictureDrawQuad* quad = | 238 PictureDrawQuad* quad = |
243 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>(); | 239 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>(); |
244 quad->SetNew(shared_quad_state, | 240 quad->SetNew(shared_quad_state, geometry_rect, opaque_rect, |
245 geometry_rect, | 241 visible_geometry_rect, texture_rect, texture_size, RGBA_8888, |
246 opaque_rect, | 242 quad_content_rect, max_contents_scale, raster_source_); |
247 visible_geometry_rect, | |
248 texture_rect, | |
249 texture_size, | |
250 RGBA_8888, | |
251 quad_content_rect, | |
252 max_contents_scale, | |
253 pile_); | |
254 return; | 243 return; |
255 } | 244 } |
256 | 245 |
257 AppendDebugBorderQuad( | 246 AppendDebugBorderQuad( |
258 render_pass, scaled_content_bounds, shared_quad_state, append_quads_data); | 247 render_pass, scaled_content_bounds, shared_quad_state, append_quads_data); |
259 | 248 |
260 if (ShowDebugBorders()) { | 249 if (ShowDebugBorders()) { |
261 for (PictureLayerTilingSet::CoverageIterator iter( | 250 for (PictureLayerTilingSet::CoverageIterator iter( |
262 tilings_.get(), | 251 tilings_.get(), |
263 max_contents_scale, | 252 max_contents_scale, |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 } | 364 } |
376 | 365 |
377 gfx::RectF texture_rect = iter.texture_rect(); | 366 gfx::RectF texture_rect = iter.texture_rect(); |
378 | 367 |
379 ResourceProvider* resource_provider = | 368 ResourceProvider* resource_provider = |
380 layer_tree_impl()->resource_provider(); | 369 layer_tree_impl()->resource_provider(); |
381 ResourceFormat format = | 370 ResourceFormat format = |
382 resource_provider->memory_efficient_texture_format(); | 371 resource_provider->memory_efficient_texture_format(); |
383 PictureDrawQuad* quad = | 372 PictureDrawQuad* quad = |
384 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>(); | 373 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>(); |
385 quad->SetNew(shared_quad_state, | 374 quad->SetNew(shared_quad_state, geometry_rect, opaque_rect, |
386 geometry_rect, | 375 visible_geometry_rect, texture_rect, iter.texture_size(), |
387 opaque_rect, | 376 format, iter->content_rect(), iter->contents_scale(), |
388 visible_geometry_rect, | 377 raster_source_); |
389 texture_rect, | |
390 iter.texture_size(), | |
391 format, | |
392 iter->content_rect(), | |
393 iter->contents_scale(), | |
394 pile_); | |
395 has_draw_quad = true; | 378 has_draw_quad = true; |
396 break; | 379 break; |
397 } | 380 } |
398 case ManagedTileState::DrawInfo::SOLID_COLOR_MODE: { | 381 case ManagedTileState::DrawInfo::SOLID_COLOR_MODE: { |
399 SolidColorDrawQuad* quad = | 382 SolidColorDrawQuad* quad = |
400 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 383 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
401 quad->SetNew(shared_quad_state, | 384 quad->SetNew(shared_quad_state, |
402 geometry_rect, | 385 geometry_rect, |
403 visible_geometry_rect, | 386 visible_geometry_rect, |
404 draw_info.get_solid_color(), | 387 draw_info.get_solid_color(), |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 DCHECK(raster_page_scale_); | 482 DCHECK(raster_page_scale_); |
500 DCHECK(raster_device_scale_); | 483 DCHECK(raster_device_scale_); |
501 DCHECK(raster_source_scale_); | 484 DCHECK(raster_source_scale_); |
502 DCHECK(raster_contents_scale_); | 485 DCHECK(raster_contents_scale_); |
503 DCHECK(low_res_raster_contents_scale_); | 486 DCHECK(low_res_raster_contents_scale_); |
504 | 487 |
505 was_screen_space_transform_animating_ = | 488 was_screen_space_transform_animating_ = |
506 draw_properties().screen_space_transform_is_animating; | 489 draw_properties().screen_space_transform_is_animating; |
507 | 490 |
508 if (draw_transform_is_animating()) | 491 if (draw_transform_is_animating()) |
509 pile_->set_likely_to_be_used_for_transform_animation(); | 492 raster_source_->SetShouldAttemptToUseDistanceFieldText(); |
510 | 493 |
511 should_update_tile_priorities_ = true; | 494 should_update_tile_priorities_ = true; |
512 | 495 |
513 UpdateTilePriorities(occlusion_in_content_space); | 496 UpdateTilePriorities(occlusion_in_content_space); |
514 } | 497 } |
515 | 498 |
516 void PictureLayerImpl::UpdateTilePriorities( | 499 void PictureLayerImpl::UpdateTilePriorities( |
517 const Occlusion& occlusion_in_content_space) { | 500 const Occlusion& occlusion_in_content_space) { |
518 DCHECK(!pile_->is_solid_color() || !tilings_->num_tilings()); | 501 DCHECK(!raster_source_->IsSolidColor() || !tilings_->num_tilings()); |
519 double current_frame_time_in_seconds = | 502 double current_frame_time_in_seconds = |
520 (layer_tree_impl()->CurrentBeginFrameArgs().frame_time - | 503 (layer_tree_impl()->CurrentBeginFrameArgs().frame_time - |
521 base::TimeTicks()).InSecondsF(); | 504 base::TimeTicks()).InSecondsF(); |
522 | 505 |
523 gfx::Rect viewport_rect_in_layer_space = | 506 gfx::Rect viewport_rect_in_layer_space = |
524 GetViewportForTilePriorityInContentSpace(); | 507 GetViewportForTilePriorityInContentSpace(); |
525 bool tiling_needs_update = false; | 508 bool tiling_needs_update = false; |
526 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 509 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
527 if (tilings_->tiling_at(i)->NeedsUpdateForFrameAtTimeAndViewport( | 510 if (tilings_->tiling_at(i)->NeedsUpdateForFrameAtTimeAndViewport( |
528 current_frame_time_in_seconds, viewport_rect_in_layer_space)) { | 511 current_frame_time_in_seconds, viewport_rect_in_layer_space)) { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 } | 583 } |
601 } | 584 } |
602 | 585 |
603 void PictureLayerImpl::DidBecomeActive() { | 586 void PictureLayerImpl::DidBecomeActive() { |
604 LayerImpl::DidBecomeActive(); | 587 LayerImpl::DidBecomeActive(); |
605 // TODO(vmpstr): See if this can be removed in favour of calling it from LTHI | 588 // TODO(vmpstr): See if this can be removed in favour of calling it from LTHI |
606 layer_tree_impl()->DidModifyTilePriorities(); | 589 layer_tree_impl()->DidModifyTilePriorities(); |
607 } | 590 } |
608 | 591 |
609 void PictureLayerImpl::DidBeginTracing() { | 592 void PictureLayerImpl::DidBeginTracing() { |
610 pile_->DidBeginTracing(); | 593 raster_source_->DidBeginTracing(); |
611 } | 594 } |
612 | 595 |
613 void PictureLayerImpl::ReleaseResources() { | 596 void PictureLayerImpl::ReleaseResources() { |
614 if (tilings_) | 597 if (tilings_) |
615 RemoveAllTilings(); | 598 RemoveAllTilings(); |
616 | 599 |
617 ResetRasterScale(); | 600 ResetRasterScale(); |
618 | 601 |
619 // To avoid an edge case after lost context where the tree is up to date but | 602 // To avoid an edge case after lost context where the tree is up to date but |
620 // the tilings have not been managed, request an update draw properties | 603 // the tilings have not been managed, request an update draw properties |
621 // to force tilings to get managed. | 604 // to force tilings to get managed. |
622 layer_tree_impl()->set_needs_update_draw_properties(); | 605 layer_tree_impl()->set_needs_update_draw_properties(); |
623 } | 606 } |
624 | 607 |
625 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { | 608 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { |
626 return pile_->GetFlattenedPicture(); | 609 return raster_source_->GetFlattenedPicture(); |
627 } | 610 } |
628 | 611 |
629 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, | 612 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, |
630 const gfx::Rect& content_rect) { | 613 const gfx::Rect& content_rect) { |
631 DCHECK(!pile_->is_solid_color()); | 614 DCHECK(!raster_source_->IsSolidColor()); |
632 if (!pile_->CanRaster(tiling->contents_scale(), content_rect)) | 615 if (!raster_source_->CoversRect(content_rect, tiling->contents_scale())) |
633 return scoped_refptr<Tile>(); | 616 return scoped_refptr<Tile>(); |
634 | 617 |
635 int flags = 0; | 618 int flags = 0; |
636 | 619 |
637 // TODO(vmpstr): Revisit this. For now, enabling analysis means that we get as | 620 // TODO(vmpstr): Revisit this. For now, enabling analysis means that we get as |
638 // much savings on memory as we can. However, for some cases like ganesh or | 621 // much savings on memory as we can. However, for some cases like ganesh or |
639 // small layers, the amount of time we spend analyzing might not justify | 622 // small layers, the amount of time we spend analyzing might not justify |
640 // memory savings that we can get. Note that we don't handle solid color | 623 // memory savings that we can get. Note that we don't handle solid color |
641 // masks, so we shouldn't bother analyzing those. | 624 // masks, so we shouldn't bother analyzing those. |
642 // Bugs: crbug.com/397198, crbug.com/396908 | 625 // Bugs: crbug.com/397198, crbug.com/396908 |
643 if (!pile_->is_mask()) | 626 if (!raster_source_->IsMask()) |
644 flags = Tile::USE_PICTURE_ANALYSIS; | 627 flags = Tile::USE_PICTURE_ANALYSIS; |
645 | 628 |
646 return layer_tree_impl()->tile_manager()->CreateTile( | 629 return layer_tree_impl()->tile_manager()->CreateTile( |
647 pile_.get(), | 630 raster_source_.get(), content_rect.size(), content_rect, |
648 content_rect.size(), | 631 tiling->contents_scale(), id(), layer_tree_impl()->source_frame_number(), |
649 content_rect, | |
650 tiling->contents_scale(), | |
651 id(), | |
652 layer_tree_impl()->source_frame_number(), | |
653 flags); | 632 flags); |
654 } | 633 } |
655 | 634 |
656 RasterSource* PictureLayerImpl::GetRasterSource() { | 635 RasterSource* PictureLayerImpl::GetRasterSource() { |
657 return pile_.get(); | 636 return raster_source_.get(); |
658 } | 637 } |
659 | 638 |
660 const Region* PictureLayerImpl::GetPendingInvalidation() { | 639 const Region* PictureLayerImpl::GetPendingInvalidation() { |
661 if (layer_tree_impl()->IsPendingTree()) | 640 if (layer_tree_impl()->IsPendingTree()) |
662 return &invalidation_; | 641 return &invalidation_; |
663 DCHECK(layer_tree_impl()->IsActiveTree()); | 642 DCHECK(layer_tree_impl()->IsActiveTree()); |
664 if (PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer()) | 643 if (PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer()) |
665 return &twin_layer->invalidation_; | 644 return &twin_layer->invalidation_; |
666 return nullptr; | 645 return nullptr; |
667 } | 646 } |
(...skipping 10 matching lines...) Expand all Loading... |
678 } | 657 } |
679 | 658 |
680 PictureLayerTiling* PictureLayerImpl::GetRecycledTwinTiling( | 659 PictureLayerTiling* PictureLayerImpl::GetRecycledTwinTiling( |
681 const PictureLayerTiling* tiling) { | 660 const PictureLayerTiling* tiling) { |
682 PictureLayerImpl* recycled_twin = GetRecycledTwinLayer(); | 661 PictureLayerImpl* recycled_twin = GetRecycledTwinLayer(); |
683 if (!recycled_twin || !recycled_twin->tilings_) | 662 if (!recycled_twin || !recycled_twin->tilings_) |
684 return nullptr; | 663 return nullptr; |
685 return recycled_twin->tilings_->TilingAtScale(tiling->contents_scale()); | 664 return recycled_twin->tilings_->TilingAtScale(tiling->contents_scale()); |
686 } | 665 } |
687 | 666 |
| 667 TilePriority::PriorityBin PictureLayerImpl::GetMaxTilePriorityBin() const { |
| 668 if (!HasValidTilePriorities()) |
| 669 return TilePriority::EVENTUALLY; |
| 670 return TilePriority::NOW; |
| 671 } |
| 672 |
688 size_t PictureLayerImpl::GetMaxTilesForInterestArea() const { | 673 size_t PictureLayerImpl::GetMaxTilesForInterestArea() const { |
689 return layer_tree_impl()->settings().max_tiles_for_interest_area; | 674 return layer_tree_impl()->settings().max_tiles_for_interest_area; |
690 } | 675 } |
691 | 676 |
692 float PictureLayerImpl::GetSkewportTargetTimeInSeconds() const { | 677 float PictureLayerImpl::GetSkewportTargetTimeInSeconds() const { |
693 float skewport_target_time_in_frames = | 678 float skewport_target_time_in_frames = |
694 layer_tree_impl()->use_gpu_rasterization() | 679 layer_tree_impl()->use_gpu_rasterization() |
695 ? kGpuSkewportTargetTimeInFrames | 680 ? kGpuSkewportTargetTimeInFrames |
696 : kCpuSkewportTargetTimeInFrames; | 681 : kCpuSkewportTargetTimeInFrames; |
697 return skewport_target_time_in_frames * | 682 return skewport_target_time_in_frames * |
698 layer_tree_impl()->begin_impl_frame_interval().InSecondsF() * | 683 layer_tree_impl()->begin_impl_frame_interval().InSecondsF() * |
699 layer_tree_impl()->settings().skewport_target_time_multiplier; | 684 layer_tree_impl()->settings().skewport_target_time_multiplier; |
700 } | 685 } |
701 | 686 |
702 int PictureLayerImpl::GetSkewportExtrapolationLimitInContentPixels() const { | 687 int PictureLayerImpl::GetSkewportExtrapolationLimitInContentPixels() const { |
703 return layer_tree_impl() | 688 return layer_tree_impl() |
704 ->settings() | 689 ->settings() |
705 .skewport_extrapolation_limit_in_content_pixels; | 690 .skewport_extrapolation_limit_in_content_pixels; |
706 } | 691 } |
707 | 692 |
708 bool PictureLayerImpl::RequiresHighResToDraw() const { | 693 bool PictureLayerImpl::RequiresHighResToDraw() const { |
709 return layer_tree_impl()->RequiresHighResToDraw(); | 694 return layer_tree_impl()->RequiresHighResToDraw(); |
710 } | 695 } |
711 | 696 |
712 gfx::Size PictureLayerImpl::CalculateTileSize( | 697 gfx::Size PictureLayerImpl::CalculateTileSize( |
713 const gfx::Size& content_bounds) const { | 698 const gfx::Size& content_bounds) const { |
714 int max_texture_size = | 699 int max_texture_size = |
715 layer_tree_impl()->resource_provider()->max_texture_size(); | 700 layer_tree_impl()->resource_provider()->max_texture_size(); |
716 | 701 |
717 if (pile_->is_mask()) { | 702 if (raster_source_->IsMask()) { |
718 // Masks are not tiled, so if we can't cover the whole mask with one tile, | 703 // Masks are not tiled, so if we can't cover the whole mask with one tile, |
719 // don't make any tiles at all. Returning an empty size signals this. | 704 // don't make any tiles at all. Returning an empty size signals this. |
720 if (content_bounds.width() > max_texture_size || | 705 if (content_bounds.width() > max_texture_size || |
721 content_bounds.height() > max_texture_size) | 706 content_bounds.height() > max_texture_size) |
722 return gfx::Size(); | 707 return gfx::Size(); |
723 return content_bounds; | 708 return content_bounds; |
724 } | 709 } |
725 | 710 |
726 int default_tile_width = 0; | 711 int default_tile_width = 0; |
727 int default_tile_height = 0; | 712 int default_tile_height = 0; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 } | 781 } |
797 | 782 |
798 raster_page_scale_ = other->raster_page_scale_; | 783 raster_page_scale_ = other->raster_page_scale_; |
799 raster_device_scale_ = other->raster_device_scale_; | 784 raster_device_scale_ = other->raster_device_scale_; |
800 raster_source_scale_ = other->raster_source_scale_; | 785 raster_source_scale_ = other->raster_source_scale_; |
801 raster_contents_scale_ = other->raster_contents_scale_; | 786 raster_contents_scale_ = other->raster_contents_scale_; |
802 low_res_raster_contents_scale_ = other->low_res_raster_contents_scale_; | 787 low_res_raster_contents_scale_ = other->low_res_raster_contents_scale_; |
803 | 788 |
804 bool synced_high_res_tiling = false; | 789 bool synced_high_res_tiling = false; |
805 if (CanHaveTilings()) { | 790 if (CanHaveTilings()) { |
806 synced_high_res_tiling = tilings_->SyncTilings(*other->tilings_, | 791 synced_high_res_tiling = |
807 pile_->tiling_size(), | 792 tilings_->SyncTilings(*other->tilings_, raster_source_->GetSize(), |
808 invalidation_, | 793 invalidation_, MinimumContentsScale()); |
809 MinimumContentsScale()); | |
810 } else { | 794 } else { |
811 RemoveAllTilings(); | 795 RemoveAllTilings(); |
812 } | 796 } |
813 | 797 |
814 // If our MinimumContentsScale has changed to prevent the twin's high res | 798 // If our MinimumContentsScale has changed to prevent the twin's high res |
815 // tiling from being synced, we should reset the raster scale and let it be | 799 // tiling from being synced, we should reset the raster scale and let it be |
816 // recalculated (1) again. This can happen if our bounds shrink to the point | 800 // recalculated (1) again. This can happen if our bounds shrink to the point |
817 // where min contents scale grows. | 801 // where min contents scale grows. |
818 // (1) - TODO(vmpstr) Instead of hoping that this will be recalculated, we | 802 // (1) - TODO(vmpstr) Instead of hoping that this will be recalculated, we |
819 // should refactor this code a little bit and actually recalculate this. | 803 // should refactor this code a little bit and actually recalculate this. |
820 // However, this is a larger undertaking, so this will work for now. | 804 // However, this is a larger undertaking, so this will work for now. |
821 if (!synced_high_res_tiling) | 805 if (!synced_high_res_tiling) |
822 ResetRasterScale(); | 806 ResetRasterScale(); |
823 else | 807 else |
824 SanityCheckTilingState(); | 808 SanityCheckTilingState(); |
825 } | 809 } |
826 | 810 |
827 void PictureLayerImpl::SyncTiling( | 811 void PictureLayerImpl::SyncTiling( |
828 const PictureLayerTiling* tiling) { | 812 const PictureLayerTiling* tiling) { |
829 if (!tilings_) | 813 if (!tilings_) |
830 return; | 814 return; |
831 if (!CanHaveTilingWithScale(tiling->contents_scale())) | 815 if (!CanHaveTilingWithScale(tiling->contents_scale())) |
832 return; | 816 return; |
833 tilings_->AddTiling(tiling->contents_scale(), pile_->tiling_size()); | 817 tilings_->AddTiling(tiling->contents_scale(), raster_source_->GetSize()); |
834 | 818 |
835 // If this tree needs update draw properties, then the tiling will | 819 // If this tree needs update draw properties, then the tiling will |
836 // get updated prior to drawing or activation. If this tree does not | 820 // get updated prior to drawing or activation. If this tree does not |
837 // need update draw properties, then its transforms are up to date and | 821 // need update draw properties, then its transforms are up to date and |
838 // we can create tiles for this tiling immediately. | 822 // we can create tiles for this tiling immediately. |
839 if (!layer_tree_impl()->needs_update_draw_properties() && | 823 if (!layer_tree_impl()->needs_update_draw_properties() && |
840 should_update_tile_priorities_) { | 824 should_update_tile_priorities_) { |
841 // TODO(danakj): Add a DCHECK() that we are not using occlusion tracking | 825 // TODO(danakj): Add a DCHECK() that we are not using occlusion tracking |
842 // when we stop using the pending tree in the browser compositor. If we want | 826 // when we stop using the pending tree in the browser compositor. If we want |
843 // to support occlusion tracking here, we need to dirty the draw properties | 827 // to support occlusion tracking here, we need to dirty the draw properties |
844 // or save occlusion as a draw property. | 828 // or save occlusion as a draw property. |
845 UpdateTilePriorities(Occlusion()); | 829 UpdateTilePriorities(Occlusion()); |
846 } | 830 } |
847 } | 831 } |
848 | 832 |
849 void PictureLayerImpl::GetContentsResourceId( | 833 void PictureLayerImpl::GetContentsResourceId( |
850 ResourceProvider::ResourceId* resource_id, | 834 ResourceProvider::ResourceId* resource_id, |
851 gfx::Size* resource_size) const { | 835 gfx::Size* resource_size) const { |
852 DCHECK_EQ(bounds().ToString(), pile_->tiling_size().ToString()); | 836 DCHECK_EQ(bounds().ToString(), raster_source_->GetSize().ToString()); |
853 gfx::Rect content_rect(bounds()); | 837 gfx::Rect content_rect(bounds()); |
854 PictureLayerTilingSet::CoverageIterator iter( | 838 PictureLayerTilingSet::CoverageIterator iter( |
855 tilings_.get(), 1.f, content_rect, ideal_contents_scale_); | 839 tilings_.get(), 1.f, content_rect, ideal_contents_scale_); |
856 | 840 |
857 // Mask resource not ready yet. | 841 // Mask resource not ready yet. |
858 if (!iter || !*iter) { | 842 if (!iter || !*iter) { |
859 *resource_id = 0; | 843 *resource_id = 0; |
860 return; | 844 return; |
861 } | 845 } |
862 | 846 |
(...skipping 29 matching lines...) Expand all Loading... |
892 } | 876 } |
893 | 877 |
894 needs_post_commit_initialization_ = false; | 878 needs_post_commit_initialization_ = false; |
895 } | 879 } |
896 | 880 |
897 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { | 881 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { |
898 DCHECK(CanHaveTilingWithScale(contents_scale)) << | 882 DCHECK(CanHaveTilingWithScale(contents_scale)) << |
899 "contents_scale: " << contents_scale; | 883 "contents_scale: " << contents_scale; |
900 | 884 |
901 PictureLayerTiling* tiling = | 885 PictureLayerTiling* tiling = |
902 tilings_->AddTiling(contents_scale, pile_->tiling_size()); | 886 tilings_->AddTiling(contents_scale, raster_source_->GetSize()); |
903 | 887 |
904 DCHECK(pile_->HasRecordings()); | 888 DCHECK(raster_source_->HasRecordings()); |
905 | 889 |
906 if (PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer()) | 890 if (PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer()) |
907 twin_layer->SyncTiling(tiling); | 891 twin_layer->SyncTiling(tiling); |
908 | 892 |
909 return tiling; | 893 return tiling; |
910 } | 894 } |
911 | 895 |
912 void PictureLayerImpl::RemoveTiling(float contents_scale) { | 896 void PictureLayerImpl::RemoveTiling(float contents_scale) { |
913 if (!tilings_ || tilings_->num_tilings() == 0) | 897 if (!tilings_ || tilings_->num_tilings() == 0) |
914 return; | 898 return; |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1093 !ShouldAdjustRasterScaleDuringScaleAnimations()) { | 1077 !ShouldAdjustRasterScaleDuringScaleAnimations()) { |
1094 bool can_raster_at_maximum_scale = false; | 1078 bool can_raster_at_maximum_scale = false; |
1095 // TODO(ajuma): If we need to deal with scale-down animations starting right | 1079 // TODO(ajuma): If we need to deal with scale-down animations starting right |
1096 // as a layer gets promoted, then we'd want to have the | 1080 // as a layer gets promoted, then we'd want to have the |
1097 // |starting_animation_contents_scale| passed in here as a separate draw | 1081 // |starting_animation_contents_scale| passed in here as a separate draw |
1098 // property so we could try use that when the max is too large. | 1082 // property so we could try use that when the max is too large. |
1099 // See crbug.com/422341. | 1083 // See crbug.com/422341. |
1100 float maximum_scale = draw_properties().maximum_animation_contents_scale; | 1084 float maximum_scale = draw_properties().maximum_animation_contents_scale; |
1101 if (maximum_scale) { | 1085 if (maximum_scale) { |
1102 gfx::Size bounds_at_maximum_scale = gfx::ToCeiledSize( | 1086 gfx::Size bounds_at_maximum_scale = gfx::ToCeiledSize( |
1103 gfx::ScaleSize(pile_->tiling_size(), maximum_scale)); | 1087 gfx::ScaleSize(raster_source_->GetSize(), maximum_scale)); |
1104 if (bounds_at_maximum_scale.GetArea() <= | 1088 if (bounds_at_maximum_scale.GetArea() <= |
1105 layer_tree_impl()->device_viewport_size().GetArea()) | 1089 layer_tree_impl()->device_viewport_size().GetArea()) |
1106 can_raster_at_maximum_scale = true; | 1090 can_raster_at_maximum_scale = true; |
1107 } | 1091 } |
1108 // Use the computed scales for the raster scale directly, do not try to use | 1092 // Use the computed scales for the raster scale directly, do not try to use |
1109 // the ideal scale here. The current ideal scale may be way too large in the | 1093 // the ideal scale here. The current ideal scale may be way too large in the |
1110 // case of an animation with scale, and will be constantly changing. | 1094 // case of an animation with scale, and will be constantly changing. |
1111 if (can_raster_at_maximum_scale) | 1095 if (can_raster_at_maximum_scale) |
1112 raster_contents_scale_ = maximum_scale; | 1096 raster_contents_scale_ = maximum_scale; |
1113 else | 1097 else |
1114 raster_contents_scale_ = 1.f * ideal_page_scale_ * ideal_device_scale_; | 1098 raster_contents_scale_ = 1.f * ideal_page_scale_ * ideal_device_scale_; |
1115 } | 1099 } |
1116 | 1100 |
1117 raster_contents_scale_ = | 1101 raster_contents_scale_ = |
1118 std::max(raster_contents_scale_, MinimumContentsScale()); | 1102 std::max(raster_contents_scale_, MinimumContentsScale()); |
1119 | 1103 |
1120 // If this layer would create zero or one tiles at this content scale, | 1104 // If this layer would create zero or one tiles at this content scale, |
1121 // don't create a low res tiling. | 1105 // don't create a low res tiling. |
1122 gfx::Size raster_bounds = gfx::ToCeiledSize( | 1106 gfx::Size raster_bounds = gfx::ToCeiledSize( |
1123 gfx::ScaleSize(pile_->tiling_size(), raster_contents_scale_)); | 1107 gfx::ScaleSize(raster_source_->GetSize(), raster_contents_scale_)); |
1124 gfx::Size tile_size = CalculateTileSize(raster_bounds); | 1108 gfx::Size tile_size = CalculateTileSize(raster_bounds); |
1125 bool tile_covers_bounds = tile_size.width() >= raster_bounds.width() && | 1109 bool tile_covers_bounds = tile_size.width() >= raster_bounds.width() && |
1126 tile_size.height() >= raster_bounds.height(); | 1110 tile_size.height() >= raster_bounds.height(); |
1127 if (tile_size.IsEmpty() || tile_covers_bounds) { | 1111 if (tile_size.IsEmpty() || tile_covers_bounds) { |
1128 low_res_raster_contents_scale_ = raster_contents_scale_; | 1112 low_res_raster_contents_scale_ = raster_contents_scale_; |
1129 return; | 1113 return; |
1130 } | 1114 } |
1131 | 1115 |
1132 float low_res_factor = | 1116 float low_res_factor = |
1133 layer_tree_impl()->settings().low_res_contents_scale_factor; | 1117 layer_tree_impl()->settings().low_res_contents_scale_factor; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1220 SanityCheckTilingState(); | 1204 SanityCheckTilingState(); |
1221 } | 1205 } |
1222 | 1206 |
1223 float PictureLayerImpl::MinimumContentsScale() const { | 1207 float PictureLayerImpl::MinimumContentsScale() const { |
1224 float setting_min = layer_tree_impl()->settings().minimum_contents_scale; | 1208 float setting_min = layer_tree_impl()->settings().minimum_contents_scale; |
1225 | 1209 |
1226 // If the contents scale is less than 1 / width (also for height), | 1210 // If the contents scale is less than 1 / width (also for height), |
1227 // then it will end up having less than one pixel of content in that | 1211 // then it will end up having less than one pixel of content in that |
1228 // dimension. Bump the minimum contents scale up in this case to prevent | 1212 // dimension. Bump the minimum contents scale up in this case to prevent |
1229 // this from happening. | 1213 // this from happening. |
1230 int min_dimension = | 1214 int min_dimension = std::min(raster_source_->GetSize().width(), |
1231 std::min(pile_->tiling_size().width(), pile_->tiling_size().height()); | 1215 raster_source_->GetSize().height()); |
1232 if (!min_dimension) | 1216 if (!min_dimension) |
1233 return setting_min; | 1217 return setting_min; |
1234 | 1218 |
1235 return std::max(1.f / min_dimension, setting_min); | 1219 return std::max(1.f / min_dimension, setting_min); |
1236 } | 1220 } |
1237 | 1221 |
1238 void PictureLayerImpl::ResetRasterScale() { | 1222 void PictureLayerImpl::ResetRasterScale() { |
1239 raster_page_scale_ = 0.f; | 1223 raster_page_scale_ = 0.f; |
1240 raster_device_scale_ = 0.f; | 1224 raster_device_scale_ = 0.f; |
1241 raster_source_scale_ = 0.f; | 1225 raster_source_scale_ = 0.f; |
1242 raster_contents_scale_ = 0.f; | 1226 raster_contents_scale_ = 0.f; |
1243 low_res_raster_contents_scale_ = 0.f; | 1227 low_res_raster_contents_scale_ = 0.f; |
1244 raster_source_scale_is_fixed_ = false; | 1228 raster_source_scale_is_fixed_ = false; |
1245 | 1229 |
1246 // When raster scales aren't valid, don't update tile priorities until | 1230 // When raster scales aren't valid, don't update tile priorities until |
1247 // this layer has been updated via UpdateDrawProperties. | 1231 // this layer has been updated via UpdateDrawProperties. |
1248 should_update_tile_priorities_ = false; | 1232 should_update_tile_priorities_ = false; |
1249 } | 1233 } |
1250 | 1234 |
1251 bool PictureLayerImpl::CanHaveTilings() const { | 1235 bool PictureLayerImpl::CanHaveTilings() const { |
1252 if (pile_->is_solid_color()) | 1236 if (raster_source_->IsSolidColor()) |
1253 return false; | 1237 return false; |
1254 if (!DrawsContent()) | 1238 if (!DrawsContent()) |
1255 return false; | 1239 return false; |
1256 if (!pile_->HasRecordings()) | 1240 if (!raster_source_->HasRecordings()) |
1257 return false; | 1241 return false; |
1258 return true; | 1242 return true; |
1259 } | 1243 } |
1260 | 1244 |
1261 bool PictureLayerImpl::CanHaveTilingWithScale(float contents_scale) const { | 1245 bool PictureLayerImpl::CanHaveTilingWithScale(float contents_scale) const { |
1262 if (!CanHaveTilings()) | 1246 if (!CanHaveTilings()) |
1263 return false; | 1247 return false; |
1264 if (contents_scale < MinimumContentsScale()) | 1248 if (contents_scale < MinimumContentsScale()) |
1265 return false; | 1249 return false; |
1266 return true; | 1250 return true; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1346 | 1330 |
1347 state->BeginArray("tile_priority_rect"); | 1331 state->BeginArray("tile_priority_rect"); |
1348 MathUtil::AddToTracedValue(GetViewportForTilePriorityInContentSpace(), state); | 1332 MathUtil::AddToTracedValue(GetViewportForTilePriorityInContentSpace(), state); |
1349 state->EndArray(); | 1333 state->EndArray(); |
1350 | 1334 |
1351 state->BeginArray("visible_rect"); | 1335 state->BeginArray("visible_rect"); |
1352 MathUtil::AddToTracedValue(visible_content_rect(), state); | 1336 MathUtil::AddToTracedValue(visible_content_rect(), state); |
1353 state->EndArray(); | 1337 state->EndArray(); |
1354 | 1338 |
1355 state->BeginArray("pictures"); | 1339 state->BeginArray("pictures"); |
1356 pile_->AsValueInto(state); | 1340 raster_source_->AsValueInto(state); |
1357 state->EndArray(); | 1341 state->EndArray(); |
1358 | 1342 |
1359 state->BeginArray("invalidation"); | 1343 state->BeginArray("invalidation"); |
1360 invalidation_.AsValueInto(state); | 1344 invalidation_.AsValueInto(state); |
1361 state->EndArray(); | 1345 state->EndArray(); |
1362 | 1346 |
1363 state->BeginArray("coverage_tiles"); | 1347 state->BeginArray("coverage_tiles"); |
1364 for (PictureLayerTilingSet::CoverageIterator iter( | 1348 for (PictureLayerTilingSet::CoverageIterator iter( |
1365 tilings_.get(), | 1349 tilings_.get(), 1.f, gfx::Rect(raster_source_->GetSize()), |
1366 1.f, | |
1367 gfx::Rect(pile_->tiling_size()), | |
1368 ideal_contents_scale_); | 1350 ideal_contents_scale_); |
1369 iter; | 1351 iter; ++iter) { |
1370 ++iter) { | |
1371 state->BeginDictionary(); | 1352 state->BeginDictionary(); |
1372 | 1353 |
1373 state->BeginArray("geometry_rect"); | 1354 state->BeginArray("geometry_rect"); |
1374 MathUtil::AddToTracedValue(iter.geometry_rect(), state); | 1355 MathUtil::AddToTracedValue(iter.geometry_rect(), state); |
1375 state->EndArray(); | 1356 state->EndArray(); |
1376 | 1357 |
1377 if (*iter) | 1358 if (*iter) |
1378 TracedValue::SetIDRef(*iter, state, "tile"); | 1359 TracedValue::SetIDRef(*iter, state, "tile"); |
1379 | 1360 |
1380 state->EndDictionary(); | 1361 state->EndDictionary(); |
(...skipping 15 matching lines...) Expand all Loading... |
1396 } | 1377 } |
1397 | 1378 |
1398 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { | 1379 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { |
1399 return !layer_tree_impl()->IsRecycleTree(); | 1380 return !layer_tree_impl()->IsRecycleTree(); |
1400 } | 1381 } |
1401 | 1382 |
1402 bool PictureLayerImpl::HasValidTilePriorities() const { | 1383 bool PictureLayerImpl::HasValidTilePriorities() const { |
1403 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); | 1384 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); |
1404 } | 1385 } |
1405 | 1386 |
1406 bool PictureLayerImpl::AllTilesRequiredForActivationAreReadyToDraw() const { | 1387 bool PictureLayerImpl::AllTilesRequiredAreReadyToDraw( |
1407 if (!layer_tree_impl()->IsPendingTree()) | 1388 TileRequirementCheck is_tile_required_callback) const { |
1408 return true; | |
1409 | |
1410 if (!HasValidTilePriorities()) | 1389 if (!HasValidTilePriorities()) |
1411 return true; | 1390 return true; |
1412 | 1391 |
1413 if (!tilings_) | 1392 if (!tilings_) |
1414 return true; | 1393 return true; |
1415 | 1394 |
1416 if (visible_rect_for_tile_priority_.IsEmpty()) | 1395 if (visible_rect_for_tile_priority_.IsEmpty()) |
1417 return true; | 1396 return true; |
1418 | 1397 |
1419 gfx::Rect rect = GetViewportForTilePriorityInContentSpace(); | 1398 gfx::Rect rect = GetViewportForTilePriorityInContentSpace(); |
(...skipping 11 matching lines...) Expand all Loading... |
1431 // A null tile (i.e. missing recording) can just be skipped. | 1410 // A null tile (i.e. missing recording) can just be skipped. |
1432 // TODO(vmpstr): Verify this is true if we create tiles in raster | 1411 // TODO(vmpstr): Verify this is true if we create tiles in raster |
1433 // iterators. | 1412 // iterators. |
1434 if (!tile) | 1413 if (!tile) |
1435 continue; | 1414 continue; |
1436 | 1415 |
1437 // We can't check tile->required_for_activation, because that value might | 1416 // We can't check tile->required_for_activation, because that value might |
1438 // be out of date. It is updated in the raster/eviction iterators. | 1417 // be out of date. It is updated in the raster/eviction iterators. |
1439 // TODO(vmpstr): Remove the comment once you can't access this information | 1418 // TODO(vmpstr): Remove the comment once you can't access this information |
1440 // from the tile. | 1419 // from the tile. |
1441 if (tiling->IsTileRequiredForActivation(tile) && !tile->IsReadyToDraw()) { | 1420 if ((tiling->*is_tile_required_callback)(tile) && |
1442 TRACE_EVENT_INSTANT0("cc", | 1421 !tile->IsReadyToDraw()) { |
1443 "PictureLayerImpl::" | 1422 TRACE_EVENT_INSTANT0("cc", "Tile required, but not ready to draw.", |
1444 "AllTilesRequiredForActivationAreReadyToDraw not " | |
1445 "ready to activate", | |
1446 TRACE_EVENT_SCOPE_THREAD); | 1423 TRACE_EVENT_SCOPE_THREAD); |
1447 return false; | 1424 return false; |
1448 } | 1425 } |
1449 } | 1426 } |
1450 } | 1427 } |
1451 | 1428 |
1452 return true; | 1429 return true; |
1453 } | 1430 } |
1454 | 1431 |
| 1432 bool PictureLayerImpl::AllTilesRequiredForActivationAreReadyToDraw() const { |
| 1433 if (!layer_tree_impl()->IsPendingTree()) |
| 1434 return true; |
| 1435 |
| 1436 return AllTilesRequiredAreReadyToDraw( |
| 1437 &PictureLayerTiling::IsTileRequiredForActivationIfVisible); |
| 1438 } |
| 1439 |
| 1440 bool PictureLayerImpl::AllTilesRequiredForDrawAreReadyToDraw() const { |
| 1441 if (!layer_tree_impl()->IsActiveTree()) |
| 1442 return true; |
| 1443 |
| 1444 return AllTilesRequiredAreReadyToDraw( |
| 1445 &PictureLayerTiling::IsTileRequiredForDrawIfVisible); |
| 1446 } |
| 1447 |
1455 PictureLayerImpl::LayerRasterTileIterator::LayerRasterTileIterator() | 1448 PictureLayerImpl::LayerRasterTileIterator::LayerRasterTileIterator() |
1456 : layer_(nullptr), current_stage_(arraysize(stages_)) { | 1449 : layer_(nullptr), current_stage_(arraysize(stages_)) { |
1457 } | 1450 } |
1458 | 1451 |
1459 PictureLayerImpl::LayerRasterTileIterator::LayerRasterTileIterator( | 1452 PictureLayerImpl::LayerRasterTileIterator::LayerRasterTileIterator( |
1460 PictureLayerImpl* layer, | 1453 PictureLayerImpl* layer, |
1461 bool prioritize_low_res) | 1454 bool prioritize_low_res) |
1462 : layer_(layer), current_stage_(0) { | 1455 : layer_(layer), current_stage_(0) { |
1463 DCHECK(layer_); | 1456 DCHECK(layer_); |
1464 | 1457 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1579 current_tiling_(0u) { | 1572 current_tiling_(0u) { |
1580 } | 1573 } |
1581 | 1574 |
1582 PictureLayerImpl::LayerEvictionTileIterator::LayerEvictionTileIterator( | 1575 PictureLayerImpl::LayerEvictionTileIterator::LayerEvictionTileIterator( |
1583 PictureLayerImpl* layer, | 1576 PictureLayerImpl* layer, |
1584 TreePriority tree_priority) | 1577 TreePriority tree_priority) |
1585 : layer_(layer), | 1578 : layer_(layer), |
1586 tree_priority_(tree_priority), | 1579 tree_priority_(tree_priority), |
1587 current_category_(PictureLayerTiling::EVENTUALLY), | 1580 current_category_(PictureLayerTiling::EVENTUALLY), |
1588 current_tiling_range_type_(PictureLayerTilingSet::HIGHER_THAN_HIGH_RES), | 1581 current_tiling_range_type_(PictureLayerTilingSet::HIGHER_THAN_HIGH_RES), |
1589 current_tiling_(CurrentTilingRange().start - 1u) { | 1582 current_tiling_(0u) { |
1590 // TODO(vmpstr): Once tile priorities are determined by the iterators, ensure | 1583 // Early out if the layer has no tilings. |
1591 // that layers that don't have valid tile priorities have lowest priorities so | 1584 if (!layer_->tilings_ || !layer_->tilings_->num_tilings()) |
1592 // they evict their tiles first (crbug.com/381704) | 1585 return; |
1593 DCHECK(layer_->tilings_); | 1586 |
| 1587 current_tiling_ = CurrentTilingRange().start - 1u; |
1594 do { | 1588 do { |
1595 if (!AdvanceToNextTiling()) | 1589 if (!AdvanceToNextTiling()) |
1596 break; | 1590 break; |
1597 | 1591 |
1598 current_iterator_ = PictureLayerTiling::TilingEvictionTileIterator( | 1592 current_iterator_ = PictureLayerTiling::TilingEvictionTileIterator( |
1599 layer_->tilings_->tiling_at(CurrentTilingIndex()), | 1593 layer_->tilings_->tiling_at(CurrentTilingIndex()), |
1600 tree_priority, | 1594 tree_priority, |
1601 current_category_); | 1595 current_category_); |
1602 } while (!current_iterator_); | 1596 } while (!current_iterator_); |
1603 } | 1597 } |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1718 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); | 1712 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); |
1719 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; | 1713 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; |
1720 return tiling_range.end - 1 - current_tiling_range_offset; | 1714 return tiling_range.end - 1 - current_tiling_range_offset; |
1721 } | 1715 } |
1722 } | 1716 } |
1723 NOTREACHED(); | 1717 NOTREACHED(); |
1724 return 0; | 1718 return 0; |
1725 } | 1719 } |
1726 | 1720 |
1727 } // namespace cc | 1721 } // namespace cc |
OLD | NEW |