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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 return; | 211 return; |
212 | 212 |
213 invalidation_history_ <<= (frame_number - last_frame_number_); | 213 invalidation_history_ <<= (frame_number - last_frame_number_); |
214 last_frame_number_ = frame_number; | 214 last_frame_number_ = frame_number; |
215 } | 215 } |
216 | 216 |
217 bool PicturePileBase::PictureInfo::Invalidate(int frame_number) { | 217 bool PicturePileBase::PictureInfo::Invalidate(int frame_number) { |
218 AdvanceInvalidationHistory(frame_number); | 218 AdvanceInvalidationHistory(frame_number); |
219 invalidation_history_.set(0); | 219 invalidation_history_.set(0); |
220 | 220 |
221 bool did_invalidate = !!picture_; | 221 bool did_invalidate = !!picture_.get(); |
222 picture_ = NULL; | 222 picture_ = NULL; |
223 return did_invalidate; | 223 return did_invalidate; |
224 } | 224 } |
225 | 225 |
226 bool PicturePileBase::PictureInfo::NeedsRecording(int frame_number, | 226 bool PicturePileBase::PictureInfo::NeedsRecording(int frame_number, |
227 int distance_to_visible) { | 227 int distance_to_visible) { |
228 AdvanceInvalidationHistory(frame_number); | 228 AdvanceInvalidationHistory(frame_number); |
229 | 229 |
230 // We only need recording if we don't have a picture. Furthermore, we only | 230 // We only need recording if we don't have a picture. Furthermore, we only |
231 // need a recording if we're within frequent invalidation distance threshold | 231 // need a recording if we're within frequent invalidation distance threshold |
232 // or the invalidation is not frequent enough (below invalidation frequency | 232 // or the invalidation is not frequent enough (below invalidation frequency |
233 // threshold). | 233 // threshold). |
234 return !picture_ && | 234 return !picture_.get() && |
235 ((distance_to_visible <= kFrequentInvalidationDistanceThreshold) || | 235 ((distance_to_visible <= kFrequentInvalidationDistanceThreshold) || |
236 (GetInvalidationFrequency() < kInvalidationFrequencyThreshold)); | 236 (GetInvalidationFrequency() < kInvalidationFrequencyThreshold)); |
237 } | 237 } |
238 | 238 |
239 void PicturePileBase::PictureInfo::SetPicture(scoped_refptr<Picture> picture) { | 239 void PicturePileBase::PictureInfo::SetPicture(scoped_refptr<Picture> picture) { |
240 picture_ = picture; | 240 picture_ = picture; |
241 } | 241 } |
242 | 242 |
243 const Picture* PicturePileBase::PictureInfo::GetPicture() const { | 243 const Picture* PicturePileBase::PictureInfo::GetPicture() const { |
244 return picture_.get(); | 244 return picture_.get(); |
245 } | 245 } |
246 | 246 |
247 float PicturePileBase::PictureInfo::GetInvalidationFrequency() const { | 247 float PicturePileBase::PictureInfo::GetInvalidationFrequency() const { |
248 return invalidation_history_.count() / | 248 return invalidation_history_.count() / |
249 static_cast<float>(INVALIDATION_FRAMES_TRACKED); | 249 static_cast<float>(INVALIDATION_FRAMES_TRACKED); |
250 } | 250 } |
251 | 251 |
252 } // namespace cc | 252 } // namespace cc |
OLD | NEW |