Index: cc/resources/picture_pile_base.cc |
diff --git a/cc/resources/picture_pile_base.cc b/cc/resources/picture_pile_base.cc |
index 2fb6ef5b84a282b1b90f36affe1c2eed68df6492..993e04b997ee0b1b13a6847e216d671a7d8c07df 100644 |
--- a/cc/resources/picture_pile_base.cc |
+++ b/cc/resources/picture_pile_base.cc |
@@ -92,34 +92,39 @@ PicturePileBase::PicturePileBase(const PicturePileBase* other, |
PicturePileBase::~PicturePileBase() { |
} |
-void PicturePileBase::Resize(const gfx::Size& new_size) { |
- if (size() == new_size) |
+void PicturePileBase::SetTilingRect(const gfx::Rect& new_tiling_rect) { |
+ if (tiling_rect() == new_tiling_rect) |
return; |
- gfx::Size old_size = size(); |
- tiling_.SetTotalSize(new_size); |
+ gfx::Rect old_tiling_rect = tiling_rect(); |
+ tiling_.SetTilingRect(new_tiling_rect); |
has_any_recordings_ = false; |
- // Find all tiles that contain any pixels outside the new size. |
- std::vector<PictureMapKey> to_erase; |
- int min_toss_x = tiling_.FirstBorderTileXIndexFromSrcCoord( |
- std::min(old_size.width(), new_size.width())); |
- int min_toss_y = tiling_.FirstBorderTileYIndexFromSrcCoord( |
- std::min(old_size.height(), new_size.height())); |
- for (PictureMap::const_iterator it = picture_map_.begin(); |
- it != picture_map_.end(); |
- ++it) { |
- const PictureMapKey& key = it->first; |
- if (key.first < min_toss_x && key.second < min_toss_y) { |
- has_any_recordings_ |= !!it->second.GetPicture(); |
- continue; |
+ if (new_tiling_rect.x() == old_tiling_rect.x() && |
enne (OOO)
2014/04/11 20:19:51
This could be said more simply as new_tiling_rect.
ernstm
2014/04/11 23:43:51
Done.
|
+ new_tiling_rect.y() == old_tiling_rect.y()) { |
+ // Find all tiles that contain any pixels outside the new rect. |
+ std::vector<PictureMapKey> to_erase; |
+ int min_toss_x = tiling_.FirstBorderTileXIndexFromSrcCoord( |
+ std::min(old_tiling_rect.width(), new_tiling_rect.width())); |
enne (OOO)
2014/04/11 20:19:51
correctness: I think width/height should be right/
ernstm
2014/04/11 23:43:51
Done.
|
+ int min_toss_y = tiling_.FirstBorderTileYIndexFromSrcCoord( |
+ std::min(old_tiling_rect.height(), new_tiling_rect.height())); |
+ for (PictureMap::const_iterator it = picture_map_.begin(); |
+ it != picture_map_.end(); |
+ ++it) { |
+ const PictureMapKey& key = it->first; |
+ if (key.first < min_toss_x && key.second < min_toss_y) { |
+ has_any_recordings_ |= !!it->second.GetPicture(); |
+ continue; |
+ } |
+ to_erase.push_back(key); |
} |
- to_erase.push_back(key); |
- } |
- for (size_t i = 0; i < to_erase.size(); ++i) |
- picture_map_.erase(to_erase[i]); |
+ for (size_t i = 0; i < to_erase.size(); ++i) |
+ picture_map_.erase(to_erase[i]); |
+ } else { |
+ picture_map_.clear(); |
enne (OOO)
2014/04/11 20:19:51
style nit: this else clause is far away from its i
ernstm
2014/04/11 23:43:51
Done. I had to move the recorded_viewport_ = gfx::
|
+ } |
// Don't waste time in Resize figuring out what these hints should be. |
recorded_viewport_ = gfx::Rect(); |
@@ -188,11 +193,11 @@ bool PicturePileBase::HasRecordingAt(int x, int y) { |
bool PicturePileBase::CanRaster(float contents_scale, |
const gfx::Rect& content_rect) { |
- if (tiling_.total_size().IsEmpty()) |
+ if (tiling_.tiling_rect().IsEmpty()) |
return false; |
gfx::Rect layer_rect = gfx::ScaleToEnclosingRect( |
content_rect, 1.f / contents_scale); |
- layer_rect.Intersect(gfx::Rect(tiling_.total_size())); |
+ layer_rect.Intersect(tiling_.tiling_rect()); |
// Common case inside of viewport to avoid the slower map lookups. |
if (recorded_viewport_.Contains(layer_rect)) { |
@@ -233,10 +238,10 @@ gfx::Rect PicturePileBase::PadRect(const gfx::Rect& rect) { |
scoped_ptr<base::Value> PicturePileBase::AsValue() const { |
scoped_ptr<base::ListValue> pictures(new base::ListValue()); |
- gfx::Rect layer_rect(tiling_.total_size()); |
+ gfx::Rect tiling_rect(tiling_.tiling_rect()); |
std::set<void*> appended_pictures; |
bool include_borders = true; |
- for (TilingData::Iterator tile_iter(&tiling_, layer_rect, include_borders); |
+ for (TilingData::Iterator tile_iter(&tiling_, tiling_rect, include_borders); |
tile_iter; |
++tile_iter) { |
PictureMap::const_iterator map_iter = picture_map_.find(tile_iter.index()); |