Changeset 55283 in webkit


Ignore:
Timestamp:
Feb 26, 2010 7:48:59 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-02-26 Zhenyao Mo <zmo@google.com>

Reviewed by David Levin.

texImage2D and texSubImage2D taking ImageData ignore flipY and premultiplyAlpha
https://bugs.webkit.org/show_bug.cgi?id=34459

  • fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data-expected.txt: Added.
  • fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data.html: Added.

2010-02-26 Zhenyao Mo <zmo@google.com>

Reviewed by David Levin.

texImage2D and texSubImage2D taking ImageData ignore flipY and premultiplyAlpha
https://bugs.webkit.org/show_bug.cgi?id=34459

Test: fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data.html

  • html/canvas/WebGLRenderingContext.cpp: (WebCore::WebGLRenderingContext::texImage2D): Apply flipY and premultiplyAlpha to the texture data. (WebCore::WebGLRenderingContext::texSubImage2D): Ditto.
  • platform/graphics/GraphicsContext3D.cpp: (WebCore::GraphicsContext3D::extractImageData): Extract data from ImageData, applying flipY and premultiplyAlpha.
  • platform/graphics/GraphicsContext3D.h: Add function extractImageData declaration.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r55282 r55283  
     12010-02-26  Zhenyao Mo  <zmo@google.com>
     2
     3        Reviewed by David Levin.
     4
     5        texImage2D and texSubImage2D taking ImageData ignore flipY and premultiplyAlpha
     6        https://bugs.webkit.org/show_bug.cgi?id=34459
     7
     8        * fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data-expected.txt: Added.
     9        * fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data.html: Added.
     10
    1112010-02-26  Zhenyao Mo  <zmo@google.com>
    212
  • trunk/WebCore/ChangeLog

    r55282 r55283  
     12010-02-26  Zhenyao Mo  <zmo@google.com>
     2
     3        Reviewed by David Levin.
     4
     5        texImage2D and texSubImage2D taking ImageData ignore flipY and premultiplyAlpha
     6        https://bugs.webkit.org/show_bug.cgi?id=34459
     7
     8        Test: fast/canvas/webgl/tex-image-and-sub-image-2d-with-image-data.html
     9
     10        * html/canvas/WebGLRenderingContext.cpp:
     11        (WebCore::WebGLRenderingContext::texImage2D): Apply flipY and premultiplyAlpha to the texture data.
     12        (WebCore::WebGLRenderingContext::texSubImage2D): Ditto.
     13        * platform/graphics/GraphicsContext3D.cpp:
     14        (WebCore::GraphicsContext3D::extractImageData): Extract data from ImageData, applying flipY and premultiplyAlpha.
     15        * platform/graphics/GraphicsContext3D.h: Add function extractImageData declaration.
     16
    1172010-02-26  Zhenyao Mo  <zmo@google.com>
    218
  • trunk/WebCore/html/canvas/WebGLRenderingContext.cpp

    r55282 r55283  
    16361636{
    16371637    // FIXME: For now we ignore any errors returned
    1638     // FIXME: Need a form of this call that can take both a pixel buffer and flipY and premultiplyAlpha flags
    1639     UNUSED_PARAM(flipY);
    1640     UNUSED_PARAM(premultiplyAlpha);
    16411638    ec = 0;
    1642     m_context->texImage2D(target, level, GraphicsContext3D::RGBA, pixels->width(), pixels->height(), 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, pixels->data()->data()->data());
    1643     //RLP: m_context->texImage2D(target, level, pixels, flipY, premultiplyAlpha);
     1639    Vector<uint8_t> data;
     1640    m_context->extractImageData(pixels, flipY, premultiplyAlpha, data);
     1641    m_context->texImage2D(target, level, GraphicsContext3D::RGBA, pixels->width(), pixels->height(), 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, data.data());
    16441642    cleanupAfterGraphicsCall(false);
    16451643}
     
    17261724{
    17271725    // FIXME: For now we ignore any errors returned
    1728     UNUSED_PARAM(flipY);
    1729     UNUSED_PARAM(premultiplyAlpha);
    17301726    ec = 0;
    1731     m_context->texSubImage2D(target, level, xoffset, yoffset, pixels->width(), pixels->height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, pixels->data()->data()->data());
    1732     //RLP: m_context->texSubImage2D(target, level, xoffset, yoffset, pixels, flipY, premultiplyAlpha);
     1727    Vector<uint8_t> data;
     1728    m_context->extractImageData(pixels, flipY, premultiplyAlpha, data);
     1729    m_context->texSubImage2D(target, level, xoffset, yoffset, pixels->width(), pixels->height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, data.data());
    17331730    cleanupAfterGraphicsCall(false);
    17341731}
  • trunk/WebCore/platform/graphics/GraphicsContext3D.cpp

    r54907 r55283  
    3232
    3333#include "Image.h"
     34#include "ImageData.h"
    3435
    3536namespace WebCore {
     
    5556                     alphaOp);
    5657    *internalFormat = (hasAlphaChannel ? RGBA : RGB);
     58    return true;
     59}
     60
     61bool GraphicsContext3D::extractImageData(ImageData* imageData,
     62                                         bool flipY,
     63                                         bool premultiplyAlpha,
     64                                         Vector<uint8_t>& data)
     65{
     66    if (!imageData)
     67        return false;
     68    int width = imageData->width();
     69    int height = imageData->height();
     70    int dataBytes = width * height * 4;
     71    data.resize(dataBytes);
     72    uint8_t* dst = data.data();
     73    uint8_t* src = imageData->data()->data()->data();
     74    memcpy(dst, src, dataBytes);
     75    processImageData(dst,
     76                     width,
     77                     height,
     78                     flipY,
     79                     premultiplyAlpha ? kAlphaDoPremultiply : kAlphaDoNothing);
    5780    return true;
    5881}
  • trunk/WebCore/platform/graphics/GraphicsContext3D.h

    r55235 r55283  
    7373    class WebGLTexture;
    7474    class Image;
     75    class ImageData;
    7576
    7677    struct ActiveInfo {
     
    446447                              unsigned int* internalFormat);
    447448
     449        // Extracts the contents of the given ImageData into the passed
     450        // Vector, obeying the flipY and premultiplyAlpha flags.
     451        // Returns true upon success.
     452        bool extractImageData(ImageData*,
     453                              bool flipY,
     454                              bool premultiplyAlpha,
     455                              Vector<uint8_t>& data);
     456
    448457        // Processes the given image data in preparation for uploading
    449458        // via texImage2D or texSubImage2D. The input data must be in
Note: See TracChangeset for help on using the changeset viewer.