diff options
| author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-01-06 14:44:00 +0100 |
|---|---|---|
| committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-01-06 14:44:00 +0100 |
| commit | 40736c5763bf61337c8c14e16d8587db021a87d4 (patch) | |
| tree | b17a9c00042ad89cb1308e2484491799aa14e9f8 /Source/WebKit2/WebProcess/WebPage/TiledDrawingArea.cpp | |
| download | qtwebkit-40736c5763bf61337c8c14e16d8587db021a87d4.tar.gz | |
Imported WebKit commit 2ea9d364d0f6efa8fa64acf19f451504c59be0e4 (http://svn.webkit.org/repository/webkit/trunk@104285)
Diffstat (limited to 'Source/WebKit2/WebProcess/WebPage/TiledDrawingArea.cpp')
| -rw-r--r-- | Source/WebKit2/WebProcess/WebPage/TiledDrawingArea.cpp | 187 |
1 files changed, 187 insertions, 0 deletions
diff --git a/Source/WebKit2/WebProcess/WebPage/TiledDrawingArea.cpp b/Source/WebKit2/WebProcess/WebPage/TiledDrawingArea.cpp new file mode 100644 index 000000000..c482e664b --- /dev/null +++ b/Source/WebKit2/WebProcess/WebPage/TiledDrawingArea.cpp @@ -0,0 +1,187 @@ +/* + * Copyright (C) 2010, 2011 Nokia Corporation and/or its subsidiary(-ies) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "TiledDrawingArea.h" + +#if USE(TILED_BACKING_STORE) + +#include "DrawingAreaProxyMessages.h" +#include "MessageID.h" +#include "UpdateInfo.h" +#include "WebCoreArgumentCoders.h" +#include "WebPage.h" +#include "WebProcess.h" + +using namespace WebCore; + +namespace WebKit { + +TiledDrawingArea::TiledDrawingArea(WebPage* webPage) + : DrawingArea(DrawingAreaTypeTiled, webPage) + , m_suspended(false) + , m_isWaitingForUIProcess(false) + , m_didSendTileUpdate(false) + , m_mainBackingStore(adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackend::create(this)))) +{ +} + +TiledDrawingArea::~TiledDrawingArea() +{ +} + +void TiledDrawingArea::scroll(const IntRect& scrollRect, const IntSize& scrollDelta) +{ + // FIXME: Do something much smarter. + setNeedsDisplay(scrollRect); +} + +void TiledDrawingArea::setNeedsDisplay(const IntRect& rect) +{ + m_mainBackingStore->invalidate(rect); +} + +void TiledDrawingArea::setSize(const IntSize& viewSize) +{ + ASSERT(!m_suspended); + ASSERT_ARG(viewSize, !viewSize.isEmpty()); + + m_webPage->setSize(viewSize); +} + +void TiledDrawingArea::setVisibleContentRectAndScale(const WebCore::IntRect& visibleContentsRect, float scale) +{ + m_visibleContentRect = visibleContentsRect; + + if (scale != m_mainBackingStore->contentsScale()) { + // Keep the tiles for the previous scale until enough content is available to be shown on the screen for the new scale. + // If we already have a previous set of tiles it means that two scale changed happened successively. + // In that case, make sure that our current main tiles have more content to show than the "previous previous" + // within the visible rect before replacing it. + if (!m_previousBackingStore || m_mainBackingStore->coverageRatio(m_visibleContentRect) > m_previousBackingStore->coverageRatio(m_visibleContentRect)) + m_previousBackingStore = m_mainBackingStore.release(); + + m_mainBackingStore = adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackend::create(this))); + m_mainBackingStore->setContentsScale(scale); + } else + m_mainBackingStore->adjustVisibleRect(); +} + +void TiledDrawingArea::setVisibleContentRectTrajectoryVector(const WebCore::FloatPoint& trajectoryVector) +{ + m_mainBackingStore->setVisibleRectTrajectoryVector(trajectoryVector); +} + +void TiledDrawingArea::renderNextFrame() +{ + m_isWaitingForUIProcess = false; + m_mainBackingStore->updateTileBuffers(); +} + +void TiledDrawingArea::suspendPainting() +{ + ASSERT(!m_suspended); + + m_suspended = true; +} + +void TiledDrawingArea::resumePainting() +{ + ASSERT(m_suspended); + + m_suspended = false; + m_mainBackingStore->updateTileBuffers(); +} + +void TiledDrawingArea::tiledBackingStorePaintBegin() +{ + m_webPage->layoutIfNeeded(); +} + +void TiledDrawingArea::tiledBackingStorePaint(GraphicsContext* graphicsContext, const IntRect& contentRect) +{ + m_webPage->drawRect(*graphicsContext, contentRect); +} + +void TiledDrawingArea::tiledBackingStorePaintEnd(const Vector<IntRect>& paintedArea) +{ + if (m_didSendTileUpdate) { + // Since we know that all tile updates following a page invalidate will all be rendered + // in one paint pass for all the tiles, we can send the swap tile message here. + m_webPage->send(Messages::DrawingAreaProxy::DidRenderFrame()); + m_isWaitingForUIProcess = true; + m_didSendTileUpdate = false; + + // Make sure that we destroy the previous backing store and remove its tiles only after DidRenderFrame + // was sent to swap recently created tiles' buffer. Else a frame could be rendered after the previous + // tiles were removed and before the new tile have their first back buffer swapped. + if (m_previousBackingStore && m_mainBackingStore->coverageRatio(m_visibleContentRect) >= 1.0f) + m_previousBackingStore.clear(); + } +} + +bool TiledDrawingArea::tiledBackingStoreUpdatesAllowed() const +{ + return !m_suspended && !m_isWaitingForUIProcess; +} + +IntRect TiledDrawingArea::tiledBackingStoreContentsRect() +{ + return IntRect(IntPoint::zero(), m_webPage->size()); +} + +IntRect TiledDrawingArea::tiledBackingStoreVisibleRect() +{ + return m_visibleContentRect; +} + +Color TiledDrawingArea::tiledBackingStoreBackgroundColor() const +{ + return Color::transparent; +} + +void TiledDrawingArea::createTile(int tileID, const UpdateInfo& updateInfo) +{ + m_webPage->send(Messages::DrawingAreaProxy::CreateTile(tileID, updateInfo)); + m_didSendTileUpdate = true; +} +void TiledDrawingArea::updateTile(int tileID, const UpdateInfo& updateInfo) +{ + m_webPage->send(Messages::DrawingAreaProxy::UpdateTile(tileID, updateInfo)); + m_didSendTileUpdate = true; +} +void TiledDrawingArea::removeTile(int tileID) +{ + m_webPage->send(Messages::DrawingAreaProxy::RemoveTile(tileID)); +} + +#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER) +void TiledDrawingArea::didReceiveLayerTreeHostMessage(CoreIPC::Connection* connection, CoreIPC::MessageID, CoreIPC::ArgumentDecoder* arguments) +{ +} +#endif +} // namespace WebKit + +#endif // USE(TILED_BACKING_STORE) |
