| 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 148 |
| 149 bool PicturePileBase::HasRecordingAt(int x, int y) { | 149 bool PicturePileBase::HasRecordingAt(int x, int y) { |
| 150 PictureMap::const_iterator found = picture_map_.find(PictureMapKey(x, y)); | 150 PictureMap::const_iterator found = picture_map_.find(PictureMapKey(x, y)); |
| 151 if (found == picture_map_.end()) | 151 if (found == picture_map_.end()) |
| 152 return false; | 152 return false; |
| 153 return !!found->second.GetPicture(); | 153 return !!found->second.GetPicture(); |
| 154 } | 154 } |
| 155 | 155 |
| 156 bool PicturePileBase::CanRaster(float contents_scale, | 156 bool PicturePileBase::CanRaster(float contents_scale, |
| 157 const gfx::Rect& content_rect) { | 157 const gfx::Rect& content_rect) { |
| 158 if (tiling_.tiling_rect().IsEmpty()) | 158 if (tiling_.tiling_size().IsEmpty()) |
| 159 return false; | 159 return false; |
| 160 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect( | 160 gfx::Rect layer_rect = gfx::ScaleToEnclosingRect( |
| 161 content_rect, 1.f / contents_scale); | 161 content_rect, 1.f / contents_scale); |
| 162 layer_rect.Intersect(tiling_.tiling_rect()); | 162 layer_rect.Intersect(gfx::Rect(tiling_.tiling_size())); |
| 163 | 163 |
| 164 // Common case inside of viewport to avoid the slower map lookups. | 164 // Common case inside of viewport to avoid the slower map lookups. |
| 165 if (recorded_viewport_.Contains(layer_rect)) { | 165 if (recorded_viewport_.Contains(layer_rect)) { |
| 166 // Sanity check that there are no false positives in recorded_viewport_. | 166 // Sanity check that there are no false positives in recorded_viewport_. |
| 167 DCHECK(CanRasterSlowTileCheck(layer_rect)); | 167 DCHECK(CanRasterSlowTileCheck(layer_rect)); |
| 168 return true; | 168 return true; |
| 169 } | 169 } |
| 170 | 170 |
| 171 return CanRasterSlowTileCheck(layer_rect); | 171 return CanRasterSlowTileCheck(layer_rect); |
| 172 } | 172 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 193 | 193 |
| 194 gfx::Rect PicturePileBase::PadRect(const gfx::Rect& rect) { | 194 gfx::Rect PicturePileBase::PadRect(const gfx::Rect& rect) { |
| 195 gfx::Rect padded_rect = rect; | 195 gfx::Rect padded_rect = rect; |
| 196 padded_rect.Inset( | 196 padded_rect.Inset( |
| 197 -buffer_pixels(), -buffer_pixels(), -buffer_pixels(), -buffer_pixels()); | 197 -buffer_pixels(), -buffer_pixels(), -buffer_pixels(), -buffer_pixels()); |
| 198 return padded_rect; | 198 return padded_rect; |
| 199 } | 199 } |
| 200 | 200 |
| 201 scoped_ptr<base::Value> PicturePileBase::AsValue() const { | 201 scoped_ptr<base::Value> PicturePileBase::AsValue() const { |
| 202 scoped_ptr<base::ListValue> pictures(new base::ListValue()); | 202 scoped_ptr<base::ListValue> pictures(new base::ListValue()); |
| 203 gfx::Rect tiling_rect(tiling_.tiling_rect()); | 203 gfx::Rect tiling_rect(tiling_.tiling_size()); |
| 204 std::set<void*> appended_pictures; | 204 std::set<void*> appended_pictures; |
| 205 bool include_borders = true; | 205 bool include_borders = true; |
| 206 for (TilingData::Iterator tile_iter(&tiling_, tiling_rect, include_borders); | 206 for (TilingData::Iterator tile_iter(&tiling_, tiling_rect, include_borders); |
| 207 tile_iter; | 207 tile_iter; |
| 208 ++tile_iter) { | 208 ++tile_iter) { |
| 209 PictureMap::const_iterator map_iter = picture_map_.find(tile_iter.index()); | 209 PictureMap::const_iterator map_iter = picture_map_.find(tile_iter.index()); |
| 210 if (map_iter == picture_map_.end()) | 210 if (map_iter == picture_map_.end()) |
| 211 continue; | 211 continue; |
| 212 | 212 |
| 213 Picture* picture = map_iter->second.GetPicture(); | 213 Picture* picture = map_iter->second.GetPicture(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 info.picture_ = picture_->GetCloneForDrawingOnThread(thread_index); | 270 info.picture_ = picture_->GetCloneForDrawingOnThread(thread_index); |
| 271 return info; | 271 return info; |
| 272 } | 272 } |
| 273 | 273 |
| 274 float PicturePileBase::PictureInfo::GetInvalidationFrequency() const { | 274 float PicturePileBase::PictureInfo::GetInvalidationFrequency() const { |
| 275 return invalidation_history_.count() / | 275 return invalidation_history_.count() / |
| 276 static_cast<float>(INVALIDATION_FRAMES_TRACKED); | 276 static_cast<float>(INVALIDATION_FRAMES_TRACKED); |
| 277 } | 277 } |
| 278 | 278 |
| 279 } // namespace cc | 279 } // namespace cc |
| OLD | NEW |