Changeset 69172 in webkit


Ignore:
Timestamp:
Oct 5, 2010 8:41:47 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2010-10-05 W. James MacLean <wjmaclean@chromium.org>

Reviewed by James Robinson.

[chromium] Add mipmap support for ImageLayerChromium
https://bugs.webkit.org/show_bug.cgi?id=46493

Mipmap behaviour can be tested with existing tests.
Tests in LayoutTests/compositing/images/ will detect if
mipmaps fail.

  • platform/graphics/chromium/ContentLayerChromium.cpp: (WebCore::ContentLayerChromium::SharedValues::SharedValues): (WebCore::isPowerOfTwo): (WebCore::ContentLayerChromium::updateTextureRect):
  • platform/graphics/chromium/ContentLayerChromium.h: (WebCore::ContentLayerChromium::SharedValues::npotSupported):
  • platform/graphics/chromium/ImageLayerChromium.cpp: (WebCore::ImageLayerChromium::updateContents):
Location:
trunk/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r69170 r69172  
     12010-10-05  W. James MacLean  <wjmaclean@chromium.org>
     2
     3        Reviewed by James Robinson.
     4
     5        [chromium] Add mipmap support for ImageLayerChromium
     6        https://bugs.webkit.org/show_bug.cgi?id=46493
     7
     8        Mipmap behaviour can be tested with existing tests.
     9        Tests in LayoutTests/compositing/images/ will detect if
     10        mipmaps fail.
     11
     12        * platform/graphics/chromium/ContentLayerChromium.cpp:
     13        (WebCore::ContentLayerChromium::SharedValues::SharedValues):
     14        (WebCore::isPowerOfTwo):
     15        (WebCore::ContentLayerChromium::updateTextureRect):
     16        * platform/graphics/chromium/ContentLayerChromium.h:
     17        (WebCore::ContentLayerChromium::SharedValues::npotSupported):
     18        * platform/graphics/chromium/ImageLayerChromium.cpp:
     19        (WebCore::ImageLayerChromium::updateContents):
     20
    1212010-10-05  Adam Barth  <abarth@webkit.org>
    222
  • trunk/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp

    r69166 r69172  
    5858    , m_shaderAlphaLocation(-1)
    5959    , m_initialized(false)
     60    , m_npotSupported(false)
    6061{
    6162    // Shaders for drawing the layer contents.
     
    104105    ASSERT(m_shaderAlphaLocation != -1);
    105106
     107    m_npotSupported = GLC(context, context->getString(GraphicsContext3D::EXTENSIONS).contains("GL_OES_texture_npot"));
     108
    106109    m_initialized = true;
    107110}
     
    240243}
    241244
    242 void ContentLayerChromium::updateTextureRect(void* pixels, const IntSize& bitmapSize, const IntSize& requiredTextureSize, const IntRect& updateRect, unsigned textureId)
     245static inline bool isPowerOfTwo(int x)
     246{
     247    ASSERT(x >= 0);
     248    return !(x & (x-1));
     249}
     250
     251void ContentLayerChromium::updateTextureRect(void* pixels, const IntSize& bitmapSize,
     252    const IntSize& requiredTextureSize, const IntRect& updateRect, unsigned textureId, MipmapUse requestMipmap)
    243253{
    244254    if (!pixels)
     
    247257    GraphicsContext3D* context = layerRendererContext();
    248258    context->bindTexture(GraphicsContext3D::TEXTURE_2D, textureId);
     259
     260    bool generateMipmap = (requestMipmap == useMipmap)
     261                          && (layerRenderer()->contentLayerSharedValues()->npotSupported()
     262                              || (isPowerOfTwo(updateRect.width()) && isPowerOfTwo(updateRect.height())));
    249263
    250264    // If the texture id or size changed since last time then we need to tell GL
     
    253267        ASSERT(bitmapSize == requiredTextureSize);
    254268        GLC(context, context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, requiredTextureSize.width(), requiredTextureSize.height(), 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, pixels));
     269        if (generateMipmap) {
     270            GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER,
     271                GraphicsContext3D::LINEAR_MIPMAP_LINEAR));
     272            GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER,
     273                GraphicsContext3D::LINEAR));
     274        } else {
     275            GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER,
     276                 GraphicsContext3D::LINEAR));
     277            GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER,
     278                GraphicsContext3D::LINEAR));
     279        }
    255280
    256281        m_contentsTexture = textureId;
     
    261286        GLC(context, context->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, updateRect.x(), updateRect.y(), updateRect.width(), updateRect.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, pixels));
    262287    }
     288
     289    if (generateMipmap)
     290        GLC(context, context->generateMipmap(GraphicsContext3D::TEXTURE_2D));
    263291
    264292    m_dirtyRect.setSize(FloatSize());
  • trunk/WebCore/platform/graphics/chromium/ContentLayerChromium.h

    r69166 r69172  
    6464        int shaderAlphaLocation() const { return m_shaderAlphaLocation; }
    6565        int initialized() const { return m_initialized; }
     66        bool npotSupported() const { return m_npotSupported; }
    6667
    6768    private:
     
    7273        int m_shaderAlphaLocation;
    7374        int m_initialized;
     75        bool m_npotSupported;
    7476    };
    7577
     
    7779    ContentLayerChromium(GraphicsLayerChromium* owner);
    7880
     81    enum MipmapUse {noMipmap, useMipmap};
     82
    7983    void updateTextureRect(void* pixels, const IntSize& bitmapSize, const IntSize& requiredTextureSize,
    80                            const IntRect& updateRect, unsigned textureId);
     84                           const IntRect& updateRect, unsigned textureId, MipmapUse generateMipmap = noMipmap);
    8185
    8286    virtual void cleanupResources();
  • trunk/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp

    r67714 r69172  
    153153
    154154    if (pixels)
    155         updateTextureRect(pixels, bitmapSize, requiredTextureSize,  dirtyRect, textureId);
     155        updateTextureRect(pixels, bitmapSize, requiredTextureSize,  dirtyRect, textureId, useMipmap);
    156156}
    157157
Note: See TracChangeset for help on using the changeset viewer.