Changeset 140595 in webkit


Ignore:
Timestamp:
Jan 23, 2013 2:26:38 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Avoid unnecessary format conversion for tex{Sub}Image2D() for ImageData of WebGL
https://bugs.webkit.org/show_bug.cgi?id=107532

Patch by Jun Jiang <jun.a.jiang@intel.com> on 2013-01-23
Reviewed by Kenneth Russell.

This patch removes the unnecessary format conversion in tex{Sub}Image2D() for ImageData in WebGL to improve performance.

Already covered by current tests.

  • html/canvas/WebGLRenderingContext.cpp:

(WebCore):
(WebCore::WebGLRenderingContext::texImage2D):
(WebCore::WebGLRenderingContext::texSubImage2D):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r140593 r140595  
     12013-01-23  Jun Jiang  <jun.a.jiang@intel.com>
     2
     3        Avoid unnecessary format conversion for tex{Sub}Image2D() for ImageData of WebGL
     4        https://bugs.webkit.org/show_bug.cgi?id=107532
     5
     6        Reviewed by Kenneth Russell.
     7
     8        This patch removes the unnecessary format conversion in tex{Sub}Image2D() for ImageData in WebGL to improve performance.
     9
     10        Already covered by current tests.
     11
     12        * html/canvas/WebGLRenderingContext.cpp:
     13        (WebCore):
     14        (WebCore::WebGLRenderingContext::texImage2D):
     15        (WebCore::WebGLRenderingContext::texSubImage2D):
     16
    1172013-01-23  Xianzhu Wang  <wangxianzhu@chromium.org>
    218
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp

    r140497 r140595  
    37013701        return;
    37023702    Vector<uint8_t> data;
    3703     if (!m_context->extractImageData(pixels, format, type, m_unpackFlipY, m_unpackPremultiplyAlpha, data)) {
    3704         synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texImage2D", "bad image data");
    3705         return;
     3703    if (!pixels)
     3704        return;
     3705    bool needConversion = true;
     3706    // The data from ImageData is always of format RGBA8.
     3707    // No conversion is needed if destination format is RGBA and type is USIGNED_BYTE and no Flip or Premultiply operation is required.
     3708    if (!m_unpackFlipY && !m_unpackPremultiplyAlpha && format == GraphicsContext3D::RGBA && type == GraphicsContext3D::UNSIGNED_BYTE)
     3709        needConversion = false;
     3710    else {
     3711        if (!m_context->extractImageData(pixels, format, type, m_unpackFlipY, m_unpackPremultiplyAlpha, data)) {
     3712            synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texImage2D", "bad image data");
     3713            return;
     3714        }
    37063715    }
    37073716    if (m_unpackAlignment != 1)
    37083717        m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1);
    3709     texImage2DBase(target, level, internalformat, pixels->width(), pixels->height(), 0,
    3710                    format, type, data.data(), ec);
     3718    texImage2DBase(target, level, internalformat, pixels->width(), pixels->height(), 0, format, type, needConversion ? data.data() : pixels->data()->data(), ec);
    37113719    if (m_unpackAlignment != 1)
    37123720        m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment);
     
    39433951    if (isContextLost())
    39443952        return;
     3953    if (!pixels)
     3954        return;
    39453955    Vector<uint8_t> data;
    3946     if (!m_context->extractImageData(pixels, format, type, m_unpackFlipY, m_unpackPremultiplyAlpha, data)) {
    3947         synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texSubImage2D", "bad image data");
    3948         return;
     3956    bool needConversion = true;
     3957    // The data from ImageData is always of format RGBA8.
     3958    // No conversion is needed if destination format is RGBA and type is USIGNED_BYTE and no Flip or Premultiply operation is required.
     3959    if (format == GraphicsContext3D::RGBA && type == GraphicsContext3D::UNSIGNED_BYTE && !m_unpackFlipY && !m_unpackPremultiplyAlpha)
     3960        needConversion = false;
     3961    else {
     3962        if (!m_context->extractImageData(pixels, format, type, m_unpackFlipY, m_unpackPremultiplyAlpha, data)) {
     3963            synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texSubImage2D", "bad image data");
     3964            return;
     3965        }
    39493966    }
    39503967    if (m_unpackAlignment != 1)
    39513968        m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1);
    3952     texSubImage2DBase(target, level, xoffset, yoffset, pixels->width(), pixels->height(),
    3953                       format, type, data.data(), ec);
     3969    texSubImage2DBase(target, level, xoffset, yoffset, pixels->width(), pixels->height(), format, type, needConversion ? data.data() : pixels->data()->data(), ec);
    39543970    if (m_unpackAlignment != 1)
    39553971        m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment);
Note: See TracChangeset for help on using the changeset viewer.