Changeset 158798 in webkit


Ignore:
Timestamp:
Nov 6, 2013, 3:08:56 PM (12 years ago)
Author:
Brent Fulgham
Message:

[WebGL] We should not allow generateMipMap on compressed textures
https://bugs.webkit.org/show_bug.cgi?id=123915
<rdar://problem/15201274>

Reviewed by Dean Jackson.

Found by existing conformance/extensions/webgl-compressed-texture-s3tc.html

  • html/canvas/WebGLRenderingContext.cpp:

(WebCore::WebGLRenderingContext::compressedTexImage2D): Set compressed flag.
(WebCore::WebGLRenderingContext::compressedTexSubImage2D): Ditto.
(WebCore::WebGLRenderingContext::generateMipmap): For Apple builds, check state
of compressed flag and generate appropriate WebGL error if necessary.

  • html/canvas/WebGLTexture.cpp:

(WebCore::WebGLTexture::WebGLTexture): Set compressed flag to false by default
(WebCore::WebGLTexture::isCompressed): Added
(WebCore::WebGLTexture::setCompressed): Added

  • html/canvas/WebGLTexture.h:
  • platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:

(WebCore::GraphicsContext3D::generateMipmap): Switch implementation to use proper
glGenerateMipmaps, rather than the glGenerateMipmapsEXT method.

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r158796 r158798  
     12013-11-06  Brent Fulgham  <bfulgham@apple.com>
     2
     3        [WebGL] We should not allow generateMipMap on compressed textures
     4        https://bugs.webkit.org/show_bug.cgi?id=123915
     5        <rdar://problem/15201274>
     6
     7        Reviewed by Dean Jackson.
     8
     9        Found by existing conformance/extensions/webgl-compressed-texture-s3tc.html
     10
     11        * html/canvas/WebGLRenderingContext.cpp:
     12        (WebCore::WebGLRenderingContext::compressedTexImage2D): Set compressed flag.
     13        (WebCore::WebGLRenderingContext::compressedTexSubImage2D): Ditto.
     14        (WebCore::WebGLRenderingContext::generateMipmap): For Apple builds, check state
     15        of compressed flag and generate appropriate WebGL error if necessary.
     16        * html/canvas/WebGLTexture.cpp:
     17        (WebCore::WebGLTexture::WebGLTexture): Set compressed flag to false by default
     18        (WebCore::WebGLTexture::isCompressed): Added
     19        (WebCore::WebGLTexture::setCompressed): Added
     20        * html/canvas/WebGLTexture.h:
     21        * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
     22        (WebCore::GraphicsContext3D::generateMipmap): Switch implementation to use proper
     23        glGenerateMipmaps, rather than the glGenerateMipmapsEXT method.
     24
    1252013-11-06  Joseph Pecoraro  <pecoraro@apple.com>
    226
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp

    r157971 r158798  
    13411341                                              border, data->byteLength(), data->baseAddress());
    13421342    tex->setLevelInfo(target, level, internalformat, width, height, GraphicsContext3D::UNSIGNED_BYTE);
     1343    tex->setCompressed();
    13431344    cleanupAfterGraphicsCall(false);
    13441345}
     
    13721373    graphicsContext3D()->compressedTexSubImage2D(target, level, xoffset, yoffset,
    13731374                                                 width, height, format, data->byteLength(), data->baseAddress());
     1375    tex->setCompressed();
    13741376    cleanupAfterGraphicsCall(false);
    13751377}
     
    22212223    if (!tex->canGenerateMipmaps()) {
    22222224        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "generateMipmap", "level 0 not power of 2 or not all the same size");
     2225        return;
     2226    }
     2227    // FIXME: https://bugs.webkit.org/show_bug.cgi?id=123916. Compressed textures should be allowed in WebGL 2:
     2228    if (tex->isCompressed()) {
     2229        synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "generateMipmap", "trying to generate mipmaps from compressed texture");
    22232230        return;
    22242231    }
  • trunk/Source/WebCore/html/canvas/WebGLTexture.cpp

    r145669 r158798  
    5151    , m_isComplete(false)
    5252    , m_needToUseBlackTexture(false)
     53    , m_isCompressed(false)
    5354{
    5455    setObject(ctx->graphicsContext3D()->createTexture());
     
    240241}
    241242
     243bool WebGLTexture::isCompressed() const
     244{
     245    if (!object())
     246        return false;
     247    return m_isCompressed;
     248}
     249
     250void WebGLTexture::setCompressed()
     251{
     252    ASSERT(object());
     253    m_isCompressed = true;
     254}
     255   
    242256void WebGLTexture::deleteObjectImpl(GraphicsContext3D* context3d, Platform3DObject object)
    243257{
  • trunk/Source/WebCore/html/canvas/WebGLTexture.h

    r157653 r158798  
    6767    bool needToUseBlackTexture() const;
    6868
     69    bool isCompressed() const;
     70    void setCompressed();
     71
    6972    bool hasEverBeenBound() const { return object() && m_target; }
    7073
     
    124127    bool m_isComplete;
    125128    bool m_needToUseBlackTexture;
     129    bool m_isCompressed;
    126130};
    127131
  • trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp

    r156795 r158798  
    666666{
    667667    makeContextCurrent();
    668     ::glGenerateMipmapEXT(target);
     668    ::glGenerateMipmap(target);
    669669}
    670670
Note: See TracChangeset for help on using the changeset viewer.