OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/picture_layer_tiling.h" | 5 #include "cc/picture_layer_tiling.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "cc/math_util.h" | 8 #include "cc/math_util.h" |
9 #include "ui/gfx/point_conversions.h" | 9 #include "ui/gfx/point_conversions.h" |
10 #include "ui/gfx/rect_conversions.h" | 10 #include "ui/gfx/rect_conversions.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 | 126 |
127 for (Region::Iterator region_iter(layer_invalidation); | 127 for (Region::Iterator region_iter(layer_invalidation); |
128 region_iter.has_rect(); | 128 region_iter.has_rect(); |
129 region_iter.next()) { | 129 region_iter.next()) { |
130 | 130 |
131 gfx::Rect layer_invalidation = region_iter.rect(); | 131 gfx::Rect layer_invalidation = region_iter.rect(); |
132 layer_invalidation.Intersect(gfx::Rect(layer_bounds_)); | 132 layer_invalidation.Intersect(gfx::Rect(layer_bounds_)); |
133 gfx::Rect rect = | 133 gfx::Rect rect = |
134 gfx::ToEnclosingRect(ScaleRect(layer_invalidation, contents_scale_)); | 134 gfx::ToEnclosingRect(ScaleRect(layer_invalidation, contents_scale_)); |
135 | 135 |
136 for (PictureLayerTiling::Iterator tile_iter(this, contents_scale_, rect); | 136 for (PictureLayerTiling::Iterator tile_iter(this, contents_scale_, rect, |
137 PictureLayerTiling::LayerDeviceA lignmentUnknown); | |
137 tile_iter; | 138 tile_iter; |
138 ++tile_iter) { | 139 ++tile_iter) { |
139 TileMapKey key(tile_iter.tile_i_, tile_iter.tile_j_); | 140 TileMapKey key(tile_iter.tile_i_, tile_iter.tile_j_); |
140 TileMap::iterator found = tiles_.find(key); | 141 TileMap::iterator found = tiles_.find(key); |
141 if (found == tiles_.end()) | 142 if (found == tiles_.end()) |
142 continue; | 143 continue; |
143 | 144 |
144 tiles_.erase(found); | 145 tiles_.erase(found); |
145 new_tiles.push_back(key); | 146 new_tiles.push_back(key); |
146 } | 147 } |
(...skipping 26 matching lines...) Expand all Loading... | |
173 tile_i_(0), | 174 tile_i_(0), |
174 tile_j_(0), | 175 tile_j_(0), |
175 left_(0), | 176 left_(0), |
176 top_(0), | 177 top_(0), |
177 right_(-1), | 178 right_(-1), |
178 bottom_(-1) { | 179 bottom_(-1) { |
179 } | 180 } |
180 | 181 |
181 PictureLayerTiling::Iterator::Iterator(const PictureLayerTiling* tiling, | 182 PictureLayerTiling::Iterator::Iterator(const PictureLayerTiling* tiling, |
182 float dest_scale, | 183 float dest_scale, |
183 gfx::Rect dest_rect) | 184 gfx::Rect dest_rect, |
185 LayerDeviceAlignment layerDeviceAlignment ) | |
184 : tiling_(tiling), | 186 : tiling_(tiling), |
185 dest_rect_(dest_rect), | 187 dest_rect_(dest_rect), |
186 current_tile_(NULL), | 188 current_tile_(NULL), |
187 dest_to_content_scale_x_(0), | 189 dest_to_content_scale_x_(0), |
188 dest_to_content_scale_y_(0), | 190 dest_to_content_scale_y_(0), |
189 tile_i_(0), | 191 tile_i_(0), |
190 tile_j_(0), | 192 tile_j_(0), |
191 left_(0), | 193 left_(0), |
192 top_(0), | 194 top_(0), |
193 right_(-1), | 195 right_(-1), |
(...skipping 12 matching lines...) Expand all Loading... | |
206 // The last row/column of texels may not have full rasterization coverage, | 208 // The last row/column of texels may not have full rasterization coverage, |
207 // which can happen if the ceiled content size does not equal the floored | 209 // which can happen if the ceiled content size does not equal the floored |
208 // content size. These texels will sample outside of the recording to | 210 // content size. These texels will sample outside of the recording to |
209 // generate their pixels. Use the floored size here to ignore them. | 211 // generate their pixels. Use the floored size here to ignore them. |
210 gfx::Size content_size_floor = gfx::ToFlooredSize(tiling->ContentSizeF()); | 212 gfx::Size content_size_floor = gfx::ToFlooredSize(tiling->ContentSizeF()); |
211 dest_to_content_scale_x_ = content_size_floor.width() / | 213 dest_to_content_scale_x_ = content_size_floor.width() / |
212 static_cast<float>(dest_content_size.width()); | 214 static_cast<float>(dest_content_size.width()); |
213 dest_to_content_scale_y_ = content_size_floor.height() / | 215 dest_to_content_scale_y_ = content_size_floor.height() / |
214 static_cast<float>(dest_content_size.height()); | 216 static_cast<float>(dest_content_size.height()); |
215 | 217 |
218 // It's possible that when drawing a quad with texel:pixel ratio < 1 | |
219 // GL_LINEAR will cause us to blend in invalid texels. | |
220 // We stretch the content a little more to prevent sampling past the | |
221 // middle of the last texel. | |
222 if (layerDeviceAlignment == LayerAlignedToDevice){ | |
brianderson
2013/02/13 00:10:19
This is where the scale is taken into account.
Al
| |
223 if (dest_to_content_scale_x_ < 1.0) | |
224 dest_to_content_scale_x_ -= 0.5f / dest_content_size.width(); | |
225 if (dest_to_content_scale_y_ < 1.0) | |
226 dest_to_content_scale_y_ -= 0.5f / dest_content_size.height(); | |
227 } | |
228 else if (layerDeviceAlignment == LayerNotAlignedToDevice) { | |
229 dest_to_content_scale_x_ -= 0.5f / dest_content_size.width(); | |
230 dest_to_content_scale_y_ -= 0.5f / dest_content_size.height(); | |
231 } | |
232 | |
216 gfx::Rect content_rect = | 233 gfx::Rect content_rect = |
217 gfx::ToEnclosingRect(gfx::ScaleRect(dest_rect_, | 234 gfx::ToEnclosingRect(gfx::ScaleRect(dest_rect_, |
218 dest_to_content_scale_x_, | 235 dest_to_content_scale_x_, |
219 dest_to_content_scale_y_)); | 236 dest_to_content_scale_y_)); |
220 // IndexFromSrcCoord clamps to valid tile ranges, so it's necessary to | 237 // IndexFromSrcCoord clamps to valid tile ranges, so it's necessary to |
221 // check for non-intersection first. | 238 // check for non-intersection first. |
222 content_rect.Intersect(gfx::Rect(tiling_->tiling_data_.total_size())); | 239 content_rect.Intersect(gfx::Rect(tiling_->tiling_data_.total_size())); |
223 if (content_rect.IsEmpty()) | 240 if (content_rect.IsEmpty()) |
224 return; | 241 return; |
225 | 242 |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
498 // and recreated, then that picture pile ref could exist indefinitely. To | 515 // and recreated, then that picture pile ref could exist indefinitely. To |
499 // prevent this, ask the client to update the pile to its own ref. This | 516 // prevent this, ask the client to update the pile to its own ref. This |
500 // will cause PicturePileImpls and their clones to get deleted once the | 517 // will cause PicturePileImpls and their clones to get deleted once the |
501 // corresponding PictureLayerImpl and any in flight raster jobs go out of | 518 // corresponding PictureLayerImpl and any in flight raster jobs go out of |
502 // scope. | 519 // scope. |
503 client_->UpdatePile(it->second); | 520 client_->UpdatePile(it->second); |
504 } | 521 } |
505 } | 522 } |
506 | 523 |
507 } // namespace cc | 524 } // namespace cc |
OLD | NEW |