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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 needs_post_commit_initialization_ = true; | 131 needs_post_commit_initialization_ = true; |
133 | 132 |
134 // We always need to push properties. | 133 // We always need to push properties. |
135 // See http://crbug.com/303943 | 134 // See http://crbug.com/303943 |
136 needs_push_properties_ = true; | 135 needs_push_properties_ = true; |
137 } | 136 } |
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()); | |
143 gfx::Rect content_rect(content_bounds()); | |
144 | 141 |
145 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); | 142 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); |
143 | |
144 float max_contents_scale = GetMaxContentScale(); | |
145 gfx::Transform scaled_transform = draw_transform(); | |
danakj
2014/05/15 15:15:31
scaled_draw_transform
| |
146 scaled_transform.Scale(SK_MScalar1 / max_contents_scale, | |
147 SK_MScalar1 / max_contents_scale); | |
148 gfx::Size bounds( | |
danakj
2014/05/15 15:15:31
name this scaled_content_bounds
| |
149 gfx::Size(std::ceil(content_bounds().width() * max_contents_scale), | |
danakj
2014/05/15 15:15:31
Use gfx::ToCeiledSize(gfx::ScaleSize()) to do this
| |
150 std::ceil(content_bounds().height() * max_contents_scale))); | |
151 | |
152 gfx::Rect scaled_rect = | |
danakj
2014/05/15 15:15:31
scaled_visible_content_rect
| |
153 gfx::Rect(visible_content_rect().x() * max_contents_scale, | |
danakj
2014/05/15 15:15:31
Use gfx::ScaleToEnclosingRect() to do this.
| |
154 visible_content_rect().y() * max_contents_scale, | |
155 visible_content_rect().width() * max_contents_scale, | |
156 visible_content_rect().height() * max_contents_scale); | |
157 scaled_rect.Intersect(gfx::Rect(bounds)); | |
158 gfx::Rect rect = gfx::ToEnclosingRect(scaled_rect); | |
159 | |
160 draw_properties().content_bounds = bounds; | |
161 draw_properties().visible_content_rect = rect; | |
danakj
2014/05/15 15:15:31
The draw properties should stay unchanged here, we
| |
162 draw_properties().contents_scale_x = max_contents_scale; | |
163 draw_properties().contents_scale_y = max_contents_scale; | |
164 draw_properties().target_space_transform = scaled_transform; | |
146 PopulateSharedQuadState(shared_quad_state); | 165 PopulateSharedQuadState(shared_quad_state); |
danakj
2014/05/15 15:15:31
The SQS transform/visible_content_rect/content_bou
| |
147 | 166 |
148 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) { | 167 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) { |
149 AppendDebugBorderQuad( | 168 AppendDebugBorderQuad( |
150 quad_sink, | 169 quad_sink, |
151 shared_quad_state, | 170 shared_quad_state, |
152 append_quads_data, | 171 append_quads_data, |
153 DebugColors::DirectPictureBorderColor(), | 172 DebugColors::DirectPictureBorderColor(), |
154 DebugColors::DirectPictureBorderWidth(layer_tree_impl())); | 173 DebugColors::DirectPictureBorderWidth(layer_tree_impl())); |
155 | 174 |
156 gfx::Rect geometry_rect = rect; | 175 gfx::Rect geometry_rect = rect; |
(...skipping 21 matching lines...) Expand all Loading... | |
178 pile_); | 197 pile_); |
179 quad_sink->Append(quad.PassAs<DrawQuad>()); | 198 quad_sink->Append(quad.PassAs<DrawQuad>()); |
180 append_quads_data->num_missing_tiles++; | 199 append_quads_data->num_missing_tiles++; |
181 return; | 200 return; |
182 } | 201 } |
183 | 202 |
184 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); | 203 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); |
185 | 204 |
186 if (ShowDebugBorders()) { | 205 if (ShowDebugBorders()) { |
187 for (PictureLayerTilingSet::CoverageIterator iter( | 206 for (PictureLayerTilingSet::CoverageIterator iter( |
188 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); | 207 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); |
danakj
2014/05/15 15:15:31
because you don't want to change the draw_props, y
| |
189 iter; | 208 iter; |
190 ++iter) { | 209 ++iter) { |
191 SkColor color; | 210 SkColor color; |
192 float width; | 211 float width; |
193 if (*iter && iter->IsReadyToDraw()) { | 212 if (*iter && iter->IsReadyToDraw()) { |
194 ManagedTileState::TileVersion::Mode mode = | 213 ManagedTileState::TileVersion::Mode mode = |
195 iter->GetTileVersionForDrawing().mode(); | 214 iter->GetTileVersionForDrawing().mode(); |
196 if (mode == ManagedTileState::TileVersion::SOLID_COLOR_MODE) { | 215 if (mode == ManagedTileState::TileVersion::SOLID_COLOR_MODE) { |
197 color = DebugColors::SolidColorTileBorderColor(); | 216 color = DebugColors::SolidColorTileBorderColor(); |
198 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); | 217 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); |
(...skipping 30 matching lines...) Expand all Loading... | |
229 quad_sink->Append(debug_border_quad.PassAs<DrawQuad>()); | 248 quad_sink->Append(debug_border_quad.PassAs<DrawQuad>()); |
230 } | 249 } |
231 } | 250 } |
232 | 251 |
233 // Keep track of the tilings that were used so that tilings that are | 252 // Keep track of the tilings that were used so that tilings that are |
234 // unused can be considered for removal. | 253 // unused can be considered for removal. |
235 std::vector<PictureLayerTiling*> seen_tilings; | 254 std::vector<PictureLayerTiling*> seen_tilings; |
236 | 255 |
237 bool had_checkerboard_quads = false; | 256 bool had_checkerboard_quads = false; |
238 for (PictureLayerTilingSet::CoverageIterator iter( | 257 for (PictureLayerTilingSet::CoverageIterator iter( |
239 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); | 258 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); |
240 iter; | 259 iter; |
241 ++iter) { | 260 ++iter) { |
242 gfx::Rect geometry_rect = iter.geometry_rect(); | 261 gfx::Rect geometry_rect = iter.geometry_rect(); |
243 gfx::Rect visible_geometry_rect = | 262 gfx::Rect visible_geometry_rect = |
244 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform()); | 263 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform()); |
245 if (visible_geometry_rect.IsEmpty()) | 264 if (visible_geometry_rect.IsEmpty()) |
246 continue; | 265 continue; |
247 | 266 |
248 append_quads_data->visible_content_area += | 267 append_quads_data->visible_content_area += |
249 visible_geometry_rect.width() * visible_geometry_rect.height(); | 268 visible_geometry_rect.width() * visible_geometry_rect.height(); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
357 // finer tilings. | 376 // finer tilings. |
358 CleanUpTilingsOnActiveLayer(seen_tilings); | 377 CleanUpTilingsOnActiveLayer(seen_tilings); |
359 } | 378 } |
360 | 379 |
361 void PictureLayerImpl::DidUnregisterLayer() { | 380 void PictureLayerImpl::DidUnregisterLayer() { |
362 layer_needs_to_register_itself_ = true; | 381 layer_needs_to_register_itself_ = true; |
363 } | 382 } |
364 | 383 |
365 void PictureLayerImpl::UpdateTilePriorities() { | 384 void PictureLayerImpl::UpdateTilePriorities() { |
366 DCHECK(!needs_post_commit_initialization_); | 385 DCHECK(!needs_post_commit_initialization_); |
367 CHECK(should_update_tile_priorities_); | 386 |
387 CalculateIdealScales(); | |
388 ManageTilings(draw_properties().screen_space_transform_is_animating, | |
389 draw_properties().maximum_animation_contents_scale); | |
368 | 390 |
369 if (layer_needs_to_register_itself_) { | 391 if (layer_needs_to_register_itself_) { |
370 layer_tree_impl()->tile_manager()->RegisterPictureLayerImpl(this); | 392 layer_tree_impl()->tile_manager()->RegisterPictureLayerImpl(this); |
371 layer_needs_to_register_itself_ = false; | 393 layer_needs_to_register_itself_ = false; |
372 } | 394 } |
373 | 395 |
374 if (layer_tree_impl()->device_viewport_valid_for_tile_management()) { | 396 if (layer_tree_impl()->device_viewport_valid_for_tile_management()) { |
375 visible_rect_for_tile_priority_ = visible_content_rect(); | 397 visible_rect_for_tile_priority_ = visible_content_rect(); |
376 viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize(); | 398 viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize(); |
377 screen_space_transform_for_tile_priority_ = screen_space_transform(); | 399 screen_space_transform_for_tile_priority_ = screen_space_transform(); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
449 RemoveAllTilings(); | 471 RemoveAllTilings(); |
450 | 472 |
451 ResetRasterScale(); | 473 ResetRasterScale(); |
452 | 474 |
453 // To avoid an edge case after lost context where the tree is up to date but | 475 // 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 | 476 // the tilings have not been managed, request an update draw properties |
455 // to force tilings to get managed. | 477 // to force tilings to get managed. |
456 layer_tree_impl()->set_needs_update_draw_properties(); | 478 layer_tree_impl()->set_needs_update_draw_properties(); |
457 } | 479 } |
458 | 480 |
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() { | 481 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { |
528 return pile_->GetFlattenedPicture(); | 482 return pile_->GetFlattenedPicture(); |
529 } | 483 } |
530 | 484 |
531 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, | 485 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, |
532 const gfx::Rect& content_rect) { | 486 const gfx::Rect& content_rect) { |
533 if (!pile_->CanRaster(tiling->contents_scale(), content_rect)) | 487 if (!pile_->CanRaster(tiling->contents_scale(), content_rect)) |
534 return scoped_refptr<Tile>(); | 488 return scoped_refptr<Tile>(); |
535 | 489 |
536 int flags = 0; | 490 int flags = 0; |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
695 RemoveAllTilings(); | 649 RemoveAllTilings(); |
696 } | 650 } |
697 | 651 |
698 SanityCheckTilingState(); | 652 SanityCheckTilingState(); |
699 } | 653 } |
700 | 654 |
701 void PictureLayerImpl::SyncTiling( | 655 void PictureLayerImpl::SyncTiling( |
702 const PictureLayerTiling* tiling) { | 656 const PictureLayerTiling* tiling) { |
703 if (!CanHaveTilingWithScale(tiling->contents_scale())) | 657 if (!CanHaveTilingWithScale(tiling->contents_scale())) |
704 return; | 658 return; |
659 | |
660 if (!IsDrawnRenderSurfaceLayerListMember()) | |
danakj
2014/05/15 15:15:31
Do this in a separate CL? This isn't related right
| |
661 return; | |
662 | |
705 tilings_->AddTiling(tiling->contents_scale()); | 663 tilings_->AddTiling(tiling->contents_scale()); |
706 | 664 |
707 // If this tree needs update draw properties, then the tiling will | 665 // If this tree needs update draw properties, then the tiling will |
708 // get updated prior to drawing or activation. If this tree does not | 666 // 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 | 667 // need update draw properties, then its transforms are up to date and |
710 // we can create tiles for this tiling immediately. | 668 // we can create tiles for this tiling immediately. |
711 if (!layer_tree_impl()->needs_update_draw_properties() && | 669 if (!layer_tree_impl()->needs_update_draw_properties()) { |
712 should_update_tile_priorities_) { | |
713 UpdateTilePriorities(); | 670 UpdateTilePriorities(); |
714 } | 671 } |
715 } | 672 } |
716 | 673 |
717 void PictureLayerImpl::SetIsMask(bool is_mask) { | 674 void PictureLayerImpl::SetIsMask(bool is_mask) { |
718 if (is_mask_ == is_mask) | 675 if (is_mask_ == is_mask) |
719 return; | 676 return; |
720 is_mask_ = is_mask; | 677 is_mask_ = is_mask; |
721 if (tilings_) | 678 if (tilings_) |
722 tilings_->RemoveAllTiles(); | 679 tilings_->RemoveAllTiles(); |
723 } | 680 } |
724 | 681 |
725 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { | 682 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { |
726 gfx::Rect content_rect(content_bounds()); | 683 gfx::Rect content_rect(content_bounds()); |
727 float scale = contents_scale_x(); | 684 float scale = GetMaxContentScale(); |
728 PictureLayerTilingSet::CoverageIterator iter( | 685 PictureLayerTilingSet::CoverageIterator iter( |
729 tilings_.get(), scale, content_rect, ideal_contents_scale_); | 686 tilings_.get(), scale, content_rect, ideal_contents_scale_); |
730 | 687 |
731 // Mask resource not ready yet. | 688 // Mask resource not ready yet. |
732 if (!iter || !*iter) | 689 if (!iter || !*iter) |
733 return 0; | 690 return 0; |
734 | 691 |
735 // Masks only supported if they fit on exactly one tile. | 692 // Masks only supported if they fit on exactly one tile. |
736 if (iter.geometry_rect() != content_rect) | 693 if (iter.geometry_rect() != content_rect) |
737 return 0; | 694 return 0; |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
978 if (change_target_tiling) { | 935 if (change_target_tiling) { |
979 RecalculateRasterScales(animating_transform_to_screen, | 936 RecalculateRasterScales(animating_transform_to_screen, |
980 maximum_animation_contents_scale); | 937 maximum_animation_contents_scale); |
981 } | 938 } |
982 | 939 |
983 was_animating_transform_to_screen_ = animating_transform_to_screen; | 940 was_animating_transform_to_screen_ = animating_transform_to_screen; |
984 | 941 |
985 if (!change_target_tiling) | 942 if (!change_target_tiling) |
986 return; | 943 return; |
987 | 944 |
945 if (!IsDrawnRenderSurfaceLayerListMember()) | |
danakj
2014/05/15 15:15:31
Same here, separate CL?
| |
946 return; | |
947 | |
988 PictureLayerTiling* high_res = NULL; | 948 PictureLayerTiling* high_res = NULL; |
989 PictureLayerTiling* low_res = NULL; | 949 PictureLayerTiling* low_res = NULL; |
990 | 950 |
991 PictureLayerTiling* previous_low_res = NULL; | 951 PictureLayerTiling* previous_low_res = NULL; |
992 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 952 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
993 PictureLayerTiling* tiling = tilings_->tiling_at(i); | 953 PictureLayerTiling* tiling = tilings_->tiling_at(i); |
994 if (tiling->contents_scale() == raster_contents_scale_) | 954 if (tiling->contents_scale() == raster_contents_scale_) |
995 high_res = tiling; | 955 high_res = tiling; |
996 if (tiling->contents_scale() == low_res_raster_contents_scale_) | 956 if (tiling->contents_scale() == low_res_raster_contents_scale_) |
997 low_res = tiling; | 957 low_res = tiling; |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1244 tilings_->SetCanUseLCDText(is_using_lcd_text_); | 1204 tilings_->SetCanUseLCDText(is_using_lcd_text_); |
1245 } | 1205 } |
1246 | 1206 |
1247 void PictureLayerImpl::ResetRasterScale() { | 1207 void PictureLayerImpl::ResetRasterScale() { |
1248 raster_page_scale_ = 0.f; | 1208 raster_page_scale_ = 0.f; |
1249 raster_device_scale_ = 0.f; | 1209 raster_device_scale_ = 0.f; |
1250 raster_source_scale_ = 0.f; | 1210 raster_source_scale_ = 0.f; |
1251 raster_contents_scale_ = 0.f; | 1211 raster_contents_scale_ = 0.f; |
1252 low_res_raster_contents_scale_ = 0.f; | 1212 low_res_raster_contents_scale_ = 0.f; |
1253 raster_source_scale_is_fixed_ = false; | 1213 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 } | 1214 } |
1259 | 1215 |
1260 bool PictureLayerImpl::CanHaveTilings() const { | 1216 bool PictureLayerImpl::CanHaveTilings() const { |
1261 if (!DrawsContent()) | 1217 if (!DrawsContent()) |
1262 return false; | 1218 return false; |
1263 if (!pile_->HasRecordings()) | 1219 if (!pile_->HasRecordings()) |
1264 return false; | 1220 return false; |
1265 return true; | 1221 return true; |
1266 } | 1222 } |
1267 | 1223 |
(...skipping 13 matching lines...) Expand all Loading... | |
1281 } | 1237 } |
1282 if (tilings_->num_tilings() == 0) | 1238 if (tilings_->num_tilings() == 0) |
1283 return; | 1239 return; |
1284 | 1240 |
1285 // MarkVisibleResourcesAsRequired depends on having exactly 1 high res | 1241 // MarkVisibleResourcesAsRequired depends on having exactly 1 high res |
1286 // tiling to mark its tiles as being required for activation. | 1242 // tiling to mark its tiles as being required for activation. |
1287 DCHECK_EQ(1, tilings_->NumHighResTilings()); | 1243 DCHECK_EQ(1, tilings_->NumHighResTilings()); |
1288 #endif | 1244 #endif |
1289 } | 1245 } |
1290 | 1246 |
1247 float PictureLayerImpl::GetMaxContentScale() const { | |
1248 float max_contents_scale = 1.f; | |
1249 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | |
1250 const PictureLayerTiling* tiling = tilings_->tiling_at(i); | |
1251 max_contents_scale = std::max(max_contents_scale, tiling->contents_scale()); | |
1252 } | |
1253 return max_contents_scale; | |
1254 } | |
1255 | |
1256 void PictureLayerImpl::CalculateIdealScales() { | |
1257 DoPostCommitInitializationIfNeeded(); | |
danakj
2014/05/15 15:15:31
Move this up to the UpdateTilePrios method please
| |
1258 | |
1259 if (!CanHaveTilings()) { | |
1260 ideal_page_scale_ = layer_tree_impl()->page_scale_factor(); | |
danakj
2014/05/15 15:15:31
This value is different from before, this is the v
| |
1261 ideal_device_scale_ = layer_tree_impl()->device_scale_factor(); | |
1262 ideal_contents_scale_ = draw_properties().ideal_contents_scale; | |
1263 ideal_source_scale_ = | |
1264 ideal_contents_scale_ / ideal_page_scale_ / ideal_device_scale_; | |
1265 return; | |
1266 } | |
1267 | |
1268 float min_contents_scale = MinimumContentsScale(); | |
1269 DCHECK_GT(min_contents_scale, 0.f); | |
1270 float min_page_scale = layer_tree_impl()->min_page_scale_factor(); | |
1271 DCHECK_GT(min_page_scale, 0.f); | |
1272 float min_device_scale = 1.f; | |
1273 float min_source_scale = | |
1274 min_contents_scale / min_page_scale / min_device_scale; | |
1275 | |
1276 float ideal_page_scale = layer_tree_impl()->page_scale_factor(); | |
1277 float ideal_device_scale = layer_tree_impl()->device_scale_factor(); | |
1278 float ideal_source_scale = draw_properties().ideal_contents_scale / | |
1279 ideal_page_scale / ideal_device_scale; | |
1280 | |
1281 ideal_contents_scale_ = | |
1282 std::max(draw_properties().ideal_contents_scale, min_contents_scale); | |
1283 ideal_page_scale_ = layer_tree_impl()->page_scale_factor(); | |
1284 ideal_device_scale_ = layer_tree_impl()->device_scale_factor(); | |
1285 ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale); | |
1286 } | |
1287 | |
1291 void PictureLayerImpl::GetDebugBorderProperties( | 1288 void PictureLayerImpl::GetDebugBorderProperties( |
1292 SkColor* color, | 1289 SkColor* color, |
1293 float* width) const { | 1290 float* width) const { |
1294 *color = DebugColors::TiledContentLayerBorderColor(); | 1291 *color = DebugColors::TiledContentLayerBorderColor(); |
1295 *width = DebugColors::TiledContentLayerBorderWidth(layer_tree_impl()); | 1292 *width = DebugColors::TiledContentLayerBorderWidth(layer_tree_impl()); |
1296 } | 1293 } |
1297 | 1294 |
1298 void PictureLayerImpl::AsValueInto(base::DictionaryValue* state) const { | 1295 void PictureLayerImpl::AsValueInto(base::DictionaryValue* state) const { |
1299 const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded(); | 1296 const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded(); |
1300 LayerImpl::AsValueInto(state); | 1297 LayerImpl::AsValueInto(state); |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1557 return iterator_index_ < iterators_.size(); | 1554 return iterator_index_ < iterators_.size(); |
1558 } | 1555 } |
1559 | 1556 |
1560 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( | 1557 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( |
1561 PictureLayerTiling::TilingEvictionTileIterator* it) const { | 1558 PictureLayerTiling::TilingEvictionTileIterator* it) const { |
1562 return it->get_type() == iteration_stage_ && | 1559 return it->get_type() == iteration_stage_ && |
1563 (**it)->required_for_activation() == required_for_activation_; | 1560 (**it)->required_for_activation() == required_for_activation_; |
1564 } | 1561 } |
1565 | 1562 |
1566 } // namespace cc | 1563 } // namespace cc |
OLD | NEW |