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/resources/picture_pile.h" | 5 #include "cc/resources/picture_pile.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 #endif | 159 #endif |
160 | 160 |
161 } // namespace | 161 } // namespace |
162 | 162 |
163 namespace cc { | 163 namespace cc { |
164 | 164 |
165 PicturePile::PicturePile(float min_contents_scale, | 165 PicturePile::PicturePile(float min_contents_scale, |
166 const gfx::Size& tile_grid_size) | 166 const gfx::Size& tile_grid_size) |
167 : min_contents_scale_(0), | 167 : min_contents_scale_(0), |
168 slow_down_raster_scale_factor_for_debug_(0), | 168 slow_down_raster_scale_factor_for_debug_(0), |
| 169 can_use_lcd_text_(true), |
169 has_any_recordings_(false), | 170 has_any_recordings_(false), |
170 clear_canvas_with_debug_color_(kDefaultClearCanvasSetting), | 171 clear_canvas_with_debug_color_(kDefaultClearCanvasSetting), |
171 requires_clear_(true), | 172 requires_clear_(true), |
172 is_solid_color_(false), | 173 is_solid_color_(false), |
173 solid_color_(SK_ColorTRANSPARENT), | 174 solid_color_(SK_ColorTRANSPARENT), |
174 background_color_(SK_ColorTRANSPARENT), | 175 background_color_(SK_ColorTRANSPARENT), |
175 pixel_record_distance_(kPixelDistanceToRecord), | 176 pixel_record_distance_(kPixelDistanceToRecord), |
176 is_suitable_for_gpu_rasterization_(true) { | 177 is_suitable_for_gpu_rasterization_(true) { |
177 tiling_.SetMaxTextureSize(gfx::Size(kBasePictureSize, kBasePictureSize)); | 178 tiling_.SetMaxTextureSize(gfx::Size(kBasePictureSize, kBasePictureSize)); |
178 SetMinContentsScale(min_contents_scale); | 179 SetMinContentsScale(min_contents_scale); |
179 SetTileGridSize(tile_grid_size); | 180 SetTileGridSize(tile_grid_size); |
180 } | 181 } |
181 | 182 |
182 PicturePile::~PicturePile() { | 183 PicturePile::~PicturePile() { |
183 } | 184 } |
184 | 185 |
185 bool PicturePile::UpdateAndExpandInvalidation( | 186 bool PicturePile::UpdateAndExpandInvalidation( |
186 ContentLayerClient* painter, | 187 ContentLayerClient* painter, |
187 Region* invalidation, | 188 Region* invalidation, |
| 189 bool can_use_lcd_text, |
188 const gfx::Size& layer_size, | 190 const gfx::Size& layer_size, |
189 const gfx::Rect& visible_layer_rect, | 191 const gfx::Rect& visible_layer_rect, |
190 int frame_number, | 192 int frame_number, |
191 RecordingSource::RecordingMode recording_mode) { | 193 RecordingSource::RecordingMode recording_mode) { |
| 194 bool can_use_lcd_text_changed = can_use_lcd_text_ != can_use_lcd_text; |
| 195 can_use_lcd_text_ = can_use_lcd_text; |
| 196 |
192 gfx::Rect interest_rect = visible_layer_rect; | 197 gfx::Rect interest_rect = visible_layer_rect; |
193 interest_rect.Inset(-pixel_record_distance_, -pixel_record_distance_); | 198 interest_rect.Inset(-pixel_record_distance_, -pixel_record_distance_); |
194 recorded_viewport_ = interest_rect; | 199 recorded_viewport_ = interest_rect; |
195 recorded_viewport_.Intersect(gfx::Rect(layer_size)); | 200 recorded_viewport_.Intersect(gfx::Rect(layer_size)); |
196 | 201 |
197 bool updated = ApplyInvalidationAndResize(interest_rect, invalidation, | 202 bool updated = |
198 layer_size, frame_number); | 203 ApplyInvalidationAndResize(interest_rect, invalidation, layer_size, |
| 204 frame_number, can_use_lcd_text_changed); |
199 std::vector<gfx::Rect> invalid_tiles; | 205 std::vector<gfx::Rect> invalid_tiles; |
200 GetInvalidTileRects(interest_rect, invalidation, visible_layer_rect, | 206 GetInvalidTileRects(interest_rect, invalidation, visible_layer_rect, |
201 frame_number, &invalid_tiles); | 207 frame_number, &invalid_tiles); |
202 std::vector<gfx::Rect> record_rects; | 208 std::vector<gfx::Rect> record_rects; |
203 ClusterTiles(invalid_tiles, &record_rects); | 209 ClusterTiles(invalid_tiles, &record_rects); |
204 | 210 |
205 if (record_rects.empty()) | 211 if (record_rects.empty()) |
206 return updated; | 212 return updated; |
207 | 213 |
208 CreatePictures(painter, recording_mode, record_rects); | 214 CreatePictures(painter, recording_mode, record_rects); |
209 | 215 |
210 DetermineIfSolidColor(); | 216 DetermineIfSolidColor(); |
211 | 217 |
212 has_any_recordings_ = true; | 218 has_any_recordings_ = true; |
213 DCHECK(CanRasterSlowTileCheck(recorded_viewport_)); | 219 DCHECK(CanRasterSlowTileCheck(recorded_viewport_)); |
214 return true; | 220 return true; |
215 } | 221 } |
216 | 222 |
217 bool PicturePile::ApplyInvalidationAndResize(const gfx::Rect& interest_rect, | 223 bool PicturePile::ApplyInvalidationAndResize(const gfx::Rect& interest_rect, |
218 Region* invalidation, | 224 Region* invalidation, |
219 const gfx::Size& layer_size, | 225 const gfx::Size& layer_size, |
220 int frame_number) { | 226 int frame_number, |
| 227 bool can_use_lcd_text_changed) { |
221 bool updated = false; | 228 bool updated = false; |
222 | 229 |
223 Region synthetic_invalidation; | 230 Region synthetic_invalidation; |
224 gfx::Size old_tiling_size = GetSize(); | 231 gfx::Size old_tiling_size = GetSize(); |
225 if (old_tiling_size != layer_size) { | 232 if (old_tiling_size != layer_size) { |
226 tiling_.SetTilingSize(layer_size); | 233 tiling_.SetTilingSize(layer_size); |
227 updated = true; | 234 updated = true; |
228 } | 235 } |
| 236 if (can_use_lcd_text_changed) { |
| 237 // When LCD text is enabled/disabled, we must drop any raster tiles for |
| 238 // the pile, so they can be recreated in a manner consistent with the new |
| 239 // setting. We do this with |synthetic_invalidation| since we don't need to |
| 240 // do a new recording, just invalidate rastered content. |
| 241 synthetic_invalidation.Union(gfx::Rect(GetSize())); |
| 242 updated = true; |
| 243 } |
229 | 244 |
230 gfx::Rect interest_rect_over_tiles = | 245 gfx::Rect interest_rect_over_tiles = |
231 tiling_.ExpandRectToTileBounds(interest_rect); | 246 tiling_.ExpandRectToTileBounds(interest_rect); |
232 | 247 |
233 if (old_tiling_size != layer_size) { | 248 if (old_tiling_size != layer_size) { |
234 gfx::Size min_tiling_size( | 249 gfx::Size min_tiling_size( |
235 std::min(GetSize().width(), old_tiling_size.width()), | 250 std::min(GetSize().width(), old_tiling_size.width()), |
236 std::min(GetSize().height(), old_tiling_size.height())); | 251 std::min(GetSize().height(), old_tiling_size.height())); |
237 gfx::Size max_tiling_size( | 252 gfx::Size max_tiling_size( |
238 std::max(GetSize().width(), old_tiling_size.width()), | 253 std::max(GetSize().width(), old_tiling_size.width()), |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 if (padded_record_rect.Contains(tile)) { | 586 if (padded_record_rect.Contains(tile)) { |
572 PictureInfo& info = picture_map_[key]; | 587 PictureInfo& info = picture_map_[key]; |
573 info.SetPicture(picture); | 588 info.SetPicture(picture); |
574 found_tile_for_recorded_picture = true; | 589 found_tile_for_recorded_picture = true; |
575 } | 590 } |
576 } | 591 } |
577 DCHECK(found_tile_for_recorded_picture); | 592 DCHECK(found_tile_for_recorded_picture); |
578 } | 593 } |
579 } | 594 } |
580 | 595 |
581 scoped_refptr<RasterSource> PicturePile::CreateRasterSource( | 596 scoped_refptr<RasterSource> PicturePile::CreateRasterSource() const { |
582 bool can_use_lcd_text) const { | |
583 return scoped_refptr<RasterSource>( | 597 return scoped_refptr<RasterSource>( |
584 PicturePileImpl::CreateFromPicturePile(this, can_use_lcd_text)); | 598 PicturePileImpl::CreateFromPicturePile(this)); |
585 } | 599 } |
586 | 600 |
587 gfx::Size PicturePile::GetSize() const { | 601 gfx::Size PicturePile::GetSize() const { |
588 return tiling_.tiling_size(); | 602 return tiling_.tiling_size(); |
589 } | 603 } |
590 | 604 |
591 void PicturePile::SetEmptyBounds() { | 605 void PicturePile::SetEmptyBounds() { |
592 tiling_.SetTilingSize(gfx::Size()); | 606 tiling_.SetTilingSize(gfx::Size()); |
593 Clear(); | 607 Clear(); |
594 } | 608 } |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 const Picture* PicturePile::PictureInfo::GetPicture() const { | 776 const Picture* PicturePile::PictureInfo::GetPicture() const { |
763 return picture_.get(); | 777 return picture_.get(); |
764 } | 778 } |
765 | 779 |
766 float PicturePile::PictureInfo::GetInvalidationFrequency() const { | 780 float PicturePile::PictureInfo::GetInvalidationFrequency() const { |
767 return invalidation_history_.count() / | 781 return invalidation_history_.count() / |
768 static_cast<float>(INVALIDATION_FRAMES_TRACKED); | 782 static_cast<float>(INVALIDATION_FRAMES_TRACKED); |
769 } | 783 } |
770 | 784 |
771 } // namespace cc | 785 } // namespace cc |
OLD | NEW |