Changeset 113678 in webkit


Ignore:
Timestamp:
Apr 9, 2012 9:57:32 PM (12 years ago)
Author:
noam.rosenthal@nokia.com
Message:

[WK2] Enable using a single ShareableBitmap for multiple updates
https://bugs.webkit.org/show_bug.cgi?id=83424

Source/WebCore:

Modify BitmapTexture::updateContents to include a source offset.
This allows us to update a texture from a sub-image.

Reviewed by Kenneth Rohde Christiansen.

Tested by existing API tests.

  • platform/graphics/texmap/TextureMapper.h:

(BitmapTexture):

  • platform/graphics/texmap/TextureMapperGL.cpp:

(WebCore::BitmapTextureGL::didReset):
(WebCore::driverSupportsBGRASwizzling):
(WebCore::BitmapTextureGL::updateContents):

  • platform/graphics/texmap/TextureMapperGL.h:

(WebCore::BitmapTextureGL::textureTarget):
(BitmapTextureGL):

  • platform/graphics/texmap/TextureMapperImageBuffer.cpp:

(WebCore::BitmapTextureImageBuffer::updateContents):

  • platform/graphics/texmap/TextureMapperImageBuffer.h:

(BitmapTextureImageBuffer):

Source/WebKit2:

Reviewed by Kenneth Rohde Christiansen.

Enabled creating a GraphicsContext that references a rect inside ShareableBitmap.
Added bitmapOffset to UpdateInfo, to allow updates to reference an offset inside the bitmap.
Added UpdateAtlas, a class that manages available rects in a larger ShareableBitmap.

In this iteration, UpdateAtlas has a simple behavior where a rect inside the bitmap is
either available or used. When the buffers are swapped, all used buffers become available
again. A future enhancement might allow triple-buffering, where available rects can be
updated while other rects from the same atlas are in use.

Added the necessary plumbing to allow Qt's UI-side compositing to take advantage of
UpdateAtlas. LayerTreeHostQt creates an atlas per type of bitmap (i.e. one opaque and one
alpha-enabled atlas). When a tile wants to update and there's no available scratch-buffer,
the update would be postponed to the next frame, creating a tiling-artifact in low memory
situations.

  • Shared/UpdateInfo.cpp:

(WebKit::UpdateInfo::encode):
(WebKit::UpdateInfo::decode):

  • Shared/UpdateInfo.h:

(UpdateInfo):

  • Target.pri:
  • UIProcess/LayerTreeHostProxy.cpp:

(WebKit::LayerTreeHostProxy::updateTileForLayer):

  • UIProcess/WebLayerTreeRenderer.cpp:

(WebKit::WebLayerTreeRenderer::syncLayerParameters):
(WebKit::WebLayerTreeRenderer::updateTile):
(WebKit::WebLayerTreeRenderer::createImage):

  • UIProcess/WebLayerTreeRenderer.h:

(TileUpdate):
(WebKit::WebLayerTreeRenderer::TileUpdate::TileUpdate):
(WebLayerTreeRenderer):

  • UIProcess/qt/LayerBackingStore.cpp:

(WebKit::LayerBackingStoreTile::swapBuffers):
(WebKit::LayerBackingStoreTile::setBackBuffer):
(WebKit::LayerBackingStore::createTile):

  • UIProcess/qt/LayerBackingStore.h:

(LayerBackingStoreTile):
(LayerBackingStore):

  • WebProcess/WebCoreSupport/WebGraphicsLayer.cpp:

(WebCore::WebGraphicsLayer::tiledBackingStoreBackgroundColor):
(WebCore::WebGraphicsLayer::beginContentUpdate):
(WebCore):

  • WebProcess/WebCoreSupport/WebGraphicsLayer.h:

(WebGraphicsLayerClient):
(WebGraphicsLayer):

  • WebProcess/WebPage/TiledBackingStoreRemoteTile.cpp:

(WebKit::TiledBackingStoreRemoteTile::updateBackBuffer):

  • WebProcess/WebPage/TiledBackingStoreRemoteTile.h:

(TiledBackingStoreRemoteTileClient):

  • WebProcess/WebPage/UpdateAtlas.cpp: Added.

(WebKit):
(WebKit::UpdateAtlas::UpdateAtlas):
(WebKit::nextPowerOfTwo):
(WebKit::UpdateAtlas::buildLayoutIfNeeded):
(WebKit::UpdateAtlas::findAvailableIndex):
(WebKit::UpdateAtlas::didSwapBuffers):
(WebKit::UpdateAtlas::acquireScratchBuffer):
(WebKit::UpdateAtlas::offsetForIndex):

  • WebProcess/WebPage/UpdateAtlas.h: Added.

(WebCore):
(WebKit):
(UpdateAtlas):
(WebKit::UpdateAtlas::bitmap):
(WebKit::UpdateAtlas::size):
(WebKit::UpdateAtlas::flags):

  • WebProcess/WebPage/qt/LayerTreeHostQt.cpp:

(WebKit::LayerTreeHostQt::adoptImageBackingStore):
(WebKit::LayerTreeHostQt::renderNextFrame):
(WebKit::LayerTreeHostQt::purgeBackingStores):
(WebKit):
(WebKit::LayerTreeHostQt::getAtlas):
(WebKit::LayerTreeHostQt::beginContentUpdate):

  • WebProcess/WebPage/qt/LayerTreeHostQt.h:

(LayerTreeHostQt):

