OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_base.h" | 5 #include "cc/resources/picture_pile_base.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 slow_down_raster_scale_factor_for_debug_( | 65 slow_down_raster_scale_factor_for_debug_( |
66 other->slow_down_raster_scale_factor_for_debug_), | 66 other->slow_down_raster_scale_factor_for_debug_), |
67 contents_opaque_(other->contents_opaque_), | 67 contents_opaque_(other->contents_opaque_), |
68 contents_fill_bounds_completely_(other->contents_fill_bounds_completely_), | 68 contents_fill_bounds_completely_(other->contents_fill_bounds_completely_), |
69 show_debug_picture_borders_(other->show_debug_picture_borders_), | 69 show_debug_picture_borders_(other->show_debug_picture_borders_), |
70 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_), | 70 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_), |
71 has_any_recordings_(other->has_any_recordings_), | 71 has_any_recordings_(other->has_any_recordings_), |
72 has_text_(other->has_text_) { | 72 has_text_(other->has_text_) { |
73 } | 73 } |
74 | 74 |
75 PicturePileBase::PicturePileBase(const PicturePileBase* other, | |
76 unsigned thread_index) | |
77 : tiling_(other->tiling_), | |
78 recorded_viewport_(other->recorded_viewport_), | |
79 min_contents_scale_(other->min_contents_scale_), | |
80 tile_grid_info_(other->tile_grid_info_), | |
81 background_color_(other->background_color_), | |
82 slow_down_raster_scale_factor_for_debug_( | |
83 other->slow_down_raster_scale_factor_for_debug_), | |
84 contents_opaque_(other->contents_opaque_), | |
85 contents_fill_bounds_completely_(other->contents_fill_bounds_completely_), | |
86 show_debug_picture_borders_(other->show_debug_picture_borders_), | |
87 clear_canvas_with_debug_color_(other->clear_canvas_with_debug_color_), | |
88 has_any_recordings_(other->has_any_recordings_), | |
89 has_text_(other->has_text_) { | |
90 for (PictureMap::const_iterator it = other->picture_map_.begin(); | |
91 it != other->picture_map_.end(); | |
92 ++it) { | |
93 picture_map_[it->first] = it->second.CloneForThread(thread_index); | |
94 } | |
95 } | |
96 | |
97 PicturePileBase::~PicturePileBase() { | 75 PicturePileBase::~PicturePileBase() { |
98 } | 76 } |
99 | 77 |
100 void PicturePileBase::SetMinContentsScale(float min_contents_scale) { | 78 void PicturePileBase::SetMinContentsScale(float min_contents_scale) { |
101 DCHECK(min_contents_scale); | 79 DCHECK(min_contents_scale); |
102 if (min_contents_scale_ == min_contents_scale) | 80 if (min_contents_scale_ == min_contents_scale) |
103 return; | 81 return; |
104 | 82 |
105 // Picture contents are played back scaled. When the final contents scale is | 83 // Picture contents are played back scaled. When the final contents scale is |
106 // less than 1 (i.e. low res), then multiple recorded pixels will be used | 84 // less than 1 (i.e. low res), then multiple recorded pixels will be used |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 ++tile_iter) { | 162 ++tile_iter) { |
185 PictureMap::const_iterator map_iter = picture_map_.find(tile_iter.index()); | 163 PictureMap::const_iterator map_iter = picture_map_.find(tile_iter.index()); |
186 if (map_iter == picture_map_.end()) | 164 if (map_iter == picture_map_.end()) |
187 return false; | 165 return false; |
188 if (!map_iter->second.GetPicture()) | 166 if (!map_iter->second.GetPicture()) |
189 return false; | 167 return false; |
190 } | 168 } |
191 return true; | 169 return true; |
192 } | 170 } |
193 | 171 |
194 gfx::Rect PicturePileBase::PaddedRect(const PictureMapKey& key) { | 172 gfx::Rect PicturePileBase::PaddedRect(const PictureMapKey& key) const { |
195 gfx::Rect tile = tiling_.TileBounds(key.first, key.second); | 173 gfx::Rect tile = tiling_.TileBounds(key.first, key.second); |
196 return PadRect(tile); | 174 return PadRect(tile); |
197 } | 175 } |
198 | 176 |
199 gfx::Rect PicturePileBase::PadRect(const gfx::Rect& rect) { | 177 gfx::Rect PicturePileBase::PadRect(const gfx::Rect& rect) const { |
200 gfx::Rect padded_rect = rect; | 178 gfx::Rect padded_rect = rect; |
201 padded_rect.Inset( | 179 padded_rect.Inset( |
202 -buffer_pixels(), -buffer_pixels(), -buffer_pixels(), -buffer_pixels()); | 180 -buffer_pixels(), -buffer_pixels(), -buffer_pixels(), -buffer_pixels()); |
203 return padded_rect; | 181 return padded_rect; |
204 } | 182 } |
205 | 183 |
206 void PicturePileBase::AsValueInto(base::debug::TracedValue* pictures) const { | 184 void PicturePileBase::AsValueInto(base::debug::TracedValue* pictures) const { |
207 gfx::Rect tiling_rect(tiling_.tiling_size()); | 185 gfx::Rect tiling_rect(tiling_.tiling_size()); |
208 std::set<void*> appended_pictures; | 186 std::set<const void*> appended_pictures; |
209 bool include_borders = true; | 187 bool include_borders = true; |
210 for (TilingData::Iterator tile_iter(&tiling_, tiling_rect, include_borders); | 188 for (TilingData::Iterator tile_iter(&tiling_, tiling_rect, include_borders); |
211 tile_iter; | 189 tile_iter; |
212 ++tile_iter) { | 190 ++tile_iter) { |
213 PictureMap::const_iterator map_iter = picture_map_.find(tile_iter.index()); | 191 PictureMap::const_iterator map_iter = picture_map_.find(tile_iter.index()); |
214 if (map_iter == picture_map_.end()) | 192 if (map_iter == picture_map_.end()) |
215 continue; | 193 continue; |
216 | 194 |
217 Picture* picture = map_iter->second.GetPicture(); | 195 const Picture* picture = map_iter->second.GetPicture(); |
218 if (picture && (appended_pictures.count(picture) == 0)) { | 196 if (picture && (appended_pictures.count(picture) == 0)) { |
219 appended_pictures.insert(picture); | 197 appended_pictures.insert(picture); |
220 TracedValue::AppendIDRef(picture, pictures); | 198 TracedValue::AppendIDRef(picture, pictures); |
221 } | 199 } |
222 } | 200 } |
223 } | 201 } |
224 | 202 |
225 PicturePileBase::PictureInfo::PictureInfo() : last_frame_number_(0) {} | 203 PicturePileBase::PictureInfo::PictureInfo() : last_frame_number_(0) {} |
226 | 204 |
227 PicturePileBase::PictureInfo::~PictureInfo() {} | 205 PicturePileBase::PictureInfo::~PictureInfo() {} |
(...skipping 27 matching lines...) Expand all Loading... |
255 // threshold). | 233 // threshold). |
256 return !picture_ && | 234 return !picture_ && |
257 ((distance_to_visible <= kFrequentInvalidationDistanceThreshold) || | 235 ((distance_to_visible <= kFrequentInvalidationDistanceThreshold) || |
258 (GetInvalidationFrequency() < kInvalidationFrequencyThreshold)); | 236 (GetInvalidationFrequency() < kInvalidationFrequencyThreshold)); |
259 } | 237 } |
260 | 238 |
261 void PicturePileBase::PictureInfo::SetPicture(scoped_refptr<Picture> picture) { | 239 void PicturePileBase::PictureInfo::SetPicture(scoped_refptr<Picture> picture) { |
262 picture_ = picture; | 240 picture_ = picture; |
263 } | 241 } |
264 | 242 |
265 Picture* PicturePileBase::PictureInfo::GetPicture() const { | 243 const Picture* PicturePileBase::PictureInfo::GetPicture() const { |
266 return picture_.get(); | 244 return picture_.get(); |
267 } | 245 } |
268 | 246 |
269 PicturePileBase::PictureInfo PicturePileBase::PictureInfo::CloneForThread( | |
270 int thread_index) const { | |
271 PictureInfo info = *this; | |
272 if (picture_.get()) | |
273 info.picture_ = picture_->GetCloneForDrawingOnThread(thread_index); | |
274 return info; | |
275 } | |
276 | |
277 float PicturePileBase::PictureInfo::GetInvalidationFrequency() const { | 247 float PicturePileBase::PictureInfo::GetInvalidationFrequency() const { |
278 return invalidation_history_.count() / | 248 return invalidation_history_.count() / |
279 static_cast<float>(INVALIDATION_FRAMES_TRACKED); | 249 static_cast<float>(INVALIDATION_FRAMES_TRACKED); |
280 } | 250 } |
281 | 251 |
282 } // namespace cc | 252 } // namespace cc |
OLD | NEW |