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 | |
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
3 files changed, 24 insertions, 20 deletions
diff --git a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp index 54290cc..1fa69f8 100644 --- a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp @@ -266,13 +266,11 @@ bool BaseLayerAndroid::drawGL(double currentTime, LayerAndroid* compositedRoot, compositedRoot->updateFixedLayersPositions(visibleRect); FloatRect clip(0, 0, viewRect.width(), viewRect.height()); - compositedRoot->updateGLPositions(ident, clip, 1); + compositedRoot->updateGLPositionsAndScale( + ident, clip, 1, m_glWebViewState->zoomManager()->layersScale()); SkMatrix matrix; matrix.setTranslate(viewRect.x(), viewRect.y()); - // get the scale factor from the zoom manager - compositedRoot->setScale(m_glWebViewState->zoomManager()->layersScale()); - #ifdef DEBUG compositedRoot->showLayer(0); XLOG("We have %d layers, %d textured", 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(); diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.h b/Source/WebCore/platform/graphics/android/LayerAndroid.h index a28f1e7..7192aaf 100644 --- a/Source/WebCore/platform/graphics/android/LayerAndroid.h +++ b/Source/WebCore/platform/graphics/android/LayerAndroid.h @@ -120,12 +120,11 @@ public: int nbTexturedLayers(); void showLayer(int indent); - void setScale(float scale); float getScale() { return m_scale; } virtual bool drawGL(GLWebViewState*, SkMatrix&); bool drawChildrenGL(GLWebViewState*, SkMatrix&); - void updateGLPositions(const TransformationMatrix& parentMatrix, - const FloatRect& clip, float opacity); + void updateGLPositionsAndScale(const TransformationMatrix& parentMatrix, + const FloatRect& clip, float opacity, float scale); void setDrawOpacity(float opacity) { m_drawOpacity = opacity; } float drawOpacity() { return m_drawOpacity; } void setVisible(bool value) { m_visible = value; } |