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

Side by Side Diff: cc/layers/painted_scrollbar_layer.cc

Issue 1357423009: gfx: Make conversions from Size to SizeF be explicit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sizefconvert-gfx: . Created 5 years, 2 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
« no previous file with comments | « cc/layers/layer_impl.cc ('k') | cc/layers/picture_layer_impl.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/layers/painted_scrollbar_layer.h" 5 #include "cc/layers/painted_scrollbar_layer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 87
88 int PaintedScrollbarLayer::MaxTextureSize() { 88 int PaintedScrollbarLayer::MaxTextureSize() {
89 DCHECK(layer_tree_host()); 89 DCHECK(layer_tree_host());
90 return layer_tree_host()->GetRendererCapabilities().max_texture_size; 90 return layer_tree_host()->GetRendererCapabilities().max_texture_size;
91 } 91 }
92 92
93 float PaintedScrollbarLayer::ClampScaleToMaxTextureSize(float scale) { 93 float PaintedScrollbarLayer::ClampScaleToMaxTextureSize(float scale) {
94 // If the scaled bounds() is bigger than the max texture size of the 94 // If the scaled bounds() is bigger than the max texture size of the
95 // device, we need to clamp it by rescaling, since this is used 95 // device, we need to clamp it by rescaling, since this is used
96 // below to set the texture size. 96 // below to set the texture size.
97 gfx::Size scaled_bounds = gfx::ToCeiledSize(gfx::ScaleSize(bounds(), scale)); 97 gfx::Size scaled_bounds = gfx::ScaleToCeiledSize(bounds(), scale);
98 if (scaled_bounds.width() > MaxTextureSize() || 98 if (scaled_bounds.width() > MaxTextureSize() ||
99 scaled_bounds.height() > MaxTextureSize()) { 99 scaled_bounds.height() > MaxTextureSize()) {
100 if (scaled_bounds.width() > scaled_bounds.height()) 100 if (scaled_bounds.width() > scaled_bounds.height())
101 return (MaxTextureSize() - 1) / static_cast<float>(bounds().width()); 101 return (MaxTextureSize() - 1) / static_cast<float>(bounds().width());
102 else 102 else
103 return (MaxTextureSize() - 1) / static_cast<float>(bounds().height()); 103 return (MaxTextureSize() - 1) / static_cast<float>(bounds().height());
104 } 104 }
105 return scale; 105 return scale;
106 } 106 }
107 107
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 transform = DrawTransformFromPropertyTrees( 211 transform = DrawTransformFromPropertyTrees(
212 this, layer_tree_host()->property_trees()->transform_tree); 212 this, layer_tree_host()->property_trees()->transform_tree);
213 213
214 gfx::Vector2dF transform_scales = 214 gfx::Vector2dF transform_scales =
215 MathUtil::ComputeTransform2dScaleComponents(transform, scale); 215 MathUtil::ComputeTransform2dScaleComponents(transform, scale);
216 scale = std::max(transform_scales.x(), transform_scales.y()); 216 scale = std::max(transform_scales.x(), transform_scales.y());
217 } 217 }
218 bool changed = false; 218 bool changed = false;
219 changed |= UpdateProperty(ClampScaleToMaxTextureSize(scale), 219 changed |= UpdateProperty(ClampScaleToMaxTextureSize(scale),
220 &internal_contents_scale_); 220 &internal_contents_scale_);
221 changed |= UpdateProperty( 221 changed |=
222 gfx::ToCeiledSize(gfx::ScaleSize(bounds(), internal_contents_scale_)), 222 UpdateProperty(gfx::ScaleToCeiledSize(bounds(), internal_contents_scale_),
223 &internal_content_bounds_); 223 &internal_content_bounds_);
224 if (changed) { 224 if (changed) {
225 // If the content scale or bounds change, repaint. 225 // If the content scale or bounds change, repaint.
226 SetNeedsDisplay(); 226 SetNeedsDisplay();
227 } 227 }
228 } 228 }
229 229
230 bool PaintedScrollbarLayer::Update() { 230 bool PaintedScrollbarLayer::Update() {
231 { 231 {
232 base::AutoReset<bool> ignore_set_needs_commit(&ignore_set_needs_commit_, 232 base::AutoReset<bool> ignore_set_needs_commit(&ignore_set_needs_commit_,
233 true); 233 true);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 311
312 scrollbar_->PaintPart(&skcanvas, part, layer_rect); 312 scrollbar_->PaintPart(&skcanvas, part, layer_rect);
313 // Make sure that the pixels are no longer mutable to unavoid unnecessary 313 // Make sure that the pixels are no longer mutable to unavoid unnecessary
314 // allocation and copying. 314 // allocation and copying.
315 skbitmap.setImmutable(); 315 skbitmap.setImmutable();
316 316
317 return UIResourceBitmap(skbitmap); 317 return UIResourceBitmap(skbitmap);
318 } 318 }
319 319
320 } // namespace cc 320 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.cc ('k') | cc/layers/picture_layer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698