Changeset 139738 in webkit


Ignore:
Timestamp:
Jan 15, 2013 7:41:34 AM (11 years ago)
Author:
zeno.albisser@digia.com
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):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r139735 r139738  
     12013-01-15  Zeno Albisser  <zeno@webkit.org>
     2
     3        GraphicsSurface: Canvas with WebGL content is painted off by one pixel
     4        https://bugs.webkit.org/show_bug.cgi?id=106446
     5
     6        When painting to TextureMapper the provided targetRect is in contents
     7        coordinate system. This leads to an off by one pixel error when painting
     8        outlines of 1px.
     9        This needs to be taken into account in the transformation matrix
     10        and in the TextureMapperGL::drawTexture call.
     11
     12        Test: fast/canvas/webgl/webgl-composite-modes.html
     13
     14        Reviewed by Noam Rosenthal.
     15
     16        * platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp:
     17        (WebCore::GraphicsSurface::platformPaintToTextureMapper):
     18        * platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp:
     19        (WebCore::GraphicsSurface::platformPaintToTextureMapper):
     20        * platform/graphics/surfaces/win/GraphicsSurfaceWin.cpp:
     21        (WebCore::GraphicsSurface::platformPaintToTextureMapper):
     22
    1232013-01-14  Kentaro Hara  <haraken@chromium.org>
    224
  • trunk/Source/WebCore/platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp

    r139725 r139738  
    516516void GraphicsSurface::platformPaintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
    517517{
    518     TextureMapperGL* texMapGL = static_cast<TextureMapperGL*>(textureMapper);
    519518    IntSize size = m_private->size();
    520519    if (size.isEmpty())
     
    523522    if (!texture)
    524523        return;
    525     TransformationMatrix adjustedTransform = transform;
    526     adjustedTransform.multiply(TransformationMatrix::rectToRect(FloatRect(FloatPoint::zero(), size), targetRect));
     524
    527525    TextureMapperGL::Flags flags = m_private->textureIsYInverted() ? TextureMapperGL::ShouldFlipTexture : 0;
    528526    flags |= TextureMapperGL::ShouldBlend;
    529     texMapGL->drawTexture(texture, flags, size, targetRect, adjustedTransform, opacity, mask);
     527
     528    FloatRect rectOnContents(FloatPoint::zero(), size);
     529    TransformationMatrix adjustedTransform = transform;
     530    adjustedTransform.multiply(TransformationMatrix::rectToRect(rectOnContents, targetRect));
     531    static_cast<TextureMapperGL*>(textureMapper)->drawTexture(texture, flags, size, rectOnContents, adjustedTransform, opacity, mask);
    530532}
    531533
  • trunk/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp

    r139182 r139738  
    336336void GraphicsSurface::platformPaintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
    337337{
     338    IntSize size = m_private->size();
     339    FloatRect rectOnContents(FloatPoint::zero(), size);
    338340    TransformationMatrix adjustedTransform = transform;
    339     adjustedTransform.multiply(TransformationMatrix::rectToRect(FloatRect(FloatPoint::zero(), m_private->size()), targetRect));
    340     static_cast<TextureMapperGL*>(textureMapper)->drawTexture(m_private->frontBufferTextureID(), TextureMapperGL::ShouldBlend | TextureMapperGL::ShouldUseARBTextureRect, m_private->size(), targetRect, adjustedTransform, opacity, mask);
     341    adjustedTransform.multiply(TransformationMatrix::rectToRect(rectOnContents, targetRect));
     342    static_cast<TextureMapperGL*>(textureMapper)->drawTexture(m_private->frontBufferTextureID(), TextureMapperGL::ShouldBlend | TextureMapperGL::ShouldUseARBTextureRect, size, rectOnContents, adjustedTransform, opacity, mask);
    341343}
    342344
  • trunk/Source/WebCore/platform/graphics/surfaces/win/GraphicsSurfaceWin.cpp

    r135715 r139738  
    424424void GraphicsSurface::platformPaintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
    425425{
    426     GLuint frontBufferTexture = platformGetTextureID();
    427 
     426    IntSize size = m_private->size();
     427    FloatRect rectOnContents(FloatPoint::zero(), size);
    428428    TransformationMatrix adjustedTransform = transform;
    429     adjustedTransform.multiply(TransformationMatrix::rectToRect(FloatRect(FloatPoint::zero(), m_private->size()), targetRect));
    430     static_cast<TextureMapperGL*>(textureMapper)->drawTexture(frontBufferTexture, 0, m_private->size(), targetRect, adjustedTransform, opacity, mask);
     429    adjustedTransform.multiply(TransformationMatrix::rectToRect(rectOnContents, targetRect));
     430    static_cast<TextureMapperGL*>(textureMapper)->drawTexture(platformGetTextureID(), 0, size, rectOnContents, adjustedTransform, opacity, mask);
    431431}
    432432
Note: See TracChangeset for help on using the changeset viewer.