Changeset 86301 in webkit


Ignore:
Timestamp:
May 11, 2011 7:16:38 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-05-11 Nat Duca <nduca@chromium.org>

Reviewed by James Robinson.

[chromium] Use mapTexSubImage2D for tile uploads if available
https://bugs.webkit.org/show_bug.cgi?id=60008

  • platform/graphics/chromium/LayerTilerChromium.cpp: (WebCore::LayerTilerChromium::LayerTilerChromium): (WebCore::LayerTilerChromium::update): (WebCore::LayerTilerChromium::updateFromPixels):
  • platform/graphics/chromium/LayerTilerChromium.h:
Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r86299 r86301  
     12011-05-11  Nat Duca  <nduca@chromium.org>
     2
     3        Reviewed by James Robinson.
     4
     5        [chromium] Use mapTexSubImage2D for tile uploads if available
     6        https://bugs.webkit.org/show_bug.cgi?id=60008
     7
     8        * platform/graphics/chromium/LayerTilerChromium.cpp:
     9        (WebCore::LayerTilerChromium::LayerTilerChromium):
     10        (WebCore::LayerTilerChromium::update):
     11        (WebCore::LayerTilerChromium::updateFromPixels):
     12        * platform/graphics/chromium/LayerTilerChromium.h:
     13
    1142011-05-11  Alexis Menard  <alexis.menard@openbossa.org>
    215
  • trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp

    r86278 r86301  
    122122{
    123123    m_contextSupportsLatch = m_context->getExtensions()->supports("GL_CHROMIUM_latch");
     124    m_contextSupportsMapSub = m_context->getExtensions()->supports("GL_CHROMIUM_map_sub");
     125    if (m_contextSupportsMapSub)
     126        m_context->getExtensions()->ensureEnabled("GL_CHROMIUM_map_sub");
    124127    m_hardwareCompositing = initializeSharedObjects();
    125128    m_rootLayerContentTiler = LayerTilerChromium::create(this, IntSize(256, 256), LayerTilerChromium::NoBorderTexels);
  • trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h

    r86278 r86301  
    7474
    7575    GraphicsContext3D* context();
     76    bool contextSupportsMapSub() const { return m_contextSupportsMapSub; }
    7677
    7778    void invalidateRootLayerRect(const IntRect& dirtyRect);
     
    241242
    242243    bool m_contextSupportsLatch;
     244    bool m_contextSupportsMapSub;
    243245
    244246    bool m_animating;
  • trunk/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.cpp

    r85716 r86301  
    3131#include "LayerTilerChromium.h"
    3232
     33#include "Extensions3DChromium.h"
    3334#include "GraphicsContext.h"
    3435#include "GraphicsContext3D.h"
     
    5455    : m_skipsDraw(false)
    5556    , m_tilingData(max(tileSize.width(), tileSize.height()), 0, 0, border == HasBorderTexels)
     57    , m_useMapSubForUploads(layerRenderer->contextSupportsMapSub())
    5658    , m_layerRenderer(layerRenderer)
    5759{
     
    8587
    8688    m_tileSize = size;
    87     m_tilePixels = adoptArrayPtr(new uint8_t[m_tileSize.width() * m_tileSize.height() * 4]);
     89    if (!m_useMapSubForUploads)
     90        m_tilePixels = adoptArrayPtr(new uint8_t[m_tileSize.width() * m_tileSize.height() * 4]);
    8891    m_tilingData.setMaxTextureSize(max(size.width(), size.height()));
    8992}
     
    342345                CRASH();
    343346
    344             const uint8_t* pixelSource;
    345             if (paintRect.width() == sourceRect.width() && !paintOffset.x())
    346                 pixelSource = &paintPixels[4 * paintOffset.y() * paintRect.width()];
    347             else {
    348                 // Strides not equal, so do a row-by-row memcpy from the
    349                 // paint results into a temp buffer for uploading.
    350                 for (int row = 0; row < destRect.height(); ++row)
    351                     memcpy(&m_tilePixels[destRect.width() * 4 * row],
    352                            &paintPixels[4 * (paintOffset.x() + (paintOffset.y() + row) * paintRect.width())],
    353                            destRect.width() * 4);
    354 
    355                 pixelSource = &m_tilePixels[0];
    356             }
    357 
    358             tile->texture()->bindTexture();
    359 
    360347            const GC3Dint filter = m_tilingData.borderTexels() ? GraphicsContext3D::LINEAR : GraphicsContext3D::NEAREST;
    361348            GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, filter));
    362349            GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, filter));
    363350
    364             GLC(context, context->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, destRect.x(), destRect.y(), destRect.width(), destRect.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, pixelSource));
     351            tile->texture()->bindTexture();
     352
     353            if (m_useMapSubForUploads) {
     354                // Upload tile data via a mapped transfer buffer
     355                Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(context->getExtensions());
     356                uint8_t* pixelDest = static_cast<uint8_t*>(extensions->mapTexSubImage2DCHROMIUM(GraphicsContext3D::TEXTURE_2D, 0, destRect.x(), destRect.y(), destRect.width(), destRect.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, Extensions3DChromium::WRITE_ONLY));
     357                ASSERT(pixelDest);
     358                if (paintRect.width() == sourceRect.width() && !paintOffset.x())
     359                    memcpy(pixelDest, &paintPixels[4 * paintOffset.y() * paintRect.width()], paintRect.width() * destRect.height() * 4);
     360                else {
     361                    // Strides not equal, so do a row-by-row memcpy from the
     362                    // paint results into the pixelDest
     363                    for (int row = 0; row < destRect.height(); ++row)
     364                        memcpy(&pixelDest[destRect.width() * 4 * row],
     365                               &paintPixels[4 * (paintOffset.x() + (paintOffset.y() + row) * paintRect.width())],
     366                               destRect.width() * 4);
     367                }
     368                extensions->unmapTexSubImage2DCHROMIUM(pixelDest);
     369            } else {
     370                const uint8_t* pixelSource;
     371                if (paintRect.width() == sourceRect.width() && !paintOffset.x())
     372                    pixelSource = &paintPixels[4 * paintOffset.y() * paintRect.width()];
     373                else {
     374                    // Strides not equal, so do a row-by-row memcpy from the
     375                    // paint results into a temp buffer for uploading.
     376                    for (int row = 0; row < destRect.height(); ++row)
     377                        memcpy(&m_tilePixels[destRect.width() * 4 * row],
     378                               &paintPixels[4 * (paintOffset.x() + (paintOffset.y() + row) * paintRect.width())],
     379                               destRect.width() * 4);
     380
     381                    pixelSource = &m_tilePixels[0];
     382                }
     383
     384
     385                GLC(context, context->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, destRect.x(), destRect.y(), destRect.width(), destRect.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, pixelSource));
     386            }
    365387
    366388            tile->clearDirty();
  • trunk/Source/WebCore/platform/graphics/chromium/LayerTilerChromium.h

    r85002 r86301  
    168168    TilingData m_tilingData;
    169169
     170    // Whether the tiler will use GL_CHROMIUM_map_sub for texture uploads.
     171    bool m_useMapSubForUploads;
     172
    170173    LayerRendererChromium* m_layerRenderer;
    171174};
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp

    r85261 r86301  
    2828#include "CCHeadsUpDisplay.h"
    2929
     30#include "Extensions3DChromium.h"
    3031#include "Font.h"
    3132#include "FontDescription.h"
     
    5152    , m_showFPSCounter(false)
    5253    , m_showPlatformLayerTree(false)
     54    , m_useMapSubForUploads(owner->contextSupportsMapSub())
    5355{
    5456    m_beginTimeHistoryInSec[0] = currentTime();
     
    107109
    108110        m_hudTexture->bindTexture();
    109         GLC(context.get(), context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, canvas.size().width(), canvas.size().height(), 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, locker.pixels()));
     111        if (m_useMapSubForUploads) {
     112            Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(context->getExtensions());
     113            uint8_t* pixelDest = static_cast<uint8_t*>(extensions->mapTexSubImage2DCHROMIUM(GraphicsContext3D::TEXTURE_2D, 0, 0, 0, hudSize.width(), hudSize.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, Extensions3DChromium::WRITE_ONLY));
     114            memcpy(pixelDest, locker.pixels(), hudSize.width() * hudSize.height() * 4);
     115            extensions->unmapTexSubImage2DCHROMIUM(pixelDest);
     116        } else
     117            GLC(context.get(), context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, canvas.size().width(), canvas.size().height(), 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, locker.pixels()));
    110118    }
    111119
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.h

    r85261 r86301  
    8787    OwnPtr<Font> m_smallFont;
    8888    OwnPtr<Font> m_mediumFont;
     89
     90    bool m_useMapSubForUploads;
    8991};
    9092
Note: See TracChangeset for help on using the changeset viewer.