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

Unified Diff: cc/layers/painted_scrollbar_layer.cc

Issue 2282443002: 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, 4 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/layers/painted_scrollbar_layer.h ('k') | cc/layers/scrollbar_layer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/painted_scrollbar_layer.cc
diff --git a/cc/layers/painted_scrollbar_layer.cc b/cc/layers/painted_scrollbar_layer.cc
index aa544ea0db9004330ab01dbce0c557fc848316db..e10947b3dc6864920a0295cdeee87bc5c4798253 100644
--- a/cc/layers/painted_scrollbar_layer.cc
+++ b/cc/layers/painted_scrollbar_layer.cc
@@ -78,6 +78,26 @@
return scrollbar_->Orientation();
}
+int PaintedScrollbarLayer::MaxTextureSize() {
+ DCHECK(layer_tree_host());
+ return layer_tree_host()->GetRendererCapabilities().max_texture_size;
+}
+
+float PaintedScrollbarLayer::ClampScaleToMaxTextureSize(float scale) {
+ // If the scaled bounds() is bigger than the max texture size of the
+ // device, we need to clamp it by rescaling, since this is used
+ // below to set the texture size.
+ gfx::Size scaled_bounds = gfx::ScaleToCeiledSize(bounds(), scale);
+ if (scaled_bounds.width() > MaxTextureSize() ||
+ scaled_bounds.height() > MaxTextureSize()) {
+ if (bounds().width() > bounds().height())
+ return (MaxTextureSize() - 1) / static_cast<float>(bounds().width());
+ else
+ return (MaxTextureSize() - 1) / static_cast<float>(bounds().height());
+ }
+ return scale;
+}
+
void PaintedScrollbarLayer::PushPropertiesTo(LayerImpl* layer) {
Layer::PushPropertiesTo(layer);
@@ -182,7 +202,8 @@
scale = std::max(transform_scales.x(), transform_scales.y());
}
bool changed = false;
- changed |= UpdateProperty(scale, &internal_contents_scale_);
+ changed |= UpdateProperty(ClampScaleToMaxTextureSize(scale),
+ &internal_contents_scale_);
changed |=
UpdateProperty(gfx::ScaleToCeiledSize(bounds(), internal_contents_scale_),
&internal_content_bounds_);
« 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