GraphicsSurface: Canvas with WebGL content is painted off by one pixel
authorzeno.albisser@digia.com <zeno.albisser@digia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Jan 2013 15:41:34 +0000 (15:41 +0000)
committerzeno.albisser@digia.com <zeno.albisser@digia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Jan 2013 15:41:34 +0000 (15:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=106446

When painting to TextureMapper the provided targetRect is in contents
coordinate system. This leads to an off by one pixel error when painting
outlines of 1px.
This needs to be taken into account in the transformation matrix
and in the TextureMapperGL::drawTexture call.

Test: fast/canvas/webgl/webgl-composite-modes.html

Reviewed by Noam Rosenthal.

* platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp:
(WebCore::GraphicsSurface::platformPaintToTextureMapper):
* platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp:
(WebCore::GraphicsSurface::platformPaintToTextureMapper):
* platform/graphics/surfaces/win/GraphicsSurfaceWin.cpp:
(WebCore::GraphicsSurface::platformPaintToTextureMapper):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@139738 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp
Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp
Source/WebCore/platform/graphics/surfaces/win/GraphicsSurfaceWin.cpp

index 154ab64..12f86c4 100644 (file)
@@ -1,3 +1,25 @@
+2013-01-15  Zeno Albisser  <zeno@webkit.org>
+
+        GraphicsSurface: Canvas with WebGL content is painted off by one pixel
+        https://bugs.webkit.org/show_bug.cgi?id=106446
+
+        When painting to TextureMapper the provided targetRect is in contents
+        coordinate system. This leads to an off by one pixel error when painting
+        outlines of 1px.
+        This needs to be taken into account in the transformation matrix
+        and in the TextureMapperGL::drawTexture call.
+
+        Test: fast/canvas/webgl/webgl-composite-modes.html
+
+        Reviewed by Noam Rosenthal.
+
+        * platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp:
+        (WebCore::GraphicsSurface::platformPaintToTextureMapper):
+        * platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp:
+        (WebCore::GraphicsSurface::platformPaintToTextureMapper):
+        * platform/graphics/surfaces/win/GraphicsSurfaceWin.cpp:
+        (WebCore::GraphicsSurface::platformPaintToTextureMapper):
+
 2013-01-14  Kentaro Hara  <haraken@chromium.org>
 
         [V8] Make an Isolate parameter mandatory in SerializedScriptValue methods
index 22f6b19..d3463e8 100644 (file)
@@ -515,18 +515,20 @@ void GraphicsSurface::platformCopyFromTexture(uint32_t texture, const IntRect& s
 
 void GraphicsSurface::platformPaintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
 {
-    TextureMapperGL* texMapGL = static_cast<TextureMapperGL*>(textureMapper);
     IntSize size = m_private->size();
     if (size.isEmpty())
         return;
     uint32_t texture = platformGetTextureID();
     if (!texture)
         return;
-    TransformationMatrix adjustedTransform = transform;
-    adjustedTransform.multiply(TransformationMatrix::rectToRect(FloatRect(FloatPoint::zero(), size), targetRect));
+
     TextureMapperGL::Flags flags = m_private->textureIsYInverted() ? TextureMapperGL::ShouldFlipTexture : 0;
     flags |= TextureMapperGL::ShouldBlend;
-    texMapGL->drawTexture(texture, flags, size, targetRect, adjustedTransform, opacity, mask);
+
+    FloatRect rectOnContents(FloatPoint::zero(), size);
+    TransformationMatrix adjustedTransform = transform;
+    adjustedTransform.multiply(TransformationMatrix::rectToRect(rectOnContents, targetRect));
+    static_cast<TextureMapperGL*>(textureMapper)->drawTexture(texture, flags, size, rectOnContents, adjustedTransform, opacity, mask);
 }
 
 uint32_t GraphicsSurface::platformFrontBuffer() const
index 0e0e7b5..bf62fb1 100644 (file)
@@ -335,9 +335,11 @@ void GraphicsSurface::platformCopyFromTexture(uint32_t texture, const IntRect& s
 
 void GraphicsSurface::platformPaintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
 {
+    IntSize size = m_private->size();
+    FloatRect rectOnContents(FloatPoint::zero(), size);
     TransformationMatrix adjustedTransform = transform;
-    adjustedTransform.multiply(TransformationMatrix::rectToRect(FloatRect(FloatPoint::zero(), m_private->size()), targetRect));
-    static_cast<TextureMapperGL*>(textureMapper)->drawTexture(m_private->frontBufferTextureID(), TextureMapperGL::ShouldBlend | TextureMapperGL::ShouldUseARBTextureRect, m_private->size(), targetRect, adjustedTransform, opacity, mask);
+    adjustedTransform.multiply(TransformationMatrix::rectToRect(rectOnContents, targetRect));
+    static_cast<TextureMapperGL*>(textureMapper)->drawTexture(m_private->frontBufferTextureID(), TextureMapperGL::ShouldBlend | TextureMapperGL::ShouldUseARBTextureRect, size, rectOnContents, adjustedTransform, opacity, mask);
 }
 
 uint32_t GraphicsSurface::platformFrontBuffer() const
index b8586ac..9509f09 100644 (file)
@@ -423,11 +423,11 @@ void GraphicsSurface::platformCopyFromTexture(uint32_t texture, const IntRect& s
 
 void GraphicsSurface::platformPaintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
 {
-    GLuint frontBufferTexture = platformGetTextureID();
-
+    IntSize size = m_private->size();
+    FloatRect rectOnContents(FloatPoint::zero(), size);
     TransformationMatrix adjustedTransform = transform;
-    adjustedTransform.multiply(TransformationMatrix::rectToRect(FloatRect(FloatPoint::zero(), m_private->size()), targetRect));
-    static_cast<TextureMapperGL*>(textureMapper)->drawTexture(frontBufferTexture, 0, m_private->size(), targetRect, adjustedTransform, opacity, mask);
+    adjustedTransform.multiply(TransformationMatrix::rectToRect(rectOnContents, targetRect));
+    static_cast<TextureMapperGL*>(textureMapper)->drawTexture(platformGetTextureID(), 0, size, rectOnContents, adjustedTransform, opacity, mask);
 }
 
 uint32_t GraphicsSurface::platformFrontBuffer() const