Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: cc/layers/picture_layer_impl.cc

Issue 271533011: cc: Move tiling management out of draw properties calculation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: PictureImageLayerImpl unittests updated. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
142 float max_contents_scale = MaximumTilingContentScale();
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));
143 152
144 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); 153 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState();
145 PopulateSharedQuadState(shared_quad_state); 154 PopulateSharedQuadStateWithOverrides(shared_quad_state,
155 scaled_draw_transform,
156 scaled_content_bounds,
157 scaled_visible_content_rect);
158
159 gfx::Rect rect = scaled_visible_content_rect;
146 160
147 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) { 161 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) {
148 AppendDebugBorderQuad( 162 AppendDebugBorderQuad(
149 quad_sink, 163 quad_sink,
150 shared_quad_state, 164 shared_quad_state,
151 append_quads_data, 165 append_quads_data,
152 DebugColors::DirectPictureBorderColor(), 166 DebugColors::DirectPictureBorderColor(),
153 DebugColors::DirectPictureBorderWidth(layer_tree_impl())); 167 DebugColors::DirectPictureBorderWidth(layer_tree_impl()));
154 168
155 gfx::Rect geometry_rect = rect; 169 gfx::Rect geometry_rect = rect;
156 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); 170 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect();
157 gfx::Rect visible_geometry_rect = 171 gfx::Rect visible_geometry_rect =
158 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform()); 172 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform());
159 if (visible_geometry_rect.IsEmpty()) 173 if (visible_geometry_rect.IsEmpty())
160 return; 174 return;
161 175
162 gfx::Size texture_size = rect.size(); 176 gfx::Size texture_size = rect.size();
163 gfx::RectF texture_rect = gfx::RectF(texture_size); 177 gfx::RectF texture_rect = gfx::RectF(texture_size);
164 gfx::Rect quad_content_rect = rect; 178 gfx::Rect quad_content_rect = rect;
165 float contents_scale = contents_scale_x(); 179 float contents_scale = max_contents_scale;
166 180
167 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); 181 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create();
168 quad->SetNew(shared_quad_state, 182 quad->SetNew(shared_quad_state,
169 geometry_rect, 183 geometry_rect,
170 opaque_rect, 184 opaque_rect,
171 visible_geometry_rect, 185 visible_geometry_rect,
172 texture_rect, 186 texture_rect,
173 texture_size, 187 texture_size,
174 RGBA_8888, 188 RGBA_8888,
175 quad_content_rect, 189 quad_content_rect,
176 contents_scale, 190 contents_scale,
177 pile_); 191 pile_);
178 quad_sink->Append(quad.PassAs<DrawQuad>()); 192 quad_sink->Append(quad.PassAs<DrawQuad>());
179 append_quads_data->num_missing_tiles++; 193 append_quads_data->num_missing_tiles++;
180 return; 194 return;
181 } 195 }
182 196
183 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); 197 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data);
184
enne (OOO) 2014/05/20 17:48:09 Please leave this line.
sohanjg 2014/05/21 10:32:38 Done.
185 if (ShowDebugBorders()) { 198 if (ShowDebugBorders()) {
186 for (PictureLayerTilingSet::CoverageIterator iter( 199 for (PictureLayerTilingSet::CoverageIterator iter(
187 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); 200 tilings_.get(), max_contents_scale, rect, ideal_contents_scale_);
188 iter; 201 iter;
189 ++iter) { 202 ++iter) {
190 SkColor color; 203 SkColor color;
191 float width; 204 float width;
192 if (*iter && iter->IsReadyToDraw()) { 205 if (*iter && iter->IsReadyToDraw()) {
193 ManagedTileState::TileVersion::Mode mode = 206 ManagedTileState::TileVersion::Mode mode =
194 iter->GetTileVersionForDrawing().mode(); 207 iter->GetTileVersionForDrawing().mode();
195 if (mode == ManagedTileState::TileVersion::SOLID_COLOR_MODE) { 208 if (mode == ManagedTileState::TileVersion::SOLID_COLOR_MODE) {
196 color = DebugColors::SolidColorTileBorderColor(); 209 color = DebugColors::SolidColorTileBorderColor();
197 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); 210 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl());
198 } else if (mode == ManagedTileState::TileVersion::PICTURE_PILE_MODE) { 211 } else if (mode == ManagedTileState::TileVersion::PICTURE_PILE_MODE) {
199 color = DebugColors::PictureTileBorderColor(); 212 color = DebugColors::PictureTileBorderColor();
200 width = DebugColors::PictureTileBorderWidth(layer_tree_impl()); 213 width = DebugColors::PictureTileBorderWidth(layer_tree_impl());
201 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { 214 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) {
202 color = DebugColors::HighResTileBorderColor(); 215 color = DebugColors::HighResTileBorderColor();
203 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); 216 width = DebugColors::HighResTileBorderWidth(layer_tree_impl());
204 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { 217 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) {
205 color = DebugColors::LowResTileBorderColor(); 218 color = DebugColors::LowResTileBorderColor();
206 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); 219 width = DebugColors::LowResTileBorderWidth(layer_tree_impl());
207 } else if (iter->contents_scale() > contents_scale_x()) { 220 } else if (iter->contents_scale() > max_contents_scale) {
208 color = DebugColors::ExtraHighResTileBorderColor(); 221 color = DebugColors::ExtraHighResTileBorderColor();
209 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); 222 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl());
210 } else { 223 } else {
211 color = DebugColors::ExtraLowResTileBorderColor(); 224 color = DebugColors::ExtraLowResTileBorderColor();
212 width = DebugColors::ExtraLowResTileBorderWidth(layer_tree_impl()); 225 width = DebugColors::ExtraLowResTileBorderWidth(layer_tree_impl());
213 } 226 }
214 } else { 227 } else {
215 color = DebugColors::MissingTileBorderColor(); 228 color = DebugColors::MissingTileBorderColor();
216 width = DebugColors::MissingTileBorderWidth(layer_tree_impl()); 229 width = DebugColors::MissingTileBorderWidth(layer_tree_impl());
217 } 230 }
(...skipping 10 matching lines...) Expand all
228 quad_sink->Append(debug_border_quad.PassAs<DrawQuad>()); 241 quad_sink->Append(debug_border_quad.PassAs<DrawQuad>());
229 } 242 }
230 } 243 }
231 244
232 // Keep track of the tilings that were used so that tilings that are 245 // Keep track of the tilings that were used so that tilings that are
233 // unused can be considered for removal. 246 // unused can be considered for removal.
234 std::vector<PictureLayerTiling*> seen_tilings; 247 std::vector<PictureLayerTiling*> seen_tilings;
235 248
236 bool had_checkerboard_quads = false; 249 bool had_checkerboard_quads = false;
237 for (PictureLayerTilingSet::CoverageIterator iter( 250 for (PictureLayerTilingSet::CoverageIterator iter(
238 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); 251 tilings_.get(), max_contents_scale, rect, ideal_contents_scale_);
239 iter; 252 iter;
240 ++iter) { 253 ++iter) {
241 gfx::Rect geometry_rect = iter.geometry_rect(); 254 gfx::Rect geometry_rect = iter.geometry_rect();
242 gfx::Rect visible_geometry_rect = 255 gfx::Rect visible_geometry_rect =
243 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform()); 256 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform());
244 if (visible_geometry_rect.IsEmpty()) 257 if (visible_geometry_rect.IsEmpty())
245 continue; 258 continue;
246 259
247 append_quads_data->visible_content_area += 260 append_quads_data->visible_content_area +=
248 visible_geometry_rect.width() * visible_geometry_rect.height(); 261 visible_geometry_rect.width() * visible_geometry_rect.height();
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 372
360 void PictureLayerImpl::DidUnregisterLayer() { 373 void PictureLayerImpl::DidUnregisterLayer() {
361 TRACE_EVENT0("cc", "PictureLayerImpl::DidUnregisterLayer"); 374 TRACE_EVENT0("cc", "PictureLayerImpl::DidUnregisterLayer");
362 375
363 layer_needs_to_register_itself_ = true; 376 layer_needs_to_register_itself_ = true;
364 } 377 }
365 378
366 void PictureLayerImpl::UpdateTilePriorities() { 379 void PictureLayerImpl::UpdateTilePriorities() {
367 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities"); 380 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities");
368 381
369 DCHECK(!needs_post_commit_initialization_); 382 DCHECK(!needs_post_commit_initialization_);
vmpstr 2014/05/20 17:10:38 Is this DCHECK valid, considering that you do post
sohanjg 2014/05/21 10:32:38 Done. sorry, i missed it in the last round.
370 CHECK(should_update_tile_priorities_); 383
384 DoPostCommitInitializationIfNeeded();
385 CalculateIdealScales();
386 if (CanHaveTilings()) {
387 ManageTilings(draw_properties().screen_space_transform_is_animating,
388 draw_properties().maximum_animation_contents_scale);
389 }
371 390
372 if (layer_needs_to_register_itself_) { 391 if (layer_needs_to_register_itself_) {
373 layer_tree_impl()->tile_manager()->RegisterPictureLayerImpl(this); 392 layer_tree_impl()->tile_manager()->RegisterPictureLayerImpl(this);
374 layer_needs_to_register_itself_ = false; 393 layer_needs_to_register_itself_ = false;
375 } 394 }
376 395
377 if (layer_tree_impl()->device_viewport_valid_for_tile_management()) { 396 if (layer_tree_impl()->device_viewport_valid_for_tile_management()) {
378 visible_rect_for_tile_priority_ = visible_content_rect(); 397 visible_rect_for_tile_priority_ = visible_content_rect();
379 viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize(); 398 viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize();
380 screen_space_transform_for_tile_priority_ = screen_space_transform(); 399 screen_space_transform_for_tile_priority_ = screen_space_transform();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 } 433 }
415 } 434 }
416 435
417 WhichTree tree = 436 WhichTree tree =
418 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; 437 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE;
419 438
420 tilings_->UpdateTilePriorities(tree, 439 tilings_->UpdateTilePriorities(tree,
421 visible_rect_in_content_space, 440 visible_rect_in_content_space,
422 contents_scale_x(), 441 contents_scale_x(),
423 current_frame_time_in_seconds); 442 current_frame_time_in_seconds);
424
enne (OOO) 2014/05/20 17:48:09 Please leave this line.
sohanjg 2014/05/21 10:32:38 Done.
425 if (layer_tree_impl()->IsPendingTree()) 443 if (layer_tree_impl()->IsPendingTree())
426 MarkVisibleResourcesAsRequired(); 444 MarkVisibleResourcesAsRequired();
427 445
428 // Tile priorities were modified. 446 // Tile priorities were modified.
429 layer_tree_impl()->DidModifyTilePriorities(); 447 layer_tree_impl()->DidModifyTilePriorities();
430 } 448 }
431 449
432 void PictureLayerImpl::NotifyTileInitialized(const Tile* tile) { 450 void PictureLayerImpl::NotifyTileInitialized(const Tile* tile) {
433 if (layer_tree_impl()->IsActiveTree()) { 451 if (layer_tree_impl()->IsActiveTree()) {
434 gfx::RectF layer_damage_rect = 452 gfx::RectF layer_damage_rect =
(...skipping 17 matching lines...) Expand all
452 RemoveAllTilings(); 470 RemoveAllTilings();
453 471
454 ResetRasterScale(); 472 ResetRasterScale();
455 473
456 // To avoid an edge case after lost context where the tree is up to date but 474 // To avoid an edge case after lost context where the tree is up to date but
457 // the tilings have not been managed, request an update draw properties 475 // the tilings have not been managed, request an update draw properties
458 // to force tilings to get managed. 476 // to force tilings to get managed.
459 layer_tree_impl()->set_needs_update_draw_properties(); 477 layer_tree_impl()->set_needs_update_draw_properties();
460 } 478 }
461 479
462 void PictureLayerImpl::CalculateContentsScale(
463 float ideal_contents_scale,
464 float device_scale_factor,
465 float page_scale_factor,
466 float maximum_animation_contents_scale,
467 bool animating_transform_to_screen,
468 float* contents_scale_x,
469 float* contents_scale_y,
470 gfx::Size* content_bounds) {
471 DoPostCommitInitializationIfNeeded();
472
473 // This function sets valid raster scales and manages tilings, so tile
474 // priorities can now be updated.
475 should_update_tile_priorities_ = true;
476
477 if (!CanHaveTilings()) {
478 ideal_page_scale_ = page_scale_factor;
479 ideal_device_scale_ = device_scale_factor;
480 ideal_contents_scale_ = ideal_contents_scale;
481 ideal_source_scale_ =
482 ideal_contents_scale_ / ideal_page_scale_ / ideal_device_scale_;
483 *contents_scale_x = ideal_contents_scale_;
484 *contents_scale_y = ideal_contents_scale_;
485 *content_bounds = gfx::ToCeiledSize(gfx::ScaleSize(bounds(),
486 ideal_contents_scale_,
487 ideal_contents_scale_));
488 return;
489 }
490
491 float min_contents_scale = MinimumContentsScale();
492 DCHECK_GT(min_contents_scale, 0.f);
493 float min_page_scale = layer_tree_impl()->min_page_scale_factor();
494 DCHECK_GT(min_page_scale, 0.f);
495 float min_device_scale = 1.f;
496 float min_source_scale =
497 min_contents_scale / min_page_scale / min_device_scale;
498
499 float ideal_page_scale = page_scale_factor;
500 float ideal_device_scale = device_scale_factor;
501 float ideal_source_scale =
502 ideal_contents_scale / ideal_page_scale / ideal_device_scale;
503
504 ideal_contents_scale_ = std::max(ideal_contents_scale, min_contents_scale);
505 ideal_page_scale_ = ideal_page_scale;
506 ideal_device_scale_ = ideal_device_scale;
507 ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale);
508
509 ManageTilings(animating_transform_to_screen,
510 maximum_animation_contents_scale);
511
512 // The content scale and bounds for a PictureLayerImpl is somewhat fictitious.
513 // There are (usually) several tilings at different scales. However, the
514 // content bounds is the (integer!) space in which quads are generated.
515 // In order to guarantee that we can fill this integer space with any set of
516 // tilings (and then map back to floating point texture coordinates), the
517 // contents scale must be at least as large as the largest of the tilings.
518 float max_contents_scale = min_contents_scale;
519 for (size_t i = 0; i < tilings_->num_tilings(); ++i) {
520 const PictureLayerTiling* tiling = tilings_->tiling_at(i);
521 max_contents_scale = std::max(max_contents_scale, tiling->contents_scale());
522 }
523
524 *contents_scale_x = max_contents_scale;
525 *contents_scale_y = max_contents_scale;
526 *content_bounds = gfx::ToCeiledSize(
527 gfx::ScaleSize(bounds(), max_contents_scale, max_contents_scale));
528 }
529
530 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { 480 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() {
531 return pile_->GetFlattenedPicture(); 481 return pile_->GetFlattenedPicture();
532 } 482 }
533 483
534 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, 484 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling,
535 const gfx::Rect& content_rect) { 485 const gfx::Rect& content_rect) {
536 if (!pile_->CanRaster(tiling->contents_scale(), content_rect)) 486 if (!pile_->CanRaster(tiling->contents_scale(), content_rect))
537 return scoped_refptr<Tile>(); 487 return scoped_refptr<Tile>();
538 488
539 int flags = 0; 489 int flags = 0;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 if (!synced_high_res_tiling) 659 if (!synced_high_res_tiling)
710 ResetRasterScale(); 660 ResetRasterScale();
711 else 661 else
712 SanityCheckTilingState(); 662 SanityCheckTilingState();
713 } 663 }
714 664
715 void PictureLayerImpl::SyncTiling( 665 void PictureLayerImpl::SyncTiling(
716 const PictureLayerTiling* tiling) { 666 const PictureLayerTiling* tiling) {
717 if (!CanHaveTilingWithScale(tiling->contents_scale())) 667 if (!CanHaveTilingWithScale(tiling->contents_scale()))
718 return; 668 return;
669
719 tilings_->AddTiling(tiling->contents_scale()); 670 tilings_->AddTiling(tiling->contents_scale());
720 671
721 // If this tree needs update draw properties, then the tiling will 672 // If this tree needs update draw properties, then the tiling will
722 // get updated prior to drawing or activation. If this tree does not 673 // get updated prior to drawing or activation. If this tree does not
723 // need update draw properties, then its transforms are up to date and 674 // need update draw properties, then its transforms are up to date and
724 // we can create tiles for this tiling immediately. 675 // we can create tiles for this tiling immediately.
725 if (!layer_tree_impl()->needs_update_draw_properties() && 676 if (!layer_tree_impl()->needs_update_draw_properties()) {
726 should_update_tile_priorities_) {
enne (OOO) 2014/05/20 17:48:09 I don't think this flag or logic should go away.
sohanjg 2014/05/21 10:32:38 Done.
727 UpdateTilePriorities(); 677 UpdateTilePriorities();
728 } 678 }
729 } 679 }
730 680
731 void PictureLayerImpl::SetIsMask(bool is_mask) { 681 void PictureLayerImpl::SetIsMask(bool is_mask) {
732 if (is_mask_ == is_mask) 682 if (is_mask_ == is_mask)
733 return; 683 return;
734 is_mask_ = is_mask; 684 is_mask_ = is_mask;
735 if (tilings_) 685 if (tilings_)
736 tilings_->RemoveAllTiles(); 686 tilings_->RemoveAllTiles();
737 } 687 }
738 688
739 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { 689 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const {
740 gfx::Rect content_rect(content_bounds()); 690 gfx::Rect content_rect(content_bounds());
741 float scale = contents_scale_x(); 691 float scale = MaximumTilingContentScale();
742 PictureLayerTilingSet::CoverageIterator iter( 692 PictureLayerTilingSet::CoverageIterator iter(
743 tilings_.get(), scale, content_rect, ideal_contents_scale_); 693 tilings_.get(), scale, content_rect, ideal_contents_scale_);
744 694
745 // Mask resource not ready yet. 695 // Mask resource not ready yet.
746 if (!iter || !*iter) 696 if (!iter || !*iter)
747 return 0; 697 return 0;
748 698
749 // Masks only supported if they fit on exactly one tile. 699 // Masks only supported if they fit on exactly one tile.
750 if (iter.geometry_rect() != content_rect) 700 if (iter.geometry_rect() != content_rect)
751 return 0; 701 return 0;
(...skipping 25 matching lines...) Expand all
777 if (PictureLayerImpl* twin = twin_layer_) { 727 if (PictureLayerImpl* twin = twin_layer_) {
778 float twin_min_acceptable_scale = 728 float twin_min_acceptable_scale =
779 std::min(twin->ideal_contents_scale_, twin->raster_contents_scale_); 729 std::min(twin->ideal_contents_scale_, twin->raster_contents_scale_);
780 // Ignore 0 scale in case CalculateContentsScale() has never been 730 // Ignore 0 scale in case CalculateContentsScale() has never been
781 // called for active twin. 731 // called for active twin.
782 if (twin_min_acceptable_scale != 0.0f) { 732 if (twin_min_acceptable_scale != 0.0f) {
783 min_acceptable_scale = 733 min_acceptable_scale =
784 std::min(min_acceptable_scale, twin_min_acceptable_scale); 734 std::min(min_acceptable_scale, twin_min_acceptable_scale);
785 } 735 }
786 } 736 }
787
enne (OOO) 2014/05/20 17:48:09 This line was helpful for readability.
sohanjg 2014/05/21 10:32:38 Done.
788 PictureLayerTiling* high_res = NULL; 737 PictureLayerTiling* high_res = NULL;
789 PictureLayerTiling* low_res = NULL; 738 PictureLayerTiling* low_res = NULL;
790 739
791 // First pass: ready to draw tiles in acceptable but non-ideal tilings are 740 // First pass: ready to draw tiles in acceptable but non-ideal tilings are
792 // marked as required for activation so that their textures are not thrown 741 // marked as required for activation so that their textures are not thrown
793 // away; any non-ready tiles are not marked as required. 742 // away; any non-ready tiles are not marked as required.
794 Region missing_region = rect; 743 Region missing_region = rect;
795 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { 744 for (size_t i = 0; i < tilings_->num_tilings(); ++i) {
796 PictureLayerTiling* tiling = tilings_->tiling_at(i); 745 PictureLayerTiling* tiling = tilings_->tiling_at(i);
797 DCHECK(tiling->has_ever_been_updated()); 746 DCHECK(tiling->has_ever_been_updated());
798
enne (OOO) 2014/05/20 17:48:09 This line was helpful for readability.
sohanjg 2014/05/21 10:32:38 Done.
799 if (tiling->resolution() == LOW_RESOLUTION) { 747 if (tiling->resolution() == LOW_RESOLUTION) {
800 DCHECK(!low_res) << "There can only be one low res tiling"; 748 DCHECK(!low_res) << "There can only be one low res tiling";
801 low_res = tiling; 749 low_res = tiling;
802 } 750 }
803 if (tiling->contents_scale() < min_acceptable_scale) 751 if (tiling->contents_scale() < min_acceptable_scale)
804 continue; 752 continue;
805 if (tiling->resolution() == HIGH_RESOLUTION) { 753 if (tiling->resolution() == HIGH_RESOLUTION) {
806 DCHECK(!high_res) << "There can only be one high res tiling"; 754 DCHECK(!high_res) << "There can only be one high res tiling";
807 high_res = tiling; 755 high_res = tiling;
808 continue; 756 continue;
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 tilings_->SetCanUseLCDText(is_using_lcd_text_); 1207 tilings_->SetCanUseLCDText(is_using_lcd_text_);
1260 } 1208 }
1261 1209
1262 void PictureLayerImpl::ResetRasterScale() { 1210 void PictureLayerImpl::ResetRasterScale() {
1263 raster_page_scale_ = 0.f; 1211 raster_page_scale_ = 0.f;
1264 raster_device_scale_ = 0.f; 1212 raster_device_scale_ = 0.f;
1265 raster_source_scale_ = 0.f; 1213 raster_source_scale_ = 0.f;
1266 raster_contents_scale_ = 0.f; 1214 raster_contents_scale_ = 0.f;
1267 low_res_raster_contents_scale_ = 0.f; 1215 low_res_raster_contents_scale_ = 0.f;
1268 raster_source_scale_is_fixed_ = false; 1216 raster_source_scale_is_fixed_ = false;
1269
1270 // When raster scales aren't valid, don't update tile priorities until
1271 // this layer has been updated via UpdateDrawProperties.
1272 should_update_tile_priorities_ = false;
1273 } 1217 }
1274 1218
1275 bool PictureLayerImpl::CanHaveTilings() const { 1219 bool PictureLayerImpl::CanHaveTilings() const {
1276 if (!DrawsContent()) 1220 if (!DrawsContent())
1277 return false; 1221 return false;
1278 if (!pile_->HasRecordings()) 1222 if (!pile_->HasRecordings())
1279 return false; 1223 return false;
1280 return true; 1224 return true;
1281 } 1225 }
1282 1226
(...skipping 13 matching lines...) Expand all
1296 } 1240 }
1297 if (tilings_->num_tilings() == 0) 1241 if (tilings_->num_tilings() == 0)
1298 return; 1242 return;
1299 1243
1300 // MarkVisibleResourcesAsRequired depends on having exactly 1 high res 1244 // MarkVisibleResourcesAsRequired depends on having exactly 1 high res
1301 // tiling to mark its tiles as being required for activation. 1245 // tiling to mark its tiles as being required for activation.
1302 DCHECK_EQ(1, tilings_->NumHighResTilings()); 1246 DCHECK_EQ(1, tilings_->NumHighResTilings());
1303 #endif 1247 #endif
1304 } 1248 }
1305 1249
1250 float PictureLayerImpl::MaximumTilingContentScale() const {
1251 float max_contents_scale = 1.f;
enne (OOO) 2014/05/20 17:48:09 This is wrong. Replace 1.f with MinimumContentsSc
sohanjg 2014/05/21 10:32:38 Done.
1252 for (size_t i = 0; i < tilings_->num_tilings(); ++i) {
1253 const PictureLayerTiling* tiling = tilings_->tiling_at(i);
1254 max_contents_scale = std::max(max_contents_scale, tiling->contents_scale());
1255 }
1256 return max_contents_scale;
1257 }
1258
1259 void PictureLayerImpl::CalculateIdealScales() {
enne (OOO) 2014/05/20 17:48:09 Could you name this UpdateIdealScales? It's mostly
sohanjg 2014/05/21 10:32:38 Done.
1260 if (!CanHaveTilings()) {
1261 ideal_page_scale_ = draw_properties().page_scale;
1262 ideal_device_scale_ = draw_properties().device_scale;
1263 ideal_contents_scale_ = draw_properties().ideal_contents_scale;
1264 ideal_source_scale_ =
1265 ideal_contents_scale_ / ideal_page_scale_ / ideal_device_scale_;
1266 return;
1267 }
1268
1269 float min_contents_scale = MinimumContentsScale();
1270 DCHECK_GT(min_contents_scale, 0.f);
1271 float min_page_scale = layer_tree_impl()->min_page_scale_factor();
1272 DCHECK_GT(min_page_scale, 0.f);
1273 float min_device_scale = 1.f;
1274 float min_source_scale =
1275 min_contents_scale / min_page_scale / min_device_scale;
1276
1277 float ideal_page_scale = draw_properties().page_scale;
1278 float ideal_device_scale = draw_properties().device_scale;
1279 float ideal_source_scale = draw_properties().ideal_contents_scale /
1280 ideal_page_scale / ideal_device_scale;
1281 ideal_contents_scale_ =
1282 std::max(draw_properties().ideal_contents_scale, min_contents_scale);
1283 ideal_page_scale_ = draw_properties().page_scale;
1284 ideal_device_scale_ = draw_properties().device_scale;
1285 ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale);
1286 }
1287
1306 void PictureLayerImpl::GetDebugBorderProperties( 1288 void PictureLayerImpl::GetDebugBorderProperties(
1307 SkColor* color, 1289 SkColor* color,
1308 float* width) const { 1290 float* width) const {
1309 *color = DebugColors::TiledContentLayerBorderColor(); 1291 *color = DebugColors::TiledContentLayerBorderColor();
1310 *width = DebugColors::TiledContentLayerBorderWidth(layer_tree_impl()); 1292 *width = DebugColors::TiledContentLayerBorderWidth(layer_tree_impl());
1311 } 1293 }
1312 1294
1313 void PictureLayerImpl::AsValueInto(base::DictionaryValue* state) const { 1295 void PictureLayerImpl::AsValueInto(base::DictionaryValue* state) const {
1314 const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded(); 1296 const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded();
1315 LayerImpl::AsValueInto(state); 1297 LayerImpl::AsValueInto(state);
1316 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); 1298 state->SetDouble("ideal_contents_scale", ideal_contents_scale_);
1317 state->SetDouble("geometry_contents_scale", contents_scale_x()); 1299 state->SetDouble("geometry_contents_scale", MaximumTilingContentScale());
1318 state->Set("tilings", tilings_->AsValue().release()); 1300 state->Set("tilings", tilings_->AsValue().release());
1319 state->Set("pictures", pile_->AsValue().release()); 1301 state->Set("pictures", pile_->AsValue().release());
1320 state->Set("invalidation", invalidation_.AsValue().release()); 1302 state->Set("invalidation", invalidation_.AsValue().release());
1321 1303
1322 scoped_ptr<base::ListValue> coverage_tiles(new base::ListValue); 1304 scoped_ptr<base::ListValue> coverage_tiles(new base::ListValue);
1323 for (PictureLayerTilingSet::CoverageIterator iter(tilings_.get(), 1305 for (PictureLayerTilingSet::CoverageIterator iter(tilings_.get(),
1324 contents_scale_x(), 1306 contents_scale_x(),
1325 gfx::Rect(content_bounds()), 1307 gfx::Rect(content_bounds()),
1326 ideal_contents_scale_); 1308 ideal_contents_scale_);
1327 iter; 1309 iter;
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
1572 return iterator_index_ < iterators_.size(); 1554 return iterator_index_ < iterators_.size();
1573 } 1555 }
1574 1556
1575 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( 1557 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType(
1576 PictureLayerTiling::TilingEvictionTileIterator* it) const { 1558 PictureLayerTiling::TilingEvictionTileIterator* it) const {
1577 return it->get_type() == iteration_stage_ && 1559 return it->get_type() == iteration_stage_ &&
1578 (**it)->required_for_activation() == required_for_activation_; 1560 (**it)->required_for_activation() == required_for_activation_;
1579 } 1561 }
1580 1562
1581 } // namespace cc 1563 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698