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), | |
170 has_any_recordings_(false), | 169 has_any_recordings_(false), |
171 clear_canvas_with_debug_color_(kDefaultClearCanvasSetting), | 170 clear_canvas_with_debug_color_(kDefaultClearCanvasSetting), |
172 requires_clear_(true), | 171 requires_clear_(true), |
173 is_solid_color_(false), | 172 is_solid_color_(false), |
174 solid_color_(SK_ColorTRANSPARENT), | 173 solid_color_(SK_ColorTRANSPARENT), |
175 background_color_(SK_ColorTRANSPARENT), | 174 background_color_(SK_ColorTRANSPARENT), |
176 pixel_record_distance_(kPixelDistanceToRecord), | 175 pixel_record_distance_(kPixelDistanceToRecord), |
177 is_suitable_for_gpu_rasterization_(true) { | 176 is_suitable_for_gpu_rasterization_(true) { |
178 tiling_.SetMaxTextureSize(gfx::Size(kBasePictureSize, kBasePictureSize)); | 177 tiling_.SetMaxTextureSize(gfx::Size(kBasePictureSize, kBasePictureSize)); |
179 SetMinContentsScale(min_contents_scale); | 178 SetMinContentsScale(min_contents_scale); |
180 SetTileGridSize(tile_grid_size); | 179 SetTileGridSize(tile_grid_size); |
181 } | 180 } |
182 | 181 |
183 PicturePile::~PicturePile() { | 182 PicturePile::~PicturePile() { |
184 } | 183 } |
185 | 184 |
186 bool PicturePile::UpdateAndExpandInvalidation( | 185 bool PicturePile::UpdateAndExpandInvalidation( |
187 ContentLayerClient* painter, | 186 ContentLayerClient* painter, |
188 Region* invalidation, | 187 Region* invalidation, |
189 bool can_use_lcd_text, | |
190 const gfx::Size& layer_size, | 188 const gfx::Size& layer_size, |
191 const gfx::Rect& visible_layer_rect, | 189 const gfx::Rect& visible_layer_rect, |
192 int frame_number, | 190 int frame_number, |
193 RecordingSource::RecordingMode recording_mode) { | 191 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 | |
197 gfx::Rect interest_rect = visible_layer_rect; | 192 gfx::Rect interest_rect = visible_layer_rect; |
198 interest_rect.Inset(-pixel_record_distance_, -pixel_record_distance_); | 193 interest_rect.Inset(-pixel_record_distance_, -pixel_record_distance_); |
199 recorded_viewport_ = interest_rect; | 194 recorded_viewport_ = interest_rect; |
200 recorded_viewport_.Intersect(gfx::Rect(layer_size)); | 195 recorded_viewport_.Intersect(gfx::Rect(layer_size)); |
201 | 196 |
202 bool updated = | 197 bool updated = ApplyInvalidationAndResize(interest_rect, invalidation, |
203 ApplyInvalidationAndResize(interest_rect, invalidation, layer_size, | 198 layer_size, frame_number); |
204 frame_number, can_use_lcd_text_changed); | |
205 std::vector<gfx::Rect> invalid_tiles; | 199 std::vector<gfx::Rect> invalid_tiles; |
206 GetInvalidTileRects(interest_rect, invalidation, visible_layer_rect, | 200 GetInvalidTileRects(interest_rect, invalidation, visible_layer_rect, |
207 frame_number, &invalid_tiles); | 201 frame_number, &invalid_tiles); |
208 std::vector<gfx::Rect> record_rects; | 202 std::vector<gfx::Rect> record_rects; |
209 ClusterTiles(invalid_tiles, &record_rects); | 203 ClusterTiles(invalid_tiles, &record_rects); |
210 | 204 |
211 if (record_rects.empty()) | 205 if (record_rects.empty()) |
212 return updated; | 206 return updated; |
213 | 207 |
214 CreatePictures(painter, recording_mode, record_rects); | 208 CreatePictures(painter, recording_mode, record_rects); |
215 | 209 |
216 DetermineIfSolidColor(); | 210 DetermineIfSolidColor(); |
217 | 211 |
218 has_any_recordings_ = true; | 212 has_any_recordings_ = true; |
219 DCHECK(CanRasterSlowTileCheck(recorded_viewport_)); | 213 DCHECK(CanRasterSlowTileCheck(recorded_viewport_)); |
220 return true; | 214 return true; |
221 } | 215 } |
222 | 216 |
223 bool PicturePile::ApplyInvalidationAndResize(const gfx::Rect& interest_rect, | 217 bool PicturePile::ApplyInvalidationAndResize(const gfx::Rect& interest_rect, |
224 Region* invalidation, | 218 Region* invalidation, |
225 const gfx::Size& layer_size, | 219 const gfx::Size& layer_size, |
226 int frame_number, | 220 int frame_number) { |
227 bool can_use_lcd_text_changed) { | |
228 bool updated = false; | 221 bool updated = false; |
229 | 222 |
230 Region synthetic_invalidation; | 223 Region synthetic_invalidation; |
231 gfx::Size old_tiling_size = GetSize(); | 224 gfx::Size old_tiling_size = GetSize(); |
232 if (old_tiling_size != layer_size) { | 225 if (old_tiling_size != layer_size) { |
233 tiling_.SetTilingSize(layer_size); | 226 tiling_.SetTilingSize(layer_size); |
234 updated = true; | 227 updated = true; |
235 } | 228 } |
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 } | |
244 | 229 |
245 gfx::Rect interest_rect_over_tiles = | 230 gfx::Rect interest_rect_over_tiles = |
246 tiling_.ExpandRectToTileBounds(interest_rect); | 231 tiling_.ExpandRectToTileBounds(interest_rect); |
247 | 232 |
248 if (old_tiling_size != layer_size) { | 233 if (old_tiling_size != layer_size) { |
249 gfx::Size min_tiling_size( | 234 gfx::Size min_tiling_size( |
250 std::min(GetSize().width(), old_tiling_size.width()), | 235 std::min(GetSize().width(), old_tiling_size.width()), |
251 std::min(GetSize().height(), old_tiling_size.height())); | 236 std::min(GetSize().height(), old_tiling_size.height())); |
252 gfx::Size max_tiling_size( | 237 gfx::Size max_tiling_size( |
253 std::max(GetSize().width(), old_tiling_size.width()), | 238 std::max(GetSize().width(), old_tiling_size.width()), |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 if (padded_record_rect.Contains(tile)) { | 571 if (padded_record_rect.Contains(tile)) { |
587 PictureInfo& info = picture_map_[key]; | 572 PictureInfo& info = picture_map_[key]; |
588 info.SetPicture(picture); | 573 info.SetPicture(picture); |
589 found_tile_for_recorded_picture = true; | 574 found_tile_for_recorded_picture = true; |
590 } | 575 } |
591 } | 576 } |
592 DCHECK(found_tile_for_recorded_picture); | 577 DCHECK(found_tile_for_recorded_picture); |
593 } | 578 } |
594 } | 579 } |
595 | 580 |
596 scoped_refptr<RasterSource> PicturePile::CreateRasterSource() const { | 581 scoped_refptr<RasterSource> PicturePile::CreateRasterSource( |
| 582 bool can_use_lcd_text) const { |
597 return scoped_refptr<RasterSource>( | 583 return scoped_refptr<RasterSource>( |
598 PicturePileImpl::CreateFromPicturePile(this)); | 584 PicturePileImpl::CreateFromPicturePile(this, can_use_lcd_text)); |
599 } | 585 } |
600 | 586 |
601 gfx::Size PicturePile::GetSize() const { | 587 gfx::Size PicturePile::GetSize() const { |
602 return tiling_.tiling_size(); | 588 return tiling_.tiling_size(); |
603 } | 589 } |
604 | 590 |
605 void PicturePile::SetEmptyBounds() { | 591 void PicturePile::SetEmptyBounds() { |
606 tiling_.SetTilingSize(gfx::Size()); | 592 tiling_.SetTilingSize(gfx::Size()); |
607 Clear(); | 593 Clear(); |
608 } | 594 } |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 const Picture* PicturePile::PictureInfo::GetPicture() const { | 762 const Picture* PicturePile::PictureInfo::GetPicture() const { |
777 return picture_.get(); | 763 return picture_.get(); |
778 } | 764 } |
779 | 765 |
780 float PicturePile::PictureInfo::GetInvalidationFrequency() const { | 766 float PicturePile::PictureInfo::GetInvalidationFrequency() const { |
781 return invalidation_history_.count() / | 767 return invalidation_history_.count() / |
782 static_cast<float>(INVALIDATION_FRAMES_TRACKED); | 768 static_cast<float>(INVALIDATION_FRAMES_TRACKED); |
783 } | 769 } |
784 | 770 |
785 } // namespace cc | 771 } // namespace cc |
OLD | NEW |