summaryrefslogtreecommitdiffstats
path: root/cc/scrollbar_layer.cc
diff options
context:
space:
mode:
authoraelias@chromium.org <aelias@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-28 06:34:44 +0000
committeraelias@chromium.org <aelias@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-28 06:34:44 +0000
commit9281fc02ac6c3a3b65b3789694ec52756702dbe1 (patch)
treed1c78d4305cabae465d83a923670d0ec0acfef53 /cc/scrollbar_layer.cc
parentc9d37ea870d7c541f3622997f5ec0a28382e8f2e (diff)
downloadchromium_src-9281fc02ac6c3a3b65b3789694ec52756702dbe1.zip
chromium_src-9281fc02ac6c3a3b65b3789694ec52756702dbe1.tar.gz
chromium_src-9281fc02ac6c3a3b65b3789694ec52756702dbe1.tar.bz2
Clamp ScrollbarLayer's texture size to GL_MAX_TEXTURE_SIZE.
When a scale transformation is applied to a scrollbar, its texture size can be larger than the GL maximum. Limit the value of contentsScale to avoid this. Picked up from original patch at https://codereview.chromium.org/11419140/ BUG=161029 Review URL: https://chromiumcodereview.appspot.com/11428042 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169869 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/scrollbar_layer.cc')
-rw-r--r--cc/scrollbar_layer.cc28
1 files changed, 28 insertions, 0 deletions
diff --git a/cc/scrollbar_layer.cc b/cc/scrollbar_layer.cc
index 392369f..09c4e7f 100644
--- a/cc/scrollbar_layer.cc
+++ b/cc/scrollbar_layer.cc
@@ -40,6 +40,32 @@ ScrollbarLayer::~ScrollbarLayer()
{
}
+int ScrollbarLayer::maxTextureSize() {
+ DCHECK(layerTreeHost());
+ return layerTreeHost()->rendererCapabilities().maxTextureSize;
+}
+
+float ScrollbarLayer::clampScaleToMaxTextureSize(float scale) {
+ // If the scaled contentBounds() is bigger than the max texture size of the
+ // device, we need to clamp it by rescaling, since contentBounds() is used
+ // below to set the texture size.
+ gfx::Size scaledBounds = computeContentBoundsForScale(scale, scale);
+ if (scaledBounds.width() > maxTextureSize() || scaledBounds.height() > maxTextureSize()) {
+ if (scaledBounds.width() > scaledBounds.height())
+ return (maxTextureSize() - 1) / static_cast<float>(bounds().width());
+ else
+ return (maxTextureSize() - 1) / static_cast<float>(bounds().height());
+ }
+ return scale;
+}
+
+void ScrollbarLayer::setContentsScale(float contentsScale) {
+ contentsScale = clampScaleToMaxTextureSize(contentsScale);
+ ContentsScalingLayer::setContentsScale(contentsScale);
+ DCHECK_LE(contentBounds().width(), maxTextureSize());
+ DCHECK_LE(contentBounds().height(), maxTextureSize());
+}
+
void ScrollbarLayer::pushPropertiesTo(LayerImpl* layer)
{
ContentsScalingLayer::pushPropertiesTo(layer);
@@ -235,6 +261,8 @@ void ScrollbarLayer::setTexturePriorities(const PriorityCalculator&)
{
if (contentBounds().IsEmpty())
return;
+ DCHECK_LE(contentBounds().width(), maxTextureSize());
+ DCHECK_LE(contentBounds().height(), maxTextureSize());
createUpdaterIfNeeded();