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

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

Issue 12865017: Makes tile-creation lazy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: a bug fix and removal of several now useless functions Created 7 years, 8 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 | Annotate | Revision Log
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 8
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 pile_ = PicturePileImpl::Create(is_using_lcd_text_); 83 pile_ = PicturePileImpl::Create(is_using_lcd_text_);
84 84
85 layer_impl->raster_page_scale_ = raster_page_scale_; 85 layer_impl->raster_page_scale_ = raster_page_scale_;
86 layer_impl->raster_device_scale_ = raster_device_scale_; 86 layer_impl->raster_device_scale_ = raster_device_scale_;
87 layer_impl->raster_source_scale_ = raster_source_scale_; 87 layer_impl->raster_source_scale_ = raster_source_scale_;
88 layer_impl->raster_contents_scale_ = raster_contents_scale_; 88 layer_impl->raster_contents_scale_ = raster_contents_scale_;
89 layer_impl->low_res_raster_contents_scale_ = low_res_raster_contents_scale_; 89 layer_impl->low_res_raster_contents_scale_ = low_res_raster_contents_scale_;
90 layer_impl->is_using_lcd_text_ = is_using_lcd_text_; 90 layer_impl->is_using_lcd_text_ = is_using_lcd_text_;
91 } 91 }
92 92
93
94 void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, 93 void PictureLayerImpl::AppendQuads(QuadSink* quad_sink,
95 AppendQuadsData* append_quads_data) { 94 AppendQuadsData* append_quads_data) {
96 const gfx::Rect& rect = visible_content_rect(); 95 const gfx::Rect& rect = visible_content_rect();
97 gfx::Rect content_rect(content_bounds()); 96 gfx::Rect content_rect(content_bounds());
98 97
99 SharedQuadState* shared_quad_state = 98 SharedQuadState* shared_quad_state =
100 quad_sink->UseSharedQuadState(CreateSharedQuadState()); 99 quad_sink->UseSharedQuadState(CreateSharedQuadState());
101 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); 100 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data);
102 101
103 bool clipped = false; 102 bool clipped = false;
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 content_rect, 364 content_rect,
366 contents_opaque() ? content_rect : gfx::Rect(), 365 contents_opaque() ? content_rect : gfx::Rect(),
367 tiling->contents_scale(), 366 tiling->contents_scale(),
368 id())); 367 id()));
369 } 368 }
370 369
371 void PictureLayerImpl::UpdatePile(Tile* tile) { 370 void PictureLayerImpl::UpdatePile(Tile* tile) {
372 tile->set_picture_pile(pile_); 371 tile->set_picture_pile(pile_);
373 } 372 }
374 373
374 const Region* PictureLayerImpl::GetInvalidation() {
375 return &invalidation_;
376 }
377
378 const PictureLayerTiling* PictureLayerImpl::GetTwinTiling(
379 const PictureLayerTiling* tiling) {
380
381 const PictureLayerImpl* other_layer = layer_tree_impl()->IsActiveTree() ?
382 PendingTwin() : ActiveTwin();
383 if (!other_layer)
384 return NULL;
385 for (size_t i = 0; i < other_layer->tilings_->num_tilings(); ++i)
386 if (other_layer->tilings_->tiling_at(i)->contents_scale() ==
387 tiling->contents_scale())
388 return other_layer->tilings_->tiling_at(i);
389 return NULL;
390 }
391
375 gfx::Size PictureLayerImpl::CalculateTileSize( 392 gfx::Size PictureLayerImpl::CalculateTileSize(
376 gfx::Size current_tile_size, 393 gfx::Size current_tile_size,
377 gfx::Size content_bounds) { 394 gfx::Size content_bounds) {
378 if (is_mask_) { 395 if (is_mask_) {
379 int max_size = layer_tree_impl()->MaxTextureSize(); 396 int max_size = layer_tree_impl()->MaxTextureSize();
380 return gfx::Size( 397 return gfx::Size(
381 std::min(max_size, content_bounds.width()), 398 std::min(max_size, content_bounds.width()),
382 std::min(max_size, content_bounds.height())); 399 std::min(max_size, content_bounds.height()));
383 } 400 }
384 401
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 for (int y = 0; y < pile_->num_tiles_y(); ++y) { 474 for (int y = 0; y < pile_->num_tiles_y(); ++y) {
458 bool previously_had = other->pile_->HasRecordingAt(x, y); 475 bool previously_had = other->pile_->HasRecordingAt(x, y);
459 bool now_has = pile_->HasRecordingAt(x, y); 476 bool now_has = pile_->HasRecordingAt(x, y);
460 if (now_has || !previously_had) 477 if (now_has || !previously_had)
461 continue; 478 continue;
462 gfx::Rect layer_rect = pile_->tile_bounds(x, y); 479 gfx::Rect layer_rect = pile_->tile_bounds(x, y);
463 invalidation_.Union(layer_rect); 480 invalidation_.Union(layer_rect);
464 } 481 }
465 } 482 }
466 483
467 tilings_->CloneAll(*other->tilings_, invalidation_, MinimumContentsScale()); 484 // Union in the other newly exposed regions as invalid.
485 Region difference_region = Region(gfx::Rect(bounds()));
486 difference_region.Subtract(gfx::Rect(other->bounds()));
487 invalidation_.Union(difference_region);
488
489 tilings_->CloneAll(*other->tilings_, MinimumContentsScale());
468 DCHECK(bounds() == tilings_->LayerBounds()); 490 DCHECK(bounds() == tilings_->LayerBounds());
469
470 // It's a sad but unfortunate fact that PicturePile tiling edges do not line
471 // up with PictureLayerTiling edges. Tiles can only be added if they are
472 // entirely covered by recordings (that may come from multiple PicturePile
473 // tiles). This check happens in this class's CreateTile() call.
474 for (int x = 0; x < pile_->num_tiles_x(); ++x) {
475 for (int y = 0; y < pile_->num_tiles_y(); ++y) {
476 bool previously_had = other->pile_->HasRecordingAt(x, y);
477 bool now_has = pile_->HasRecordingAt(x, y);
478 if (!now_has || previously_had)
479 continue;
480 gfx::Rect layer_rect = pile_->tile_bounds(x, y);
481 tilings_->CreateTilesFromLayerRect(layer_rect);
482 }
483 }
484 } 491 }
485 492
486 void PictureLayerImpl::SyncTiling( 493 void PictureLayerImpl::SyncTiling(
487 const PictureLayerTiling* tiling, 494 const PictureLayerTiling* tiling) {
488 const Region& pending_layer_invalidation) {
489 if (!DrawsContent() || tiling->contents_scale() < MinimumContentsScale()) 495 if (!DrawsContent() || tiling->contents_scale() < MinimumContentsScale())
490 return; 496 return;
491 tilings_->Clone(tiling, pending_layer_invalidation); 497 tilings_->Clone(tiling);
492 } 498 }
493 499
494 void PictureLayerImpl::SetIsMask(bool is_mask) { 500 void PictureLayerImpl::SetIsMask(bool is_mask) {
495 if (is_mask_ == is_mask) 501 if (is_mask_ == is_mask)
496 return; 502 return;
497 is_mask_ = is_mask; 503 is_mask_ = is_mask;
498 if (tilings_) 504 if (tilings_)
499 tilings_->RemoveAllTiles(); 505 tilings_->RemoveAllTiles();
500 } 506 }
501 507
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 } 570 }
565 571
566 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { 572 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) {
567 DCHECK(contents_scale >= MinimumContentsScale()); 573 DCHECK(contents_scale >= MinimumContentsScale());
568 574
569 PictureLayerTiling* tiling = tilings_->AddTiling(contents_scale); 575 PictureLayerTiling* tiling = tilings_->AddTiling(contents_scale);
570 576
571 const Region& recorded = pile_->recorded_region(); 577 const Region& recorded = pile_->recorded_region();
572 DCHECK(!recorded.IsEmpty()); 578 DCHECK(!recorded.IsEmpty());
573 579
574 for (Region::Iterator iter(recorded); iter.has_rect(); iter.next())
575 tiling->CreateTilesFromLayerRect(iter.rect());
576
577 PictureLayerImpl* twin = 580 PictureLayerImpl* twin =
578 layer_tree_impl()->IsPendingTree() ? ActiveTwin() : PendingTwin(); 581 layer_tree_impl()->IsPendingTree() ? ActiveTwin() : PendingTwin();
579 if (!twin) 582 if (!twin)
580 return tiling; 583 return tiling;
581 584
582 if (layer_tree_impl()->IsPendingTree()) 585 if (layer_tree_impl()->IsPendingTree())
enne (OOO) 2013/03/29 20:50:58 This if statement can be simplified.
whunt 2013/03/29 21:52:04 Clearly. I'll go do that.
583 twin->SyncTiling(tiling, invalidation_); 586 twin->SyncTiling(tiling);
584 else 587 else
585 twin->SyncTiling(tiling, twin->invalidation_); 588 twin->SyncTiling(tiling);
586 589
587 return tiling; 590 return tiling;
588 } 591 }
589 592
590 void PictureLayerImpl::RemoveTiling(float contents_scale) { 593 void PictureLayerImpl::RemoveTiling(float contents_scale) {
591 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { 594 for (size_t i = 0; i < tilings_->num_tilings(); ++i) {
592 PictureLayerTiling* tiling = tilings_->tiling_at(i); 595 PictureLayerTiling* tiling = tilings_->tiling_at(i);
593 if (tiling->contents_scale() == contents_scale) { 596 if (tiling->contents_scale() == contents_scale) {
594 tilings_->Remove(tiling); 597 tilings_->Remove(tiling);
595 break; 598 break;
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 layer_tree_impl()->IsActiveTree() ? PendingTwin() : this; 844 layer_tree_impl()->IsActiveTree() ? PendingTwin() : this;
842 if (layer_tree_impl()->IsActiveTree() && 845 if (layer_tree_impl()->IsActiveTree() &&
843 pending_layer->is_using_lcd_text_ == is_using_lcd_text_) 846 pending_layer->is_using_lcd_text_ == is_using_lcd_text_)
844 return; 847 return;
845 848
846 // Further tiles created due to new tilings should be considered invalidated. 849 // Further tiles created due to new tilings should be considered invalidated.
847 pending_layer->invalidation_.Union(gfx::Rect(bounds())); 850 pending_layer->invalidation_.Union(gfx::Rect(bounds()));
848 pending_layer->is_using_lcd_text_ = is_using_lcd_text_; 851 pending_layer->is_using_lcd_text_ = is_using_lcd_text_;
849 pending_layer->pile_ = PicturePileImpl::CreateFromOther(pending_layer->pile_, 852 pending_layer->pile_ = PicturePileImpl::CreateFromOther(pending_layer->pile_,
850 is_using_lcd_text_); 853 is_using_lcd_text_);
851
852 // TODO(enne): if we tracked text regions, we could just invalidate those
853 // directly rather than tossing away every tile.
854 pending_layer->tilings_->Invalidate(gfx::Rect(bounds()));
enne (OOO) 2013/03/29 20:50:58 This is incorrect to remove wholesale. Invalidate
whunt 2013/03/29 21:52:04 Good call, I'll investigate the best way to keep t
whunt 2013/03/29 22:17:55 On second thought, I'm not actually sure, we shoul
855 } 854 }
856 855
857 void PictureLayerImpl::GetDebugBorderProperties( 856 void PictureLayerImpl::GetDebugBorderProperties(
858 SkColor* color, 857 SkColor* color,
859 float* width) const { 858 float* width) const {
860 *color = DebugColors::TiledContentLayerBorderColor(); 859 *color = DebugColors::TiledContentLayerBorderColor();
861 *width = DebugColors::TiledContentLayerBorderWidth(layer_tree_impl()); 860 *width = DebugColors::TiledContentLayerBorderWidth(layer_tree_impl());
862 } 861 }
863 862
864 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { 863 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const {
865 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 864 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
866 LayerImpl::AsValueInto(state.get()); 865 LayerImpl::AsValueInto(state.get());
867 866
868 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); 867 state->SetDouble("ideal_contents_scale", ideal_contents_scale_);
869 state->Set("tilings", tilings_->AsValue().release()); 868 state->Set("tilings", tilings_->AsValue().release());
870 return state.PassAs<base::Value>(); 869 return state.PassAs<base::Value>();
871 } 870 }
872 871
873 } // namespace cc 872 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698