OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 #include <set> | 10 #include <set> |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 } | 558 } |
559 | 559 |
560 // We could do this after doing UpdateTiles, which would avoid doing this for | 560 // We could do this after doing UpdateTiles, which would avoid doing this for |
561 // tilings that are going to disappear on the pending tree (if scale changed). | 561 // tilings that are going to disappear on the pending tree (if scale changed). |
562 // But that would also be more complicated, so we just do it here for now. | 562 // But that would also be more complicated, so we just do it here for now. |
563 tilings_->UpdateTilingsToCurrentRasterSource( | 563 tilings_->UpdateTilingsToCurrentRasterSource( |
564 raster_source_, pending_set, invalidation_, MinimumContentsScale(), | 564 raster_source_, pending_set, invalidation_, MinimumContentsScale(), |
565 MaximumContentsScale()); | 565 MaximumContentsScale()); |
566 } | 566 } |
567 | 567 |
| 568 void PictureLayerImpl::UpdateCanUseLCDTextAfterCommit() { |
| 569 // This function is only allowed to be called after commit, due to it not |
| 570 // being smart about sharing tiles and because otherwise it would cause |
| 571 // flashes by switching out tiles in place that may be currently on screen. |
| 572 DCHECK(layer_tree_impl()->IsSyncTree()); |
| 573 |
| 574 // Don't allow the LCD text state to change once disabled. |
| 575 if (!RasterSourceUsesLCDText()) |
| 576 return; |
| 577 if (can_use_lcd_text() == RasterSourceUsesLCDText()) |
| 578 return; |
| 579 |
| 580 // Raster sources are considered const, so in order to update the state |
| 581 // a new one must be created and all tiles recreated. |
| 582 scoped_refptr<RasterSource> new_raster_source = |
| 583 raster_source_->CreateCloneWithoutLCDText(); |
| 584 // Synthetically invalidate everything. |
| 585 gfx::Rect bounds_rect(bounds()); |
| 586 Region invalidation(bounds_rect); |
| 587 UpdateRasterSource(new_raster_source, &invalidation, nullptr); |
| 588 SetUpdateRect(bounds_rect); |
| 589 |
| 590 DCHECK(!RasterSourceUsesLCDText()); |
| 591 } |
| 592 |
| 593 bool PictureLayerImpl::RasterSourceUsesLCDText() const { |
| 594 return raster_source_ ? raster_source_->CanUseLCDText() |
| 595 : layer_tree_impl()->settings().can_use_lcd_text; |
| 596 } |
| 597 |
568 void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) { | 598 void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) { |
569 if (layer_tree_impl()->IsActiveTree()) { | 599 if (layer_tree_impl()->IsActiveTree()) { |
570 gfx::RectF layer_damage_rect = | 600 gfx::RectF layer_damage_rect = |
571 gfx::ScaleRect(tile->content_rect(), 1.f / tile->contents_scale()); | 601 gfx::ScaleRect(tile->content_rect(), 1.f / tile->contents_scale()); |
572 AddDamageRect(layer_damage_rect); | 602 AddDamageRect(layer_damage_rect); |
573 } | 603 } |
574 } | 604 } |
575 | 605 |
576 void PictureLayerImpl::DidBeginTracing() { | 606 void PictureLayerImpl::DidBeginTracing() { |
577 raster_source_->DidBeginTracing(); | 607 raster_source_->DidBeginTracing(); |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1211 | 1241 |
1212 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { | 1242 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { |
1213 return !layer_tree_impl()->IsRecycleTree(); | 1243 return !layer_tree_impl()->IsRecycleTree(); |
1214 } | 1244 } |
1215 | 1245 |
1216 bool PictureLayerImpl::HasValidTilePriorities() const { | 1246 bool PictureLayerImpl::HasValidTilePriorities() const { |
1217 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); | 1247 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); |
1218 } | 1248 } |
1219 | 1249 |
1220 } // namespace cc | 1250 } // namespace cc |
OLD | NEW |