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

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

Issue 2278083002: Revert of Move scaling of ui resources for scrollbars to the time of upload (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scrollbarpixeltests
Patch Set: Created 4 years, 3 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/painted_scrollbar_layer.h ('k') | cc/layers/scrollbar_layer_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 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 "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 71 }
72 72
73 bool PaintedScrollbarLayer::AlwaysUseActiveTreeOpacity() const { 73 bool PaintedScrollbarLayer::AlwaysUseActiveTreeOpacity() const {
74 return true; 74 return true;
75 } 75 }
76 76
77 ScrollbarOrientation PaintedScrollbarLayer::orientation() const { 77 ScrollbarOrientation PaintedScrollbarLayer::orientation() const {
78 return scrollbar_->Orientation(); 78 return scrollbar_->Orientation();
79 } 79 }
80 80
81 int PaintedScrollbarLayer::MaxTextureSize() {
82 DCHECK(layer_tree_host());
83 return layer_tree_host()->GetRendererCapabilities().max_texture_size;
84 }
85
86 float PaintedScrollbarLayer::ClampScaleToMaxTextureSize(float scale) {
87 // If the scaled bounds() is bigger than the max texture size of the
88 // device, we need to clamp it by rescaling, since this is used
89 // below to set the texture size.
90 gfx::Size scaled_bounds = gfx::ScaleToCeiledSize(bounds(), scale);
91 if (scaled_bounds.width() > MaxTextureSize() ||
92 scaled_bounds.height() > MaxTextureSize()) {
93 if (bounds().width() > bounds().height())
94 return (MaxTextureSize() - 1) / static_cast<float>(bounds().width());
95 else
96 return (MaxTextureSize() - 1) / static_cast<float>(bounds().height());
97 }
98 return scale;
99 }
100
81 void PaintedScrollbarLayer::PushPropertiesTo(LayerImpl* layer) { 101 void PaintedScrollbarLayer::PushPropertiesTo(LayerImpl* layer) {
82 Layer::PushPropertiesTo(layer); 102 Layer::PushPropertiesTo(layer);
83 103
84 PaintedScrollbarLayerImpl* scrollbar_layer = 104 PaintedScrollbarLayerImpl* scrollbar_layer =
85 static_cast<PaintedScrollbarLayerImpl*>(layer); 105 static_cast<PaintedScrollbarLayerImpl*>(layer);
86 106
87 scrollbar_layer->SetScrollLayerId(scroll_layer_id_); 107 scrollbar_layer->SetScrollLayerId(scroll_layer_id_);
88 scrollbar_layer->set_internal_contents_scale_and_bounds( 108 scrollbar_layer->set_internal_contents_scale_and_bounds(
89 internal_contents_scale_, internal_content_bounds_); 109 internal_contents_scale_, internal_content_bounds_);
90 110
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 .layer_transforms_should_scale_layer_contents) { 195 .layer_transforms_should_scale_layer_contents) {
176 gfx::Transform transform; 196 gfx::Transform transform;
177 transform = draw_property_utils::ScreenSpaceTransform( 197 transform = draw_property_utils::ScreenSpaceTransform(
178 this, GetLayerTree()->property_trees()->transform_tree); 198 this, GetLayerTree()->property_trees()->transform_tree);
179 199
180 gfx::Vector2dF transform_scales = 200 gfx::Vector2dF transform_scales =
181 MathUtil::ComputeTransform2dScaleComponents(transform, scale); 201 MathUtil::ComputeTransform2dScaleComponents(transform, scale);
182 scale = std::max(transform_scales.x(), transform_scales.y()); 202 scale = std::max(transform_scales.x(), transform_scales.y());
183 } 203 }
184 bool changed = false; 204 bool changed = false;
185 changed |= UpdateProperty(scale, &internal_contents_scale_); 205 changed |= UpdateProperty(ClampScaleToMaxTextureSize(scale),
206 &internal_contents_scale_);
186 changed |= 207 changed |=
187 UpdateProperty(gfx::ScaleToCeiledSize(bounds(), internal_contents_scale_), 208 UpdateProperty(gfx::ScaleToCeiledSize(bounds(), internal_contents_scale_),
188 &internal_content_bounds_); 209 &internal_content_bounds_);
189 if (changed) { 210 if (changed) {
190 // If the content scale or bounds change, repaint. 211 // If the content scale or bounds change, repaint.
191 SetNeedsDisplay(); 212 SetNeedsDisplay();
192 } 213 }
193 } 214 }
194 215
195 bool PaintedScrollbarLayer::Update() { 216 bool PaintedScrollbarLayer::Update() {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 304
284 scrollbar_->PaintPart(&skcanvas, part, layer_rect); 305 scrollbar_->PaintPart(&skcanvas, part, layer_rect);
285 // Make sure that the pixels are no longer mutable to unavoid unnecessary 306 // Make sure that the pixels are no longer mutable to unavoid unnecessary
286 // allocation and copying. 307 // allocation and copying.
287 skbitmap.setImmutable(); 308 skbitmap.setImmutable();
288 309
289 return UIResourceBitmap(skbitmap); 310 return UIResourceBitmap(skbitmap);
290 } 311 }
291 312
292 } // namespace cc 313 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/painted_scrollbar_layer.h ('k') | cc/layers/scrollbar_layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698