summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/graphics/android/rendering
diff options
context:
space:
mode:
authorChris Craik <ccraik@google.com>2012-05-15 12:54:51 -0700
committerChris Craik <ccraik@google.com>2012-05-15 13:35:27 -0700
commitbeeb1d657b9aae3dc30bdc5cb06570b982261bb8 (patch)
treeadbf660a7799372fd4365a193410b4ff096dfbd8 /Source/WebCore/platform/graphics/android/rendering
parent8001929cfbff025063aab7bd129277b24cf3a9ff (diff)
downloadexternal_webkit-beeb1d657b9aae3dc30bdc5cb06570b982261bb8.zip
external_webkit-beeb1d657b9aae3dc30bdc5cb06570b982261bb8.tar.gz
external_webkit-beeb1d657b9aae3dc30bdc5cb06570b982261bb8.tar.bz2
Account for image scaling in calculating ImageTexture visible area
bug:6494473 Change-Id: I03e72faa0815337b46930dbaeb9062c057aa1e2a
Diffstat (limited to 'Source/WebCore/platform/graphics/android/rendering')
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp35
-rw-r--r--Source/WebCore/platform/graphics/android/rendering/ImageTexture.h1
2 files changed, 33 insertions, 3 deletions
diff --git a/Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp b/Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp
index 2819baa..6ff71d9 100644
--- a/Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp
@@ -198,11 +198,12 @@ const TransformationMatrix* ImageTexture::transform()
if (!m_layer)
return 0;
- IntRect layerArea = m_layer->fullContentArea();
- float scaleW = static_cast<float>(layerArea.width()) / static_cast<float>(m_image->width());
- float scaleH = static_cast<float>(layerArea.height()) / static_cast<float>(m_image->height());
TransformationMatrix d = *(m_layer->drawTransform());
TransformationMatrix m;
+ float scaleW = 1.0f;
+ float scaleH = 1.0f;
+ getImageToLayerScale(&scaleW, &scaleH);
+
m.scaleNonUniform(scaleW, scaleH);
m_layerMatrix = d.multiply(m);
return &m_layerMatrix;
@@ -228,6 +229,24 @@ bool ImageTexture::paint(SkCanvas* canvas)
return true;
}
+void ImageTexture::getImageToLayerScale(float* scaleW, float* scaleH) const
+{
+ if (!scaleW || !scaleH)
+ return;
+
+
+ IntRect layerArea = m_layer->fullContentArea();
+
+ if (layerArea.width() == 0 || layerArea.height() == 0)
+ return;
+
+ // calculate X, Y scale difference between image pixel coordinates and layer
+ // content coordinates
+
+ *scaleW = static_cast<float>(layerArea.width()) / static_cast<float>(m_image->width());
+ *scaleH = static_cast<float>(layerArea.height()) / static_cast<float>(m_image->height());
+}
+
void ImageTexture::drawGL(LayerAndroid* layer,
float opacity, FloatPoint* offset)
{
@@ -242,6 +261,16 @@ void ImageTexture::drawGL(LayerAndroid* layer,
if (m_tileGrid) {
bool force3dContentVisible = true;
IntRect visibleContentArea = m_layer->visibleContentArea(force3dContentVisible);
+
+ // transform visibleContentArea size to image size
+ float scaleW = 1.0f;
+ float scaleH = 1.0f;
+ getImageToLayerScale(&scaleW, &scaleH);
+ visibleContentArea.setX(visibleContentArea.x() / scaleW);
+ visibleContentArea.setWidth(visibleContentArea.width() / scaleW);
+ visibleContentArea.setY(visibleContentArea.y() / scaleH);
+ visibleContentArea.setHeight(visibleContentArea.height() / scaleH);
+
const TransformationMatrix* transformation = transform();
if (offset)
m_layerMatrix.translate(offset->x(), offset->y());
diff --git a/Source/WebCore/platform/graphics/android/rendering/ImageTexture.h b/Source/WebCore/platform/graphics/android/rendering/ImageTexture.h
index 0571b83..99bec90 100644
--- a/Source/WebCore/platform/graphics/android/rendering/ImageTexture.h
+++ b/Source/WebCore/platform/graphics/android/rendering/ImageTexture.h
@@ -95,6 +95,7 @@ public:
private:
const TransformationMatrix* transform();
+ void getImageToLayerScale(float* scaleW, float* scaleH) const;
SkBitmapRef* m_imageRef;
SkBitmap* m_image;