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

Unified Diff: cc/layer_impl.cc

Issue 11276060: Pass accurate contentsScale to LayerImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/layer_impl.h ('k') | cc/layer_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layer_impl.cc
diff --git a/cc/layer_impl.cc b/cc/layer_impl.cc
index 3de9483fccaa6f420319d0fb77bf5b0fd8b1af06..197e6194385e62d64eec6db63f29c892cbc8dd7e 100644
--- a/cc/layer_impl.cc
+++ b/cc/layer_impl.cc
@@ -29,6 +29,8 @@ LayerImpl::LayerImpl(int id)
, m_layerTreeHostImpl(0)
, m_anchorPoint(0.5, 0.5)
, m_anchorPointZ(0)
+ , m_contentsScaleX(1.0)
+ , m_contentsScaleY(1.0)
, m_scrollable(false)
, m_shouldScrollOnMainThread(false)
, m_haveWheelEventHandlers(false)
@@ -233,13 +235,15 @@ bool LayerImpl::drawCheckerboardForMissingTiles() const
return m_drawCheckerboardForMissingTiles && !Settings::backgroundColorInsteadOfCheckerboard();
}
-IntRect LayerImpl::layerRectToContentRect(const WebKit::WebRect& layerRect)
+IntRect LayerImpl::layerRectToContentRect(const FloatRect& layerRect) const
{
- 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);
+ FloatRect contentRect(layerRect);
+ contentRect.scale(contentsScaleX(), contentsScaleY());
+ IntRect intContentRect = enclosingIntRect(contentRect);
+ // Intersect with content rect to avoid the extra pixel because for some
+ // values x and y, ceil((x / y) * y) may be x + 1.
+ intContentRect.intersect(IntRect(IntPoint(), contentBounds()));
+ return intContentRect;
}
std::string LayerImpl::indentString(int indent)
@@ -609,6 +613,16 @@ void LayerImpl::setContentBounds(const IntSize& contentBounds)
m_layerPropertyChanged = true;
}
+void LayerImpl::setContentsScale(float contentsScaleX, float contentsScaleY)
+{
+ if (m_contentsScaleX == contentsScaleX && m_contentsScaleY == contentsScaleY)
+ return;
+
+ m_contentsScaleX = contentsScaleX;
+ m_contentsScaleY = contentsScaleY;
+ m_layerPropertyChanged = true;
+}
+
void LayerImpl::setScrollPosition(const IntPoint& scrollPosition)
{
if (m_scrollPosition == scrollPosition)
« no previous file with comments | « cc/layer_impl.h ('k') | cc/layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698