summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-24 21:39:15 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-24 21:39:15 +0000
commite1324f25756a4fa4acc1ffd2bf99ee35796b83b5 (patch)
tree69a3b18aa21165b264349f7eccd932e0c6c88642 /cc
parent8f74058b17e25c17b6c7f7bfdf47590fbe5a8ff0 (diff)
downloadchromium_src-e1324f25756a4fa4acc1ffd2bf99ee35796b83b5.zip
chromium_src-e1324f25756a4fa4acc1ffd2bf99ee35796b83b5.tar.gz
chromium_src-e1324f25756a4fa4acc1ffd2bf99ee35796b83b5.tar.bz2
Revert 158386 - Revert 158362 - Support high DPI scrollbar on top level web frame.
BUG=141389 TEST=Run chrome with --force-device-scale-factor=2 --force-compositing-mode and verify that the top-level scrollbar is high dpi. CC tests are known flaky: http://code.google.com/p/chromium/issues/detail?id=148490 Re-committing the CC change. Review URL: https://chromiumcodereview.appspot.com/10909255 TBR=flackr@chromium.org Review URL: https://codereview.chromium.org/10990004 TBR=avi@chromium.org Review URL: https://codereview.chromium.org/10989003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@158398 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/CCLayerImpl.cpp9
-rw-r--r--cc/CCLayerImpl.h2
-rw-r--r--cc/CCScrollbarLayerImpl.cpp13
-rw-r--r--cc/LayerChromium.cpp12
-rw-r--r--cc/LayerChromium.h3
-rw-r--r--cc/ScrollbarLayerChromium.cpp22
-rw-r--r--cc/ScrollbarLayerChromium.h2
7 files changed, 52 insertions, 11 deletions
diff --git a/cc/CCLayerImpl.cpp b/cc/CCLayerImpl.cpp
index 84597c5..b59ddb4 100644
--- a/cc/CCLayerImpl.cpp
+++ b/cc/CCLayerImpl.cpp
@@ -224,6 +224,15 @@ CCInputHandlerClient::ScrollStatus CCLayerImpl::tryScroll(const IntPoint& viewpo
return CCInputHandlerClient::ScrollStarted;
}
+IntRect CCLayerImpl::layerRectToContentRect(const WebKit::WebRect& layerRect)
+{
+ float widthScale = static_cast<float>(contentBounds().width()) / bounds().width();
+ float heightScale = static_cast<float>(contentBounds().height()) / bounds().height();
+ FloatRect contentRect(layerRect.x, layerRect.y, layerRect.width, layerRect.height);
+ contentRect.scale(widthScale, heightScale);
+ return enclosingIntRect(contentRect);
+}
+
std::string CCLayerImpl::indentString(int indent)
{
std::string str;
diff --git a/cc/CCLayerImpl.h b/cc/CCLayerImpl.h
index d5c903b..65e12f3 100644
--- a/cc/CCLayerImpl.h
+++ b/cc/CCLayerImpl.h
@@ -262,6 +262,8 @@ protected:
void appendDebugBorderQuad(CCQuadSink&, const CCSharedQuadState*, CCAppendQuadsData&) const;
+ IntRect layerRectToContentRect(const WebKit::WebRect& layerRect);
+
virtual void dumpLayerProperties(std::string*, int indent) const;
static std::string indentString(int indent);
diff --git a/cc/CCScrollbarLayerImpl.cpp b/cc/CCScrollbarLayerImpl.cpp
index 63be4f5..dd4791f 100644
--- a/cc/CCScrollbarLayerImpl.cpp
+++ b/cc/CCScrollbarLayerImpl.cpp
@@ -79,7 +79,8 @@ void CCScrollbarLayerImpl::appendQuads(CCQuadSink& quadSink, CCAppendQuadsData&
bool premultipledAlpha = false;
bool flipped = false;
FloatRect uvRect(0, 0, 1, 1);
- IntRect boundsRect(IntPoint(), contentBounds());
+ IntRect boundsRect(IntPoint(), bounds());
+ IntRect contentBoundsRect(IntPoint(), contentBounds());
CCSharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQuadState());
appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData);
@@ -90,7 +91,7 @@ void CCScrollbarLayerImpl::appendQuads(CCQuadSink& quadSink, CCAppendQuadsData&
thumbRect = WebRect();
if (m_thumbResourceId && !thumbRect.isEmpty()) {
- OwnPtr<CCTextureDrawQuad> quad = CCTextureDrawQuad::create(sharedQuadState, IntRect(thumbRect.x, thumbRect.y, thumbRect.width, thumbRect.height), m_thumbResourceId, premultipledAlpha, uvRect, flipped);
+ OwnPtr<CCTextureDrawQuad> quad = CCTextureDrawQuad::create(sharedQuadState, layerRectToContentRect(thumbRect), m_thumbResourceId, premultipledAlpha, uvRect, flipped);
quad->setNeedsBlending();
quadSink.append(quad.release(), appendQuadsData);
}
@@ -100,12 +101,12 @@ void CCScrollbarLayerImpl::appendQuads(CCQuadSink& quadSink, CCAppendQuadsData&
// We only paint the track in two parts if we were given a texture for the forward track part.
if (m_foreTrackResourceId && !foreTrackRect.isEmpty())
- quadSink.append(CCTextureDrawQuad::create(sharedQuadState, IntRect(foreTrackRect.x, foreTrackRect.y, foreTrackRect.width, foreTrackRect.height), m_foreTrackResourceId, premultipledAlpha, toUVRect(foreTrackRect, boundsRect), flipped), appendQuadsData);
+ quadSink.append(CCTextureDrawQuad::create(sharedQuadState, layerRectToContentRect(foreTrackRect), m_foreTrackResourceId, premultipledAlpha, toUVRect(foreTrackRect, boundsRect), flipped), appendQuadsData);
// Order matters here: since the back track texture is being drawn to the entire contents rect, we must append it after the thumb and
// fore track quads. The back track texture contains (and displays) the buttons.
- if (!boundsRect.isEmpty())
- quadSink.append(CCTextureDrawQuad::create(sharedQuadState, IntRect(boundsRect), m_backTrackResourceId, premultipledAlpha, uvRect, flipped), appendQuadsData);
+ if (!contentBoundsRect.isEmpty())
+ quadSink.append(CCTextureDrawQuad::create(sharedQuadState, IntRect(contentBoundsRect), m_backTrackResourceId, premultipledAlpha, uvRect, flipped), appendQuadsData);
}
void CCScrollbarLayerImpl::didLoseContext()
@@ -132,7 +133,7 @@ WebKit::WebPoint CCScrollbarLayerImpl::CCScrollbar::location() const
WebKit::WebSize CCScrollbarLayerImpl::CCScrollbar::size() const
{
- return WebKit::WebSize(m_owner->contentBounds().width(), m_owner->contentBounds().height());
+ return WebKit::WebSize(m_owner->bounds().width(), m_owner->bounds().height());
}
bool CCScrollbarLayerImpl::CCScrollbar::enabled() const
diff --git a/cc/LayerChromium.cpp b/cc/LayerChromium.cpp
index b053403..a7db9fd 100644
--- a/cc/LayerChromium.cpp
+++ b/cc/LayerChromium.cpp
@@ -116,6 +116,15 @@ void LayerChromium::setNeedsCommit()
m_layerTreeHost->setNeedsCommit();
}
+IntRect LayerChromium::layerRectToContentRect(const WebKit::WebRect& layerRect)
+{
+ float widthScale = static_cast<float>(contentBounds().width()) / bounds().width();
+ float heightScale = static_cast<float>(contentBounds().height()) / bounds().height();
+ FloatRect contentRect(layerRect.x, layerRect.y, layerRect.width, layerRect.height);
+ contentRect.scale(widthScale, heightScale);
+ return enclosingIntRect(contentRect);
+}
+
void LayerChromium::setParent(LayerChromium* layer)
{
ASSERT(!layer || !layer->hasAncestor(this));
@@ -622,6 +631,9 @@ void LayerChromium::setContentsScale(float contentsScale)
void LayerChromium::setBoundsContainPageScale(bool boundsContainPageScale)
{
+ for (size_t i = 0; i < m_children.size(); ++i)
+ m_children[i]->setBoundsContainPageScale(boundsContainPageScale);
+
if (boundsContainPageScale == m_boundsContainPageScale)
return;
diff --git a/cc/LayerChromium.h b/cc/LayerChromium.h
index 0e02cfd..fc7a6739 100644
--- a/cc/LayerChromium.h
+++ b/cc/LayerChromium.h
@@ -232,6 +232,7 @@ public:
void setContentsScale(float);
// When true, the layer's contents are not scaled by the current page scale factor.
+ // setBoundsContainPageScale recursively sets the value on all child layers.
void setBoundsContainPageScale(bool);
bool boundsContainPageScale() const { return m_boundsContainPageScale; }
@@ -273,6 +274,8 @@ protected:
void setNeedsCommit();
+ IntRect layerRectToContentRect(const WebKit::WebRect& layerRect);
+
// This flag is set when layer need repainting/updating.
bool m_needsDisplay;
diff --git a/cc/ScrollbarLayerChromium.cpp b/cc/ScrollbarLayerChromium.cpp
index 80e36fb..614e0ee 100644
--- a/cc/ScrollbarLayerChromium.cpp
+++ b/cc/ScrollbarLayerChromium.cpp
@@ -131,6 +131,16 @@ private:
WebKit::WebScrollbar::ScrollbarPart m_trackPart;
};
+bool ScrollbarLayerChromium::needsContentsScale() const
+{
+ return true;
+}
+
+IntSize ScrollbarLayerChromium::contentBounds() const
+{
+ return IntSize(lroundf(bounds().width() * contentsScale()), lroundf(bounds().height() * contentsScale()));
+}
+
class ScrollbarThumbPainter : public LayerPainterChromium {
WTF_MAKE_NONCOPYABLE(ScrollbarThumbPainter);
public:
@@ -213,8 +223,10 @@ void ScrollbarLayerChromium::updatePart(LayerTextureUpdater* painter, LayerTextu
return;
// Paint and upload the entire part.
+ float widthScale = static_cast<float>(contentBounds().width()) / bounds().width();
+ float heightScale = static_cast<float>(contentBounds().height()) / bounds().height();
IntRect paintedOpaqueRect;
- painter->prepareToUpdate(rect, rect.size(), 1, 1, paintedOpaqueRect, stats);
+ painter->prepareToUpdate(rect, rect.size(), widthScale, heightScale, paintedOpaqueRect, stats);
texture->prepareRect(rect, stats);
IntSize destOffset(0, 0);
@@ -240,8 +252,8 @@ void ScrollbarLayerChromium::setTexturePriorities(const CCPriorityCalculator&)
m_foreTrack->texture()->setRequestPriority(CCPriorityCalculator::uiPriority(drawsToRoot));
}
if (m_thumb) {
- WebKit::WebRect thumbRect = m_geometry->thumbRect(m_scrollbar.get());
- m_thumb->texture()->setDimensions(IntSize(thumbRect.width, thumbRect.height), m_textureFormat);
+ IntSize thumbSize = layerRectToContentRect(m_geometry->thumbRect(m_scrollbar.get())).size();
+ m_thumb->texture()->setDimensions(thumbSize, m_textureFormat);
m_thumb->texture()->setRequestPriority(CCPriorityCalculator::uiPriority(drawsToRoot));
}
}
@@ -254,14 +266,14 @@ void ScrollbarLayerChromium::update(CCTextureUpdateQueue& queue, const CCOcclusi
createTextureUpdaterIfNeeded();
IntPoint scrollbarOrigin(m_scrollbar->location().x, m_scrollbar->location().y);
- IntRect contentRect(scrollbarOrigin, contentBounds());
+ IntRect contentRect = layerRectToContentRect(WebKit::WebRect(scrollbarOrigin.x(), scrollbarOrigin.y(), bounds().width(), bounds().height()));
updatePart(m_backTrackUpdater.get(), m_backTrack.get(), contentRect, queue, stats);
if (m_foreTrack && m_foreTrackUpdater)
updatePart(m_foreTrackUpdater.get(), m_foreTrack.get(), contentRect, queue, stats);
// Consider the thumb to be at the origin when painting.
WebKit::WebRect thumbRect = m_geometry->thumbRect(m_scrollbar.get());
- IntRect originThumbRect = IntRect(0, 0, thumbRect.width, thumbRect.height);
+ IntRect originThumbRect = layerRectToContentRect(WebKit::WebRect(0, 0, thumbRect.width, thumbRect.height));
if (!originThumbRect.isEmpty())
updatePart(m_thumbUpdater.get(), m_thumb.get(), originThumbRect, queue, stats);
}
diff --git a/cc/ScrollbarLayerChromium.h b/cc/ScrollbarLayerChromium.h
index 62ace2d..236ba83 100644
--- a/cc/ScrollbarLayerChromium.h
+++ b/cc/ScrollbarLayerChromium.h
@@ -29,6 +29,8 @@ public:
virtual ~ScrollbarLayerChromium();
// LayerChromium interface
+ virtual bool needsContentsScale() const OVERRIDE;
+ virtual IntSize contentBounds() const OVERRIDE;
virtual void setTexturePriorities(const CCPriorityCalculator&) OVERRIDE;
virtual void update(CCTextureUpdateQueue&, const CCOcclusionTracker*, CCRenderingStats&) OVERRIDE;
virtual void setLayerTreeHost(CCLayerTreeHost*) OVERRIDE;