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

Side by Side Diff: cc/picture_layer_impl.cc

Issue 12774006: cc: Chromify Layer and LayerImpl classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: MoreAndroidCompilings Created 7 years, 9 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_impl.h ('k') | cc/picture_layer_impl_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_impl.h" 5 #include "cc/picture_layer_impl.h"
6 6
7 #include "base/time.h" 7 #include "base/time.h"
8 #include "cc/append_quads_data.h" 8 #include "cc/append_quads_data.h"
9 #include "cc/checkerboard_draw_quad.h" 9 #include "cc/checkerboard_draw_quad.h"
10 #include "cc/debug_border_draw_quad.h" 10 #include "cc/debug_border_draw_quad.h"
(...skipping 25 matching lines...) Expand all
36 ideal_source_scale_(0.f), 36 ideal_source_scale_(0.f),
37 raster_page_scale_(0.f), 37 raster_page_scale_(0.f),
38 raster_device_scale_(0.f), 38 raster_device_scale_(0.f),
39 raster_source_scale_(0.f), 39 raster_source_scale_(0.f),
40 raster_source_scale_was_animating_(false) { 40 raster_source_scale_was_animating_(false) {
41 } 41 }
42 42
43 PictureLayerImpl::~PictureLayerImpl() { 43 PictureLayerImpl::~PictureLayerImpl() {
44 } 44 }
45 45
46 const char* PictureLayerImpl::layerTypeAsString() const { 46 const char* PictureLayerImpl::LayerTypeAsString() const {
47 return "PictureLayer"; 47 return "PictureLayer";
48 } 48 }
49 49
50 scoped_ptr<LayerImpl> PictureLayerImpl::createLayerImpl( 50 scoped_ptr<LayerImpl> PictureLayerImpl::CreateLayerImpl(
51 LayerTreeImpl* treeImpl) { 51 LayerTreeImpl* treeImpl) {
52 return PictureLayerImpl::create(treeImpl, id()).PassAs<LayerImpl>(); 52 return PictureLayerImpl::Create(treeImpl, id()).PassAs<LayerImpl>();
53 } 53 }
54 54
55 void PictureLayerImpl::CreateTilingSet() { 55 void PictureLayerImpl::CreateTilingSet() {
56 DCHECK(layerTreeImpl()->IsPendingTree()); 56 DCHECK(layer_tree_impl()->IsPendingTree());
57 DCHECK(!tilings_); 57 DCHECK(!tilings_);
58 tilings_.reset(new PictureLayerTilingSet(this)); 58 tilings_.reset(new PictureLayerTilingSet(this));
59 tilings_->SetLayerBounds(bounds()); 59 tilings_->SetLayerBounds(bounds());
60 } 60 }
61 61
62 void PictureLayerImpl::TransferTilingSet(scoped_ptr<PictureLayerTilingSet> tilin gs) { 62 void PictureLayerImpl::TransferTilingSet(scoped_ptr<PictureLayerTilingSet> tilin gs) {
63 DCHECK(layerTreeImpl()->IsActiveTree()); 63 DCHECK(layer_tree_impl()->IsActiveTree());
64 tilings->SetClient(this); 64 tilings->SetClient(this);
65 tilings_ = tilings.Pass(); 65 tilings_ = tilings.Pass();
66 } 66 }
67 67
68 void PictureLayerImpl::pushPropertiesTo(LayerImpl* base_layer) { 68 void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) {
69 LayerImpl::pushPropertiesTo(base_layer); 69 LayerImpl::PushPropertiesTo(base_layer);
70 70
71 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); 71 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer);
72 72
73 layer_impl->SetIsMask(is_mask_); 73 layer_impl->SetIsMask(is_mask_);
74 layer_impl->TransferTilingSet(tilings_.Pass()); 74 layer_impl->TransferTilingSet(tilings_.Pass());
75 layer_impl->pile_ = pile_; 75 layer_impl->pile_ = pile_;
76 pile_ = PicturePileImpl::Create(); 76 pile_ = PicturePileImpl::Create();
77 pile_->set_slow_down_raster_scale_factor( 77 pile_->set_slow_down_raster_scale_factor(
78 layerTreeImpl()->debug_state().slowDownRasterScaleFactor); 78 layer_tree_impl()->debug_state().slowDownRasterScaleFactor);
79 79
80 layer_impl->raster_page_scale_ = raster_page_scale_; 80 layer_impl->raster_page_scale_ = raster_page_scale_;
81 layer_impl->raster_device_scale_ = raster_device_scale_; 81 layer_impl->raster_device_scale_ = raster_device_scale_;
82 layer_impl->raster_source_scale_ = raster_source_scale_; 82 layer_impl->raster_source_scale_ = raster_source_scale_;
83 } 83 }
84 84
85 85
86 void PictureLayerImpl::appendQuads(QuadSink& quadSink, 86 void PictureLayerImpl::AppendQuads(QuadSink* quadSink,
87 AppendQuadsData& appendQuadsData) { 87 AppendQuadsData* appendQuadsData) {
88 const gfx::Rect& rect = visibleContentRect(); 88 const gfx::Rect& rect = visible_content_rect();
89 gfx::Rect content_rect(gfx::Point(), contentBounds()); 89 gfx::Rect content_rect(content_bounds());
90 90
91 SharedQuadState* sharedQuadState = 91 SharedQuadState* sharedQuadState =
92 quadSink.useSharedQuadState(createSharedQuadState()); 92 quadSink->useSharedQuadState(CreateSharedQuadState());
93 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); 93 AppendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData);
94 94
95 bool clipped = false; 95 bool clipped = false;
96 gfx::QuadF target_quad = MathUtil::mapQuad( 96 gfx::QuadF target_quad = MathUtil::mapQuad(
97 drawTransform(), 97 draw_transform(),
98 gfx::QuadF(rect), 98 gfx::QuadF(rect),
99 clipped); 99 clipped);
100 bool isAxisAlignedInTarget = !clipped && target_quad.IsRectilinear(); 100 bool isAxisAlignedInTarget = !clipped && target_quad.IsRectilinear();
101 101
102 bool isPixelAligned = isAxisAlignedInTarget && drawTransform().IsIdentityOrInt egerTranslation(); 102 bool isPixelAligned = isAxisAlignedInTarget &&
103 draw_transform().IsIdentityOrIntegerTranslation();
103 PictureLayerTiling::LayerDeviceAlignment layerDeviceAlignment = 104 PictureLayerTiling::LayerDeviceAlignment layerDeviceAlignment =
104 isPixelAligned ? PictureLayerTiling::LayerAlignedToDevice 105 isPixelAligned ? PictureLayerTiling::LayerAlignedToDevice
105 : PictureLayerTiling::LayerNotAlignedToDevice; 106 : PictureLayerTiling::LayerNotAlignedToDevice;
106 107
107 if (showDebugBorders()) { 108 if (ShowDebugBorders()) {
108 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), 109 for (PictureLayerTilingSet::Iterator iter(tilings_.get(),
109 contentsScaleX(), 110 contents_scale_x(),
110 rect, 111 rect,
111 ideal_contents_scale_, 112 ideal_contents_scale_,
112 layerDeviceAlignment); 113 layerDeviceAlignment);
113 iter; 114 iter;
114 ++iter) { 115 ++iter) {
115 SkColor color; 116 SkColor color;
116 float width; 117 float width;
117 if (*iter && iter->IsReadyToDraw()) { 118 if (*iter && iter->IsReadyToDraw()) {
118 if (iter->is_solid_color() || iter->is_transparent()) { 119 if (iter->is_solid_color() || iter->is_transparent()) {
119 color = DebugColors::SolidColorTileBorderColor(); 120 color = DebugColors::SolidColorTileBorderColor();
120 width = DebugColors::SolidColorTileBorderWidth(layerTreeImpl()); 121 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl());
121 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { 122 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) {
122 color = DebugColors::HighResTileBorderColor(); 123 color = DebugColors::HighResTileBorderColor();
123 width = DebugColors::HighResTileBorderWidth(layerTreeImpl()); 124 width = DebugColors::HighResTileBorderWidth(layer_tree_impl());
124 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { 125 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) {
125 color = DebugColors::LowResTileBorderColor(); 126 color = DebugColors::LowResTileBorderColor();
126 width = DebugColors::LowResTileBorderWidth(layerTreeImpl()); 127 width = DebugColors::LowResTileBorderWidth(layer_tree_impl());
127 } else if (iter->contents_scale() > contentsScaleX()) { 128 } else if (iter->contents_scale() > contents_scale_x()) {
128 color = DebugColors::ExtraHighResTileBorderColor(); 129 color = DebugColors::ExtraHighResTileBorderColor();
129 width = DebugColors::ExtraHighResTileBorderWidth(layerTreeImpl()); 130 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl());
130 } else { 131 } else {
131 color = DebugColors::ExtraLowResTileBorderColor(); 132 color = DebugColors::ExtraLowResTileBorderColor();
132 width = DebugColors::ExtraLowResTileBorderWidth(layerTreeImpl()); 133 width = DebugColors::ExtraLowResTileBorderWidth(layer_tree_impl());
133 } 134 }
134 } else { 135 } else {
135 color = DebugColors::MissingTileBorderColor(); 136 color = DebugColors::MissingTileBorderColor();
136 width = DebugColors::MissingTileBorderWidth(layerTreeImpl()); 137 width = DebugColors::MissingTileBorderWidth(layer_tree_impl());
137 } 138 }
138 139
139 scoped_ptr<DebugBorderDrawQuad> debugBorderQuad = 140 scoped_ptr<DebugBorderDrawQuad> debugBorderQuad =
140 DebugBorderDrawQuad::Create(); 141 DebugBorderDrawQuad::Create();
141 gfx::Rect geometry_rect = iter.geometry_rect(); 142 gfx::Rect geometry_rect = iter.geometry_rect();
142 debugBorderQuad->SetNew(sharedQuadState, geometry_rect, color, width); 143 debugBorderQuad->SetNew(sharedQuadState, geometry_rect, color, width);
143 quadSink.append(debugBorderQuad.PassAs<DrawQuad>(), appendQuadsData); 144 quadSink->append(debugBorderQuad.PassAs<DrawQuad>(), appendQuadsData);
144 } 145 }
145 } 146 }
146 147
147 // Keep track of the tilings that were used so that tilings that are 148 // Keep track of the tilings that were used so that tilings that are
148 // unused can be considered for removal. 149 // unused can be considered for removal.
149 std::vector<PictureLayerTiling*> seen_tilings; 150 std::vector<PictureLayerTiling*> seen_tilings;
150 151
151 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), 152 for (PictureLayerTilingSet::Iterator iter(tilings_.get(),
152 contentsScaleX(), 153 contents_scale_x(),
153 rect, 154 rect,
154 ideal_contents_scale_, 155 ideal_contents_scale_,
155 layerDeviceAlignment); 156 layerDeviceAlignment);
156 iter; 157 iter;
157 ++iter) { 158 ++iter) {
158 159
159 gfx::Rect geometry_rect = iter.geometry_rect(); 160 gfx::Rect geometry_rect = iter.geometry_rect();
160 ResourceProvider::ResourceId resource = 0; 161 ResourceProvider::ResourceId resource = 0;
161 if (*iter) { 162 if (*iter) {
162 if (iter->is_solid_color()) { 163 if (iter->is_solid_color()) {
163 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); 164 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create();
164 quad->SetNew(sharedQuadState, geometry_rect, iter->solid_color()); 165 quad->SetNew(sharedQuadState, geometry_rect, iter->solid_color());
165 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); 166 quadSink->append(quad.PassAs<DrawQuad>(), appendQuadsData);
166 167
167 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling()) 168 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling())
168 seen_tilings.push_back(iter.CurrentTiling()); 169 seen_tilings.push_back(iter.CurrentTiling());
169 continue; 170 continue;
170 } else if (iter->is_transparent()) { 171 } else if (iter->is_transparent()) {
171 continue; 172 continue;
172 } 173 }
173 resource = iter->GetResourceId(); 174 resource = iter->GetResourceId();
174 } 175 }
175 if (!resource) { 176 if (!resource) {
176 if (drawCheckerboardForMissingTiles()) { 177 if (DrawCheckerboardForMissingTiles()) {
177 // TODO(enne): Figure out how to show debug "invalidated checker" color 178 // TODO(enne): Figure out how to show debug "invalidated checker" color
178 scoped_ptr<CheckerboardDrawQuad> quad = CheckerboardDrawQuad::Create(); 179 scoped_ptr<CheckerboardDrawQuad> quad = CheckerboardDrawQuad::Create();
179 SkColor color = DebugColors::DefaultCheckerboardColor(); 180 SkColor color = DebugColors::DefaultCheckerboardColor();
180 quad->SetNew(sharedQuadState, geometry_rect, color); 181 quad->SetNew(sharedQuadState, geometry_rect, color);
181 if (quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData)) 182 if (quadSink->append(quad.PassAs<DrawQuad>(), appendQuadsData))
182 appendQuadsData.numMissingTiles++; 183 appendQuadsData->numMissingTiles++;
183 } else { 184 } else {
184 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); 185 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create();
185 quad->SetNew(sharedQuadState, geometry_rect, backgroundColor()); 186 quad->SetNew(sharedQuadState, geometry_rect, background_color());
186 if (quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData)) 187 if (quadSink->append(quad.PassAs<DrawQuad>(), appendQuadsData))
187 appendQuadsData.numMissingTiles++; 188 appendQuadsData->numMissingTiles++;
188 } 189 }
189 190
190 appendQuadsData.hadIncompleteTile = true; 191 appendQuadsData->hadIncompleteTile = true;
191 continue; 192 continue;
192 } 193 }
193 194
194 if (iter->contents_scale() != ideal_contents_scale_) 195 if (iter->contents_scale() != ideal_contents_scale_)
195 appendQuadsData.hadIncompleteTile = true; 196 appendQuadsData->hadIncompleteTile = true;
196 197
197 gfx::RectF texture_rect = iter.texture_rect(); 198 gfx::RectF texture_rect = iter.texture_rect();
198 gfx::Rect opaque_rect = iter->opaque_rect(); 199 gfx::Rect opaque_rect = iter->opaque_rect();
199 opaque_rect.Intersect(content_rect); 200 opaque_rect.Intersect(content_rect);
200 201
201 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create(); 202 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create();
202 quad->SetNew(sharedQuadState, 203 quad->SetNew(sharedQuadState,
203 geometry_rect, 204 geometry_rect,
204 opaque_rect, 205 opaque_rect,
205 resource, 206 resource,
206 texture_rect, 207 texture_rect,
207 iter.texture_size(), 208 iter.texture_size(),
208 iter->contents_swizzled()); 209 iter->contents_swizzled());
209 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); 210 quadSink->append(quad.PassAs<DrawQuad>(), appendQuadsData);
210 211
211 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling()) 212 if (!seen_tilings.size() || seen_tilings.back() != iter.CurrentTiling())
212 seen_tilings.push_back(iter.CurrentTiling()); 213 seen_tilings.push_back(iter.CurrentTiling());
213 } 214 }
214 215
215 // Aggressively remove any tilings that are not seen to save memory. Note 216 // Aggressively remove any tilings that are not seen to save memory. Note
216 // that this is at the expense of doing cause more frequent re-painting. A 217 // that this is at the expense of doing cause more frequent re-painting. A
217 // better scheme would be to maintain a tighter visibleContentRect for the 218 // better scheme would be to maintain a tighter visibleContentRect for the
218 // finer tilings. 219 // finer tilings.
219 CleanUpTilingsOnActiveLayer(seen_tilings); 220 CleanUpTilingsOnActiveLayer(seen_tilings);
220 } 221 }
221 222
222 void PictureLayerImpl::dumpLayerProperties(std::string*, int indent) const { 223 void PictureLayerImpl::DumpLayerProperties(std::string*, int indent) const {
223 // TODO(enne): implement me 224 // TODO(enne): implement me
224 } 225 }
225 226
226 void PictureLayerImpl::updateTilePriorities() { 227 void PictureLayerImpl::UpdateTilePriorities() {
227 int current_source_frame_number = layerTreeImpl()->source_frame_number(); 228 int current_source_frame_number = layer_tree_impl()->source_frame_number();
228 double current_frame_time = 229 double current_frame_time =
229 (layerTreeImpl()->CurrentFrameTime() - base::TimeTicks()).InSecondsF(); 230 (layer_tree_impl()->CurrentFrameTime() - base::TimeTicks()).InSecondsF();
230 231
231 gfx::Transform current_screen_space_transform = 232 gfx::Transform current_screen_space_transform = screen_space_transform();
232 screenSpaceTransform();
233 233
234 gfx::Rect viewport_in_content_space; 234 gfx::Rect viewport_in_content_space;
235 gfx::Transform screenToLayer(gfx::Transform::kSkipInitialization); 235 gfx::Transform screenToLayer(gfx::Transform::kSkipInitialization);
236 if (screenSpaceTransform().GetInverse(&screenToLayer)) { 236 if (screen_space_transform().GetInverse(&screenToLayer)) {
237 gfx::Rect device_viewport(layerTreeImpl()->device_viewport_size()); 237 gfx::Rect device_viewport(layer_tree_impl()->device_viewport_size());
238 viewport_in_content_space = gfx::ToEnclosingRect( 238 viewport_in_content_space = gfx::ToEnclosingRect(
239 MathUtil::projectClippedRect(screenToLayer, device_viewport)); 239 MathUtil::projectClippedRect(screenToLayer, device_viewport));
240 } 240 }
241 241
242 WhichTree tree = layerTreeImpl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TREE; 242 WhichTree tree = layer_tree_impl()->IsActiveTree() ? ACTIVE_TREE : PENDING_TRE E;
243 bool store_screen_space_quads_on_tiles = 243 bool store_screen_space_quads_on_tiles =
244 layerTreeImpl()->debug_state().traceAllRenderedFrames; 244 layer_tree_impl()->debug_state().traceAllRenderedFrames;
245 tilings_->UpdateTilePriorities( 245 tilings_->UpdateTilePriorities(
246 tree, 246 tree,
247 layerTreeImpl()->device_viewport_size(), 247 layer_tree_impl()->device_viewport_size(),
248 viewport_in_content_space, 248 viewport_in_content_space,
249 last_bounds_, 249 last_bounds_,
250 bounds(), 250 bounds(),
251 last_content_scale_, 251 last_content_scale_,
252 contentsScaleX(), 252 contents_scale_x(),
253 last_screen_space_transform_, 253 last_screen_space_transform_,
254 current_screen_space_transform, 254 current_screen_space_transform,
255 current_source_frame_number, 255 current_source_frame_number,
256 current_frame_time, 256 current_frame_time,
257 store_screen_space_quads_on_tiles); 257 store_screen_space_quads_on_tiles);
258 258
259 last_screen_space_transform_ = current_screen_space_transform; 259 last_screen_space_transform_ = current_screen_space_transform;
260 last_bounds_ = bounds(); 260 last_bounds_ = bounds();
261 last_content_scale_ = contentsScaleX(); 261 last_content_scale_ = contents_scale_x();
262 } 262 }
263 263
264 void PictureLayerImpl::didBecomeActive() { 264 void PictureLayerImpl::DidBecomeActive() {
265 LayerImpl::didBecomeActive(); 265 LayerImpl::DidBecomeActive();
266 tilings_->DidBecomeActive(); 266 tilings_->DidBecomeActive();
267 } 267 }
268 268
269 void PictureLayerImpl::didLoseOutputSurface() { 269 void PictureLayerImpl::DidLoseOutputSurface() {
270 if (tilings_) 270 if (tilings_)
271 tilings_->RemoveAllTilings(); 271 tilings_->RemoveAllTilings();
272 } 272 }
273 273
274 void PictureLayerImpl::calculateContentsScale( 274 void PictureLayerImpl::CalculateContentsScale(
275 float ideal_contents_scale, 275 float ideal_contents_scale,
276 bool animating_transform_to_screen, 276 bool animating_transform_to_screen,
277 float* contents_scale_x, 277 float* contents_scale_x,
278 float* contents_scale_y, 278 float* contents_scale_y,
279 gfx::Size* content_bounds) { 279 gfx::Size* content_bounds) {
280 if (!drawsContent()) { 280 if (!DrawsContent()) {
281 DCHECK(!tilings_->num_tilings()); 281 DCHECK(!tilings_->num_tilings());
282 return; 282 return;
283 } 283 }
284 284
285 float min_contents_scale = MinimumContentsScale(); 285 float min_contents_scale = MinimumContentsScale();
286 float min_page_scale = layerTreeImpl()->min_page_scale_factor(); 286 float min_page_scale = layer_tree_impl()->min_page_scale_factor();
287 float min_device_scale = 1.f; 287 float min_device_scale = 1.f;
288 float min_source_scale = 288 float min_source_scale =
289 min_contents_scale / min_page_scale / min_device_scale; 289 min_contents_scale / min_page_scale / min_device_scale;
290 290
291 float ideal_page_scale = layerTreeImpl()->total_page_scale_factor(); 291 float ideal_page_scale = layer_tree_impl()->total_page_scale_factor();
292 float ideal_device_scale = layerTreeImpl()->device_scale_factor(); 292 float ideal_device_scale = layer_tree_impl()->device_scale_factor();
293 float ideal_source_scale = 293 float ideal_source_scale =
294 ideal_contents_scale / ideal_page_scale / ideal_device_scale; 294 ideal_contents_scale / ideal_page_scale / ideal_device_scale;
295 295
296 ideal_contents_scale_ = std::max(ideal_contents_scale, min_contents_scale); 296 ideal_contents_scale_ = std::max(ideal_contents_scale, min_contents_scale);
297 ideal_page_scale_ = ideal_page_scale; 297 ideal_page_scale_ = ideal_page_scale;
298 ideal_device_scale_ = ideal_device_scale; 298 ideal_device_scale_ = ideal_device_scale;
299 ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale); 299 ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale);
300 300
301 ManageTilings(animating_transform_to_screen); 301 ManageTilings(animating_transform_to_screen);
302 302
303 // The content scale and bounds for a PictureLayerImpl is somewhat fictitious. 303 // The content scale and bounds for a PictureLayerImpl is somewhat fictitious.
304 // There are (usually) several tilings at different scales. However, the 304 // There are (usually) several tilings at different scales. However, the
305 // content bounds is the (integer!) space in which quads are generated. 305 // content bounds is the (integer!) space in which quads are generated.
306 // In order to guarantee that we can fill this integer space with any set of 306 // In order to guarantee that we can fill this integer space with any set of
307 // tilings (and then map back to floating point texture coordinates), the 307 // tilings (and then map back to floating point texture coordinates), the
308 // contents scale must be at least as large as the largest of the tilings. 308 // contents scale must be at least as large as the largest of the tilings.
309 float max_contents_scale = min_contents_scale; 309 float max_contents_scale = min_contents_scale;
310 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { 310 for (size_t i = 0; i < tilings_->num_tilings(); ++i) {
311 const PictureLayerTiling* tiling = tilings_->tiling_at(i); 311 const PictureLayerTiling* tiling = tilings_->tiling_at(i);
312 max_contents_scale = std::max(max_contents_scale, tiling->contents_scale()); 312 max_contents_scale = std::max(max_contents_scale, tiling->contents_scale());
313 } 313 }
314 314
315 *contents_scale_x = max_contents_scale; 315 *contents_scale_x = max_contents_scale;
316 *contents_scale_y = max_contents_scale; 316 *contents_scale_y = max_contents_scale;
317 *content_bounds = gfx::ToCeiledSize( 317 *content_bounds = gfx::ToCeiledSize(
318 gfx::ScaleSize(bounds(), max_contents_scale, max_contents_scale)); 318 gfx::ScaleSize(bounds(), max_contents_scale, max_contents_scale));
319 } 319 }
320 320
321 skia::RefPtr<SkPicture> PictureLayerImpl::getPicture() { 321 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() {
322 return pile_->GetFlattenedPicture(); 322 return pile_->GetFlattenedPicture();
323 } 323 }
324 324
325 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, 325 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling,
326 gfx::Rect content_rect) { 326 gfx::Rect content_rect) {
327 if (!pile_->CanRaster(tiling->contents_scale(), content_rect)) 327 if (!pile_->CanRaster(tiling->contents_scale(), content_rect))
328 return scoped_refptr<Tile>(); 328 return scoped_refptr<Tile>();
329 329
330 return make_scoped_refptr(new Tile( 330 return make_scoped_refptr(new Tile(
331 layerTreeImpl()->tile_manager(), 331 layer_tree_impl()->tile_manager(),
332 pile_.get(), 332 pile_.get(),
333 content_rect.size(), 333 content_rect.size(),
334 GL_RGBA, 334 GL_RGBA,
335 content_rect, 335 content_rect,
336 contentsOpaque() ? content_rect : gfx::Rect(), 336 contents_opaque() ? content_rect : gfx::Rect(),
337 tiling->contents_scale(), 337 tiling->contents_scale(),
338 id())); 338 id()));
339 } 339 }
340 340
341 void PictureLayerImpl::UpdatePile(Tile* tile) { 341 void PictureLayerImpl::UpdatePile(Tile* tile) {
342 tile->set_picture_pile(pile_); 342 tile->set_picture_pile(pile_);
343 } 343 }
344 344
345 gfx::Size PictureLayerImpl::CalculateTileSize( 345 gfx::Size PictureLayerImpl::CalculateTileSize(
346 gfx::Size /* current_tile_size */, 346 gfx::Size /* current_tile_size */,
347 gfx::Size content_bounds) { 347 gfx::Size content_bounds) {
348 if (is_mask_) { 348 if (is_mask_) {
349 int max_size = layerTreeImpl()->MaxTextureSize(); 349 int max_size = layer_tree_impl()->MaxTextureSize();
350 return gfx::Size( 350 return gfx::Size(
351 std::min(max_size, content_bounds.width()), 351 std::min(max_size, content_bounds.width()),
352 std::min(max_size, content_bounds.height())); 352 std::min(max_size, content_bounds.height()));
353 } 353 }
354 354
355 gfx::Size default_tile_size = layerTreeImpl()->settings().defaultTileSize; 355 gfx::Size default_tile_size = layer_tree_impl()->settings().defaultTileSize;
356 gfx::Size max_untiled_content_size = 356 gfx::Size max_untiled_content_size =
357 layerTreeImpl()->settings().maxUntiledLayerSize; 357 layer_tree_impl()->settings().maxUntiledLayerSize;
358 358
359 bool any_dimension_too_large = 359 bool any_dimension_too_large =
360 content_bounds.width() > max_untiled_content_size.width() || 360 content_bounds.width() > max_untiled_content_size.width() ||
361 content_bounds.height() > max_untiled_content_size.height(); 361 content_bounds.height() > max_untiled_content_size.height();
362 362
363 bool any_dimension_one_tile = 363 bool any_dimension_one_tile =
364 content_bounds.width() <= default_tile_size.width() || 364 content_bounds.width() <= default_tile_size.width() ||
365 content_bounds.height() <= default_tile_size.height(); 365 content_bounds.height() <= default_tile_size.height();
366 366
367 // If long and skinny, tile at the max untiled content size, and clamp 367 // If long and skinny, tile at the max untiled content size, and clamp
368 // the smaller dimension to the content size, e.g. 1000x12 layer with 368 // the smaller dimension to the content size, e.g. 1000x12 layer with
369 // 500x500 max untiled size would get 500x12 tiles. Also do this 369 // 500x500 max untiled size would get 500x12 tiles. Also do this
370 // if the layer is small. 370 // if the layer is small.
371 if (any_dimension_one_tile || !any_dimension_too_large) { 371 if (any_dimension_one_tile || !any_dimension_too_large) {
372 int width = 372 int width =
373 std::min(max_untiled_content_size.width(), content_bounds.width()); 373 std::min(max_untiled_content_size.width(), content_bounds.width());
374 int height = 374 int height =
375 std::min(max_untiled_content_size.height(), content_bounds.height()); 375 std::min(max_untiled_content_size.height(), content_bounds.height());
376 // Round width and height up to the closest multiple of 64, or 56 if 376 // Round width and height up to the closest multiple of 64, or 56 if
377 // we should avoid power-of-two textures. This helps reduce the number 377 // we should avoid power-of-two textures. This helps reduce the number
378 // of different textures sizes to help recycling, and also keeps all 378 // of different textures sizes to help recycling, and also keeps all
379 // textures multiple-of-eight, which is preferred on some drivers (IMG). 379 // textures multiple-of-eight, which is preferred on some drivers (IMG).
380 bool avoidPow2 = layerTreeImpl()->rendererCapabilities().avoidPow2Textures; 380 bool avoidPow2 = layer_tree_impl()->rendererCapabilities().avoidPow2Textures ;
381 int roundUpTo = avoidPow2 ? 56 : 64; 381 int roundUpTo = avoidPow2 ? 56 : 64;
382 width = RoundUp(width, roundUpTo); 382 width = RoundUp(width, roundUpTo);
383 height = RoundUp(height, roundUpTo); 383 height = RoundUp(height, roundUpTo);
384 return gfx::Size(width, height); 384 return gfx::Size(width, height);
385 } 385 }
386 386
387 return default_tile_size; 387 return default_tile_size;
388 } 388 }
389 389
390 void PictureLayerImpl::SyncFromActiveLayer() { 390 void PictureLayerImpl::SyncFromActiveLayer() {
391 DCHECK(layerTreeImpl()->IsPendingTree()); 391 DCHECK(layer_tree_impl()->IsPendingTree());
392 392
393 if (!drawsContent()) { 393 if (!DrawsContent()) {
394 raster_page_scale_ = 0; 394 raster_page_scale_ = 0;
395 raster_device_scale_ = 0; 395 raster_device_scale_ = 0;
396 raster_source_scale_ = 0; 396 raster_source_scale_ = 0;
397 return; 397 return;
398 } 398 }
399 399
400 // If there is an active tree version of this layer, get a copy of its 400 // If there is an active tree version of this layer, get a copy of its
401 // tiles. This needs to be done last, after setting invalidation and the 401 // tiles. This needs to be done last, after setting invalidation and the
402 // pile. 402 // pile.
403 if (PictureLayerImpl* active_twin = ActiveTwin()) 403 if (PictureLayerImpl* active_twin = ActiveTwin())
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 continue; 443 continue;
444 gfx::Rect layer_rect = pile_->tile_bounds(x, y); 444 gfx::Rect layer_rect = pile_->tile_bounds(x, y);
445 tilings_->CreateTilesFromLayerRect(layer_rect); 445 tilings_->CreateTilesFromLayerRect(layer_rect);
446 } 446 }
447 } 447 }
448 } 448 }
449 449
450 void PictureLayerImpl::SyncTiling( 450 void PictureLayerImpl::SyncTiling(
451 const PictureLayerTiling* tiling, 451 const PictureLayerTiling* tiling,
452 const Region& pending_layer_invalidation) { 452 const Region& pending_layer_invalidation) {
453 if (!drawsContent() || tiling->contents_scale() < MinimumContentsScale()) 453 if (!DrawsContent() || tiling->contents_scale() < MinimumContentsScale())
454 return; 454 return;
455 tilings_->Clone(tiling, pending_layer_invalidation); 455 tilings_->Clone(tiling, pending_layer_invalidation);
456 } 456 }
457 457
458 void PictureLayerImpl::SetIsMask(bool is_mask) { 458 void PictureLayerImpl::SetIsMask(bool is_mask) {
459 if (is_mask_ == is_mask) 459 if (is_mask_ == is_mask)
460 return; 460 return;
461 is_mask_ = is_mask; 461 is_mask_ = is_mask;
462 if (tilings_) 462 if (tilings_)
463 tilings_->RemoveAllTiles(); 463 tilings_->RemoveAllTiles();
464 } 464 }
465 465
466 ResourceProvider::ResourceId PictureLayerImpl::contentsResourceId() const { 466 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const {
467 gfx::Rect content_rect(gfx::Point(), contentBounds()); 467 gfx::Rect content_rect(content_bounds());
468 float scale = contentsScaleX(); 468 float scale = contents_scale_x();
469 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), 469 for (PictureLayerTilingSet::Iterator iter(tilings_.get(),
470 scale, 470 scale,
471 content_rect, 471 content_rect,
472 ideal_contents_scale_, 472 ideal_contents_scale_,
473 PictureLayerTiling::LayerDeviceAlign mentUnknown); 473 PictureLayerTiling::LayerDeviceAlign mentUnknown);
474 iter; 474 iter;
475 ++iter) { 475 ++iter) {
476 // Mask resource not ready yet. 476 // Mask resource not ready yet.
477 if (!*iter || !iter->GetResourceId()) 477 if (!*iter || !iter->GetResourceId())
478 return 0; 478 return 0;
479 // Masks only supported if they fit on exactly one tile. 479 // Masks only supported if they fit on exactly one tile.
480 if (iter.geometry_rect() != content_rect) 480 if (iter.geometry_rect() != content_rect)
481 return 0; 481 return 0;
482 return iter->GetResourceId(); 482 return iter->GetResourceId();
483 } 483 }
484 return 0; 484 return 0;
485 } 485 }
486 486
487 bool PictureLayerImpl::areVisibleResourcesReady() const { 487 bool PictureLayerImpl::AreVisibleResourcesReady() const {
488 DCHECK(layerTreeImpl()->IsPendingTree()); 488 DCHECK(layer_tree_impl()->IsPendingTree());
489 DCHECK(ideal_contents_scale_); 489 DCHECK(ideal_contents_scale_);
490 490
491 const gfx::Rect& rect = visibleContentRect(); 491 const gfx::Rect& rect = visible_content_rect();
492 492
493 float raster_contents_scale = 493 float raster_contents_scale =
494 raster_page_scale_ * 494 raster_page_scale_ *
495 raster_device_scale_ * 495 raster_device_scale_ *
496 raster_source_scale_; 496 raster_source_scale_;
497 497
498 float min_acceptable_scale = 498 float min_acceptable_scale =
499 std::min(raster_contents_scale, ideal_contents_scale_); 499 std::min(raster_contents_scale, ideal_contents_scale_);
500 500
501 if (PictureLayerImpl* twin = ActiveTwin()) { 501 if (PictureLayerImpl* twin = ActiveTwin()) {
502 float twin_raster_contents_scale = 502 float twin_raster_contents_scale =
503 twin->raster_page_scale_ * 503 twin->raster_page_scale_ *
504 twin->raster_device_scale_ * 504 twin->raster_device_scale_ *
505 twin->raster_source_scale_; 505 twin->raster_source_scale_;
506 506
507 min_acceptable_scale = std::min( 507 min_acceptable_scale = std::min(
508 min_acceptable_scale, 508 min_acceptable_scale,
509 std::min(twin->ideal_contents_scale_, twin_raster_contents_scale)); 509 std::min(twin->ideal_contents_scale_, twin_raster_contents_scale));
510 } 510 }
511 511
512 Region missing_region = rect; 512 Region missing_region = rect;
513 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { 513 for (size_t i = 0; i < tilings_->num_tilings(); ++i) {
514 PictureLayerTiling* tiling = tilings_->tiling_at(i); 514 PictureLayerTiling* tiling = tilings_->tiling_at(i);
515 515
516 if (tiling->contents_scale() < min_acceptable_scale) 516 if (tiling->contents_scale() < min_acceptable_scale)
517 continue; 517 continue;
518 518
519 for (PictureLayerTiling::Iterator iter(tiling, 519 for (PictureLayerTiling::Iterator iter(tiling,
520 contentsScaleX(), 520 contents_scale_x(),
521 rect, 521 rect,
522 PictureLayerTiling::LayerDeviceAlignm entUnknown); 522 PictureLayerTiling::LayerDeviceAlignm entUnknown);
523 iter; 523 iter;
524 ++iter) { 524 ++iter) {
525 // A null tile (i.e. no recording) is considered "ready". 525 // A null tile (i.e. no recording) is considered "ready".
526 if (!*iter || iter->IsReadyToDraw()) 526 if (!*iter || iter->IsReadyToDraw())
527 missing_region.Subtract(iter.geometry_rect()); 527 missing_region.Subtract(iter.geometry_rect());
528 } 528 }
529 } 529 }
530 530
531 return missing_region.IsEmpty(); 531 return missing_region.IsEmpty();
532 } 532 }
533 533
534 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { 534 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) {
535 DCHECK(contents_scale >= MinimumContentsScale()); 535 DCHECK(contents_scale >= MinimumContentsScale());
536 536
537 PictureLayerTiling* tiling = tilings_->AddTiling(contents_scale); 537 PictureLayerTiling* tiling = tilings_->AddTiling(contents_scale);
538 538
539 const Region& recorded = pile_->recorded_region(); 539 const Region& recorded = pile_->recorded_region();
540 DCHECK(!recorded.IsEmpty()); 540 DCHECK(!recorded.IsEmpty());
541 541
542 for (Region::Iterator iter(recorded); iter.has_rect(); iter.next()) 542 for (Region::Iterator iter(recorded); iter.has_rect(); iter.next())
543 tiling->CreateTilesFromLayerRect(iter.rect()); 543 tiling->CreateTilesFromLayerRect(iter.rect());
544 544
545 PictureLayerImpl* twin = 545 PictureLayerImpl* twin =
546 layerTreeImpl()->IsPendingTree() ? ActiveTwin() : PendingTwin(); 546 layer_tree_impl()->IsPendingTree() ? ActiveTwin() : PendingTwin();
547 if (!twin) 547 if (!twin)
548 return tiling; 548 return tiling;
549 549
550 if (layerTreeImpl()->IsPendingTree()) 550 if (layer_tree_impl()->IsPendingTree())
551 twin->SyncTiling(tiling, invalidation_); 551 twin->SyncTiling(tiling, invalidation_);
552 else 552 else
553 twin->SyncTiling(tiling, twin->invalidation_); 553 twin->SyncTiling(tiling, twin->invalidation_);
554 554
555 return tiling; 555 return tiling;
556 } 556 }
557 557
558 void PictureLayerImpl::RemoveTiling(float contents_scale) { 558 void PictureLayerImpl::RemoveTiling(float contents_scale) {
559 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { 559 for (size_t i = 0; i < tilings_->num_tilings(); ++i) {
560 PictureLayerTiling* tiling = tilings_->tiling_at(i); 560 PictureLayerTiling* tiling = tilings_->tiling_at(i);
(...skipping 26 matching lines...) Expand all
587 587
588 void PictureLayerImpl::ManageTilings(bool animating_transform_to_screen) { 588 void PictureLayerImpl::ManageTilings(bool animating_transform_to_screen) {
589 DCHECK(ideal_contents_scale_); 589 DCHECK(ideal_contents_scale_);
590 DCHECK(ideal_page_scale_); 590 DCHECK(ideal_page_scale_);
591 DCHECK(ideal_device_scale_); 591 DCHECK(ideal_device_scale_);
592 DCHECK(ideal_source_scale_); 592 DCHECK(ideal_source_scale_);
593 593
594 if (pile_->recorded_region().IsEmpty()) 594 if (pile_->recorded_region().IsEmpty())
595 return; 595 return;
596 596
597 bool is_active_layer = layerTreeImpl()->IsActiveTree(); 597 bool is_active_layer = layer_tree_impl()->IsActiveTree();
598 bool is_pinching = layerTreeImpl()->PinchGestureActive(); 598 bool is_pinching = layer_tree_impl()->PinchGestureActive();
599 599
600 bool change_target_tiling = false; 600 bool change_target_tiling = false;
601 601
602 if (!raster_page_scale_ || !raster_device_scale_ || !raster_source_scale_) 602 if (!raster_page_scale_ || !raster_device_scale_ || !raster_source_scale_)
603 change_target_tiling = true; 603 change_target_tiling = true;
604 604
605 // TODO(danakj): Adjust raster_source_scale_ closer to ideal_source_scale_ at 605 // TODO(danakj): Adjust raster_source_scale_ closer to ideal_source_scale_ at
606 // a throttled rate. Possibly make use of invalidation_.IsEmpty() on pending 606 // a throttled rate. Possibly make use of invalidation_.IsEmpty() on pending
607 // tree. This will allow CSS scale changes to get re-rastered at an 607 // tree. This will allow CSS scale changes to get re-rastered at an
608 // appropriate rate. 608 // appropriate rate.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 float* raster_contents_scale, 677 float* raster_contents_scale,
678 float* low_res_raster_contents_scale) { 678 float* low_res_raster_contents_scale) {
679 *raster_contents_scale = ideal_contents_scale_; 679 *raster_contents_scale = ideal_contents_scale_;
680 680
681 // Don't allow animating CSS scales to drop below 1. 681 // Don't allow animating CSS scales to drop below 1.
682 if (animating_transform_to_screen) { 682 if (animating_transform_to_screen) {
683 *raster_contents_scale = std::max( 683 *raster_contents_scale = std::max(
684 *raster_contents_scale, 1.f * ideal_page_scale_ * ideal_device_scale_); 684 *raster_contents_scale, 1.f * ideal_page_scale_ * ideal_device_scale_);
685 } 685 }
686 686
687 float low_res_factor = layerTreeImpl()->settings().lowResContentsScaleFactor; 687 float low_res_factor = layer_tree_impl()->settings().lowResContentsScaleFactor ;
688 *low_res_raster_contents_scale = std::max( 688 *low_res_raster_contents_scale = std::max(
689 *raster_contents_scale * low_res_factor, 689 *raster_contents_scale * low_res_factor,
690 MinimumContentsScale()); 690 MinimumContentsScale());
691 } 691 }
692 692
693 void PictureLayerImpl::CleanUpTilingsOnActiveLayer( 693 void PictureLayerImpl::CleanUpTilingsOnActiveLayer(
694 std::vector<PictureLayerTiling*> used_tilings) { 694 std::vector<PictureLayerTiling*> used_tilings) {
695 DCHECK(layerTreeImpl()->IsActiveTree()); 695 DCHECK(layer_tree_impl()->IsActiveTree());
696 696
697 float raster_contents_scale = 697 float raster_contents_scale =
698 raster_page_scale_ * raster_device_scale_ * raster_source_scale_; 698 raster_page_scale_ * raster_device_scale_ * raster_source_scale_;
699 699
700 float min_acceptable_high_res_scale = std::min( 700 float min_acceptable_high_res_scale = std::min(
701 raster_contents_scale, ideal_contents_scale_); 701 raster_contents_scale, ideal_contents_scale_);
702 float max_acceptable_high_res_scale = std::max( 702 float max_acceptable_high_res_scale = std::max(
703 raster_contents_scale, ideal_contents_scale_); 703 raster_contents_scale, ideal_contents_scale_);
704 704
705 PictureLayerImpl* twin = PendingTwin(); 705 PictureLayerImpl* twin = PendingTwin();
706 if (twin) { 706 if (twin) {
707 float twin_raster_contents_scale = 707 float twin_raster_contents_scale =
708 twin->raster_page_scale_ * 708 twin->raster_page_scale_ *
709 twin->raster_device_scale_ * 709 twin->raster_device_scale_ *
710 twin->raster_source_scale_; 710 twin->raster_source_scale_;
711 711
712 min_acceptable_high_res_scale = std::min( 712 min_acceptable_high_res_scale = std::min(
713 min_acceptable_high_res_scale, 713 min_acceptable_high_res_scale,
714 std::min(twin_raster_contents_scale, twin->ideal_contents_scale_)); 714 std::min(twin_raster_contents_scale, twin->ideal_contents_scale_));
715 max_acceptable_high_res_scale = std::max( 715 max_acceptable_high_res_scale = std::max(
716 max_acceptable_high_res_scale, 716 max_acceptable_high_res_scale,
717 std::max(twin_raster_contents_scale, twin->ideal_contents_scale_)); 717 std::max(twin_raster_contents_scale, twin->ideal_contents_scale_));
718 } 718 }
719 719
720 float low_res_factor = layerTreeImpl()->settings().lowResContentsScaleFactor; 720 float low_res_factor = layer_tree_impl()->settings().lowResContentsScaleFactor ;
721 721
722 float min_acceptable_low_res_scale = 722 float min_acceptable_low_res_scale =
723 low_res_factor * min_acceptable_high_res_scale; 723 low_res_factor * min_acceptable_high_res_scale;
724 float max_acceptable_low_res_scale = 724 float max_acceptable_low_res_scale =
725 low_res_factor * max_acceptable_high_res_scale; 725 low_res_factor * max_acceptable_high_res_scale;
726 726
727 std::vector<PictureLayerTiling*> to_remove; 727 std::vector<PictureLayerTiling*> to_remove;
728 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { 728 for (size_t i = 0; i < tilings_->num_tilings(); ++i) {
729 PictureLayerTiling* tiling = tilings_->tiling_at(i); 729 PictureLayerTiling* tiling = tilings_->tiling_at(i);
730 730
(...skipping 14 matching lines...) Expand all
745 } 745 }
746 746
747 for (size_t i = 0; i < to_remove.size(); ++i) { 747 for (size_t i = 0; i < to_remove.size(); ++i) {
748 if (twin) 748 if (twin)
749 twin->RemoveTiling(to_remove[i]->contents_scale()); 749 twin->RemoveTiling(to_remove[i]->contents_scale());
750 tilings_->Remove(to_remove[i]); 750 tilings_->Remove(to_remove[i]);
751 } 751 }
752 } 752 }
753 753
754 PictureLayerImpl* PictureLayerImpl::PendingTwin() const { 754 PictureLayerImpl* PictureLayerImpl::PendingTwin() const {
755 DCHECK(layerTreeImpl()->IsActiveTree()); 755 DCHECK(layer_tree_impl()->IsActiveTree());
756 756
757 PictureLayerImpl* twin = static_cast<PictureLayerImpl*>( 757 PictureLayerImpl* twin = static_cast<PictureLayerImpl*>(
758 layerTreeImpl()->FindPendingTreeLayerById(id())); 758 layer_tree_impl()->FindPendingTreeLayerById(id()));
759 if (twin) 759 if (twin)
760 DCHECK_EQ(id(), twin->id()); 760 DCHECK_EQ(id(), twin->id());
761 return twin; 761 return twin;
762 } 762 }
763 763
764 PictureLayerImpl* PictureLayerImpl::ActiveTwin() const { 764 PictureLayerImpl* PictureLayerImpl::ActiveTwin() const {
765 DCHECK(layerTreeImpl()->IsPendingTree()); 765 DCHECK(layer_tree_impl()->IsPendingTree());
766 766
767 PictureLayerImpl* twin = static_cast<PictureLayerImpl*>( 767 PictureLayerImpl* twin = static_cast<PictureLayerImpl*>(
768 layerTreeImpl()->FindActiveTreeLayerById(id())); 768 layer_tree_impl()->FindActiveTreeLayerById(id()));
769 if (twin) 769 if (twin)
770 DCHECK_EQ(id(), twin->id()); 770 DCHECK_EQ(id(), twin->id());
771 return twin; 771 return twin;
772 } 772 }
773 773
774 float PictureLayerImpl::MinimumContentsScale() const { 774 float PictureLayerImpl::MinimumContentsScale() const {
775 float setting_min = layerTreeImpl()->settings().minimumContentsScale; 775 float setting_min = layer_tree_impl()->settings().minimumContentsScale;
776 776
777 // If the contents scale is less than 1 / width (also for height), 777 // If the contents scale is less than 1 / width (also for height),
778 // then it will end up having less than one pixel of content in that 778 // then it will end up having less than one pixel of content in that
779 // dimension. Bump the minimum contents scale up in this case to prevent 779 // dimension. Bump the minimum contents scale up in this case to prevent
780 // this from happening. 780 // this from happening.
781 int min_dimension = std::min(bounds().width(), bounds().height()); 781 int min_dimension = std::min(bounds().width(), bounds().height());
782 if (!min_dimension) 782 if (!min_dimension)
783 return setting_min; 783 return setting_min;
784 784
785 return std::max(1.f / min_dimension, setting_min); 785 return std::max(1.f / min_dimension, setting_min);
786 } 786 }
787 787
788 void PictureLayerImpl::getDebugBorderProperties( 788 void PictureLayerImpl::GetDebugBorderProperties(
789 SkColor* color, float* width) const { 789 SkColor* color, float* width) const {
790 *color = DebugColors::TiledContentLayerBorderColor(); 790 *color = DebugColors::TiledContentLayerBorderColor();
791 *width = DebugColors::TiledContentLayerBorderWidth(layerTreeImpl()); 791 *width = DebugColors::TiledContentLayerBorderWidth(layer_tree_impl());
792 } 792 }
793 793
794 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { 794 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const {
795 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 795 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
796 LayerImpl::AsValueInto(state.get()); 796 LayerImpl::AsValueInto(state.get());
797 797
798 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); 798 state->SetDouble("ideal_contents_scale", ideal_contents_scale_);
799 state->Set("tilings", tilings_->AsValue().release()); 799 state->Set("tilings", tilings_->AsValue().release());
800 return state.PassAs<base::Value>(); 800 return state.PassAs<base::Value>();
801 } 801 }
802 802
803 } // namespace cc 803 } // namespace cc
OLDNEW
« no previous file with comments | « cc/picture_layer_impl.h ('k') | cc/picture_layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698