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.
+ // Don't waste time in Resize figuring out what these hints should be.
+ recorded_viewport_ = gfx::Rect();
+
+ if (new_tiling_rect.origin() != old_tiling_rect.origin()) {
+ picture_map_.clear();
+ return;
+ }
+
+ // 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_size.width(), new_size.width()));
+ std::min(old_tiling_rect.right(), new_tiling_rect.right()));
int min_toss_y = tiling_.FirstBorderTileYIndexFromSrcCoord(
- std::min(old_size.height(), new_size.height()));
+ std::min(old_tiling_rect.bottom(), new_tiling_rect.bottom()));
for (PictureMap::const_iterator it = picture_map_.begin();
it != picture_map_.end();
++it) {
for (size_t i = 0; i < to_erase.size(); ++i)
picture_map_.erase(to_erase[i]);
-
- // Don't waste time in Resize figuring out what these hints should be.
- recorded_viewport_ = gfx::Rect();
}
void PicturePileBase::SetMinContentsScale(float min_contents_scale) {
// static
void PicturePileBase::ComputeTileGridInfo(
const gfx::Size& tile_grid_size,
- SkTileGridPicture::TileGridInfo* info) {
+ SkTileGridFactory::TileGridInfo* info) {
DCHECK(info);
info->fTileInterval.set(tile_grid_size.width() - 2 * kTileGridBorderPixels,
tile_grid_size.height() - 2 * kTileGridBorderPixels);
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)) {
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());