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

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: Review comments added, unittests pending. 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
« no previous file with comments | « cc/layers/picture_layer_impl.h ('k') | cc/trees/layer_tree_host_common.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
143 gfx::Rect content_rect(content_bounds()); 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));
152 gfx::Rect rect = scaled_visible_content_rect;
danakj 2014/05/16 15:47:49 one nit, move this |rect| down below PopulateSQSWi
144 153
145 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); 154 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState();
146 PopulateSharedQuadState(shared_quad_state); 155 PopulateSharedQuadStateWithOverrides(shared_quad_state,
156 scaled_draw_transform,
157 scaled_content_bounds,
158 scaled_visible_content_rect);
147 159
148 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) { 160 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) {
149 AppendDebugBorderQuad( 161 AppendDebugBorderQuad(
150 quad_sink, 162 quad_sink,
151 shared_quad_state, 163 shared_quad_state,
152 append_quads_data, 164 append_quads_data,
153 DebugColors::DirectPictureBorderColor(), 165 DebugColors::DirectPictureBorderColor(),
154 DebugColors::DirectPictureBorderWidth(layer_tree_impl())); 166 DebugColors::DirectPictureBorderWidth(layer_tree_impl()));
155 167
156 gfx::Rect geometry_rect = rect; 168 gfx::Rect geometry_rect = rect;
157 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); 169 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect();
158 gfx::Rect visible_geometry_rect = 170 gfx::Rect visible_geometry_rect =
159 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform()); 171 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform());
160 if (visible_geometry_rect.IsEmpty()) 172 if (visible_geometry_rect.IsEmpty())
161 return; 173 return;
162 174
163 gfx::Size texture_size = rect.size(); 175 gfx::Size texture_size = rect.size();
164 gfx::RectF texture_rect = gfx::RectF(texture_size); 176 gfx::RectF texture_rect = gfx::RectF(texture_size);
165 gfx::Rect quad_content_rect = rect; 177 gfx::Rect quad_content_rect = rect;
166 float contents_scale = contents_scale_x(); 178 float contents_scale = max_contents_scale;
167 179
168 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); 180 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create();
169 quad->SetNew(shared_quad_state, 181 quad->SetNew(shared_quad_state,
170 geometry_rect, 182 geometry_rect,
171 opaque_rect, 183 opaque_rect,
172 visible_geometry_rect, 184 visible_geometry_rect,
173 texture_rect, 185 texture_rect,
174 texture_size, 186 texture_size,
175 RGBA_8888, 187 RGBA_8888,
176 quad_content_rect, 188 quad_content_rect,
177 contents_scale, 189 contents_scale,
178 pile_); 190 pile_);
179 quad_sink->Append(quad.PassAs<DrawQuad>()); 191 quad_sink->Append(quad.PassAs<DrawQuad>());
180 append_quads_data->num_missing_tiles++; 192 append_quads_data->num_missing_tiles++;
181 return; 193 return;
182 } 194 }
183 195
184 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); 196 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data);
185 197
186 if (ShowDebugBorders()) { 198 if (ShowDebugBorders()) {
187 for (PictureLayerTilingSet::CoverageIterator iter( 199 for (PictureLayerTilingSet::CoverageIterator iter(
188 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); 200 tilings_.get(), max_contents_scale, rect, ideal_contents_scale_);
189 iter; 201 iter;
190 ++iter) { 202 ++iter) {
191 SkColor color; 203 SkColor color;
192 float width; 204 float width;
193 if (*iter && iter->IsReadyToDraw()) { 205 if (*iter && iter->IsReadyToDraw()) {
194 ManagedTileState::TileVersion::Mode mode = 206 ManagedTileState::TileVersion::Mode mode =
195 iter->GetTileVersionForDrawing().mode(); 207 iter->GetTileVersionForDrawing().mode();
196 if (mode == ManagedTileState::TileVersion::SOLID_COLOR_MODE) { 208 if (mode == ManagedTileState::TileVersion::SOLID_COLOR_MODE) {
197 color = DebugColors::SolidColorTileBorderColor(); 209 color = DebugColors::SolidColorTileBorderColor();
198 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); 210 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl());
199 } else if (mode == ManagedTileState::TileVersion::PICTURE_PILE_MODE) { 211 } else if (mode == ManagedTileState::TileVersion::PICTURE_PILE_MODE) {
200 color = DebugColors::PictureTileBorderColor(); 212 color = DebugColors::PictureTileBorderColor();
201 width = DebugColors::PictureTileBorderWidth(layer_tree_impl()); 213 width = DebugColors::PictureTileBorderWidth(layer_tree_impl());
202 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { 214 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) {
203 color = DebugColors::HighResTileBorderColor(); 215 color = DebugColors::HighResTileBorderColor();
204 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); 216 width = DebugColors::HighResTileBorderWidth(layer_tree_impl());
205 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { 217 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) {
206 color = DebugColors::LowResTileBorderColor(); 218 color = DebugColors::LowResTileBorderColor();
207 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); 219 width = DebugColors::LowResTileBorderWidth(layer_tree_impl());
208 } else if (iter->contents_scale() > contents_scale_x()) { 220 } else if (iter->contents_scale() > max_contents_scale) {
209 color = DebugColors::ExtraHighResTileBorderColor(); 221 color = DebugColors::ExtraHighResTileBorderColor();
210 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); 222 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl());
211 } else { 223 } else {
212 color = DebugColors::ExtraLowResTileBorderColor(); 224 color = DebugColors::ExtraLowResTileBorderColor();
213 width = DebugColors::ExtraLowResTileBorderWidth(layer_tree_impl()); 225 width = DebugColors::ExtraLowResTileBorderWidth(layer_tree_impl());
214 } 226 }
215 } else { 227 } else {
216 color = DebugColors::MissingTileBorderColor(); 228 color = DebugColors::MissingTileBorderColor();
217 width = DebugColors::MissingTileBorderWidth(layer_tree_impl()); 229 width = DebugColors::MissingTileBorderWidth(layer_tree_impl());
218 } 230 }
(...skipping 10 matching lines...) Expand all
229 quad_sink->Append(debug_border_quad.PassAs<DrawQuad>()); 241 quad_sink->Append(debug_border_quad.PassAs<DrawQuad>());
230 } 242 }
231 } 243 }
232 244
233 // 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
234 // unused can be considered for removal. 246 // unused can be considered for removal.
235 std::vector<PictureLayerTiling*> seen_tilings; 247 std::vector<PictureLayerTiling*> seen_tilings;
236 248
237 bool had_checkerboard_quads = false; 249 bool had_checkerboard_quads = false;
238 for (PictureLayerTilingSet::CoverageIterator iter( 250 for (PictureLayerTilingSet::CoverageIterator iter(
239 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); 251 tilings_.get(), max_contents_scale, rect, ideal_contents_scale_);
240 iter; 252 iter;
241 ++iter) { 253 ++iter) {
242 gfx::Rect geometry_rect = iter.geometry_rect(); 254 gfx::Rect geometry_rect = iter.geometry_rect();
243 gfx::Rect visible_geometry_rect = 255 gfx::Rect visible_geometry_rect =
244 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform()); 256 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform());
245 if (visible_geometry_rect.IsEmpty()) 257 if (visible_geometry_rect.IsEmpty())
246 continue; 258 continue;
247 259
248 append_quads_data->visible_content_area += 260 append_quads_data->visible_content_area +=
249 visible_geometry_rect.width() * visible_geometry_rect.height(); 261 visible_geometry_rect.width() * visible_geometry_rect.height();
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 // better scheme would be to maintain a tighter visible_content_rect for the 368 // better scheme would be to maintain a tighter visible_content_rect for the
357 // finer tilings. 369 // finer tilings.
358 CleanUpTilingsOnActiveLayer(seen_tilings); 370 CleanUpTilingsOnActiveLayer(seen_tilings);
359 } 371 }
360 372
361 void PictureLayerImpl::DidUnregisterLayer() { 373 void PictureLayerImpl::DidUnregisterLayer() {
362 layer_needs_to_register_itself_ = true; 374 layer_needs_to_register_itself_ = true;
363 } 375 }
364 376
365 void PictureLayerImpl::UpdateTilePriorities() { 377 void PictureLayerImpl::UpdateTilePriorities() {
366 DCHECK(!needs_post_commit_initialization_); 378 DCHECK(!needs_post_commit_initialization_);
vmpstr 2014/05/16 22:23:38 Just a note, this DCHECK will probably fail if you
367 CHECK(should_update_tile_priorities_); 379
380 DoPostCommitInitializationIfNeeded();
381 CalculateIdealScales();
382 ManageTilings(draw_properties().screen_space_transform_is_animating,
383 draw_properties().maximum_animation_contents_scale);
368 384
369 if (layer_needs_to_register_itself_) { 385 if (layer_needs_to_register_itself_) {
370 layer_tree_impl()->tile_manager()->RegisterPictureLayerImpl(this); 386 layer_tree_impl()->tile_manager()->RegisterPictureLayerImpl(this);
371 layer_needs_to_register_itself_ = false; 387 layer_needs_to_register_itself_ = false;
372 } 388 }
373 389
374 if (layer_tree_impl()->device_viewport_valid_for_tile_management()) { 390 if (layer_tree_impl()->device_viewport_valid_for_tile_management()) {
375 visible_rect_for_tile_priority_ = visible_content_rect(); 391 visible_rect_for_tile_priority_ = visible_content_rect();
376 viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize(); 392 viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize();
377 screen_space_transform_for_tile_priority_ = screen_space_transform(); 393 screen_space_transform_for_tile_priority_ = screen_space_transform();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 RemoveAllTilings(); 465 RemoveAllTilings();
450 466
451 ResetRasterScale(); 467 ResetRasterScale();
452 468
453 // To avoid an edge case after lost context where the tree is up to date but 469 // 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 470 // the tilings have not been managed, request an update draw properties
455 // to force tilings to get managed. 471 // to force tilings to get managed.
456 layer_tree_impl()->set_needs_update_draw_properties(); 472 layer_tree_impl()->set_needs_update_draw_properties();
457 } 473 }
458 474
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() { 475 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() {
528 return pile_->GetFlattenedPicture(); 476 return pile_->GetFlattenedPicture();
529 } 477 }
530 478
531 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, 479 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling,
532 const gfx::Rect& content_rect) { 480 const gfx::Rect& content_rect) {
533 if (!pile_->CanRaster(tiling->contents_scale(), content_rect)) 481 if (!pile_->CanRaster(tiling->contents_scale(), content_rect))
534 return scoped_refptr<Tile>(); 482 return scoped_refptr<Tile>();
535 483
536 int flags = 0; 484 int flags = 0;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 RemoveAllTilings(); 643 RemoveAllTilings();
696 } 644 }
697 645
698 SanityCheckTilingState(); 646 SanityCheckTilingState();
699 } 647 }
700 648
701 void PictureLayerImpl::SyncTiling( 649 void PictureLayerImpl::SyncTiling(
702 const PictureLayerTiling* tiling) { 650 const PictureLayerTiling* tiling) {
703 if (!CanHaveTilingWithScale(tiling->contents_scale())) 651 if (!CanHaveTilingWithScale(tiling->contents_scale()))
704 return; 652 return;
653
705 tilings_->AddTiling(tiling->contents_scale()); 654 tilings_->AddTiling(tiling->contents_scale());
706 655
707 // If this tree needs update draw properties, then the tiling will 656 // If this tree needs update draw properties, then the tiling will
708 // get updated prior to drawing or activation. If this tree does not 657 // 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 658 // need update draw properties, then its transforms are up to date and
710 // we can create tiles for this tiling immediately. 659 // we can create tiles for this tiling immediately.
711 if (!layer_tree_impl()->needs_update_draw_properties() && 660 if (!layer_tree_impl()->needs_update_draw_properties()) {
712 should_update_tile_priorities_) {
713 UpdateTilePriorities(); 661 UpdateTilePriorities();
714 } 662 }
715 } 663 }
716 664
717 void PictureLayerImpl::SetIsMask(bool is_mask) { 665 void PictureLayerImpl::SetIsMask(bool is_mask) {
718 if (is_mask_ == is_mask) 666 if (is_mask_ == is_mask)
719 return; 667 return;
720 is_mask_ = is_mask; 668 is_mask_ = is_mask;
721 if (tilings_) 669 if (tilings_)
722 tilings_->RemoveAllTiles(); 670 tilings_->RemoveAllTiles();
723 } 671 }
724 672
725 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { 673 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const {
726 gfx::Rect content_rect(content_bounds()); 674 gfx::Rect content_rect(content_bounds());
727 float scale = contents_scale_x(); 675 float scale = MaximumTilingContentScale();
728 PictureLayerTilingSet::CoverageIterator iter( 676 PictureLayerTilingSet::CoverageIterator iter(
729 tilings_.get(), scale, content_rect, ideal_contents_scale_); 677 tilings_.get(), scale, content_rect, ideal_contents_scale_);
730 678
731 // Mask resource not ready yet. 679 // Mask resource not ready yet.
732 if (!iter || !*iter) 680 if (!iter || !*iter)
733 return 0; 681 return 0;
734 682
735 // Masks only supported if they fit on exactly one tile. 683 // Masks only supported if they fit on exactly one tile.
736 if (iter.geometry_rect() != content_rect) 684 if (iter.geometry_rect() != content_rect)
737 return 0; 685 return 0;
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 tilings_->SetCanUseLCDText(is_using_lcd_text_); 1192 tilings_->SetCanUseLCDText(is_using_lcd_text_);
1245 } 1193 }
1246 1194
1247 void PictureLayerImpl::ResetRasterScale() { 1195 void PictureLayerImpl::ResetRasterScale() {
1248 raster_page_scale_ = 0.f; 1196 raster_page_scale_ = 0.f;
1249 raster_device_scale_ = 0.f; 1197 raster_device_scale_ = 0.f;
1250 raster_source_scale_ = 0.f; 1198 raster_source_scale_ = 0.f;
1251 raster_contents_scale_ = 0.f; 1199 raster_contents_scale_ = 0.f;
1252 low_res_raster_contents_scale_ = 0.f; 1200 low_res_raster_contents_scale_ = 0.f;
1253 raster_source_scale_is_fixed_ = false; 1201 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 } 1202 }
1259 1203
1260 bool PictureLayerImpl::CanHaveTilings() const { 1204 bool PictureLayerImpl::CanHaveTilings() const {
1261 if (!DrawsContent()) 1205 if (!DrawsContent())
1262 return false; 1206 return false;
1263 if (!pile_->HasRecordings()) 1207 if (!pile_->HasRecordings())
1264 return false; 1208 return false;
1265 return true; 1209 return true;
1266 } 1210 }
1267 1211
(...skipping 13 matching lines...) Expand all
1281 } 1225 }
1282 if (tilings_->num_tilings() == 0) 1226 if (tilings_->num_tilings() == 0)
1283 return; 1227 return;
1284 1228
1285 // MarkVisibleResourcesAsRequired depends on having exactly 1 high res 1229 // MarkVisibleResourcesAsRequired depends on having exactly 1 high res
1286 // tiling to mark its tiles as being required for activation. 1230 // tiling to mark its tiles as being required for activation.
1287 DCHECK_EQ(1, tilings_->NumHighResTilings()); 1231 DCHECK_EQ(1, tilings_->NumHighResTilings());
1288 #endif 1232 #endif
1289 } 1233 }
1290 1234
1235 float PictureLayerImpl::MaximumTilingContentScale() const {
1236 float max_contents_scale = 1.f;
1237 for (size_t i = 0; i < tilings_->num_tilings(); ++i) {
1238 const PictureLayerTiling* tiling = tilings_->tiling_at(i);
1239 max_contents_scale = std::max(max_contents_scale, tiling->contents_scale());
1240 }
1241 return max_contents_scale;
1242 }
1243
1244 void PictureLayerImpl::CalculateIdealScales() {
1245 if (!CanHaveTilings()) {
1246 ideal_page_scale_ = draw_properties().page_scale;
1247 ideal_device_scale_ = layer_tree_impl()->device_scale_factor();
1248 ideal_contents_scale_ = draw_properties().ideal_contents_scale;
1249 ideal_source_scale_ =
1250 ideal_contents_scale_ / ideal_page_scale_ / ideal_device_scale_;
1251 return;
1252 }
1253
1254 float min_contents_scale = MinimumContentsScale();
1255 DCHECK_GT(min_contents_scale, 0.f);
1256 float min_page_scale = layer_tree_impl()->min_page_scale_factor();
1257 DCHECK_GT(min_page_scale, 0.f);
1258 float min_device_scale = 1.f;
1259 float min_source_scale =
1260 min_contents_scale / min_page_scale / min_device_scale;
1261
1262 float ideal_page_scale = layer_tree_impl()->page_scale_factor();
1263 float ideal_device_scale = layer_tree_impl()->device_scale_factor();
1264 float ideal_source_scale = draw_properties().ideal_contents_scale /
1265 ideal_page_scale / ideal_device_scale;
1266
1267 ideal_contents_scale_ =
1268 std::max(draw_properties().ideal_contents_scale, min_contents_scale);
1269 ideal_page_scale_ = layer_tree_impl()->page_scale_factor();
1270 ideal_device_scale_ = layer_tree_impl()->device_scale_factor();
1271 ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale);
1272 }
1273
1291 void PictureLayerImpl::GetDebugBorderProperties( 1274 void PictureLayerImpl::GetDebugBorderProperties(
1292 SkColor* color, 1275 SkColor* color,
1293 float* width) const { 1276 float* width) const {
1294 *color = DebugColors::TiledContentLayerBorderColor(); 1277 *color = DebugColors::TiledContentLayerBorderColor();
1295 *width = DebugColors::TiledContentLayerBorderWidth(layer_tree_impl()); 1278 *width = DebugColors::TiledContentLayerBorderWidth(layer_tree_impl());
1296 } 1279 }
1297 1280
1298 void PictureLayerImpl::AsValueInto(base::DictionaryValue* state) const { 1281 void PictureLayerImpl::AsValueInto(base::DictionaryValue* state) const {
1299 const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded(); 1282 const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded();
1300 LayerImpl::AsValueInto(state); 1283 LayerImpl::AsValueInto(state);
1301 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); 1284 state->SetDouble("ideal_contents_scale", ideal_contents_scale_);
1302 state->SetDouble("geometry_contents_scale", contents_scale_x()); 1285 state->SetDouble("geometry_contents_scale", contents_scale_x());
danakj 2014/05/16 15:47:49 oh, can you change this to MaximumTilingContentsSc
1303 state->Set("tilings", tilings_->AsValue().release()); 1286 state->Set("tilings", tilings_->AsValue().release());
1304 state->Set("pictures", pile_->AsValue().release()); 1287 state->Set("pictures", pile_->AsValue().release());
1305 state->Set("invalidation", invalidation_.AsValue().release()); 1288 state->Set("invalidation", invalidation_.AsValue().release());
1306 1289
1307 scoped_ptr<base::ListValue> coverage_tiles(new base::ListValue); 1290 scoped_ptr<base::ListValue> coverage_tiles(new base::ListValue);
1308 for (PictureLayerTilingSet::CoverageIterator iter(tilings_.get(), 1291 for (PictureLayerTilingSet::CoverageIterator iter(tilings_.get(),
1309 contents_scale_x(), 1292 contents_scale_x(),
1310 gfx::Rect(content_bounds()), 1293 gfx::Rect(content_bounds()),
1311 ideal_contents_scale_); 1294 ideal_contents_scale_);
1312 iter; 1295 iter;
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 return iterator_index_ < iterators_.size(); 1540 return iterator_index_ < iterators_.size();
1558 } 1541 }
1559 1542
1560 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( 1543 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType(
1561 PictureLayerTiling::TilingEvictionTileIterator* it) const { 1544 PictureLayerTiling::TilingEvictionTileIterator* it) const {
1562 return it->get_type() == iteration_stage_ && 1545 return it->get_type() == iteration_stage_ &&
1563 (**it)->required_for_activation() == required_for_activation_; 1546 (**it)->required_for_activation() == required_for_activation_;
1564 } 1547 }
1565 1548
1566 } // namespace cc 1549 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.h ('k') | cc/trees/layer_tree_host_common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698