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) |