Location:
trunk/Source
Files:
2 added
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r113677 r113678  
     12012-04-09  No'am Rosenthal  <noam.rosenthal@nokia.com>
     2
     3        [WK2] Enable using a single ShareableBitmap for multiple updates
     4        https://bugs.webkit.org/show_bug.cgi?id=83424
     5
     6        Modify BitmapTexture::updateContents to include a source offset.
     7        This allows us to update a texture from a sub-image.
     8
     9        Reviewed by Kenneth Rohde Christiansen.
     10
     11        Tested by existing API tests.
     12
     13        * platform/graphics/texmap/TextureMapper.h:
     14        (BitmapTexture):
     15        * platform/graphics/texmap/TextureMapperGL.cpp:
     16        (WebCore::BitmapTextureGL::didReset):
     17        (WebCore::driverSupportsBGRASwizzling):
     18        (WebCore::BitmapTextureGL::updateContents):
     19        * platform/graphics/texmap/TextureMapperGL.h:
     20        (WebCore::BitmapTextureGL::textureTarget):
     21        (BitmapTextureGL):
     22        * platform/graphics/texmap/TextureMapperImageBuffer.cpp:
     23        (WebCore::BitmapTextureImageBuffer::updateContents):
     24        * platform/graphics/texmap/TextureMapperImageBuffer.h:
     25        (BitmapTextureImageBuffer):
     26
    1272012-04-09  Dana Jansens  <danakj@chromium.org>
    228
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.h

    r110979 r113678  
    5353class BitmapTexture  : public RefCounted<BitmapTexture> {
    5454public:
    55     enum PixelFormat { BGRAFormat, RGBAFormat, BGRFormat, RGBFormat };
    5655    enum Flag {
    5756        SupportsAlpha = 0x01
     
    6867
    6968    virtual IntSize size() const = 0;
    70     virtual void updateContents(Image*, const IntRect&, const IntRect&, BitmapTexture::PixelFormat) = 0;
    71     virtual void updateContents(const void*, const IntRect&) = 0;
     69    virtual void updateContents(Image*, const IntRect&, const IntPoint& offset) = 0;
     70    virtual void updateContents(const void*, const IntRect& target, const IntPoint& offset, int bytesPerLine) = 0;
    7271    virtual bool isValid() const = 0;
    7372    inline Flags flags() const { return m_flags; }
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.cpp

    r108135 r113678  
    2727namespace WebCore {
    2828
    29 void TextureMapperTile::updateContents(TextureMapper* textureMapper, Image* image, const IntRect& dirtyRect, BitmapTexture::PixelFormat format)
     29void TextureMapperTile::updateContents(TextureMapper* textureMapper, Image* image, const IntRect& dirtyRect)
    3030{
    3131    IntRect targetRect = enclosingIntRect(m_rect);
     
    3333    if (targetRect.isEmpty())
    3434        return;
    35     IntRect sourceRect = targetRect;
     35    IntPoint sourceOffset = targetRect.location();
    3636
    3737    // Normalize sourceRect to the buffer's coordinates.
    38     sourceRect.move(-dirtyRect.x(), -dirtyRect.y());
     38    sourceOffset.move(-dirtyRect.x(), -dirtyRect.y());
    3939
    4040    // Normalize targetRect to the texture's coordinates.
     
    4545    }
    4646
    47     m_texture->updateContents(image, targetRect, sourceRect, format);
     47    m_texture->updateContents(image, targetRect, sourceOffset);
    4848}
    4949
     
    5858        return;
    5959
    60     updateContents(textureMapper, m_image.get(), m_image->currentFrameHasAlpha() ? BitmapTexture::BGRAFormat : BitmapTexture::BGRFormat);
     60    updateContents(textureMapper, m_image.get());
    6161    m_image.clear();
    6262}
     
    135135}
    136136
    137 void TextureMapperTiledBackingStore::updateContents(TextureMapper* textureMapper, Image* image, const FloatSize& totalSize, const IntRect& dirtyRect, BitmapTexture::PixelFormat format)
     137void TextureMapperTiledBackingStore::updateContents(TextureMapper* textureMapper, Image* image, const FloatSize& totalSize, const IntRect& dirtyRect)
    138138{
    139139    createOrDestroyTilesIfNeeded(totalSize, textureMapper->maxTextureSize(), image->currentFrameHasAlpha());
    140140    for (size_t i = 0; i < m_tiles.size(); ++i)
    141         m_tiles[i].updateContents(textureMapper, image, dirtyRect, format);
     141        m_tiles[i].updateContents(textureMapper, image, dirtyRect);
    142142}
    143143
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.h

    r111258 r113678  
    4646    inline void setRect(const FloatRect& rect) { m_rect = rect; }
    4747
    48     void updateContents(TextureMapper*, Image*, const IntRect&, BitmapTexture::PixelFormat);
     48    void updateContents(TextureMapper*, Image*, const IntRect&);
    4949    virtual void paint(TextureMapper*, const TransformationMatrix&, float, BitmapTexture*);
    5050    virtual ~TextureMapperTile() { }
     
    6666    virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float, BitmapTexture*);
    6767    virtual PassRefPtr<BitmapTexture> texture() const;
    68     void updateContents(TextureMapper*, Image*, const FloatSize&, const IntRect&, BitmapTexture::PixelFormat);
    69     void updateContents(TextureMapper* textureMapper, Image* image, BitmapTexture::PixelFormat format) { updateContents(textureMapper, image, image->size(), image->rect(), format); }
     68    void updateContents(TextureMapper*, Image*, const FloatSize&, const IntRect&);
     69    void updateContents(TextureMapper* textureMapper, Image* image) { updateContents(textureMapper, image, image->size(), image->rect()); }
    7070    inline FloatRect rect() const { return FloatRect(FloatPoint::zero(), m_size); }
    7171    static PassRefPtr<TextureMapperTiledBackingStore> create() { return adoptRef(new TextureMapperTiledBackingStore); }
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp

    r113533 r113678  
    410410}
    411411
    412 static void swizzleBGRAToRGBA(uint32_t* data, const IntSize& size)
     412static void swizzleBGRAToRGBA(uint32_t* data, const IntSize& size, int stride = 0)
    413413{
    414414    int width = size.width();
    415415    int height = size.height();
     416    stride = stride | width;
    416417    for (int y = 0; y < height; ++y) {
    417         uint32_t* p = data + y * width;
     418        uint32_t* p = data + y * stride;
    418419        for (int x = 0; x < width; ++x)
    419420            p[x] = ((p[x] << 16) & 0xff0000) | ((p[x] >> 16) & 0xff) | (p[x] & 0xff00ff00);
     
    431432}
    432433
    433 void BitmapTextureGL::updateContents(const void* data, const IntRect& targetRect)
     434static bool driverSupportsSubImage()
     435{
     436#if defined(TEXMAP_OPENGL_ES_2)
     437    // FIXME: Implement reliable detection.
     438    return false;
     439#else
     440    return true;
     441#endif
     442}
     443
     444void BitmapTextureGL::updateContents(const void* data, const IntRect& targetRect, const IntPoint& sourceOffset, int bytesPerLine)
    434445{
    435446    GLuint glFormat = GL_RGBA;
    436447    GL_CMD(glBindTexture(GL_TEXTURE_2D, m_id))
     448
    437449    if (driverSupportsBGRASwizzling())
    438450        glFormat = GL_BGRA;
    439     else {
    440         swizzleBGRAToRGBA(static_cast<uint32_t*>(const_cast<void*>(data)), targetRect.size());
    441         glFormat = GL_RGBA;
    442     }
    443 
    444     GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, GL_UNSIGNED_BYTE, data))
    445 }
    446 
    447 void BitmapTextureGL::updateContents(Image* image, const IntRect& targetRect, const IntRect& sourceRect, BitmapTexture::PixelFormat format)
     451    else
     452        swizzleBGRAToRGBA(static_cast<uint32_t*>(const_cast<void*>(data)), targetRect.size(), bytesPerLine / 4);
     453
     454    if (bytesPerLine == targetRect.width() / 4 && sourceOffset == IntPoint::zero()) {
     455        GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, GL_UNSIGNED_BYTE, (const char*)data))
     456        return;
     457    }
     458
     459    // For ES drivers that don't support sub-images, transfer the pixels row-by-row.
     460    if (!driverSupportsSubImage()) {
     461        const char* bits = static_cast<const char*>(data);
     462        for (int y = 0; y < targetRect.height(); ++y) {
     463            const char *row = bits + ((sourceOffset.y() + y) * bytesPerLine + sourceOffset.x() * 4);
     464            GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y() + y, targetRect.width(), 1, glFormat, GL_UNSIGNED_BYTE, row))
     465        }
     466        return;
     467    }
     468
     469    // Use the OpenGL sub-image extension, now that we know it's available.
     470    glPixelStorei(GL_UNPACK_ROW_LENGTH, bytesPerLine / 4);
     471    glPixelStorei(GL_UNPACK_SKIP_ROWS, sourceOffset.y());
     472    glPixelStorei(GL_UNPACK_SKIP_PIXELS, sourceOffset.x());
     473    GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, GL_UNSIGNED_BYTE, (const char*)data))
     474    glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
     475    glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
     476    glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
     477}
     478
     479void BitmapTextureGL::updateContents(Image* image, const IntRect& targetRect, const IntPoint& offset)
    448480{
    449481    if (!image)
    450482        return;
    451     GL_CMD(glBindTexture(GL_TEXTURE_2D, m_id))
    452     GLuint glFormat = isOpaque() ? GL_RGB : GL_RGBA;
    453483    NativeImagePtr frameImage = image->nativeImageForCurrentFrame();
    454484    if (!frameImage)
    455485        return;
    456486
     487    int bytesPerLine;
     488    const char* imageData;
     489
    457490#if PLATFORM(QT)
    458491    QImage qtImage;
    459 
    460492#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
    461493    // With QPA, we can avoid a deep copy.
     
    465497    qtImage = frameImage->toImage();
    466498#endif
    467 
    468     if (IntSize(qtImage.size()) != sourceRect.size())
    469         qtImage = qtImage.copy(sourceRect);
    470     if (format == BGRAFormat || format == BGRFormat) {
    471         if (driverSupportsBGRASwizzling())
    472             glFormat = isOpaque() ? GL_BGR : GL_BGRA;
    473         else
    474             swizzleBGRAToRGBA(reinterpret_cast<uint32_t*>(qtImage.bits()), qtImage.size());
    475     }
    476     GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, GL_UNSIGNED_BYTE, qtImage.constBits()))
    477 
     499    imageData = reinterpret_cast<const char*>(qtImage.constBits());
     500    bytesPerLine = qtImage.bytesPerLine();
    478501#elif USE(CAIRO)
    479 
    480 #if !CPU(BIG_ENDIAN)
    481 #if defined(TEXMAP_OPENGL_ES_2)
    482     swizzleBGRAToRGBA(reinterpret_cast<uint32_t*>(cairo_image_surface_get_data(frameImage)),
    483                       cairo_image_surface_get_stride(frameImage) * cairo_image_surface_get_height(frameImage));
    484 #else
    485     glFormat = isOpaque() ? GL_BGR : GL_BGRA;
    486 #endif
    487 #endif
    488 
    489     glPixelStorei(GL_UNPACK_ROW_LENGTH, cairo_image_surface_get_stride(frameImage) / 4);
    490     glPixelStorei(GL_UNPACK_SKIP_ROWS, sourceRect.y());
    491     glPixelStorei(GL_UNPACK_SKIP_PIXELS, sourceRect.x());
    492     GL_CMD(glTexSubImage2D(GL_TEXTURE_2D, 0,
    493                            targetRect.x(), targetRect.y(),
    494                            targetRect.width(), targetRect.height(),
    495                            glFormat, GL_UNSIGNED_BYTE,
    496                            cairo_image_surface_get_data(frameImage)));
    497     glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
    498     glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
    499     glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
    500 #endif
     502    imageData = cairo_image_surface_get_data(frameImage);
     503    bytesPerLine = cairo_image_surface_get_stride(frameImage);
     504#endif
     505
     506    updateContents(imageData, targetRect, offset, bytesPerLine);
     507
    501508}
    502509
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h

    r110979 r113678  
    6363    GraphicsContext* graphicsContext() { return m_context; }
    6464    virtual bool isOpenGLBacked() const { return true; }
    65     void platformUpdateContents(NativeImagePtr, const IntRect&, const IntRect&, BitmapTexture::PixelFormat);
     65    void platformUpdateContents(NativeImagePtr, const IntRect&, const IntRect&);
    6666    virtual AccelerationMode accelerationMode() const { return OpenGLMode; }
    6767
     
    8484    ~BitmapTextureGL();
    8585    virtual uint32_t id() const { return m_id; }
     86    uint32_t textureTarget() const { return GL_TEXTURE_2D; }
    8687    IntSize textureSize() const { return m_textureSize; }
    8788    void setTextureMapper(TextureMapperGL* texmap) { m_textureMapper = texmap; }
    88     void updateContents(Image*, const IntRect&, const IntRect&, PixelFormat);
    89     void updateContents(const void*, const IntRect&);
     89    void updateContents(Image*, const IntRect&, const IntPoint&);
     90    virtual void updateContents(const void*, const IntRect& target, const IntPoint& sourceOffset, int bytesPerLine);
    9091
    9192private:
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.cpp

    r108135 r113678  
    2626namespace WebCore {
    2727
    28 void BitmapTextureImageBuffer::updateContents(const void* data, const IntRect& targetRect)
     28void BitmapTextureImageBuffer::updateContents(const void* data, const IntRect& targetRect, const IntPoint& sourceOffset, int bytesPerLine)
    2929{
    3030#if PLATFORM(QT)
    31     QImage image(reinterpret_cast<const uchar*>(data), targetRect.width(), targetRect.height(), targetRect.width() * 4, QImage::Format_ARGB32_Premultiplied);
     31    QImage image(reinterpret_cast<const uchar*>(data), targetRect.width(), targetRect.height(), bytesPerLine, QImage::Format_ARGB32_Premultiplied);
     32
    3233    QPainter* painter = m_image->context()->platformContext();
    3334    painter->save();
    3435    painter->setCompositionMode(QPainter::CompositionMode_Source);
    35     painter->drawImage(targetRect, image);
     36    painter->drawImage(targetRect, image, IntRect(sourceOffset, targetRect.size()));
    3637    painter->restore();
    3738#endif
     
    4344}
    4445
    45 void BitmapTextureImageBuffer::updateContents(Image* image, const IntRect& targetRect, const IntRect& sourceRect, PixelFormat)
     46void BitmapTextureImageBuffer::updateContents(Image* image, const IntRect& targetRect, const IntPoint& offset)
    4647{
    47     m_image->context()->drawImage(image, ColorSpaceDeviceRGB, targetRect, sourceRect, CompositeCopy);
     48    m_image->context()->drawImage(image, ColorSpaceDeviceRGB, targetRect, IntRect(offset, targetRect.size()), CompositeCopy);
    4849}
    4950
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.h

    r110437 r113678  
    3535    virtual bool isValid() const { return m_image; }
    3636    inline GraphicsContext* graphicsContext() { return m_image ? m_image->context() : 0; }
    37     virtual void updateContents(Image*, const IntRect&, const IntRect&, PixelFormat);
    38     void updateContents(const void* data, const IntRect& targetRect);
     37    virtual void updateContents(Image*, const IntRect&, const IntPoint&);
     38    virtual void updateContents(const void*, const IntRect& target, const IntPoint& sourceOffset, int bytesPerLine);
    3939#if ENABLE(CSS_FILTERS)
    4040    void applyFilters(const BitmapTexture&, const FilterOperations&);
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp

    r111258 r113678  
    132132#endif
    133133
    134     static_cast<TextureMapperTiledBackingStore*>(m_backingStore.get())->updateContents(textureMapper, image.get(), m_size, dirtyRect, BitmapTexture::BGRAFormat);
     134    static_cast<TextureMapperTiledBackingStore*>(m_backingStore.get())->updateContents(textureMapper, image.get(), m_size, dirtyRect);
    135135}
    136136
  • trunk/Source/WebKit2/ChangeLog

    r113640 r113678  
     12012-04-09  No'am Rosenthal  <noam.rosenthal@nokia.com>
     2
     3        [WK2] Enable using a single ShareableBitmap for multiple updates
     4        https://bugs.webkit.org/show_bug.cgi?id=83424
     5
     6        Reviewed by Kenneth Rohde Christiansen.
     7
     8        Enabled creating a GraphicsContext that references a rect inside ShareableBitmap.
     9        Added bitmapOffset to UpdateInfo, to allow updates to reference an offset inside the bitmap.
     10        Added UpdateAtlas, a class that manages available rects in a larger ShareableBitmap.
     11
     12        In this iteration, UpdateAtlas has a simple behavior where a rect inside the bitmap is
     13        either available or used. When the buffers are swapped, all used buffers become available
     14        again. A future enhancement might allow triple-buffering, where available rects can be
     15        updated while other rects from the same atlas are in use.
     16
     17        Added the necessary plumbing to allow Qt's UI-side compositing to take advantage of
     18        UpdateAtlas. LayerTreeHostQt creates an atlas per type of bitmap (i.e. one opaque and one
     19        alpha-enabled atlas). When a tile wants to update and there's no available scratch-buffer,
     20        the update would be postponed to the next frame, creating a tiling-artifact in low memory
     21        situations.
     22
     23        * Shared/UpdateInfo.cpp:
     24        (WebKit::UpdateInfo::encode):
     25        (WebKit::UpdateInfo::decode):
     26        * Shared/UpdateInfo.h:
     27        (UpdateInfo):
     28        * Target.pri:
     29        * UIProcess/LayerTreeHostProxy.cpp:
     30        (WebKit::LayerTreeHostProxy::updateTileForLayer):
     31        * UIProcess/WebLayerTreeRenderer.cpp:
     32        (WebKit::WebLayerTreeRenderer::syncLayerParameters):
     33        (WebKit::WebLayerTreeRenderer::updateTile):
     34        (WebKit::WebLayerTreeRenderer::createImage):
     35        * UIProcess/WebLayerTreeRenderer.h:
     36        (TileUpdate):
     37        (WebKit::WebLayerTreeRenderer::TileUpdate::TileUpdate):
     38        (WebLayerTreeRenderer):
     39        * UIProcess/qt/LayerBackingStore.cpp:
     40        (WebKit::LayerBackingStoreTile::swapBuffers):
     41        (WebKit::LayerBackingStoreTile::setBackBuffer):
     42        (WebKit::LayerBackingStore::createTile):
     43        * UIProcess/qt/LayerBackingStore.h:
     44        (LayerBackingStoreTile):
     45        (LayerBackingStore):
     46        * WebProcess/WebCoreSupport/WebGraphicsLayer.cpp:
     47        (WebCore::WebGraphicsLayer::tiledBackingStoreBackgroundColor):
     48        (WebCore::WebGraphicsLayer::beginContentUpdate):
     49        (WebCore):
     50        * WebProcess/WebCoreSupport/WebGraphicsLayer.h:
     51        (WebGraphicsLayerClient):
     52        (WebGraphicsLayer):
     53        * WebProcess/WebPage/TiledBackingStoreRemoteTile.cpp:
     54        (WebKit::TiledBackingStoreRemoteTile::updateBackBuffer):
     55        * WebProcess/WebPage/TiledBackingStoreRemoteTile.h:
     56        (TiledBackingStoreRemoteTileClient):
     57        * WebProcess/WebPage/UpdateAtlas.cpp: Added.
     58        (WebKit):
     59        (WebKit::UpdateAtlas::UpdateAtlas):
     60        (WebKit::nextPowerOfTwo):
     61        (WebKit::UpdateAtlas::buildLayoutIfNeeded):
     62        (WebKit::UpdateAtlas::findAvailableIndex):
     63        (WebKit::UpdateAtlas::didSwapBuffers):
     64        (WebKit::UpdateAtlas::acquireScratchBuffer):
     65        (WebKit::UpdateAtlas::offsetForIndex):
     66        * WebProcess/WebPage/UpdateAtlas.h: Added.
     67        (WebCore):
     68        (WebKit):
     69        (UpdateAtlas):
     70        (WebKit::UpdateAtlas::bitmap):
     71        (WebKit::UpdateAtlas::size):
     72        (WebKit::UpdateAtlas::flags):
     73        * WebProcess/WebPage/qt/LayerTreeHostQt.cpp:
     74        (WebKit::LayerTreeHostQt::adoptImageBackingStore):
     75        (WebKit::LayerTreeHostQt::renderNextFrame):
     76        (WebKit::LayerTreeHostQt::purgeBackingStores):
     77        (WebKit):
     78        (WebKit::LayerTreeHostQt::getAtlas):
     79        (WebKit::LayerTreeHostQt::beginContentUpdate):
     80        * WebProcess/WebPage/qt/LayerTreeHostQt.h:
     81        (LayerTreeHostQt):
     82
    1832012-04-09  No'am Rosenthal  <noam.rosenthal@nokia.com>
    284
  • trunk/Source/WebKit2/Shared/UpdateInfo.cpp

    r95901 r113678  
    4141    encoder->encode(updateScaleFactor);
    4242    encoder->encode(bitmapHandle);
     43    encoder->encode(bitmapOffset);
    4344}
    4445
     
    6162    if (!decoder->decode(result.bitmapHandle))
    6263        return false;
     64    if (!decoder->decode(result.bitmapOffset))
     65        return false;
    6366
    6467    return true;
  • trunk/Source/WebKit2/Shared/UpdateInfo.h

    r95901 r113678  
    6666    // The handle of the shareable bitmap containing the updates. Will be null if there are no updates.
    6767    ShareableBitmap::Handle bitmapHandle;
     68
     69    // The offset in the bitmap where the rendered contents are.
     70    WebCore::IntPoint bitmapOffset;
    6871};
    6972
  • trunk/Source/WebKit2/Target.pri

    r113172 r113678  
    364364    WebProcess/WebPage/TapHighlightController.h \
    365365    WebProcess/WebPage/PageOverlay.h \
     366    WebProcess/WebPage/UpdateAtlas.h \
    366367    WebProcess/WebPage/WebContextMenu.h \
    367368    WebProcess/WebPage/WebFrame.h \
     
    371372    WebProcess/WebPage/WebPageGroupProxy.h \
    372373    WebProcess/WebPage/WebUndoStep.h \
     374    WebProcess/WebPage/qt/LayerTreeHostQt.h \
    373375    WebProcess/WebConnectionToUIProcess.h \
    374376    WebProcess/WebProcess.h \
     
    730732    WebProcess/WebPage/PageOverlay.cpp \
    731733    WebProcess/WebPage/TiledBackingStoreRemoteTile.cpp \
     734    WebProcess/WebPage/UpdateAtlas.cpp \
    732735    WebProcess/WebPage/WebBackForwardListProxy.cpp \
    733736    WebProcess/WebPage/WebContextMenu.cpp \
  • trunk/Source/WebKit2/UIProcess/LayerTreeHostProxy.cpp

    r113640 r113678  
    7979    IntRect targetRect = updateInfo.updateRectBounds;
    8080    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(updateInfo.bitmapHandle);
    81     dispatchUpdate(bind(&WebLayerTreeRenderer::updateTile, m_renderer.get(), layerID, tileID, sourceRect, targetRect, bitmap));
     81    dispatchUpdate(bind(&WebLayerTreeRenderer::updateTile, m_renderer.get(), layerID, tileID, WebLayerTreeRenderer::TileUpdate(sourceRect, targetRect, bitmap, updateInfo.bitmapOffset)));
    8282}
    8383
  • trunk/Source/WebKit2/UIProcess/WebLayerTreeRenderer.cpp

    r113640 r113678  
    268268}
    269269
    270 void WebLayerTreeRenderer::updateTile(WebLayerID layerID, int tileID, const IntRect& sourceRect, const IntRect& targetRect, PassRefPtr<ShareableBitmap> weakBitmap)
    271 {
    272     RefPtr<ShareableBitmap> bitmap = weakBitmap;
     270void WebLayerTreeRenderer::updateTile(WebLayerID layerID, int tileID, const TileUpdate& update)
     271{
    273272    RefPtr<LayerBackingStore> backingStore = getBackingStore(layerID);
    274     backingStore->updateTile(tileID, sourceRect, targetRect, bitmap.get());
     273    backingStore->updateTile(tileID, update.sourceRect, update.targetRect, update.bitmap, update.offset);
    275274    m_backingStoresWithPendingBuffers.add(backingStore);
    276275}
     
    280279    RefPtr<ShareableBitmap> bitmap = weakBitmap;
    281280    RefPtr<TextureMapperTiledBackingStore> backingStore = TextureMapperTiledBackingStore::create();
    282     backingStore->updateContents(m_textureMapper.get(), bitmap->createImage().get(), BitmapTexture::BGRAFormat);
    283281    m_directlyCompositedImages.set(imageID, backingStore);
     282    backingStore->updateContents(m_textureMapper.get(), bitmap->createImage().get());
    284283}
    285284
  • trunk/Source/WebKit2/UIProcess/WebLayerTreeRenderer.h

    r113640 r113678  
    4646class WebLayerTreeRenderer : public ThreadSafeRefCounted<WebLayerTreeRenderer>, public WebCore::GraphicsLayerClient {
    4747public:
     48    struct TileUpdate {
     49        WebCore::IntRect sourceRect;
     50        WebCore::IntRect targetRect;
     51        RefPtr<ShareableBitmap> bitmap;
     52        WebCore::IntPoint offset;
     53        TileUpdate(const WebCore::IntRect& source, const WebCore::IntRect& target, PassRefPtr<ShareableBitmap> newBitmap, const WebCore::IntPoint& newOffset)
     54            : sourceRect(source)
     55            , targetRect(target)
     56            , bitmap(newBitmap)
     57            , offset(newOffset)
     58        {
     59        }
     60    };
    4861    WebLayerTreeRenderer(LayerTreeHostProxy*);
    4962    virtual ~WebLayerTreeRenderer();
     
    6477    void createTile(WebLayerID, int, float scale);
    6578    void removeTile(WebLayerID, int);
    66     void updateTile(WebLayerID, int, const WebCore::IntRect&, const WebCore::IntRect&, PassRefPtr<ShareableBitmap>);
     79    void updateTile(WebLayerID, int, const TileUpdate&);
    6780    void flushLayerChanges();
    6881    void createImage(int64_t, PassRefPtr<ShareableBitmap>);
  • trunk/Source/WebKit2/UIProcess/qt/LayerBackingStore.cpp

    r111566 r113678  
    2424#include "GraphicsLayer.h"
    2525#include "TextureMapper.h"
    26 
    27 #include "stdio.h"
     26#include "TextureMapperGL.h"
    2827
    2928using namespace WebCore;
     
    5150
    5251    QImage qImage = m_backBuffer->createQImage();
    53 
    5452    if (shouldReset)
    5553        texture->reset(m_sourceRect.size(), qImage.hasAlphaChannel() ? BitmapTexture::SupportsAlpha : 0);
    56 
    57     texture->updateContents(qImage.constBits(), m_sourceRect);
     54    texture->updateContents(qImage.constBits(), m_sourceRect, m_bitmapOffset, qImage.bytesPerLine());
    5855    m_backBuffer.clear();
    5956}
    6057
    61 void LayerBackingStoreTile::setBackBuffer(const WebCore::IntRect& targetRect, const WebCore::IntRect& sourceRect, ShareableBitmap* buffer)
     58void LayerBackingStoreTile::setBackBuffer(const IntRect& targetRect, const IntRect& sourceRect, PassRefPtr<ShareableBitmap> buffer, const IntPoint& offset)
    6259{
    6360    m_sourceRect = sourceRect;
    6461    m_targetRect = targetRect;
     62    m_bitmapOffset = offset;
    6563    m_backBuffer = buffer;
    6664}
     
    7775}
    7876
    79 void LayerBackingStore::updateTile(int id, const IntRect& sourceRect, const IntRect& targetRect, ShareableBitmap* backBuffer)
     77
     78void LayerBackingStore::updateTile(int id, const IntRect& sourceRect, const IntRect& targetRect, PassRefPtr<ShareableBitmap> backBuffer, const IntPoint& offset)
    8079{
    8180    HashMap<int, LayerBackingStoreTile>::iterator it = m_tiles.find(id);
    8281    ASSERT(it != m_tiles.end());
    83     it->second.setBackBuffer(targetRect, sourceRect, backBuffer);
     82    it->second.setBackBuffer(targetRect, sourceRect, backBuffer, offset);
    8483}
    8584
  • trunk/Source/WebKit2/UIProcess/qt/LayerBackingStore.h

    r113361 r113678  
    4040    inline float scale() const { return m_scale; }
    4141    void swapBuffers(WebCore::TextureMapper*);
    42     void setBackBuffer(const WebCore::IntRect&, const WebCore::IntRect&, ShareableBitmap* buffer);
     42    void setBackBuffer(const WebCore::IntRect&, const WebCore::IntRect&, PassRefPtr<ShareableBitmap> buffer, const WebCore::IntPoint&);
    4343
    4444private:
     
    4646    WebCore::IntRect m_sourceRect;
    4747    WebCore::IntRect m_targetRect;
     48    WebCore::IntPoint m_bitmapOffset;
    4849    float m_scale;
    4950};
     
    5354    void createTile(int, float);
    5455    void removeTile(int);
    55     void updateTile(int, const WebCore::IntRect&, const WebCore::IntRect&, ShareableBitmap*);
     56    void updateTile(int, const WebCore::IntRect&, const WebCore::IntRect&, PassRefPtr<ShareableBitmap>, const WebCore::IntPoint&);
    5657    static PassRefPtr<LayerBackingStore> create() { return adoptRef(new LayerBackingStore); }
    5758    void commitTileOperations(WebCore::TextureMapper*);
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp

    r113640 r113678  
    554554}
    555555
     556PassOwnPtr<WebCore::GraphicsContext> WebGraphicsLayer::beginContentUpdate(const WebCore::IntSize& size, ShareableBitmap::Handle& handle, WebCore::IntPoint& offset)
     557{
     558    return m_webGraphicsLayerClient->beginContentUpdate(size, contentsOpaque() ? 0 : ShareableBitmap::SupportsAlpha, handle, offset);
     559}
     560
    556561void WebGraphicsLayer::createTile(int tileID, const UpdateInfo& updateInfo)
    557562{
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h

    r113640 r113678  
    6060    virtual void attachLayer(WebCore::WebGraphicsLayer*) = 0;
    6161    virtual void detachLayer(WebCore::WebGraphicsLayer*) = 0;
     62    virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, ShareableBitmap::Flags, ShareableBitmap::Handle&, WebCore::IntPoint&) = 0;
    6263};
    6364}
     
    129130    virtual void updateTile(int tileID, const WebKit::UpdateInfo&);
    130131    virtual void removeTile(int tileID);
     132    virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, WebKit::ShareableBitmap::Handle&, WebCore::IntPoint&);
    131133
    132134    void setWebGraphicsLayerClient(WebKit::WebGraphicsLayerClient*);
  • trunk/Source/WebKit2/WebProcess/WebPage/TiledBackingStoreRemoteTile.cpp

    r108055 r113678  
    7373        return Vector<IntRect>();
    7474
    75     RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(m_dirtyRect.size(), m_tiledBackingStore->supportsAlpha() ? ShareableBitmap::SupportsAlpha : 0);
    76     OwnPtr<GraphicsContext> graphicsContext(bitmap->createGraphicsContext());
     75    UpdateInfo updateInfo;
     76    OwnPtr<GraphicsContext> graphicsContext = m_client->beginContentUpdate(m_dirtyRect.size(), updateInfo.bitmapHandle, updateInfo.bitmapOffset);
     77    if (!graphicsContext)
     78        return Vector<IntRect>();
    7779    graphicsContext->translate(-m_dirtyRect.x(), -m_dirtyRect.y());
    7880    graphicsContext->scale(FloatSize(m_tiledBackingStore->contentsScale(), m_tiledBackingStore->contentsScale()));
    7981    m_tiledBackingStore->client()->tiledBackingStorePaint(graphicsContext.get(), m_tiledBackingStore->mapToContents(m_dirtyRect));
    8082
    81     UpdateInfo updateInfo;
    8283    updateInfo.updateRectBounds = m_rect;
    8384    IntRect updateRect = m_dirtyRect;
     
    8586    updateInfo.updateRects.append(updateRect);
    8687    updateInfo.updateScaleFactor = m_tiledBackingStore->contentsScale();
    87     bitmap->createHandle(updateInfo.bitmapHandle);
     88    graphicsContext.release();
    8889
    8990    static int id = 0;
  • trunk/Source/WebKit2/WebProcess/WebPage/TiledBackingStoreRemoteTile.h

    r97571 r113678  
    2929#if USE(TILED_BACKING_STORE)
    3030
     31#include "ShareableBitmap.h"
    3132#include "Tile.h"
    3233#include "TiledBackingStore.h"
     
    7980    virtual void updateTile(int tileID, const UpdateInfo&) = 0;
    8081    virtual void removeTile(int tileID) = 0;
     82    virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, ShareableBitmap::Handle&, WebCore::IntPoint&) = 0;
    8183};
    8284
  • trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp

    r113640 r113678  
    3333#include "LayerTreeHostProxyMessages.h"
    3434#include "MessageID.h"
     35#include "WebCoreArgumentCoders.h"
    3536#include "WebGraphicsLayer.h"
    3637#include "WebPage.h"
     
    330331    }
    331332
    332     RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(image->size(), image->currentFrameHasAlpha() ? ShareableBitmap::SupportsAlpha : 0);
     333    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(image->size(), (image->currentFrameHasAlpha() ? ShareableBitmap::SupportsAlpha : 0));
    333334    {
    334335        OwnPtr<WebCore::GraphicsContext> graphicsContext = bitmap->createGraphicsContext();
     
    452453    m_waitingForUIProcess = false;
    453454    scheduleLayerFlush();
     455    for (int i = 0; i < m_updateAtlases.size(); ++i)
     456        m_updateAtlases[i].didSwapBuffers();
    454457}
    455458
     
    466469
    467470    ASSERT(!m_directlyCompositedImageRefCounts.size());
     471    m_updateAtlases.clear();
     472}
     473
     474UpdateAtlas& LayerTreeHostQt::getAtlas(ShareableBitmap::Flags flags)
     475{
     476    for (int i = 0; i < m_updateAtlases.size(); ++i) {
     477        if (m_updateAtlases[i].flags() == flags)
     478            return m_updateAtlases[i];
     479    }
     480    static const int ScratchBufferDimension = 2000;
     481    m_updateAtlases.append(UpdateAtlas(ScratchBufferDimension, flags));
     482    return m_updateAtlases.last();
     483}
     484
     485PassOwnPtr<WebCore::GraphicsContext> LayerTreeHostQt::beginContentUpdate(const WebCore::IntSize& size, ShareableBitmap::Flags flags, ShareableBitmap::Handle& handle, WebCore::IntPoint& offset)
     486{
     487    UpdateAtlas& atlas = getAtlas(flags);
     488    if (!atlas.bitmap()->createHandle(handle))
     489        return PassOwnPtr<WebCore::GraphicsContext>();
     490
     491    // This will return null if there is no available buffer.
     492    OwnPtr<WebCore::GraphicsContext> graphicsContext = atlas.beginPaintingOnAvailableBuffer(size, offset);
     493    if (!graphicsContext)
     494        return PassOwnPtr<WebCore::GraphicsContext>();
     495
     496    return graphicsContext.release();
    468497}
    469498
  • trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h

    r113640 r113678  
    2424#include "LayerTreeHost.h"
    2525#include "Timer.h"
     26#include "UpdateAtlas.h"
    2627#include "WebGraphicsLayer.h"
    2728#include <WebCore/GraphicsLayerClient.h>
     
    7778    virtual void detachLayer(WebCore::WebGraphicsLayer*);
    7879
     80    virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, ShareableBitmap::Flags, ShareableBitmap::Handle&, WebCore::IntPoint&);
     81
    7982protected:
    8083    explicit LayerTreeHostQt(WebPage*);
     
    9699    void sendLayersToUI();
    97100
     101    UpdateAtlas& getAtlas(ShareableBitmap::Flags);
     102
    98103    OwnPtr<WebCore::GraphicsLayer> m_rootLayer;
    99104
     
    106111    HashSet<WebCore::WebGraphicsLayer*> m_registeredLayers;
    107112    HashMap<int64_t, int> m_directlyCompositedImageRefCounts;
     113    Vector<UpdateAtlas> m_updateAtlases;
    108114
    109115    bool m_notifyAfterScheduledLayerFlush;
Note: See TracChangeset for help on using the changeset viewer.