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

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: rebase to TOT Created 6 years, 6 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/layers/picture_layer_impl_unittest.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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 needs_post_commit_initialization_ = true; 131 needs_post_commit_initialization_ = true;
132 132
133 // We always need to push properties. 133 // We always need to push properties.
134 // See http://crbug.com/303943 134 // See http://crbug.com/303943
135 needs_push_properties_ = true; 135 needs_push_properties_ = true;
136 } 136 }
137 137
138 void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, 138 void PictureLayerImpl::AppendQuads(QuadSink* quad_sink,
139 AppendQuadsData* append_quads_data) { 139 AppendQuadsData* append_quads_data) {
140 DCHECK(!needs_post_commit_initialization_); 140 DCHECK(!needs_post_commit_initialization_);
141 gfx::Rect rect(visible_content_rect()); 141
142 float max_contents_scale = MaximumTilingContentsScale();
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));
142 152
143 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); 153 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState();
144 PopulateSharedQuadState(shared_quad_state); 154 shared_quad_state->SetAll(scaled_draw_transform,
155 scaled_content_bounds,
156 scaled_visible_content_rect,
157 draw_properties().clip_rect,
158 draw_properties().is_clipped,
159 draw_properties().opacity,
160 blend_mode());
161
162 gfx::Rect rect = scaled_visible_content_rect;
145 163
146 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) { 164 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) {
147 AppendDebugBorderQuad( 165 AppendDebugBorderQuad(
148 quad_sink, 166 quad_sink,
149 shared_quad_state, 167 shared_quad_state,
150 append_quads_data, 168 append_quads_data,
151 DebugColors::DirectPictureBorderColor(), 169 DebugColors::DirectPictureBorderColor(),
152 DebugColors::DirectPictureBorderWidth(layer_tree_impl())); 170 DebugColors::DirectPictureBorderWidth(layer_tree_impl()));
153 171
154 gfx::Rect geometry_rect = rect; 172 gfx::Rect geometry_rect = rect;
155 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); 173 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect();
156 gfx::Rect visible_geometry_rect = 174 gfx::Rect visible_geometry_rect =
157 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform()); 175 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform());
158 if (visible_geometry_rect.IsEmpty()) 176 if (visible_geometry_rect.IsEmpty())
159 return; 177 return;
160 178
161 gfx::Size texture_size = rect.size(); 179 gfx::Size texture_size = rect.size();
162 gfx::RectF texture_rect = gfx::RectF(texture_size); 180 gfx::RectF texture_rect = gfx::RectF(texture_size);
163 gfx::Rect quad_content_rect = rect; 181 gfx::Rect quad_content_rect = rect;
164 float contents_scale = contents_scale_x();
165 182
166 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); 183 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create();
167 quad->SetNew(shared_quad_state, 184 quad->SetNew(shared_quad_state,
168 geometry_rect, 185 geometry_rect,
169 opaque_rect, 186 opaque_rect,
170 visible_geometry_rect, 187 visible_geometry_rect,
171 texture_rect, 188 texture_rect,
172 texture_size, 189 texture_size,
173 RGBA_8888, 190 RGBA_8888,
174 quad_content_rect, 191 quad_content_rect,
175 contents_scale, 192 max_contents_scale,
176 pile_); 193 pile_);
177 quad_sink->Append(quad.PassAs<DrawQuad>()); 194 quad_sink->Append(quad.PassAs<DrawQuad>());
178 append_quads_data->num_missing_tiles++; 195 append_quads_data->num_missing_tiles++;
179 return; 196 return;
180 } 197 }
181 198
182 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); 199 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data);
183 200
184 if (ShowDebugBorders()) { 201 if (ShowDebugBorders()) {
185 for (PictureLayerTilingSet::CoverageIterator iter( 202 for (PictureLayerTilingSet::CoverageIterator iter(
186 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); 203 tilings_.get(), max_contents_scale, rect, ideal_contents_scale_);
187 iter; 204 iter;
188 ++iter) { 205 ++iter) {
189 SkColor color; 206 SkColor color;
190 float width; 207 float width;
191 if (*iter && iter->IsReadyToDraw()) { 208 if (*iter && iter->IsReadyToDraw()) {
192 ManagedTileState::TileVersion::Mode mode = 209 ManagedTileState::TileVersion::Mode mode =
193 iter->GetTileVersionForDrawing().mode(); 210 iter->GetTileVersionForDrawing().mode();
194 if (mode == ManagedTileState::TileVersion::SOLID_COLOR_MODE) { 211 if (mode == ManagedTileState::TileVersion::SOLID_COLOR_MODE) {
195 color = DebugColors::SolidColorTileBorderColor(); 212 color = DebugColors::SolidColorTileBorderColor();
196 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); 213 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl());
197 } else if (mode == ManagedTileState::TileVersion::PICTURE_PILE_MODE) { 214 } else if (mode == ManagedTileState::TileVersion::PICTURE_PILE_MODE) {
198 color = DebugColors::PictureTileBorderColor(); 215 color = DebugColors::PictureTileBorderColor();
199 width = DebugColors::PictureTileBorderWidth(layer_tree_impl()); 216 width = DebugColors::PictureTileBorderWidth(layer_tree_impl());
200 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { 217 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) {
201 color = DebugColors::HighResTileBorderColor(); 218 color = DebugColors::HighResTileBorderColor();
202 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); 219 width = DebugColors::HighResTileBorderWidth(layer_tree_impl());
203 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { 220 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) {
204 color = DebugColors::LowResTileBorderColor(); 221 color = DebugColors::LowResTileBorderColor();
205 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); 222 width = DebugColors::LowResTileBorderWidth(layer_tree_impl());
206 } else if (iter->contents_scale() > contents_scale_x()) { 223 } else if (iter->contents_scale() > max_contents_scale) {
207 color = DebugColors::ExtraHighResTileBorderColor(); 224 color = DebugColors::ExtraHighResTileBorderColor();
208 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); 225 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl());
209 } else { 226 } else {
210 color = DebugColors::ExtraLowResTileBorderColor(); 227 color = DebugColors::ExtraLowResTileBorderColor();
211 width = DebugColors::ExtraLowResTileBorderWidth(layer_tree_impl()); 228 width = DebugColors::ExtraLowResTileBorderWidth(layer_tree_impl());
212 } 229 }
213 } else { 230 } else {
214 color = DebugColors::MissingTileBorderColor(); 231 color = DebugColors::MissingTileBorderColor();
215 width = DebugColors::MissingTileBorderWidth(layer_tree_impl()); 232 width = DebugColors::MissingTileBorderWidth(layer_tree_impl());
216 } 233 }
(...skipping 11 matching lines...) Expand all
228 } 245 }
229 } 246 }
230 247
231 // Keep track of the tilings that were used so that tilings that are 248 // Keep track of the tilings that were used so that tilings that are
232 // unused can be considered for removal. 249 // unused can be considered for removal.
233 std::vector<PictureLayerTiling*> seen_tilings; 250 std::vector<PictureLayerTiling*> seen_tilings;
234 251
235 size_t missing_tile_count = 0u; 252 size_t missing_tile_count = 0u;
236 size_t on_demand_missing_tile_count = 0u; 253 size_t on_demand_missing_tile_count = 0u;
237 for (PictureLayerTilingSet::CoverageIterator iter( 254 for (PictureLayerTilingSet::CoverageIterator iter(
238 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); 255 tilings_.get(), max_contents_scale, rect, ideal_contents_scale_);
239 iter; 256 iter;
240 ++iter) { 257 ++iter) {
241 gfx::Rect geometry_rect = iter.geometry_rect(); 258 gfx::Rect geometry_rect = iter.geometry_rect();
242 gfx::Rect visible_geometry_rect = 259 gfx::Rect visible_geometry_rect =
243 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform()); 260 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform());
244 if (visible_geometry_rect.IsEmpty()) 261 if (visible_geometry_rect.IsEmpty())
245 continue; 262 continue;
246 263
247 append_quads_data->visible_content_area += 264 append_quads_data->visible_content_area +=
248 visible_geometry_rect.width() * visible_geometry_rect.height(); 265 visible_geometry_rect.width() * visible_geometry_rect.height();
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 // Aggressively remove any tilings that are not seen to save memory. Note 382 // Aggressively remove any tilings that are not seen to save memory. Note
366 // that this is at the expense of doing cause more frequent re-painting. A 383 // that this is at the expense of doing cause more frequent re-painting. A
367 // better scheme would be to maintain a tighter visible_content_rect for the 384 // better scheme would be to maintain a tighter visible_content_rect for the
368 // finer tilings. 385 // finer tilings.
369 CleanUpTilingsOnActiveLayer(seen_tilings); 386 CleanUpTilingsOnActiveLayer(seen_tilings);
370 } 387 }
371 388
372 void PictureLayerImpl::UpdateTilePriorities() { 389 void PictureLayerImpl::UpdateTilePriorities() {
373 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities"); 390 TRACE_EVENT0("cc", "PictureLayerImpl::UpdateTilePriorities");
374 391
375 DCHECK(!needs_post_commit_initialization_); 392 DoPostCommitInitializationIfNeeded();
376 CHECK(should_update_tile_priorities_); 393 UpdateIdealScales();
394 // TODO(sohanjg): Avoid needlessly update priorities when syncing to a
395 // non-updated tree which will then be updated immediately afterwards.
396 should_update_tile_priorities_ = true;
397 if (CanHaveTilings()) {
398 ManageTilings(draw_properties().screen_space_transform_is_animating,
399 draw_properties().maximum_animation_contents_scale);
400 }
377 401
378 if (layer_tree_impl()->device_viewport_valid_for_tile_management()) { 402 if (layer_tree_impl()->device_viewport_valid_for_tile_management()) {
379 visible_rect_for_tile_priority_ = visible_content_rect(); 403 visible_rect_for_tile_priority_ = visible_content_rect();
380 viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize(); 404 viewport_size_for_tile_priority_ = layer_tree_impl()->DrawViewportSize();
381 screen_space_transform_for_tile_priority_ = screen_space_transform(); 405 screen_space_transform_for_tile_priority_ = screen_space_transform();
382 } 406 }
383 407
384 if (!tilings_->num_tilings()) 408 if (!tilings_->num_tilings())
385 return; 409 return;
386 410
(...skipping 19 matching lines...) Expand all
406 gfx::Transform screen_to_layer(gfx::Transform::kSkipInitialization); 430 gfx::Transform screen_to_layer(gfx::Transform::kSkipInitialization);
407 if (screen_space_transform_for_tile_priority_.GetInverse( 431 if (screen_space_transform_for_tile_priority_.GetInverse(
408 &screen_to_layer)) { 432 &screen_to_layer)) {
409 visible_rect_in_content_space = 433 visible_rect_in_content_space =
410 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( 434 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect(
411 screen_to_layer, gfx::Rect(viewport_size_for_tile_priority_))); 435 screen_to_layer, gfx::Rect(viewport_size_for_tile_priority_)));
412 visible_rect_in_content_space.Intersect(gfx::Rect(content_bounds())); 436 visible_rect_in_content_space.Intersect(gfx::Rect(content_bounds()));
413 } 437 }
414 } 438 }
415 439
440 gfx::Rect visible_layer_rect = gfx::ScaleToEnclosingRect(
441 visible_rect_in_content_space, 1.f / contents_scale_x());
416 WhichTree tree = 442 WhichTree tree =
417 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; 443 layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE;
418 444 // TODO(sohanjg): Passing MaximumContentsScale as layer contents scale
445 // in UpdateTilePriorities is wrong and should be ideal contents scale.
419 tilings_->UpdateTilePriorities(tree, 446 tilings_->UpdateTilePriorities(tree,
420 visible_rect_in_content_space, 447 visible_layer_rect,
421 contents_scale_x(), 448 MaximumTilingContentsScale(),
422 current_frame_time_in_seconds); 449 current_frame_time_in_seconds);
423 450
424 if (layer_tree_impl()->IsPendingTree()) 451 if (layer_tree_impl()->IsPendingTree())
425 MarkVisibleResourcesAsRequired(); 452 MarkVisibleResourcesAsRequired();
426 453
427 // Tile priorities were modified. 454 // Tile priorities were modified.
428 layer_tree_impl()->DidModifyTilePriorities(); 455 layer_tree_impl()->DidModifyTilePriorities();
429 } 456 }
430 457
431 void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) { 458 void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) {
(...skipping 19 matching lines...) Expand all
451 RemoveAllTilings(); 478 RemoveAllTilings();
452 479
453 ResetRasterScale(); 480 ResetRasterScale();
454 481
455 // To avoid an edge case after lost context where the tree is up to date but 482 // To avoid an edge case after lost context where the tree is up to date but
456 // the tilings have not been managed, request an update draw properties 483 // the tilings have not been managed, request an update draw properties
457 // to force tilings to get managed. 484 // to force tilings to get managed.
458 layer_tree_impl()->set_needs_update_draw_properties(); 485 layer_tree_impl()->set_needs_update_draw_properties();
459 } 486 }
460 487
461 void PictureLayerImpl::CalculateContentsScale(
462 float ideal_contents_scale,
463 float device_scale_factor,
464 float page_scale_factor,
465 float maximum_animation_contents_scale,
466 bool animating_transform_to_screen,
467 float* contents_scale_x,
468 float* contents_scale_y,
469 gfx::Size* content_bounds) {
470 DoPostCommitInitializationIfNeeded();
471
472 // This function sets valid raster scales and manages tilings, so tile
473 // priorities can now be updated.
474 should_update_tile_priorities_ = true;
475
476 if (!CanHaveTilings()) {
477 ideal_page_scale_ = page_scale_factor;
478 ideal_device_scale_ = device_scale_factor;
479 ideal_contents_scale_ = ideal_contents_scale;
480 ideal_source_scale_ =
481 ideal_contents_scale_ / ideal_page_scale_ / ideal_device_scale_;
482 *contents_scale_x = ideal_contents_scale_;
483 *contents_scale_y = ideal_contents_scale_;
484 *content_bounds = gfx::ToCeiledSize(gfx::ScaleSize(bounds(),
485 ideal_contents_scale_,
486 ideal_contents_scale_));
487 return;
488 }
489
490 float min_contents_scale = MinimumContentsScale();
491 DCHECK_GT(min_contents_scale, 0.f);
492 float min_page_scale = layer_tree_impl()->min_page_scale_factor();
493 DCHECK_GT(min_page_scale, 0.f);
494 float min_device_scale = 1.f;
495 float min_source_scale =
496 min_contents_scale / min_page_scale / min_device_scale;
497
498 float ideal_page_scale = page_scale_factor;
499 float ideal_device_scale = device_scale_factor;
500 float ideal_source_scale =
501 ideal_contents_scale / ideal_page_scale / ideal_device_scale;
502
503 ideal_contents_scale_ = std::max(ideal_contents_scale, min_contents_scale);
504 ideal_page_scale_ = ideal_page_scale;
505 ideal_device_scale_ = ideal_device_scale;
506 ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale);
507
508 ManageTilings(animating_transform_to_screen,
509 maximum_animation_contents_scale);
510
511 // The content scale and bounds for a PictureLayerImpl is somewhat fictitious.
512 // There are (usually) several tilings at different scales. However, the
513 // content bounds is the (integer!) space in which quads are generated.
514 // In order to guarantee that we can fill this integer space with any set of
515 // tilings (and then map back to floating point texture coordinates), the
516 // contents scale must be at least as large as the largest of the tilings.
517 float max_contents_scale = min_contents_scale;
518 for (size_t i = 0; i < tilings_->num_tilings(); ++i) {
519 const PictureLayerTiling* tiling = tilings_->tiling_at(i);
520 max_contents_scale = std::max(max_contents_scale, tiling->contents_scale());
521 }
522
523 *contents_scale_x = max_contents_scale;
524 *contents_scale_y = max_contents_scale;
525 *content_bounds = gfx::ToCeiledSize(
526 gfx::ScaleSize(bounds(), max_contents_scale, max_contents_scale));
527 }
528
529 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { 488 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() {
530 return pile_->GetFlattenedPicture(); 489 return pile_->GetFlattenedPicture();
531 } 490 }
532 491
533 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, 492 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling,
534 const gfx::Rect& content_rect) { 493 const gfx::Rect& content_rect) {
535 if (!pile_->CanRaster(tiling->contents_scale(), content_rect)) 494 if (!pile_->CanRaster(tiling->contents_scale(), content_rect))
536 return scoped_refptr<Tile>(); 495 return scoped_refptr<Tile>();
537 496
538 int flags = 0; 497 int flags = 0;
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 void PictureLayerImpl::SetIsMask(bool is_mask) { 702 void PictureLayerImpl::SetIsMask(bool is_mask) {
744 if (is_mask_ == is_mask) 703 if (is_mask_ == is_mask)
745 return; 704 return;
746 is_mask_ = is_mask; 705 is_mask_ = is_mask;
747 if (tilings_) 706 if (tilings_)
748 tilings_->RemoveAllTiles(); 707 tilings_->RemoveAllTiles();
749 } 708 }
750 709
751 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { 710 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const {
752 gfx::Rect content_rect(content_bounds()); 711 gfx::Rect content_rect(content_bounds());
753 float scale = contents_scale_x(); 712 float scale = MaximumTilingContentsScale();
754 PictureLayerTilingSet::CoverageIterator iter( 713 PictureLayerTilingSet::CoverageIterator iter(
755 tilings_.get(), scale, content_rect, ideal_contents_scale_); 714 tilings_.get(), scale, content_rect, ideal_contents_scale_);
756 715
757 // Mask resource not ready yet. 716 // Mask resource not ready yet.
758 if (!iter || !*iter) 717 if (!iter || !*iter)
759 return 0; 718 return 0;
760 719
761 // Masks only supported if they fit on exactly one tile. 720 // Masks only supported if they fit on exactly one tile.
762 if (iter.geometry_rect() != content_rect) 721 if (iter.geometry_rect() != content_rect)
763 return 0; 722 return 0;
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 } 1271 }
1313 if (tilings_->num_tilings() == 0) 1272 if (tilings_->num_tilings() == 0)
1314 return; 1273 return;
1315 1274
1316 // MarkVisibleResourcesAsRequired depends on having exactly 1 high res 1275 // MarkVisibleResourcesAsRequired depends on having exactly 1 high res
1317 // tiling to mark its tiles as being required for activation. 1276 // tiling to mark its tiles as being required for activation.
1318 DCHECK_EQ(1, tilings_->NumHighResTilings()); 1277 DCHECK_EQ(1, tilings_->NumHighResTilings());
1319 #endif 1278 #endif
1320 } 1279 }
1321 1280
1281 float PictureLayerImpl::MaximumTilingContentsScale() const {
1282 float max_contents_scale = MinimumContentsScale();
1283 for (size_t i = 0; i < tilings_->num_tilings(); ++i) {
1284 const PictureLayerTiling* tiling = tilings_->tiling_at(i);
1285 max_contents_scale = std::max(max_contents_scale, tiling->contents_scale());
1286 }
1287 return max_contents_scale;
1288 }
1289
1290 void PictureLayerImpl::UpdateIdealScales() {
1291 if (!CanHaveTilings()) {
1292 ideal_page_scale_ = draw_properties().page_scale_factor;
1293 ideal_device_scale_ = draw_properties().device_scale_factor;
1294 ideal_contents_scale_ = draw_properties().ideal_contents_scale;
1295 ideal_source_scale_ =
1296 ideal_contents_scale_ / ideal_page_scale_ / ideal_device_scale_;
1297 return;
1298 }
1299
1300 float min_contents_scale = MinimumContentsScale();
1301 DCHECK_GT(min_contents_scale, 0.f);
1302 float min_page_scale = layer_tree_impl()->min_page_scale_factor();
1303 DCHECK_GT(min_page_scale, 0.f);
1304 float min_device_scale = 1.f;
1305 float min_source_scale =
1306 min_contents_scale / min_page_scale / min_device_scale;
1307
1308 float ideal_page_scale = draw_properties().page_scale_factor;
1309 float ideal_device_scale = draw_properties().device_scale_factor;
1310 float ideal_source_scale = draw_properties().ideal_contents_scale /
1311 ideal_page_scale / ideal_device_scale;
1312 ideal_contents_scale_ =
1313 std::max(draw_properties().ideal_contents_scale, min_contents_scale);
1314 ideal_page_scale_ = draw_properties().page_scale_factor;
1315 ideal_device_scale_ = draw_properties().device_scale_factor;
1316 ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale);
1317 }
1318
1322 void PictureLayerImpl::GetDebugBorderProperties( 1319 void PictureLayerImpl::GetDebugBorderProperties(
1323 SkColor* color, 1320 SkColor* color,
1324 float* width) const { 1321 float* width) const {
1325 *color = DebugColors::TiledContentLayerBorderColor(); 1322 *color = DebugColors::TiledContentLayerBorderColor();
1326 *width = DebugColors::TiledContentLayerBorderWidth(layer_tree_impl()); 1323 *width = DebugColors::TiledContentLayerBorderWidth(layer_tree_impl());
1327 } 1324 }
1328 1325
1329 void PictureLayerImpl::AsValueInto(base::DictionaryValue* state) const { 1326 void PictureLayerImpl::AsValueInto(base::DictionaryValue* state) const {
1330 const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded(); 1327 const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded();
1331 LayerImpl::AsValueInto(state); 1328 LayerImpl::AsValueInto(state);
1332 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); 1329 state->SetDouble("ideal_contents_scale", ideal_contents_scale_);
1333 state->SetDouble("geometry_contents_scale", contents_scale_x()); 1330 state->SetDouble("geometry_contents_scale", MaximumTilingContentsScale());
1334 state->Set("tilings", tilings_->AsValue().release()); 1331 state->Set("tilings", tilings_->AsValue().release());
1335 state->Set("pictures", pile_->AsValue().release()); 1332 state->Set("pictures", pile_->AsValue().release());
1336 state->Set("invalidation", invalidation_.AsValue().release()); 1333 state->Set("invalidation", invalidation_.AsValue().release());
1337 1334
1338 scoped_ptr<base::ListValue> coverage_tiles(new base::ListValue); 1335 scoped_ptr<base::ListValue> coverage_tiles(new base::ListValue);
1339 for (PictureLayerTilingSet::CoverageIterator iter(tilings_.get(), 1336 for (PictureLayerTilingSet::CoverageIterator iter(tilings_.get(),
1340 contents_scale_x(), 1337 contents_scale_x(),
1341 gfx::Rect(content_bounds()), 1338 gfx::Rect(content_bounds()),
1342 ideal_contents_scale_); 1339 ideal_contents_scale_);
1343 iter; 1340 iter;
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
1640 return iterator_index_ < iterators_.size(); 1637 return iterator_index_ < iterators_.size();
1641 } 1638 }
1642 1639
1643 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( 1640 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType(
1644 PictureLayerTiling::TilingEvictionTileIterator* it) const { 1641 PictureLayerTiling::TilingEvictionTileIterator* it) const {
1645 return it->get_type() == iteration_stage_ && 1642 return it->get_type() == iteration_stage_ &&
1646 (**it)->required_for_activation() == required_for_activation_; 1643 (**it)->required_for_activation() == required_for_activation_;
1647 } 1644 }
1648 1645
1649 } // namespace cc 1646 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.h ('k') | cc/layers/picture_layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698