Changeset 87160 in webkit


Ignore:
Timestamp:
May 24, 2011 9:30:53 AM (13 years ago)
Author:
andreas.kling@nokia.com
Message:

2011-05-24 Andreas Kling <kling@webkit.org>

Reviewed by Simon Hausmann.

[WK2] Change TiledDrawingArea to use ShareableBitmap instead of UpdateChunk.
https://bugs.webkit.org/show_bug.cgi?id=61296

Pass UpdateInfo containing ShareableBitmaps instead of UpdateChunk for tile updates.
Only the bounds rect and bitmap handle in the UpdateInfo are used since none of the
other parameters are needed for TiledDrawingArea.

  • Shared/ShareableBitmap.h:
  • Shared/qt/ShareableBitmapQt.cpp: (WebKit::ShareableBitmap::createQImage): (WebKit::ShareableBitmap::createGraphicsContext): (WebKit::ShareableBitmap::paint):
  • Shared/qt/UpdateChunk.cpp: Removed.
  • Shared/qt/UpdateChunk.h: Removed.
  • UIProcess/TiledDrawingAreaProxy.cpp: (WebKit::TiledDrawingAreaProxy::didReceiveMessage): (WebKit::TiledDrawingAreaProxy::waitUntilUpdatesComplete):
  • UIProcess/TiledDrawingAreaProxy.h:
  • UIProcess/TiledDrawingAreaTile.h:
  • UIProcess/qt/TiledDrawingAreaProxyQt.cpp: (WebKit::TiledDrawingAreaProxy::snapshotTaken):
  • UIProcess/qt/TiledDrawingAreaTileQt.cpp: (WebKit::TiledDrawingAreaTile::incorporateUpdate):
  • WebKit2.pro:
  • WebProcess/WebPage/TiledDrawingArea.cpp: (WebKit::TiledDrawingArea::updateTile): (WebKit::TiledDrawingArea::didReceiveMessage):
  • WebProcess/WebPage/TiledDrawingArea.h:
  • WebProcess/WebPage/qt/TiledDrawingAreaQt.cpp: (WebKit::TiledDrawingArea::paintIntoBitmap):
