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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 for (PictureMap::const_iterator it = other->picture_map_.begin(); | 85 for (PictureMap::const_iterator it = other->picture_map_.begin(); |
86 it != other->picture_map_.end(); | 86 it != other->picture_map_.end(); |
87 ++it) { | 87 ++it) { |
88 picture_map_[it->first] = it->second.CloneForThread(thread_index); | 88 picture_map_[it->first] = it->second.CloneForThread(thread_index); |
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 PicturePileBase::~PicturePileBase() { | 92 PicturePileBase::~PicturePileBase() { |
93 } | 93 } |
94 | 94 |
95 void PicturePileBase::SetTilingRect(const gfx::Rect& new_tiling_rect) { | |
96 if (tiling_rect() == new_tiling_rect) | |
97 return; | |
98 | |
99 gfx::Rect old_tiling_rect = tiling_rect(); | |
100 tiling_.SetTilingRect(new_tiling_rect); | |
101 | |
102 has_any_recordings_ = false; | |
103 | |
104 // Don't waste time in Resize figuring out what these hints should be. | |
105 recorded_viewport_ = gfx::Rect(); | |
106 | |
107 if (new_tiling_rect.origin() != old_tiling_rect.origin()) { | |
108 picture_map_.clear(); | |
109 return; | |
110 } | |
111 | |
112 // Find all tiles that contain any pixels outside the new rect. | |
113 std::vector<PictureMapKey> to_erase; | |
114 int min_toss_x = tiling_.num_tiles_x(); | |
115 if (new_tiling_rect.right() > old_tiling_rect.right()) { | |
116 min_toss_x = | |
117 tiling_.FirstBorderTileXIndexFromSrcCoord(old_tiling_rect.right()); | |
118 } | |
119 int min_toss_y = tiling_.num_tiles_y(); | |
120 if (new_tiling_rect.bottom() > old_tiling_rect.bottom()) { | |
121 min_toss_y = | |
122 tiling_.FirstBorderTileYIndexFromSrcCoord(old_tiling_rect.bottom()); | |
123 } | |
124 for (PictureMap::const_iterator it = picture_map_.begin(); | |
125 it != picture_map_.end(); | |
126 ++it) { | |
127 const PictureMapKey& key = it->first; | |
128 if (key.first < min_toss_x && key.second < min_toss_y) { | |
129 has_any_recordings_ |= !!it->second.GetPicture(); | |
130 continue; | |
131 } | |
132 to_erase.push_back(key); | |
133 } | |
134 | |
135 for (size_t i = 0; i < to_erase.size(); ++i) | |
136 picture_map_.erase(to_erase[i]); | |
137 } | |
138 | |
139 void PicturePileBase::SetMinContentsScale(float min_contents_scale) { | 95 void PicturePileBase::SetMinContentsScale(float min_contents_scale) { |
140 DCHECK(min_contents_scale); | 96 DCHECK(min_contents_scale); |
141 if (min_contents_scale_ == min_contents_scale) | 97 if (min_contents_scale_ == min_contents_scale) |
142 return; | 98 return; |
143 | 99 |
144 // Picture contents are played back scaled. When the final contents scale is | 100 // Picture contents are played back scaled. When the final contents scale is |
145 // less than 1 (i.e. low res), then multiple recorded pixels will be used | 101 // less than 1 (i.e. low res), then multiple recorded pixels will be used |
146 // to raster one final pixel. To avoid splitting a final pixel across | 102 // to raster one final pixel. To avoid splitting a final pixel across |
147 // pictures (which would result in incorrect rasterization due to blending), a | 103 // pictures (which would result in incorrect rasterization due to blending), a |
148 // buffer margin is added so that any picture can be snapped to integral | 104 // buffer margin is added so that any picture can be snapped to integral |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 info.picture_ = picture_->GetCloneForDrawingOnThread(thread_index); | 270 info.picture_ = picture_->GetCloneForDrawingOnThread(thread_index); |
315 return info; | 271 return info; |
316 } | 272 } |
317 | 273 |
318 float PicturePileBase::PictureInfo::GetInvalidationFrequency() const { | 274 float PicturePileBase::PictureInfo::GetInvalidationFrequency() const { |
319 return invalidation_history_.count() / | 275 return invalidation_history_.count() / |
320 static_cast<float>(INVALIDATION_FRAMES_TRACKED); | 276 static_cast<float>(INVALIDATION_FRAMES_TRACKED); |
321 } | 277 } |
322 | 278 |
323 } // namespace cc | 279 } // namespace cc |
OLD | NEW |