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

Side by Side Diff: cc/picture_layer_tiling_set.cc

Issue 11704002: cc: Generate tilings at other scales for impl-side painting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, sort() Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/picture_layer_tiling_set.h ('k') | cc/picture_layer_tiling_set_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_set.h" 5 #include "cc/picture_layer_tiling_set.h"
6 6
7 namespace cc { 7 namespace cc {
8 8
9 namespace {
10
11 class LargestToSmallestScaleFunctor {
12 public:
13 bool operator() (PictureLayerTiling* left, PictureLayerTiling* right) {
14 return left->contents_scale() > right->contents_scale();
15 }
16 };
17
18 } // namespace
19
20
9 PictureLayerTilingSet::PictureLayerTilingSet( 21 PictureLayerTilingSet::PictureLayerTilingSet(
10 PictureLayerTilingClient * client) 22 PictureLayerTilingClient * client)
11 : client_(client) { 23 : client_(client) {
12 } 24 }
13 25
14 PictureLayerTilingSet::~PictureLayerTilingSet() { 26 PictureLayerTilingSet::~PictureLayerTilingSet() {
15 } 27 }
16 28
17 void PictureLayerTilingSet::CloneAll( 29 void PictureLayerTilingSet::CloneAll(
18 const PictureLayerTilingSet& other, 30 const PictureLayerTilingSet& other,
(...skipping 11 matching lines...) Expand all
30 void PictureLayerTilingSet::Clone( 42 void PictureLayerTilingSet::Clone(
31 const PictureLayerTiling* tiling, 43 const PictureLayerTiling* tiling,
32 const Region& invalidation) { 44 const Region& invalidation) {
33 45
34 for (size_t i = 0; i < tilings_.size(); ++i) 46 for (size_t i = 0; i < tilings_.size(); ++i)
35 DCHECK_NE(tilings_[i]->contents_scale(), tiling->contents_scale()); 47 DCHECK_NE(tilings_[i]->contents_scale(), tiling->contents_scale());
36 48
37 tilings_.push_back(tiling->Clone()); 49 tilings_.push_back(tiling->Clone());
38 tilings_.back()->SetClient(client_); 50 tilings_.back()->SetClient(client_);
39 tilings_.back()->Invalidate(invalidation); 51 tilings_.back()->Invalidate(invalidation);
52
53 tilings_.sort(LargestToSmallestScaleFunctor());
40 } 54 }
41 55
42 void PictureLayerTilingSet::SetLayerBounds(gfx::Size layer_bounds) { 56 void PictureLayerTilingSet::SetLayerBounds(gfx::Size layer_bounds) {
43 if (layer_bounds_ == layer_bounds) 57 if (layer_bounds_ == layer_bounds)
44 return; 58 return;
45 layer_bounds_ = layer_bounds; 59 layer_bounds_ = layer_bounds;
46 for (size_t i = 0; i < tilings_.size(); ++i) 60 for (size_t i = 0; i < tilings_.size(); ++i)
47 tilings_[i]->SetLayerBounds(layer_bounds); 61 tilings_[i]->SetLayerBounds(layer_bounds);
48 } 62 }
49 63
50 gfx::Size PictureLayerTilingSet::LayerBounds() const { 64 gfx::Size PictureLayerTilingSet::LayerBounds() const {
51 return layer_bounds_; 65 return layer_bounds_;
52 } 66 }
53 67
54 const PictureLayerTiling* PictureLayerTilingSet::AddTiling( 68 PictureLayerTiling* PictureLayerTilingSet::AddTiling(
55 float contents_scale, 69 float contents_scale,
56 gfx::Size tile_size) { 70 gfx::Size tile_size) {
57 tilings_.push_back(PictureLayerTiling::Create(contents_scale, tile_size)); 71 tilings_.push_back(PictureLayerTiling::Create(contents_scale, tile_size));
58 tilings_.back()->SetClient(client_); 72 PictureLayerTiling* appended = tilings_.back();
59 tilings_.back()->SetLayerBounds(layer_bounds_); 73 appended->SetClient(client_);
60 return tilings_.back(); 74 appended->SetLayerBounds(layer_bounds_);
75
76 tilings_.sort(LargestToSmallestScaleFunctor());
77 return appended;
61 } 78 }
62 79
63 void PictureLayerTilingSet::Reset() { 80 void PictureLayerTilingSet::RemoveAllTilings() {
81 tilings_.clear();
82 }
83
84 void PictureLayerTilingSet::Remove(PictureLayerTiling* tiling) {
85 ScopedPtrVector<PictureLayerTiling>::iterator iter =
86 std::find(tilings_.begin(), tilings_.end(), tiling);
87 if (iter == tilings_.end())
88 return;
89 tilings_.erase(iter);
90 }
91
92 void PictureLayerTilingSet::RemoveAllTiles() {
64 for (size_t i = 0; i < tilings_.size(); ++i) 93 for (size_t i = 0; i < tilings_.size(); ++i)
65 tilings_[i]->Reset(); 94 tilings_[i]->Reset();
66 } 95 }
67 96
68 PictureLayerTilingSet::Iterator::Iterator(const PictureLayerTilingSet* set, 97 PictureLayerTilingSet::Iterator::Iterator(
69 float contents_scale, 98 const PictureLayerTilingSet* set,
70 gfx::Rect content_rect) 99 float contents_scale,
100 gfx::Rect content_rect,
101 float ideal_contents_scale)
71 : set_(set), 102 : set_(set),
72 contents_scale_(contents_scale), 103 contents_scale_(contents_scale),
104 ideal_contents_scale_(ideal_contents_scale),
73 current_tiling_(-1) { 105 current_tiling_(-1) {
74 missing_region_.Union(content_rect); 106 missing_region_.Union(content_rect);
107
108 for (ideal_tiling_ = 0;
109 static_cast<size_t>(ideal_tiling_) < set_->tilings_.size();
110 ++ideal_tiling_) {
111 PictureLayerTiling* tiling = set_->tilings_[ideal_tiling_];
112 if (tiling->contents_scale() < ideal_contents_scale_) {
113 if (ideal_tiling_ > 0)
114 ideal_tiling_--;
115 break;
116 }
117 }
118
75 ++(*this); 119 ++(*this);
76 } 120 }
77 121
78 PictureLayerTilingSet::Iterator::~Iterator() { 122 PictureLayerTilingSet::Iterator::~Iterator() {
79 } 123 }
80 124
81 gfx::Rect PictureLayerTilingSet::Iterator::geometry_rect() const { 125 gfx::Rect PictureLayerTilingSet::Iterator::geometry_rect() const {
82 if (!tiling_iter_) { 126 if (!tiling_iter_) {
83 if (!region_iter_.has_rect()) 127 if (!region_iter_.has_rect())
84 return gfx::Rect(); 128 return gfx::Rect();
(...skipping 19 matching lines...) Expand all
104 return NULL; 148 return NULL;
105 return *tiling_iter_; 149 return *tiling_iter_;
106 } 150 }
107 151
108 Tile* PictureLayerTilingSet::Iterator::operator*() const { 152 Tile* PictureLayerTilingSet::Iterator::operator*() const {
109 if (!tiling_iter_) 153 if (!tiling_iter_)
110 return NULL; 154 return NULL;
111 return *tiling_iter_; 155 return *tiling_iter_;
112 } 156 }
113 157
158 PictureLayerTiling* PictureLayerTilingSet::Iterator::CurrentTiling() {
159 if (current_tiling_ < 0)
160 return NULL;
161 if (static_cast<size_t>(current_tiling_) >= set_->tilings_.size())
162 return NULL;
163 return set_->tilings_[current_tiling_];
164 }
165
166 int PictureLayerTilingSet::Iterator::NextTiling() const {
167 // Order returned by this method is:
168 // 1. Ideal tiling index
169 // 2. Tiling index < Ideal in decreasing order (higher res than ideal)
170 // 3. Tiling index > Ideal in increasing order (lower res than ideal)
171 // 4. Tiling index > tilings.size() (invalid index)
172 if (current_tiling_ < 0)
173 return ideal_tiling_;
174 else if (current_tiling_ > ideal_tiling_)
175 return current_tiling_ + 1;
176 else if (current_tiling_)
177 return current_tiling_ - 1;
178 else
179 return ideal_tiling_ + 1;
180 }
181
114 PictureLayerTilingSet::Iterator& PictureLayerTilingSet::Iterator::operator++() { 182 PictureLayerTilingSet::Iterator& PictureLayerTilingSet::Iterator::operator++() {
115 bool first_time = current_tiling_ < 0; 183 bool first_time = current_tiling_ < 0;
116 184
117 if (!*this && !first_time) 185 if (!*this && !first_time)
118 return *this; 186 return *this;
119 187
120 if (tiling_iter_) 188 if (tiling_iter_)
121 ++tiling_iter_; 189 ++tiling_iter_;
122 190
123 // Loop until we find a valid place to stop. 191 // Loop until we find a valid place to stop.
124 while (true) { 192 while (true) {
125 while (tiling_iter_ && (!*tiling_iter_ || !tiling_iter_->GetResourceId())) { 193 while (tiling_iter_ && (!*tiling_iter_ || !tiling_iter_->GetResourceId())) {
126 missing_region_.Union(tiling_iter_.geometry_rect()); 194 missing_region_.Union(tiling_iter_.geometry_rect());
127 ++tiling_iter_; 195 ++tiling_iter_;
128 } 196 }
129 if (tiling_iter_) 197 if (tiling_iter_)
130 return *this; 198 return *this;
131 199
132 // If the set of current rects for this tiling is done, go to the next 200 // If the set of current rects for this tiling is done, go to the next
133 // tiling and set up to iterate through all of the remaining holes. 201 // tiling and set up to iterate through all of the remaining holes.
134 // This will also happen the first time through the loop. 202 // This will also happen the first time through the loop.
135 if (!region_iter_.has_rect()) { 203 if (!region_iter_.has_rect()) {
136 current_tiling_++; 204 current_tiling_ = NextTiling();
137 current_region_.Swap(missing_region_); 205 current_region_.Swap(missing_region_);
138 missing_region_.Clear(); 206 missing_region_.Clear();
139 region_iter_ = Region::Iterator(current_region_); 207 region_iter_ = Region::Iterator(current_region_);
140 208
141 // All done and all filled. 209 // All done and all filled.
142 if (!region_iter_.has_rect()) { 210 if (!region_iter_.has_rect()) {
143 current_tiling_ = set_->tilings_.size(); 211 current_tiling_ = set_->tilings_.size();
144 return *this; 212 return *this;
145 } 213 }
146 214
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 device_viewport, 256 device_viewport,
189 layer_content_scale_x, 257 layer_content_scale_x,
190 layer_content_scale_y, 258 layer_content_scale_y,
191 last_screen_transform, 259 last_screen_transform,
192 current_screen_transform, 260 current_screen_transform,
193 time_delta); 261 time_delta);
194 } 262 }
195 } 263 }
196 264
197 } // namespace cc 265 } // namespace cc
OLDNEW
« no previous file with comments | « cc/picture_layer_tiling_set.h ('k') | cc/picture_layer_tiling_set_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698