Chromium Code Reviews| Index: cc/layer_impl.cc |
| diff --git a/cc/layer_impl.cc b/cc/layer_impl.cc |
| index 3de9483fccaa6f420319d0fb77bf5b0fd8b1af06..8db5c8b2f553429a1fbdf185e8b279377f51b8cf 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) |
| @@ -235,10 +237,8 @@ bool LayerImpl::drawCheckerboardForMissingTiles() const |
| IntRect LayerImpl::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); |
| + contentRect.scale(contentsScaleX(), contentsScaleY()); |
| return enclosingIntRect(contentRect); |
|
danakj
2012/10/29 20:06:51
Intersect+comment here too.
wangxianzhu
2012/10/30 02:14:21
Done.
|
| } |
| @@ -414,6 +414,12 @@ void LayerImpl::setBounds(const IntSize& bounds) |
| m_layerPropertyChanged = true; |
| } |
| +IntSize LayerImpl::contentBounds() const |
|
enne (OOO)
2012/10/29 19:19:41
I don't think this math works out correctly for im
danakj
2012/10/29 20:06:51
If contentBounds() is not always equal to ceil(bou
wangxianzhu
2012/10/30 02:14:21
Done.
wangxianzhu
2012/10/30 02:14:21
Done.
|
| +{ |
| + return IntSize(ceil(bounds().width() * contentsScaleX()), |
| + ceil(bounds().height() * contentsScaleY())); |
| +} |
| + |
| void LayerImpl::setMaskLayer(scoped_ptr<LayerImpl> maskLayer) |
| { |
| m_maskLayer = maskLayer.Pass(); |
| @@ -600,12 +606,13 @@ bool LayerImpl::hasDebugBorders() const |
| return SkColorGetA(m_debugBorderColor) && debugBorderWidth() > 0; |
| } |
| -void LayerImpl::setContentBounds(const IntSize& contentBounds) |
| +void LayerImpl::setContentsScale(float contentsScaleX, float contentsScaleY) |
| { |
| - if (m_contentBounds == contentBounds) |
| + if (m_contentsScaleX == contentsScaleX && m_contentsScaleY == contentsScaleY) |
| return; |
| - m_contentBounds = contentBounds; |
| + m_contentsScaleX = contentsScaleX; |
| + m_contentsScaleY = contentsScaleY; |
| m_layerPropertyChanged = true; |
| } |