Title: [139738] trunk/Source/WebCore
Revision
139738
Author
[email protected]
Date
2013-01-15 07:41:34 -0800 (Tue, 15 Jan 2013)

Log Message

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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (139737 => 139738)


--- trunk/Source/WebCore/ChangeLog	2013-01-15 15:12:11 UTC (rev 139737)
+++ trunk/Source/WebCore/ChangeLog	2013-01-15 15:41:34 UTC (rev 139738)
@@ -1,3 +1,25 @@
+2013-01-15  Zeno Albisser  <[email protected]>
+
+        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  <[email protected]>
 
         [V8] Make an Isolate parameter mandatory in SerializedScriptValue methods

Modified: trunk/Source/WebCore/platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp (139737 => 139738)


--- trunk/Source/WebCore/platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp	2013-01-15 15:12:11 UTC (rev 139737)
+++ trunk/Source/WebCore/platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp	2013-01-15 15:41:34 UTC (rev 139738)
@@ -515,18 +515,20 @@
 
 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

Modified: trunk/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp (139737 => 139738)


--- trunk/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp	2013-01-15 15:12:11 UTC (rev 139737)
+++ trunk/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp	2013-01-15 15:41:34 UTC (rev 139738)
@@ -335,9 +335,11 @@
 
 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

Modified: trunk/Source/WebCore/platform/graphics/surfaces/win/GraphicsSurfaceWin.cpp (139737 => 139738)


--- trunk/Source/WebCore/platform/graphics/surfaces/win/GraphicsSurfaceWin.cpp	2013-01-15 15:12:11 UTC (rev 139737)
+++ trunk/Source/WebCore/platform/graphics/surfaces/win/GraphicsSurfaceWin.cpp	2013-01-15 15:41:34 UTC (rev 139738)
@@ -423,11 +423,11 @@
 
 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
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to