Пример #1
0
void ChunkedUpdateDrawingArea::display()
{
    ASSERT(!m_isWaitingForUpdate);
 
    if (m_paintingIsSuspended)
        return;

    if (m_dirtyRect.isEmpty())
        return;

    // Layout if necessary.
    m_webPage->layoutIfNeeded();
 
    IntRect dirtyRect = m_dirtyRect;
    m_dirtyRect = IntRect();

    // Create a new UpdateChunk and paint into it.
    UpdateChunk updateChunk(dirtyRect);
    paintIntoUpdateChunk(&updateChunk);

    WebProcess::shared().connection()->send(DrawingAreaProxyMessage::Update, m_webPage->pageID(), CoreIPC::In(updateChunk));

    m_isWaitingForUpdate = true;
    m_displayTimer.stop();
}
Пример #2
0
void ChunkedUpdateDrawingArea::setSize(const IntSize& viewSize)
{
    ASSERT_ARG(viewSize, !viewSize.isEmpty());

    // We don't want to wait for an update until we display.
    m_isWaitingForUpdate = false;
    
    m_webPage->setSize(viewSize);

    // Layout if necessary.
    m_webPage->layoutIfNeeded();

    if (m_paintingIsSuspended) {
        ASSERT(!m_displayTimer.isActive());

        // Painting is suspended, just send back an empty update chunk.
        WebProcess::shared().connection()->send(DrawingAreaProxyMessage::DidSetSize, m_webPage->pageID(), CoreIPC::In(UpdateChunk()));
        return;
    }

    // Create a new UpdateChunk and paint into it.
    UpdateChunk updateChunk(IntRect(0, 0, viewSize.width(), viewSize.height()));
    paintIntoUpdateChunk(&updateChunk);

    m_displayTimer.stop();

    WebProcess::shared().connection()->send(DrawingAreaProxyMessage::DidSetSize, m_webPage->pageID(), CoreIPC::In(updateChunk));
}
Пример #3
0
void TiledDrawingArea::updateTile(int tileID, const IntRect& dirtyRect, float scale)
{
    m_webPage->layoutIfNeeded();

    UpdateChunk updateChunk(dirtyRect);
    paintIntoUpdateChunk(&updateChunk, scale);

    unsigned pendingUpdateCount = m_pendingUpdates.size();
    WebProcess::shared().connection()->send(DrawingAreaProxyLegacyMessage::TileUpdated, m_webPage->pageID(), CoreIPC::In(tileID, updateChunk, scale, pendingUpdateCount));
}
Пример #4
0
void TiledDrawingArea::didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
{
    switch (messageID.get<DrawingAreaLegacyMessage::Kind>()) {
    case DrawingAreaLegacyMessage::SetSize: {
        IntSize size;
        if (!arguments->decode(CoreIPC::Out(size)))
            return;

        setSize(size);
        break;
    }
    case DrawingAreaLegacyMessage::SuspendPainting:
        suspendPainting();
        break;
    case DrawingAreaLegacyMessage::ResumePainting:
        resumePainting();
        break;
    case DrawingAreaLegacyMessage::CancelTileUpdate: {
        int tileID;
        if (!arguments->decode(CoreIPC::Out(tileID)))
            return;
        UpdateMap::iterator it = m_pendingUpdates.find(tileID);
        if (it != m_pendingUpdates.end()) {
            m_pendingUpdates.remove(it);
            if (m_pendingUpdates.isEmpty()) {
                WebProcess::shared().connection()->send(DrawingAreaProxyLegacyMessage::AllTileUpdatesProcessed, m_webPage->pageID(), CoreIPC::In());
                m_tileUpdateTimer.stop();
            }
        }
        break;
    }
    case DrawingAreaLegacyMessage::RequestTileUpdate: {
        TileUpdate update;
        if (!arguments->decode(CoreIPC::Out(update.tileID, update.dirtyRect, update.scale)))
            return;
        UpdateMap::iterator it = m_pendingUpdates.find(update.tileID);
        if (it != m_pendingUpdates.end())
            it->second.dirtyRect.unite(update.dirtyRect);
        else {
            m_pendingUpdates.add(update.tileID, update);
            if (!m_tileUpdateTimer.isActive())
                m_tileUpdateTimer.startOneShot(0);
        }
        break;
    }
    case DrawingAreaLegacyMessage::TakeSnapshot: {
        IntSize targetSize;
        IntRect contentsRect;

        if (!arguments->decode(CoreIPC::Out(targetSize, contentsRect)))
            return;

        m_webPage->layoutIfNeeded();

        contentsRect.intersect(IntRect(IntPoint::zero(), m_webPage->mainFrame()->coreFrame()->view()->contentsSize()));

        float targetScale = float(targetSize.width()) / contentsRect.width();

        UpdateChunk updateChunk(IntRect(IntPoint(contentsRect.x() * targetScale, contentsRect.y() * targetScale), targetSize));
        paintIntoUpdateChunk(&updateChunk, targetScale);

        WebProcess::shared().connection()->send(DrawingAreaProxyLegacyMessage::SnapshotTaken, m_webPage->pageID(), CoreIPC::In(updateChunk));
        break;
    }
    default:
        ASSERT_NOT_REACHED();
        break;
    }
}