diff options
author | Chris Craik <ccraik@google.com> | 2011-09-09 11:56:55 -0700 |
---|---|---|
committer | Chris Craik <ccraik@google.com> | 2011-09-11 22:08:06 -0700 |
commit | 870be3d940e9e567cf40c446b52fe6fc691378fa (patch) | |
tree | d8f7f0b71aef6f3eb5e78e07d381a87e83a7df3c /Source/WebCore/platform/graphics/android/LayerAndroid.cpp | |
parent | c622298990df11240ed11cd66c8bc7671a8ec59a (diff) | |
download | external_webkit-870be3d940e9e567cf40c446b52fe6fc691378fa.zip external_webkit-870be3d940e9e567cf40c446b52fe6fc691378fa.tar.gz external_webkit-870be3d940e9e567cf40c446b52fe6fc691378fa.tar.bz2 |
Fudge layer translation to always line up with view pixels
bug:3367478
Change-Id: I37632de8503b0f3eba0a183a156d71ea48bdba98
Diffstat (limited to 'Source/WebCore/platform/graphics/android/LayerAndroid.cpp')
-rw-r--r-- | Source/WebCore/platform/graphics/android/LayerAndroid.cpp | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp index 1d52c42..48dcaaa 100644 --- a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp @@ -17,6 +17,7 @@ #include "SkPicture.h" #include "TilesManager.h" #include <wtf/CurrentTime.h> +#include <math.h> #define LAYER_DEBUG // Add diagonals for debugging #undef LAYER_DEBUG @@ -558,8 +559,8 @@ void LayerAndroid::updatePositions() this->getChild(i)->updatePositions(); } -void LayerAndroid::updateGLPositions(const TransformationMatrix& parentMatrix, - const FloatRect& clipping, float opacity) +void LayerAndroid::updateGLPositionsAndScale(const TransformationMatrix& parentMatrix, + const FloatRect& clipping, float opacity, float scale) { IntSize layerSize(getSize().width(), getSize().height()); FloatPoint anchorPoint(getAnchorPoint().fX, getAnchorPoint().fY); @@ -580,8 +581,24 @@ void LayerAndroid::updateGLPositions(const TransformationMatrix& parentMatrix, -anchorPointZ()); setDrawTransform(localMatrix); + if (m_drawTransform.isIdentityOrTranslation()) { + // adjust the translation coordinates of the draw transform matrix so + // that layers (defined in content coordinates) will align to display/view pixels + float desiredContentX = round(m_drawTransform.m41() * scale) / scale; + float desiredContentY = round(m_drawTransform.m42() * scale) / scale; + XLOG("fudging translation from %f, %f to %f, %f", + m_drawTransform.m41(), m_drawTransform.m42(), + desiredContentX, desiredContentY); + m_drawTransform.setM41(desiredContentX); + m_drawTransform.setM42(desiredContentY); + } + m_zValue = TilesManager::instance()->shader()->zValue(m_drawTransform, getSize().width(), getSize().height()); + m_atomicSync.lock(); + m_scale = scale; + m_atomicSync.unlock(); + opacity *= getOpacity(); setDrawOpacity(opacity); @@ -626,7 +643,7 @@ void LayerAndroid::updateGLPositions(const TransformationMatrix& parentMatrix, localMatrix.translate(-getSize().width() * 0.5f, -getSize().height() * 0.5f); } for (int i = 0; i < count; i++) - this->getChild(i)->updateGLPositions(localMatrix, drawClip(), opacity); + this->getChild(i)->updateGLPositionsAndScale(localMatrix, drawClip(), opacity, scale); } void LayerAndroid::copyBitmap(SkBitmap* bitmap) @@ -821,16 +838,6 @@ bool LayerAndroid::drawChildrenGL(GLWebViewState* glWebViewState, SkMatrix& matr return askPaint; } -void LayerAndroid::setScale(float scale) -{ - int count = this->countChildren(); - for (int i = 0; i < count; i++) - this->getChild(i)->setScale(scale); - - android::AutoMutex lock(m_atomicSync); - m_scale = scale; -} - void LayerAndroid::extraDraw(SkCanvas* canvas) { m_atomicSync.lock(); |