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" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 ideal_contents_scale_(0.f), | 53 ideal_contents_scale_(0.f), |
54 raster_page_scale_(0.f), | 54 raster_page_scale_(0.f), |
55 raster_device_scale_(0.f), | 55 raster_device_scale_(0.f), |
56 raster_source_scale_(0.f), | 56 raster_source_scale_(0.f), |
57 raster_contents_scale_(0.f), | 57 raster_contents_scale_(0.f), |
58 low_res_raster_contents_scale_(0.f), | 58 low_res_raster_contents_scale_(0.f), |
59 raster_source_scale_is_fixed_(false), | 59 raster_source_scale_is_fixed_(false), |
60 was_animating_transform_to_screen_(false), | 60 was_animating_transform_to_screen_(false), |
61 is_using_lcd_text_(tree_impl->settings().can_use_lcd_text), | 61 is_using_lcd_text_(tree_impl->settings().can_use_lcd_text), |
62 needs_post_commit_initialization_(true), | 62 needs_post_commit_initialization_(true), |
63 should_update_tile_priorities_(false), | |
64 should_use_low_res_tiling_(tree_impl->settings().create_low_res_tiling), | 63 should_use_low_res_tiling_(tree_impl->settings().create_low_res_tiling), |
65 layer_needs_to_register_itself_(true) { | 64 layer_needs_to_register_itself_(true) { |
66 } | 65 } |
67 | 66 |
68 PictureLayerImpl::~PictureLayerImpl() { | 67 PictureLayerImpl::~PictureLayerImpl() { |
69 if (!layer_needs_to_register_itself_) | 68 if (!layer_needs_to_register_itself_) |
70 layer_tree_impl()->tile_manager()->UnregisterPictureLayerImpl(this); | 69 layer_tree_impl()->tile_manager()->UnregisterPictureLayerImpl(this); |
71 } | 70 } |
72 | 71 |
73 const char* PictureLayerImpl::LayerTypeAsString() const { | 72 const char* PictureLayerImpl::LayerTypeAsString() const { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 | 137 |
139 void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, | 138 void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, |
140 AppendQuadsData* append_quads_data) { | 139 AppendQuadsData* append_quads_data) { |
141 DCHECK(!needs_post_commit_initialization_); | 140 DCHECK(!needs_post_commit_initialization_); |
142 gfx::Rect rect(visible_content_rect()); | 141 gfx::Rect rect(visible_content_rect()); |
143 gfx::Rect content_rect(content_bounds()); | 142 gfx::Rect content_rect(content_bounds()); |
144 | 143 |
145 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); | 144 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); |
146 PopulateSharedQuadState(shared_quad_state); | 145 PopulateSharedQuadState(shared_quad_state); |
147 | 146 |
147 float max_contents_scale = GetMaxContentScale(); | |
148 gfx::Transform scaled_transform = draw_transform(); | |
149 scaled_transform.Scale(max_contents_scale, max_contents_scale); | |
danakj
2014/05/14 14:08:27
I think you want to scale by 1/max_contents_scale
| |
150 | |
148 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) { | 151 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) { |
149 AppendDebugBorderQuad( | 152 AppendDebugBorderQuad( |
150 quad_sink, | 153 quad_sink, |
151 shared_quad_state, | 154 shared_quad_state, |
152 append_quads_data, | 155 append_quads_data, |
153 DebugColors::DirectPictureBorderColor(), | 156 DebugColors::DirectPictureBorderColor(), |
154 DebugColors::DirectPictureBorderWidth(layer_tree_impl())); | 157 DebugColors::DirectPictureBorderWidth(layer_tree_impl())); |
155 | 158 |
156 gfx::Rect geometry_rect = rect; | 159 gfx::Rect geometry_rect = rect; |
157 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); | 160 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); |
158 gfx::Rect visible_geometry_rect = | 161 gfx::Rect visible_geometry_rect = |
159 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform()); | 162 quad_sink->UnoccludedContentRect(geometry_rect, scaled_transform); |
160 if (visible_geometry_rect.IsEmpty()) | 163 if (visible_geometry_rect.IsEmpty()) |
161 return; | 164 return; |
162 | 165 |
163 gfx::Size texture_size = rect.size(); | 166 gfx::Size texture_size = rect.size(); |
164 gfx::RectF texture_rect = gfx::RectF(texture_size); | 167 gfx::RectF texture_rect = gfx::RectF(texture_size); |
165 gfx::Rect quad_content_rect = rect; | 168 gfx::Rect quad_content_rect = rect; |
166 float contents_scale = contents_scale_x(); | 169 float contents_scale = max_contents_scale; |
167 | 170 |
168 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); | 171 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); |
169 quad->SetNew(shared_quad_state, | 172 quad->SetNew(shared_quad_state, |
170 geometry_rect, | 173 geometry_rect, |
171 opaque_rect, | 174 opaque_rect, |
172 visible_geometry_rect, | 175 visible_geometry_rect, |
173 texture_rect, | 176 texture_rect, |
174 texture_size, | 177 texture_size, |
175 RGBA_8888, | 178 RGBA_8888, |
176 quad_content_rect, | 179 quad_content_rect, |
177 contents_scale, | 180 contents_scale, |
178 pile_); | 181 pile_); |
179 quad_sink->Append(quad.PassAs<DrawQuad>()); | 182 quad_sink->Append(quad.PassAs<DrawQuad>()); |
180 append_quads_data->num_missing_tiles++; | 183 append_quads_data->num_missing_tiles++; |
181 return; | 184 return; |
182 } | 185 } |
183 | 186 |
184 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); | 187 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); |
185 | 188 |
186 if (ShowDebugBorders()) { | 189 if (ShowDebugBorders()) { |
187 for (PictureLayerTilingSet::CoverageIterator iter( | 190 for (PictureLayerTilingSet::CoverageIterator iter( |
188 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); | 191 tilings_.get(), max_contents_scale, rect, ideal_contents_scale_); |
189 iter; | 192 iter; |
190 ++iter) { | 193 ++iter) { |
191 SkColor color; | 194 SkColor color; |
192 float width; | 195 float width; |
193 if (*iter && iter->IsReadyToDraw()) { | 196 if (*iter && iter->IsReadyToDraw()) { |
194 ManagedTileState::TileVersion::Mode mode = | 197 ManagedTileState::TileVersion::Mode mode = |
195 iter->GetTileVersionForDrawing().mode(); | 198 iter->GetTileVersionForDrawing().mode(); |
196 if (mode == ManagedTileState::TileVersion::SOLID_COLOR_MODE) { | 199 if (mode == ManagedTileState::TileVersion::SOLID_COLOR_MODE) { |
197 color = DebugColors::SolidColorTileBorderColor(); | 200 color = DebugColors::SolidColorTileBorderColor(); |
198 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); | 201 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); |
199 } else if (mode == ManagedTileState::TileVersion::PICTURE_PILE_MODE) { | 202 } else if (mode == ManagedTileState::TileVersion::PICTURE_PILE_MODE) { |
200 color = DebugColors::PictureTileBorderColor(); | 203 color = DebugColors::PictureTileBorderColor(); |
201 width = DebugColors::PictureTileBorderWidth(layer_tree_impl()); | 204 width = DebugColors::PictureTileBorderWidth(layer_tree_impl()); |
202 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { | 205 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { |
203 color = DebugColors::HighResTileBorderColor(); | 206 color = DebugColors::HighResTileBorderColor(); |
204 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); | 207 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); |
205 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { | 208 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { |
206 color = DebugColors::LowResTileBorderColor(); | 209 color = DebugColors::LowResTileBorderColor(); |
207 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); | 210 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); |
208 } else if (iter->contents_scale() > contents_scale_x()) { | 211 } else if (iter->contents_scale() > max_contents_scale) { |
209 color = DebugColors::ExtraHighResTileBorderColor(); | 212 color = DebugColors::ExtraHighResTileBorderColor(); |
210 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); | 213 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); |
211 } else { | 214 } else { |
212 color = DebugColors::ExtraLowResTileBorderColor(); | 215 color = DebugColors::ExtraLowResTileBorderColor(); |
213 width = DebugColors::ExtraLowResTileBorderWidth(layer_tree_impl()); | 216 width = DebugColors::ExtraLowResTileBorderWidth(layer_tree_impl()); |
214 } | 217 } |
215 } else { | 218 } else { |
216 color = DebugColors::MissingTileBorderColor(); | 219 color = DebugColors::MissingTileBorderColor(); |
217 width = DebugColors::MissingTileBorderWidth(layer_tree_impl()); | 220 width = DebugColors::MissingTileBorderWidth(layer_tree_impl()); |
218 } | 221 } |
(...skipping 10 matching lines...) Expand all Loading... | |
229 quad_sink->Append(debug_border_quad.PassAs<DrawQuad>()); | 232 quad_sink->Append(debug_border_quad.PassAs<DrawQuad>()); |
230 } | 233 } |
231 } | 234 } |
232 | 235 |
233 // Keep track of the tilings that were used so that tilings that are | 236 // Keep track of the tilings that were used so that tilings that are |
234 // unused can be considered for removal. | 237 // unused can be considered for removal. |
235 std::vector<PictureLayerTiling*> seen_tilings; | 238 std::vector<PictureLayerTiling*> seen_tilings; |
236 | 239 |
237 bool had_checkerboard_quads = false; | 240 bool had_checkerboard_quads = false; |
238 for (PictureLayerTilingSet::CoverageIterator iter( | 241 for (PictureLayerTilingSet::CoverageIterator iter( |
239 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); | 242 tilings_.get(), max_contents_scale, 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 = |
244 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform()); | 247 quad_sink->UnoccludedContentRect(geometry_rect, scaled_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 if (!*iter || !iter->IsReadyToDraw()) { | 254 if (!*iter || !iter->IsReadyToDraw()) { |
252 had_checkerboard_quads = true; | 255 had_checkerboard_quads = true; |
253 if (draw_checkerboard_for_missing_tiles()) { | 256 if (draw_checkerboard_for_missing_tiles()) { |
254 scoped_ptr<CheckerboardDrawQuad> quad = CheckerboardDrawQuad::Create(); | 257 scoped_ptr<CheckerboardDrawQuad> quad = CheckerboardDrawQuad::Create(); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
357 // finer tilings. | 360 // finer tilings. |
358 CleanUpTilingsOnActiveLayer(seen_tilings); | 361 CleanUpTilingsOnActiveLayer(seen_tilings); |
359 } | 362 } |
360 | 363 |
361 void PictureLayerImpl::DidUnregisterLayer() { | 364 void PictureLayerImpl::DidUnregisterLayer() { |
362 layer_needs_to_register_itself_ = true; | 365 layer_needs_to_register_itself_ = true; |
363 } | 366 } |
364 | 367 |
365 void PictureLayerImpl::UpdateTilePriorities() { | 368 void PictureLayerImpl::UpdateTilePriorities() { |
366 DCHECK(!needs_post_commit_initialization_); | 369 DCHECK(!needs_post_commit_initialization_); |
367 CHECK(should_update_tile_priorities_); | 370 |
371 CalculateIdealScales(); | |
372 ManageTilings(draw_properties().screen_space_transform_is_animating, | |
373 draw_properties().maximum_animation_contents_scale); | |
368 | 374 |
369 if (layer_needs_to_register_itself_) { | 375 if (layer_needs_to_register_itself_) { |
370 layer_tree_impl()->tile_manager()->RegisterPictureLayerImpl(this); | 376 layer_tree_impl()->tile_manager()->RegisterPictureLayerImpl(this); |
371 layer_needs_to_register_itself_ = false; | 377 layer_needs_to_register_itself_ = false; |
372 } | 378 } |
373 | 379 |
374 if (layer_tree_impl()->device_viewport_valid_for_tile_management()) { | 380 if (layer_tree_impl()->device_viewport_valid_for_tile_management()) { |
375 visible_rect_for_tile_priority_ = visible_content_rect(); | 381 visible_rect_for_tile_priority_ = visible_content_rect(); |
376 viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize(); | 382 viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize(); |
377 screen_space_transform_for_tile_priority_ = screen_space_transform(); | 383 screen_space_transform_for_tile_priority_ = screen_space_transform(); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
449 RemoveAllTilings(); | 455 RemoveAllTilings(); |
450 | 456 |
451 ResetRasterScale(); | 457 ResetRasterScale(); |
452 | 458 |
453 // To avoid an edge case after lost context where the tree is up to date but | 459 // To avoid an edge case after lost context where the tree is up to date but |
454 // the tilings have not been managed, request an update draw properties | 460 // the tilings have not been managed, request an update draw properties |
455 // to force tilings to get managed. | 461 // to force tilings to get managed. |
456 layer_tree_impl()->set_needs_update_draw_properties(); | 462 layer_tree_impl()->set_needs_update_draw_properties(); |
457 } | 463 } |
458 | 464 |
459 void PictureLayerImpl::CalculateContentsScale( | |
460 float ideal_contents_scale, | |
461 float device_scale_factor, | |
462 float page_scale_factor, | |
463 float maximum_animation_contents_scale, | |
464 bool animating_transform_to_screen, | |
465 float* contents_scale_x, | |
466 float* contents_scale_y, | |
467 gfx::Size* content_bounds) { | |
468 DoPostCommitInitializationIfNeeded(); | |
469 | |
470 // This function sets valid raster scales and manages tilings, so tile | |
471 // priorities can now be updated. | |
472 should_update_tile_priorities_ = true; | |
473 | |
474 if (!CanHaveTilings()) { | |
475 ideal_page_scale_ = page_scale_factor; | |
476 ideal_device_scale_ = device_scale_factor; | |
477 ideal_contents_scale_ = ideal_contents_scale; | |
478 ideal_source_scale_ = | |
479 ideal_contents_scale_ / ideal_page_scale_ / ideal_device_scale_; | |
480 *contents_scale_x = ideal_contents_scale_; | |
481 *contents_scale_y = ideal_contents_scale_; | |
482 *content_bounds = gfx::ToCeiledSize(gfx::ScaleSize(bounds(), | |
483 ideal_contents_scale_, | |
484 ideal_contents_scale_)); | |
485 return; | |
486 } | |
487 | |
488 float min_contents_scale = MinimumContentsScale(); | |
489 DCHECK_GT(min_contents_scale, 0.f); | |
490 float min_page_scale = layer_tree_impl()->min_page_scale_factor(); | |
491 DCHECK_GT(min_page_scale, 0.f); | |
492 float min_device_scale = 1.f; | |
493 float min_source_scale = | |
494 min_contents_scale / min_page_scale / min_device_scale; | |
495 | |
496 float ideal_page_scale = page_scale_factor; | |
497 float ideal_device_scale = device_scale_factor; | |
498 float ideal_source_scale = | |
499 ideal_contents_scale / ideal_page_scale / ideal_device_scale; | |
500 | |
501 ideal_contents_scale_ = std::max(ideal_contents_scale, min_contents_scale); | |
502 ideal_page_scale_ = ideal_page_scale; | |
503 ideal_device_scale_ = ideal_device_scale; | |
504 ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale); | |
505 | |
506 ManageTilings(animating_transform_to_screen, | |
507 maximum_animation_contents_scale); | |
508 | |
509 // The content scale and bounds for a PictureLayerImpl is somewhat fictitious. | |
510 // There are (usually) several tilings at different scales. However, the | |
511 // content bounds is the (integer!) space in which quads are generated. | |
512 // In order to guarantee that we can fill this integer space with any set of | |
513 // tilings (and then map back to floating point texture coordinates), the | |
514 // contents scale must be at least as large as the largest of the tilings. | |
515 float max_contents_scale = min_contents_scale; | |
516 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | |
517 const PictureLayerTiling* tiling = tilings_->tiling_at(i); | |
518 max_contents_scale = std::max(max_contents_scale, tiling->contents_scale()); | |
519 } | |
520 | |
521 *contents_scale_x = max_contents_scale; | |
522 *contents_scale_y = max_contents_scale; | |
523 *content_bounds = gfx::ToCeiledSize( | |
524 gfx::ScaleSize(bounds(), max_contents_scale, max_contents_scale)); | |
525 } | |
526 | |
527 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { | 465 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { |
528 return pile_->GetFlattenedPicture(); | 466 return pile_->GetFlattenedPicture(); |
529 } | 467 } |
530 | 468 |
531 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, | 469 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, |
532 const gfx::Rect& content_rect) { | 470 const gfx::Rect& content_rect) { |
533 if (!pile_->CanRaster(tiling->contents_scale(), content_rect)) | 471 if (!pile_->CanRaster(tiling->contents_scale(), content_rect)) |
534 return scoped_refptr<Tile>(); | 472 return scoped_refptr<Tile>(); |
535 | 473 |
536 int flags = 0; | 474 int flags = 0; |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
695 RemoveAllTilings(); | 633 RemoveAllTilings(); |
696 } | 634 } |
697 | 635 |
698 SanityCheckTilingState(); | 636 SanityCheckTilingState(); |
699 } | 637 } |
700 | 638 |
701 void PictureLayerImpl::SyncTiling( | 639 void PictureLayerImpl::SyncTiling( |
702 const PictureLayerTiling* tiling) { | 640 const PictureLayerTiling* tiling) { |
703 if (!CanHaveTilingWithScale(tiling->contents_scale())) | 641 if (!CanHaveTilingWithScale(tiling->contents_scale())) |
704 return; | 642 return; |
643 | |
644 if (!IsDrawnRenderSurfaceLayerListMember()) | |
645 return; | |
646 | |
705 tilings_->AddTiling(tiling->contents_scale()); | 647 tilings_->AddTiling(tiling->contents_scale()); |
706 | 648 |
707 // If this tree needs update draw properties, then the tiling will | 649 // If this tree needs update draw properties, then the tiling will |
708 // get updated prior to drawing or activation. If this tree does not | 650 // get updated prior to drawing or activation. If this tree does not |
709 // need update draw properties, then its transforms are up to date and | 651 // need update draw properties, then its transforms are up to date and |
710 // we can create tiles for this tiling immediately. | 652 // we can create tiles for this tiling immediately. |
711 if (!layer_tree_impl()->needs_update_draw_properties() && | 653 if (!layer_tree_impl()->needs_update_draw_properties()) { |
712 should_update_tile_priorities_) { | |
713 UpdateTilePriorities(); | 654 UpdateTilePriorities(); |
714 } | 655 } |
715 } | 656 } |
716 | 657 |
717 void PictureLayerImpl::SetIsMask(bool is_mask) { | 658 void PictureLayerImpl::SetIsMask(bool is_mask) { |
718 if (is_mask_ == is_mask) | 659 if (is_mask_ == is_mask) |
719 return; | 660 return; |
720 is_mask_ = is_mask; | 661 is_mask_ = is_mask; |
721 if (tilings_) | 662 if (tilings_) |
722 tilings_->RemoveAllTiles(); | 663 tilings_->RemoveAllTiles(); |
723 } | 664 } |
724 | 665 |
725 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { | 666 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { |
726 gfx::Rect content_rect(content_bounds()); | 667 gfx::Rect content_rect(content_bounds()); |
727 float scale = contents_scale_x(); | 668 float scale = GetMaxContentScale(); |
728 PictureLayerTilingSet::CoverageIterator iter( | 669 PictureLayerTilingSet::CoverageIterator iter( |
729 tilings_.get(), scale, content_rect, ideal_contents_scale_); | 670 tilings_.get(), scale, content_rect, ideal_contents_scale_); |
730 | 671 |
731 // Mask resource not ready yet. | 672 // Mask resource not ready yet. |
732 if (!iter || !*iter) | 673 if (!iter || !*iter) |
733 return 0; | 674 return 0; |
734 | 675 |
735 // Masks only supported if they fit on exactly one tile. | 676 // Masks only supported if they fit on exactly one tile. |
736 if (iter.geometry_rect() != content_rect) | 677 if (iter.geometry_rect() != content_rect) |
737 return 0; | 678 return 0; |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
978 if (change_target_tiling) { | 919 if (change_target_tiling) { |
979 RecalculateRasterScales(animating_transform_to_screen, | 920 RecalculateRasterScales(animating_transform_to_screen, |
980 maximum_animation_contents_scale); | 921 maximum_animation_contents_scale); |
981 } | 922 } |
982 | 923 |
983 was_animating_transform_to_screen_ = animating_transform_to_screen; | 924 was_animating_transform_to_screen_ = animating_transform_to_screen; |
984 | 925 |
985 if (!change_target_tiling) | 926 if (!change_target_tiling) |
986 return; | 927 return; |
987 | 928 |
929 if (!IsDrawnRenderSurfaceLayerListMember()) | |
930 return; | |
931 | |
988 PictureLayerTiling* high_res = NULL; | 932 PictureLayerTiling* high_res = NULL; |
989 PictureLayerTiling* low_res = NULL; | 933 PictureLayerTiling* low_res = NULL; |
990 | 934 |
991 PictureLayerTiling* previous_low_res = NULL; | 935 PictureLayerTiling* previous_low_res = NULL; |
992 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 936 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
993 PictureLayerTiling* tiling = tilings_->tiling_at(i); | 937 PictureLayerTiling* tiling = tilings_->tiling_at(i); |
994 if (tiling->contents_scale() == raster_contents_scale_) | 938 if (tiling->contents_scale() == raster_contents_scale_) |
995 high_res = tiling; | 939 high_res = tiling; |
996 if (tiling->contents_scale() == low_res_raster_contents_scale_) | 940 if (tiling->contents_scale() == low_res_raster_contents_scale_) |
997 low_res = tiling; | 941 low_res = tiling; |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1244 tilings_->SetCanUseLCDText(is_using_lcd_text_); | 1188 tilings_->SetCanUseLCDText(is_using_lcd_text_); |
1245 } | 1189 } |
1246 | 1190 |
1247 void PictureLayerImpl::ResetRasterScale() { | 1191 void PictureLayerImpl::ResetRasterScale() { |
1248 raster_page_scale_ = 0.f; | 1192 raster_page_scale_ = 0.f; |
1249 raster_device_scale_ = 0.f; | 1193 raster_device_scale_ = 0.f; |
1250 raster_source_scale_ = 0.f; | 1194 raster_source_scale_ = 0.f; |
1251 raster_contents_scale_ = 0.f; | 1195 raster_contents_scale_ = 0.f; |
1252 low_res_raster_contents_scale_ = 0.f; | 1196 low_res_raster_contents_scale_ = 0.f; |
1253 raster_source_scale_is_fixed_ = false; | 1197 raster_source_scale_is_fixed_ = false; |
1254 | |
1255 // When raster scales aren't valid, don't update tile priorities until | |
1256 // this layer has been updated via UpdateDrawProperties. | |
1257 should_update_tile_priorities_ = false; | |
1258 } | 1198 } |
1259 | 1199 |
1260 bool PictureLayerImpl::CanHaveTilings() const { | 1200 bool PictureLayerImpl::CanHaveTilings() const { |
1261 if (!DrawsContent()) | 1201 if (!DrawsContent()) |
1262 return false; | 1202 return false; |
1263 if (!pile_->HasRecordings()) | 1203 if (!pile_->HasRecordings()) |
1264 return false; | 1204 return false; |
1265 return true; | 1205 return true; |
1266 } | 1206 } |
1267 | 1207 |
(...skipping 13 matching lines...) Expand all Loading... | |
1281 } | 1221 } |
1282 if (tilings_->num_tilings() == 0) | 1222 if (tilings_->num_tilings() == 0) |
1283 return; | 1223 return; |
1284 | 1224 |
1285 // MarkVisibleResourcesAsRequired depends on having exactly 1 high res | 1225 // MarkVisibleResourcesAsRequired depends on having exactly 1 high res |
1286 // tiling to mark its tiles as being required for activation. | 1226 // tiling to mark its tiles as being required for activation. |
1287 DCHECK_EQ(1, tilings_->NumHighResTilings()); | 1227 DCHECK_EQ(1, tilings_->NumHighResTilings()); |
1288 #endif | 1228 #endif |
1289 } | 1229 } |
1290 | 1230 |
1231 float PictureLayerImpl::GetMaxContentScale() const { | |
1232 float max_contents_scale = 1.f; | |
1233 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | |
1234 const PictureLayerTiling* tiling = tilings_->tiling_at(i); | |
1235 max_contents_scale = std::max(max_contents_scale, tiling->contents_scale()); | |
1236 } | |
1237 return max_contents_scale; | |
1238 } | |
1239 | |
1240 void PictureLayerImpl::CalculateIdealScales() { | |
1241 DoPostCommitInitializationIfNeeded(); | |
1242 | |
1243 if (!CanHaveTilings()) { | |
1244 ideal_page_scale_ = layer_tree_impl()->page_scale_factor(); | |
1245 ideal_device_scale_ = layer_tree_impl()->device_scale_factor(); | |
1246 ideal_contents_scale_ = draw_properties().ideal_contents_scale; | |
1247 ideal_source_scale_ = | |
1248 ideal_contents_scale_ / ideal_page_scale_ / ideal_device_scale_; | |
1249 return; | |
1250 } | |
1251 | |
1252 float min_contents_scale = MinimumContentsScale(); | |
1253 DCHECK_GT(min_contents_scale, 0.f); | |
1254 float min_page_scale = layer_tree_impl()->min_page_scale_factor(); | |
1255 DCHECK_GT(min_page_scale, 0.f); | |
1256 float min_device_scale = 1.f; | |
1257 float min_source_scale = | |
1258 min_contents_scale / min_page_scale / min_device_scale; | |
1259 | |
1260 float ideal_page_scale = layer_tree_impl()->page_scale_factor(); | |
1261 float ideal_device_scale = layer_tree_impl()->device_scale_factor(); | |
1262 float ideal_source_scale = draw_properties().ideal_contents_scale / | |
1263 ideal_page_scale / ideal_device_scale; | |
1264 | |
1265 ideal_contents_scale_ = | |
1266 std::max(draw_properties().ideal_contents_scale, min_contents_scale); | |
1267 ideal_page_scale_ = layer_tree_impl()->page_scale_factor(); | |
1268 ideal_device_scale_ = layer_tree_impl()->device_scale_factor(); | |
1269 ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale); | |
1270 } | |
1271 | |
1291 void PictureLayerImpl::GetDebugBorderProperties( | 1272 void PictureLayerImpl::GetDebugBorderProperties( |
1292 SkColor* color, | 1273 SkColor* color, |
1293 float* width) const { | 1274 float* width) const { |
1294 *color = DebugColors::TiledContentLayerBorderColor(); | 1275 *color = DebugColors::TiledContentLayerBorderColor(); |
1295 *width = DebugColors::TiledContentLayerBorderWidth(layer_tree_impl()); | 1276 *width = DebugColors::TiledContentLayerBorderWidth(layer_tree_impl()); |
1296 } | 1277 } |
1297 | 1278 |
1298 void PictureLayerImpl::AsValueInto(base::DictionaryValue* state) const { | 1279 void PictureLayerImpl::AsValueInto(base::DictionaryValue* state) const { |
1299 const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded(); | 1280 const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded(); |
1300 LayerImpl::AsValueInto(state); | 1281 LayerImpl::AsValueInto(state); |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1557 return iterator_index_ < iterators_.size(); | 1538 return iterator_index_ < iterators_.size(); |
1558 } | 1539 } |
1559 | 1540 |
1560 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( | 1541 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( |
1561 PictureLayerTiling::TilingEvictionTileIterator* it) const { | 1542 PictureLayerTiling::TilingEvictionTileIterator* it) const { |
1562 return it->get_type() == iteration_stage_ && | 1543 return it->get_type() == iteration_stage_ && |
1563 (**it)->required_for_activation() == required_for_activation_; | 1544 (**it)->required_for_activation() == required_for_activation_; |
1564 } | 1545 } |
1565 | 1546 |
1566 } // namespace cc | 1547 } // namespace cc |
OLD | NEW |