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()); | 141 |
143 gfx::Rect content_rect(content_bounds()); | 142 float max_contents_scale = GetMaxContentScale(); |
143 gfx::Transform scaled_draw_transform = draw_transform(); | |
144 scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale, | |
145 SK_MScalar1 / max_contents_scale); | |
146 gfx::Size scaled_content_bounds = | |
147 gfx::ToCeiledSize(gfx::ScaleSize(content_bounds(), max_contents_scale)); | |
148 | |
149 gfx::Rect scaled_visible_content_rect = | |
150 gfx::ScaleToEnclosingRect(visible_content_rect(), max_contents_scale); | |
151 scaled_visible_content_rect.Intersect(gfx::Rect(scaled_content_bounds)); | |
152 gfx::Rect rect = gfx::ToEnclosingRect(scaled_visible_content_rect); | |
danakj
2014/05/16 14:49:05
this ToEnclosingRect() is redundant since scaled_v
| |
144 | 153 |
145 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); | 154 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); |
146 PopulateSharedQuadState(shared_quad_state); | 155 UpdateSharedQuadState( |
156 shared_quad_state, scaled_draw_transform, scaled_content_bounds, rect); | |
danakj
2014/05/16 14:49:05
can you pass the scaled_visible_content_rect here,
| |
147 | 157 |
148 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) { | 158 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) { |
149 AppendDebugBorderQuad( | 159 AppendDebugBorderQuad( |
150 quad_sink, | 160 quad_sink, |
151 shared_quad_state, | 161 shared_quad_state, |
152 append_quads_data, | 162 append_quads_data, |
153 DebugColors::DirectPictureBorderColor(), | 163 DebugColors::DirectPictureBorderColor(), |
154 DebugColors::DirectPictureBorderWidth(layer_tree_impl())); | 164 DebugColors::DirectPictureBorderWidth(layer_tree_impl())); |
155 | 165 |
156 gfx::Rect geometry_rect = rect; | 166 gfx::Rect geometry_rect = rect; |
157 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); | 167 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); |
158 gfx::Rect visible_geometry_rect = | 168 gfx::Rect visible_geometry_rect = |
159 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform()); | 169 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform()); |
160 if (visible_geometry_rect.IsEmpty()) | 170 if (visible_geometry_rect.IsEmpty()) |
161 return; | 171 return; |
162 | 172 |
163 gfx::Size texture_size = rect.size(); | 173 gfx::Size texture_size = rect.size(); |
164 gfx::RectF texture_rect = gfx::RectF(texture_size); | 174 gfx::RectF texture_rect = gfx::RectF(texture_size); |
165 gfx::Rect quad_content_rect = rect; | 175 gfx::Rect quad_content_rect = rect; |
166 float contents_scale = contents_scale_x(); | 176 float contents_scale = max_contents_scale; |
167 | 177 |
168 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); | 178 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); |
169 quad->SetNew(shared_quad_state, | 179 quad->SetNew(shared_quad_state, |
170 geometry_rect, | 180 geometry_rect, |
171 opaque_rect, | 181 opaque_rect, |
172 visible_geometry_rect, | 182 visible_geometry_rect, |
173 texture_rect, | 183 texture_rect, |
174 texture_size, | 184 texture_size, |
175 RGBA_8888, | 185 RGBA_8888, |
176 quad_content_rect, | 186 quad_content_rect, |
177 contents_scale, | 187 contents_scale, |
178 pile_); | 188 pile_); |
179 quad_sink->Append(quad.PassAs<DrawQuad>()); | 189 quad_sink->Append(quad.PassAs<DrawQuad>()); |
180 append_quads_data->num_missing_tiles++; | 190 append_quads_data->num_missing_tiles++; |
181 return; | 191 return; |
182 } | 192 } |
183 | 193 |
184 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); | 194 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); |
185 | 195 |
186 if (ShowDebugBorders()) { | 196 if (ShowDebugBorders()) { |
187 for (PictureLayerTilingSet::CoverageIterator iter( | 197 for (PictureLayerTilingSet::CoverageIterator iter( |
188 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); | 198 tilings_.get(), max_contents_scale, rect, ideal_contents_scale_); |
189 iter; | 199 iter; |
190 ++iter) { | 200 ++iter) { |
191 SkColor color; | 201 SkColor color; |
192 float width; | 202 float width; |
193 if (*iter && iter->IsReadyToDraw()) { | 203 if (*iter && iter->IsReadyToDraw()) { |
194 ManagedTileState::TileVersion::Mode mode = | 204 ManagedTileState::TileVersion::Mode mode = |
195 iter->GetTileVersionForDrawing().mode(); | 205 iter->GetTileVersionForDrawing().mode(); |
196 if (mode == ManagedTileState::TileVersion::SOLID_COLOR_MODE) { | 206 if (mode == ManagedTileState::TileVersion::SOLID_COLOR_MODE) { |
197 color = DebugColors::SolidColorTileBorderColor(); | 207 color = DebugColors::SolidColorTileBorderColor(); |
198 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); | 208 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); |
199 } else if (mode == ManagedTileState::TileVersion::PICTURE_PILE_MODE) { | 209 } else if (mode == ManagedTileState::TileVersion::PICTURE_PILE_MODE) { |
200 color = DebugColors::PictureTileBorderColor(); | 210 color = DebugColors::PictureTileBorderColor(); |
201 width = DebugColors::PictureTileBorderWidth(layer_tree_impl()); | 211 width = DebugColors::PictureTileBorderWidth(layer_tree_impl()); |
202 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { | 212 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { |
203 color = DebugColors::HighResTileBorderColor(); | 213 color = DebugColors::HighResTileBorderColor(); |
204 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); | 214 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); |
205 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { | 215 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { |
206 color = DebugColors::LowResTileBorderColor(); | 216 color = DebugColors::LowResTileBorderColor(); |
207 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); | 217 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); |
208 } else if (iter->contents_scale() > contents_scale_x()) { | 218 } else if (iter->contents_scale() > max_contents_scale) { |
209 color = DebugColors::ExtraHighResTileBorderColor(); | 219 color = DebugColors::ExtraHighResTileBorderColor(); |
210 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); | 220 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); |
211 } else { | 221 } else { |
212 color = DebugColors::ExtraLowResTileBorderColor(); | 222 color = DebugColors::ExtraLowResTileBorderColor(); |
213 width = DebugColors::ExtraLowResTileBorderWidth(layer_tree_impl()); | 223 width = DebugColors::ExtraLowResTileBorderWidth(layer_tree_impl()); |
214 } | 224 } |
215 } else { | 225 } else { |
216 color = DebugColors::MissingTileBorderColor(); | 226 color = DebugColors::MissingTileBorderColor(); |
217 width = DebugColors::MissingTileBorderWidth(layer_tree_impl()); | 227 width = DebugColors::MissingTileBorderWidth(layer_tree_impl()); |
218 } | 228 } |
(...skipping 10 matching lines...) Expand all Loading... | |
229 quad_sink->Append(debug_border_quad.PassAs<DrawQuad>()); | 239 quad_sink->Append(debug_border_quad.PassAs<DrawQuad>()); |
230 } | 240 } |
231 } | 241 } |
232 | 242 |
233 // Keep track of the tilings that were used so that tilings that are | 243 // Keep track of the tilings that were used so that tilings that are |
234 // unused can be considered for removal. | 244 // unused can be considered for removal. |
235 std::vector<PictureLayerTiling*> seen_tilings; | 245 std::vector<PictureLayerTiling*> seen_tilings; |
236 | 246 |
237 bool had_checkerboard_quads = false; | 247 bool had_checkerboard_quads = false; |
238 for (PictureLayerTilingSet::CoverageIterator iter( | 248 for (PictureLayerTilingSet::CoverageIterator iter( |
239 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); | 249 tilings_.get(), max_contents_scale, rect, ideal_contents_scale_); |
240 iter; | 250 iter; |
241 ++iter) { | 251 ++iter) { |
242 gfx::Rect geometry_rect = iter.geometry_rect(); | 252 gfx::Rect geometry_rect = iter.geometry_rect(); |
243 gfx::Rect visible_geometry_rect = | 253 gfx::Rect visible_geometry_rect = |
244 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform()); | 254 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform()); |
245 if (visible_geometry_rect.IsEmpty()) | 255 if (visible_geometry_rect.IsEmpty()) |
246 continue; | 256 continue; |
247 | 257 |
248 append_quads_data->visible_content_area += | 258 append_quads_data->visible_content_area += |
249 visible_geometry_rect.width() * visible_geometry_rect.height(); | 259 visible_geometry_rect.width() * visible_geometry_rect.height(); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
357 // finer tilings. | 367 // finer tilings. |
358 CleanUpTilingsOnActiveLayer(seen_tilings); | 368 CleanUpTilingsOnActiveLayer(seen_tilings); |
359 } | 369 } |
360 | 370 |
361 void PictureLayerImpl::DidUnregisterLayer() { | 371 void PictureLayerImpl::DidUnregisterLayer() { |
362 layer_needs_to_register_itself_ = true; | 372 layer_needs_to_register_itself_ = true; |
363 } | 373 } |
364 | 374 |
365 void PictureLayerImpl::UpdateTilePriorities() { | 375 void PictureLayerImpl::UpdateTilePriorities() { |
366 DCHECK(!needs_post_commit_initialization_); | 376 DCHECK(!needs_post_commit_initialization_); |
367 CHECK(should_update_tile_priorities_); | 377 |
378 DoPostCommitInitializationIfNeeded(); | |
379 CalculateIdealScales(); | |
380 ManageTilings(draw_properties().screen_space_transform_is_animating, | |
381 draw_properties().maximum_animation_contents_scale); | |
368 | 382 |
369 if (layer_needs_to_register_itself_) { | 383 if (layer_needs_to_register_itself_) { |
370 layer_tree_impl()->tile_manager()->RegisterPictureLayerImpl(this); | 384 layer_tree_impl()->tile_manager()->RegisterPictureLayerImpl(this); |
371 layer_needs_to_register_itself_ = false; | 385 layer_needs_to_register_itself_ = false; |
372 } | 386 } |
373 | 387 |
374 if (layer_tree_impl()->device_viewport_valid_for_tile_management()) { | 388 if (layer_tree_impl()->device_viewport_valid_for_tile_management()) { |
375 visible_rect_for_tile_priority_ = visible_content_rect(); | 389 visible_rect_for_tile_priority_ = visible_content_rect(); |
376 viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize(); | 390 viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize(); |
377 screen_space_transform_for_tile_priority_ = screen_space_transform(); | 391 screen_space_transform_for_tile_priority_ = screen_space_transform(); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
449 RemoveAllTilings(); | 463 RemoveAllTilings(); |
450 | 464 |
451 ResetRasterScale(); | 465 ResetRasterScale(); |
452 | 466 |
453 // To avoid an edge case after lost context where the tree is up to date but | 467 // 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 | 468 // the tilings have not been managed, request an update draw properties |
455 // to force tilings to get managed. | 469 // to force tilings to get managed. |
456 layer_tree_impl()->set_needs_update_draw_properties(); | 470 layer_tree_impl()->set_needs_update_draw_properties(); |
457 } | 471 } |
458 | 472 |
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() { | 473 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { |
528 return pile_->GetFlattenedPicture(); | 474 return pile_->GetFlattenedPicture(); |
529 } | 475 } |
530 | 476 |
531 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, | 477 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, |
532 const gfx::Rect& content_rect) { | 478 const gfx::Rect& content_rect) { |
533 if (!pile_->CanRaster(tiling->contents_scale(), content_rect)) | 479 if (!pile_->CanRaster(tiling->contents_scale(), content_rect)) |
534 return scoped_refptr<Tile>(); | 480 return scoped_refptr<Tile>(); |
535 | 481 |
536 int flags = 0; | 482 int flags = 0; |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
695 RemoveAllTilings(); | 641 RemoveAllTilings(); |
696 } | 642 } |
697 | 643 |
698 SanityCheckTilingState(); | 644 SanityCheckTilingState(); |
699 } | 645 } |
700 | 646 |
701 void PictureLayerImpl::SyncTiling( | 647 void PictureLayerImpl::SyncTiling( |
702 const PictureLayerTiling* tiling) { | 648 const PictureLayerTiling* tiling) { |
703 if (!CanHaveTilingWithScale(tiling->contents_scale())) | 649 if (!CanHaveTilingWithScale(tiling->contents_scale())) |
704 return; | 650 return; |
651 | |
705 tilings_->AddTiling(tiling->contents_scale()); | 652 tilings_->AddTiling(tiling->contents_scale()); |
706 | 653 |
707 // If this tree needs update draw properties, then the tiling will | 654 // If this tree needs update draw properties, then the tiling will |
708 // get updated prior to drawing or activation. If this tree does not | 655 // 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 | 656 // need update draw properties, then its transforms are up to date and |
710 // we can create tiles for this tiling immediately. | 657 // we can create tiles for this tiling immediately. |
711 if (!layer_tree_impl()->needs_update_draw_properties() && | 658 if (!layer_tree_impl()->needs_update_draw_properties()) { |
712 should_update_tile_priorities_) { | |
713 UpdateTilePriorities(); | 659 UpdateTilePriorities(); |
714 } | 660 } |
715 } | 661 } |
716 | 662 |
717 void PictureLayerImpl::SetIsMask(bool is_mask) { | 663 void PictureLayerImpl::SetIsMask(bool is_mask) { |
718 if (is_mask_ == is_mask) | 664 if (is_mask_ == is_mask) |
719 return; | 665 return; |
720 is_mask_ = is_mask; | 666 is_mask_ = is_mask; |
721 if (tilings_) | 667 if (tilings_) |
722 tilings_->RemoveAllTiles(); | 668 tilings_->RemoveAllTiles(); |
723 } | 669 } |
724 | 670 |
725 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { | 671 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { |
726 gfx::Rect content_rect(content_bounds()); | 672 gfx::Rect content_rect(content_bounds()); |
727 float scale = contents_scale_x(); | 673 float scale = GetMaxContentScale(); |
728 PictureLayerTilingSet::CoverageIterator iter( | 674 PictureLayerTilingSet::CoverageIterator iter( |
729 tilings_.get(), scale, content_rect, ideal_contents_scale_); | 675 tilings_.get(), scale, content_rect, ideal_contents_scale_); |
730 | 676 |
731 // Mask resource not ready yet. | 677 // Mask resource not ready yet. |
732 if (!iter || !*iter) | 678 if (!iter || !*iter) |
733 return 0; | 679 return 0; |
734 | 680 |
735 // Masks only supported if they fit on exactly one tile. | 681 // Masks only supported if they fit on exactly one tile. |
736 if (iter.geometry_rect() != content_rect) | 682 if (iter.geometry_rect() != content_rect) |
737 return 0; | 683 return 0; |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1244 tilings_->SetCanUseLCDText(is_using_lcd_text_); | 1190 tilings_->SetCanUseLCDText(is_using_lcd_text_); |
1245 } | 1191 } |
1246 | 1192 |
1247 void PictureLayerImpl::ResetRasterScale() { | 1193 void PictureLayerImpl::ResetRasterScale() { |
1248 raster_page_scale_ = 0.f; | 1194 raster_page_scale_ = 0.f; |
1249 raster_device_scale_ = 0.f; | 1195 raster_device_scale_ = 0.f; |
1250 raster_source_scale_ = 0.f; | 1196 raster_source_scale_ = 0.f; |
1251 raster_contents_scale_ = 0.f; | 1197 raster_contents_scale_ = 0.f; |
1252 low_res_raster_contents_scale_ = 0.f; | 1198 low_res_raster_contents_scale_ = 0.f; |
1253 raster_source_scale_is_fixed_ = false; | 1199 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 } | 1200 } |
1259 | 1201 |
1260 bool PictureLayerImpl::CanHaveTilings() const { | 1202 bool PictureLayerImpl::CanHaveTilings() const { |
1261 if (!DrawsContent()) | 1203 if (!DrawsContent()) |
1262 return false; | 1204 return false; |
1263 if (!pile_->HasRecordings()) | 1205 if (!pile_->HasRecordings()) |
1264 return false; | 1206 return false; |
1265 return true; | 1207 return true; |
1266 } | 1208 } |
1267 | 1209 |
(...skipping 13 matching lines...) Expand all Loading... | |
1281 } | 1223 } |
1282 if (tilings_->num_tilings() == 0) | 1224 if (tilings_->num_tilings() == 0) |
1283 return; | 1225 return; |
1284 | 1226 |
1285 // MarkVisibleResourcesAsRequired depends on having exactly 1 high res | 1227 // MarkVisibleResourcesAsRequired depends on having exactly 1 high res |
1286 // tiling to mark its tiles as being required for activation. | 1228 // tiling to mark its tiles as being required for activation. |
1287 DCHECK_EQ(1, tilings_->NumHighResTilings()); | 1229 DCHECK_EQ(1, tilings_->NumHighResTilings()); |
1288 #endif | 1230 #endif |
1289 } | 1231 } |
1290 | 1232 |
1233 float PictureLayerImpl::GetMaxContentScale() const { | |
1234 float max_contents_scale = 1.f; | |
1235 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | |
1236 const PictureLayerTiling* tiling = tilings_->tiling_at(i); | |
1237 max_contents_scale = std::max(max_contents_scale, tiling->contents_scale()); | |
1238 } | |
1239 return max_contents_scale; | |
1240 } | |
1241 | |
1242 void PictureLayerImpl::CalculateIdealScales() { | |
1243 if (!CanHaveTilings()) { | |
1244 ideal_page_scale_ = draw_properties().page_scale; | |
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 |