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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 } | 181 } |
182 } | 182 } |
183 | 183 |
184 bool PicturePileBase::HasRecordingAt(int x, int y) { | 184 bool PicturePileBase::HasRecordingAt(int x, int y) { |
185 PictureMap::const_iterator found = picture_map_.find(PictureMapKey(x, y)); | 185 PictureMap::const_iterator found = picture_map_.find(PictureMapKey(x, y)); |
186 if (found == picture_map_.end()) | 186 if (found == picture_map_.end()) |
187 return false; | 187 return false; |
188 return !!found->second.GetPicture(); | 188 return !!found->second.GetPicture(); |
189 } | 189 } |
190 | 190 |
191 bool PicturePileBase::CanRaster(float contents_scale, gfx::Rect content_rect) { | 191 bool PicturePileBase::CanRaster(float contents_scale, |
| 192 const gfx::Rect& content_rect) { |
192 if (tiling_.total_size().IsEmpty()) | 193 if (tiling_.total_size().IsEmpty()) |
193 return false; | 194 return false; |
194 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect( | 195 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect( |
195 content_rect, 1.f / contents_scale); | 196 content_rect, 1.f / contents_scale); |
196 layer_rect.Intersect(gfx::Rect(tiling_.total_size())); | 197 layer_rect.Intersect(gfx::Rect(tiling_.total_size())); |
197 return recorded_region_.Contains(layer_rect); | 198 return recorded_region_.Contains(layer_rect); |
198 } | 199 } |
199 | 200 |
200 gfx::Rect PicturePileBase::PaddedRect(const PictureMapKey& key) { | 201 gfx::Rect PicturePileBase::PaddedRect(const PictureMapKey& key) { |
201 gfx::Rect tile = tiling_.TileBounds(key.first, key.second); | 202 gfx::Rect tile = tiling_.TileBounds(key.first, key.second); |
202 return PadRect(tile); | 203 return PadRect(tile); |
203 } | 204 } |
204 | 205 |
205 gfx::Rect PicturePileBase::PadRect(gfx::Rect rect) { | 206 gfx::Rect PicturePileBase::PadRect(const gfx::Rect& rect) { |
206 gfx::Rect padded_rect = rect; | 207 gfx::Rect padded_rect = rect; |
207 padded_rect.Inset( | 208 padded_rect.Inset( |
208 -buffer_pixels(), -buffer_pixels(), -buffer_pixels(), -buffer_pixels()); | 209 -buffer_pixels(), -buffer_pixels(), -buffer_pixels(), -buffer_pixels()); |
209 return padded_rect; | 210 return padded_rect; |
210 } | 211 } |
211 | 212 |
212 scoped_ptr<base::Value> PicturePileBase::AsValue() const { | 213 scoped_ptr<base::Value> PicturePileBase::AsValue() const { |
213 scoped_ptr<base::ListValue> pictures(new base::ListValue()); | 214 scoped_ptr<base::ListValue> pictures(new base::ListValue()); |
214 gfx::Rect layer_rect(tiling_.total_size()); | 215 gfx::Rect layer_rect(tiling_.total_size()); |
215 std::set<void*> appended_pictures; | 216 std::set<void*> appended_pictures; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 info.picture_ = picture_->GetCloneForDrawingOnThread(thread_index); | 280 info.picture_ = picture_->GetCloneForDrawingOnThread(thread_index); |
280 return info; | 281 return info; |
281 } | 282 } |
282 | 283 |
283 float PicturePileBase::PictureInfo::GetInvalidationFrequency() const { | 284 float PicturePileBase::PictureInfo::GetInvalidationFrequency() const { |
284 return invalidation_history_.count() / | 285 return invalidation_history_.count() / |
285 static_cast<float>(INVALIDATION_FRAMES_TRACKED); | 286 static_cast<float>(INVALIDATION_FRAMES_TRACKED); |
286 } | 287 } |
287 | 288 |
288 } // namespace cc | 289 } // namespace cc |
OLD | NEW |