Location:
trunk/Source/WebKit2
Files:
2 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r87154 r87160  
     12011-05-24  Andreas Kling  <kling@webkit.org>
     2
     3        Reviewed by Simon Hausmann.
     4
     5        [WK2] Change TiledDrawingArea to use ShareableBitmap instead of UpdateChunk.
     6        https://bugs.webkit.org/show_bug.cgi?id=61296
     7
     8        Pass UpdateInfo containing ShareableBitmaps instead of UpdateChunk for tile updates.
     9        Only the bounds rect and bitmap handle in the UpdateInfo are used since none of the
     10        other parameters are needed for TiledDrawingArea.
     11
     12        * Shared/ShareableBitmap.h:
     13        * Shared/qt/ShareableBitmapQt.cpp:
     14        (WebKit::ShareableBitmap::createQImage):
     15        (WebKit::ShareableBitmap::createGraphicsContext):
     16        (WebKit::ShareableBitmap::paint):
     17        * Shared/qt/UpdateChunk.cpp: Removed.
     18        * Shared/qt/UpdateChunk.h: Removed.
     19        * UIProcess/TiledDrawingAreaProxy.cpp:
     20        (WebKit::TiledDrawingAreaProxy::didReceiveMessage):
     21        (WebKit::TiledDrawingAreaProxy::waitUntilUpdatesComplete):
     22        * UIProcess/TiledDrawingAreaProxy.h:
     23        * UIProcess/TiledDrawingAreaTile.h:
     24        * UIProcess/qt/TiledDrawingAreaProxyQt.cpp:
     25        (WebKit::TiledDrawingAreaProxy::snapshotTaken):
     26        * UIProcess/qt/TiledDrawingAreaTileQt.cpp:
     27        (WebKit::TiledDrawingAreaTile::incorporateUpdate):
     28        * WebKit2.pro:
     29        * WebProcess/WebPage/TiledDrawingArea.cpp:
     30        (WebKit::TiledDrawingArea::updateTile):
     31        (WebKit::TiledDrawingArea::didReceiveMessage):
     32        * WebProcess/WebPage/TiledDrawingArea.h:
     33        * WebProcess/WebPage/qt/TiledDrawingAreaQt.cpp:
     34        (WebKit::TiledDrawingArea::paintIntoBitmap):
     35
    1362011-05-24  Brady Eidson  <beidson@apple.com>
    237
  • trunk/Source/WebKit2/Shared/ShareableBitmap.h

    r86247 r87160  
    4040#if USE(CAIRO)
    4141#include <WebCore/RefPtrCairo.h>
     42#endif
     43
     44#if PLATFORM(QT)
     45#include <QImage>
    4246#endif
    4347
     
    114118    // This is only safe to use when we know that the contents of the shareable bitmap won't change.
    115119    PassRefPtr<cairo_surface_t> createCairoSurface();
     120#elif PLATFORM(QT)
     121    // This creates a QImage that directly references the shared bitmap data.
     122    // This is only safe to use when we know that the contents of the shareable bitmap won't change.
     123    QImage createQImage();
    116124#endif
    117125
  • trunk/Source/WebKit2/Shared/qt/ShareableBitmapQt.cpp

    r86544 r87160  
    3535namespace WebKit {
    3636
    37 static inline QImage createQImage(void* data, int width, int height)
     37QImage ShareableBitmap::createQImage()
    3838{
    39     return QImage(reinterpret_cast<uchar*>(data), width, height, width * 4, QImage::Format_RGB32);
     39    return QImage(reinterpret_cast<uchar*>(data()), m_size.width(), m_size.height(), m_size.width() * 4, QImage::Format_RGB32);
    4040}
    4141
     
    4343{
    4444    // FIXME: Should this be OwnPtr<QImage>?
    45     QImage* image = new QImage(createQImage(data(), m_size.width(), m_size.height()));
     45    QImage* image = new QImage(createQImage());
    4646    OwnPtr<GraphicsContext> context = adoptPtr(new GraphicsContext(new QPainter(image)));
    4747    context->takeOwnershipOfPlatformContext();
     
    5151void ShareableBitmap::paint(GraphicsContext& context, const IntPoint& dstPoint, const IntRect& srcRect)
    5252{
    53     QImage image = createQImage(data(), m_size.width(), m_size.height());
     53    QImage image = createQImage();
    5454    QPainter* painter = context.platformContext();
    5555    painter->drawImage(dstPoint, image, QRect(srcRect));
  • trunk/Source/WebKit2/UIProcess/TiledDrawingAreaProxy.cpp

    r86045 r87160  
    3131#include "DrawingAreaProxyMessageKinds.h"
    3232#include "MessageID.h"
    33 #include "UpdateChunk.h"
     33#include "UpdateInfo.h"
    3434#include "WebCoreArgumentCoders.h"
    3535#include "WebPageProxy.h"
     
    127127    case DrawingAreaProxyLegacyMessage::TileUpdated: {
    128128        int tileID;
    129         UpdateChunk updateChunk;
     129        UpdateInfo updateInfo;
    130130        float scale;
    131131        unsigned pendingUpdateCount;
    132         if (!arguments->decode(CoreIPC::Out(tileID, updateChunk, scale, pendingUpdateCount)))
     132        if (!arguments->decode(CoreIPC::Out(tileID, updateInfo, scale, pendingUpdateCount)))
    133133            return;
    134134
     
    136136        ASSERT(!tile || tile->ID() == tileID);
    137137        if (tile)
    138             tile->updateFromChunk(&updateChunk, scale);
     138            tile->incorporateUpdate(updateInfo, scale);
    139139        tileBufferUpdateComplete();
    140140        break;
     
    161161    }
    162162    case DrawingAreaProxyLegacyMessage::SnapshotTaken: {
    163         UpdateChunk chunk;
    164         if (!arguments->decode(CoreIPC::Out(chunk)))
     163        ShareableBitmap::Handle handle;
     164        if (!arguments->decode(CoreIPC::Out(handle)))
    165165            return;
    166         snapshotTaken(chunk);
     166        RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(handle);
     167        snapshotTaken(bitmap.get());
    167168        break;
    168169    }
     
    181182    while (hasPendingUpdates()) {
    182183        int tileID;
    183         UpdateChunk updateChunk;
     184        UpdateInfo updateInfo;
    184185        float scale;
    185186        unsigned pendingUpdateCount;
     
    188189        if (!arguments)
    189190            break;
    190         if (!arguments->decode(CoreIPC::Out(tileID, updateChunk, scale, pendingUpdateCount)))
     191        if (!arguments->decode(CoreIPC::Out(tileID, updateInfo, scale, pendingUpdateCount)))
    191192            break;
    192193        TiledDrawingAreaTile* tile = m_tilesByID.get(tileID);
    193194        ASSERT(!tile || tile->ID() == tileID);
    194195        if (tile)
    195             tile->updateFromChunk(&updateChunk, scale);
     196            tile->incorporateUpdate(updateInfo, scale);
    196197    }
    197198    tileBufferUpdateComplete();
  • trunk/Source/WebKit2/UIProcess/TiledDrawingAreaProxy.h

    r79803 r87160  
    5151namespace WebKit {
    5252
    53 class UpdateChunk;
     53class ShareableBitmap;
    5454class WebPageProxy;
    5555
     
    110110    void updateWebView(const Vector<WebCore::IntRect>& paintedArea);
    111111
    112     void snapshotTaken(UpdateChunk&);
     112    void snapshotTaken(ShareableBitmap*);
    113113
    114114    // DrawingAreaProxy
  • trunk/Source/WebKit2/UIProcess/TiledDrawingAreaTile.h

    r74324 r87160  
    4242
    4343class TiledDrawingAreaProxy;
    44 class UpdateChunk;
     44class UpdateInfo;
    4545
    4646class TiledDrawingAreaTile : public RefCounted<TiledDrawingAreaTile> {
     
    6464    void resize(const WebCore::IntSize&);
    6565
    66     void updateFromChunk(UpdateChunk* updateChunk, float);
     66    void incorporateUpdate(const UpdateInfo&, float scale);
    6767
    6868    int ID() const { return m_ID; }
  • trunk/Source/WebKit2/UIProcess/qt/TiledDrawingAreaProxyQt.cpp

    r76916 r87160  
    3131#include "DrawingAreaMessageKinds.h"
    3232#include "DrawingAreaProxyMessageKinds.h"
    33 #include "UpdateChunk.h"
     33#include "ShareableBitmap.h"
    3434#include "WKAPICast.h"
    3535#include "WebPageProxy.h"
     
    6363}
    6464
    65 void TiledDrawingAreaProxy::snapshotTaken(UpdateChunk& chunk)
     65void TiledDrawingAreaProxy::snapshotTaken(ShareableBitmap* bitmap)
    6666{
    67     emit m_webView->snapshotTaken(chunk.createImage());
     67    emit m_webView->snapshotTaken(bitmap->createQImage());
    6868}
    6969
  • trunk/Source/WebKit2/UIProcess/qt/TiledDrawingAreaTileQt.cpp

    r77317 r87160  
    3030
    3131#include "GraphicsContext.h"
     32#include "ShareableBitmap.h"
    3233#include "TiledDrawingAreaProxy.h"
     34#include "UpdateInfo.h"
    3335#include "WebPageProxy.h"
    3436#include "WebProcessProxy.h"
    35 #include "UpdateChunk.h"
    3637#include <QApplication>
    3738#include <QObject>
     
    118119}
    119120
    120 void TiledDrawingAreaTile::updateFromChunk(UpdateChunk* updateChunk, float)
     121void TiledDrawingAreaTile::incorporateUpdate(const UpdateInfo& updateInfo, float)
    121122{
    122     QImage image(updateChunk->createImage());
    123     const IntRect& updateChunkRect = updateChunk->rect();
     123    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(updateInfo.bitmapHandle);
     124    QImage image(bitmap->createQImage());
     125    const IntRect& updateChunkRect = updateInfo.updateRectBounds;
    124126
    125127#ifdef TILE_DEBUG_LOG
  • trunk/Source/WebKit2/WebKit2.pro

    r87065 r87160  
    172172    Shared/Plugins/PluginQuirks.h \
    173173    Shared/qt/PlatformCertificateInfo.h \
    174     Shared/qt/UpdateChunk.h \
    175174    Shared/qt/WebEventFactoryQt.h \
    176175    UIProcess/Authentication/AuthenticationChallengeProxy.h \
     
    378377    Shared/qt/NativeWebMouseEventQt.cpp \
    379378    Shared/qt/NativeWebWheelEventQt.cpp \
    380     Shared/qt/UpdateChunk.cpp \
    381379    Shared/qt/WebCoreArgumentCodersQt.cpp \
    382380    Shared/qt/WebEventFactoryQt.cpp \
  • trunk/Source/WebKit2/WebProcess/WebPage/TiledDrawingArea.cpp

    r79803 r87160  
    3232#include "DrawingAreaProxyMessageKinds.h"
    3333#include "MessageID.h"
    34 #include "UpdateChunk.h"
     34#include "UpdateInfo.h"
    3535#include "WebCore/Frame.h"
    3636#include "WebCore/FrameView.h"
     
    139139    m_webPage->layoutIfNeeded();
    140140
    141     UpdateChunk updateChunk(dirtyRect);
    142     paintIntoUpdateChunk(&updateChunk, scale);
     141    UpdateInfo updateInfo;
     142    updateInfo.updateRectBounds = dirtyRect;
     143    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(dirtyRect.size(), ShareableBitmap::SupportsAlpha);
     144    bitmap->createHandle(updateInfo.bitmapHandle);
     145    paintIntoBitmap(bitmap.get(), dirtyRect, scale);
    143146
    144147    unsigned pendingUpdateCount = m_pendingUpdates.size();
    145     WebProcess::shared().connection()->deprecatedSend(DrawingAreaProxyLegacyMessage::TileUpdated, m_webPage->pageID(), CoreIPC::In(tileID, updateChunk, scale, pendingUpdateCount));
     148    WebProcess::shared().connection()->deprecatedSend(DrawingAreaProxyLegacyMessage::TileUpdated, m_webPage->pageID(), CoreIPC::In(tileID, updateInfo, scale, pendingUpdateCount));
    146149}
    147150
     
    220223        float targetScale = float(targetSize.width()) / contentsRect.width();
    221224
    222         UpdateChunk updateChunk(IntRect(IntPoint(contentsRect.x() * targetScale, contentsRect.y() * targetScale), targetSize));
    223         paintIntoUpdateChunk(&updateChunk, targetScale);
    224 
    225         WebProcess::shared().connection()->deprecatedSend(DrawingAreaProxyLegacyMessage::SnapshotTaken, m_webPage->pageID(), CoreIPC::In(updateChunk));
     225        IntRect tileRect(IntPoint(contentsRect.x() * targetScale, contentsRect.y() * targetScale), targetSize);
     226
     227        UpdateInfo updateInfo;
     228        updateInfo.updateRectBounds = tileRect;
     229        RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(tileRect.size(), ShareableBitmap::SupportsAlpha);
     230        bitmap->createHandle(updateInfo.bitmapHandle);
     231
     232        paintIntoBitmap(bitmap.get(), tileRect, targetScale);
     233
     234        WebProcess::shared().connection()->deprecatedSend(DrawingAreaProxyLegacyMessage::SnapshotTaken, m_webPage->pageID(), CoreIPC::In(updateInfo));
    226235        break;
    227236    }
  • trunk/Source/WebKit2/WebProcess/WebPage/TiledDrawingArea.h

    r79803 r87160  
    3636namespace WebKit {
    3737
    38 class UpdateChunk;
     38class ShareableBitmap;
    3939
    4040class TiledDrawingArea : public DrawingArea {
     
    6868
    6969    // Platform overrides
    70     void paintIntoUpdateChunk(UpdateChunk*, float scale);
     70    void paintIntoBitmap(ShareableBitmap*, const WebCore::IntRect& tileRect, float scale);
    7171
    7272    void tileUpdateTimerFired();
  • trunk/Source/WebKit2/WebProcess/WebPage/qt/TiledDrawingAreaQt.cpp

    r76916 r87160  
    2929#if ENABLE(TILED_BACKING_STORE)
    3030
    31 #include "UpdateChunk.h"
     31#include "ShareableBitmap.h"
    3232#include "WebPage.h"
    3333#include <WebCore/GraphicsContext.h>
     
    4040namespace WebKit {
    4141
    42 void TiledDrawingArea::paintIntoUpdateChunk(UpdateChunk* updateChunk, float scale)
     42void TiledDrawingArea::paintIntoBitmap(ShareableBitmap* bitmap, const WebCore::IntRect& tileRect, float scale)
    4343{
    44     IntRect tileRect = updateChunk->rect();
    45     QImage image(updateChunk->createImage());
    46     QPainter painter(&image);
    47     // Now paint into the backing store.
    48     GraphicsContext graphicsContext(&painter);
    49     graphicsContext.translate(-tileRect.x(), -tileRect.y());
    50     graphicsContext.scale(FloatSize(scale, scale));
     44    OwnPtr<GraphicsContext> graphicsContext(bitmap->createGraphicsContext());
     45    graphicsContext->translate(-tileRect.x(), -tileRect.y());
     46    graphicsContext->scale(FloatSize(scale, scale));
    5147    IntRect contentRect = enclosingIntRect(FloatRect(tileRect.x() / scale,
    5248                                                     tileRect.y() / scale,
    5349                                                     tileRect.width() / scale,
    5450                                                     tileRect.height() / scale));
    55     m_webPage->drawRect(graphicsContext, contentRect);
     51    m_webPage->drawRect(*graphicsContext.get(), contentRect);
    5652}
    5753
Note: See TracChangeset for help on using the changeset viewer.