Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Unified Diff: cc/resources/picture_pile_base.cc

Issue 235753002: cc: Give TilingData a Rect instead of a Size (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Git cl format Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/resources/picture_pile_base.h ('k') | cc/resources/picture_pile_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..aa00876f7882f6d338f7b3f2751ceb2a79e14b5c 100644
--- a/cc/resources/picture_pile_base.cc
+++ b/cc/resources/picture_pile_base.cc
@@ -92,21 +92,29 @@ 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.
+ // 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) {
@@ -120,9 +128,6 @@ void PicturePileBase::Resize(const gfx::Size& new_size) {
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) {
@@ -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());
« no previous file with comments | « cc/resources/picture_pile_base.h ('k') | cc/resources/picture_pile_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698