diff options
author | Steve Block <steveblock@google.com> | 2011-05-18 13:36:51 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2011-05-24 15:38:28 +0100 |
commit | 2fc2651226baac27029e38c9d6ef883fa32084db (patch) | |
tree | e396d4bf89dcce6ed02071be66212495b1df1dec /Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp | |
parent | b3725cedeb43722b3b175aaeff70552e562d2c94 (diff) | |
download | external_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.zip external_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.tar.gz external_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.tar.bz2 |
Merge WebKit at r78450: Initial merge by git.
Change-Id: I6d3e5f1f868ec266a0aafdef66182ddc3f265dc1
Diffstat (limited to 'Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp')
-rw-r--r-- | Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp | 107 |
1 files changed, 103 insertions, 4 deletions
diff --git a/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp b/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp index 3207094..6a65841 100644 --- a/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp +++ b/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp @@ -23,15 +23,18 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "DrawingAreaProxyImpl.h" #include "DrawingAreaMessages.h" +#include "DrawingAreaProxyMessages.h" +#include "LayerTreeContext.h" #include "Region.h" #include "UpdateInfo.h" #include "WebPageProxy.h" #include "WebProcessProxy.h" -#ifndef __APPLE__ +#if !PLATFORM(MAC) && !PLATFORM(WIN) #error "This drawing area is not ready for use by other ports yet." #endif @@ -47,11 +50,15 @@ PassOwnPtr<DrawingAreaProxyImpl> DrawingAreaProxyImpl::create(WebPageProxy* webP DrawingAreaProxyImpl::DrawingAreaProxyImpl(WebPageProxy* webPageProxy) : DrawingAreaProxy(DrawingAreaInfo::Impl, webPageProxy) , m_isWaitingForDidSetSize(false) + , m_lastDidSetSizeSequenceNumber(0) { } DrawingAreaProxyImpl::~DrawingAreaProxyImpl() { + // Make sure to exit accelerated compositing mode. + if (isInAcceleratedCompositingMode()) + exitAcceleratedCompositingMode(); } void DrawingAreaProxyImpl::paint(BackingStore::PlatformGraphicsContext context, const IntRect& rect, Region& unpaintedRegion) @@ -61,6 +68,18 @@ void DrawingAreaProxyImpl::paint(BackingStore::PlatformGraphicsContext context, if (!m_backingStore) return; + ASSERT(!isInAcceleratedCompositingMode()); + + if (m_isWaitingForDidSetSize) { + // Wait for a DidSetSize message that contains the new bits before we paint + // what's currently in the backing store. + waitForAndDispatchDidSetSize(); + + // Dispatching DidSetSize could destroy our backing store or change the compositing mode. + if (!m_backingStore || isInAcceleratedCompositingMode()) + return; + } + m_backingStore->paint(context, rect); unpaintedRegion.subtract(IntRect(IntPoint(), m_backingStore->size())); } @@ -112,29 +131,71 @@ void DrawingAreaProxyImpl::detachCompositingContext() ASSERT_NOT_REACHED(); } -void DrawingAreaProxyImpl::update(const UpdateInfo& updateInfo) +void DrawingAreaProxyImpl::update(uint64_t sequenceNumber, const UpdateInfo& updateInfo) { + if (sequenceNumber < m_lastDidSetSizeSequenceNumber) + return; + // FIXME: Handle the case where the view is hidden. incorporateUpdate(updateInfo); m_webPageProxy->process()->send(Messages::DrawingArea::DidUpdate(), m_webPageProxy->pageID()); } -void DrawingAreaProxyImpl::didSetSize(const UpdateInfo& updateInfo) +void DrawingAreaProxyImpl::didSetSize(uint64_t sequenceNumber, const UpdateInfo& updateInfo, const LayerTreeContext& layerTreeContext) { + ASSERT(sequenceNumber > m_lastDidSetSizeSequenceNumber); + m_lastDidSetSizeSequenceNumber = sequenceNumber; + ASSERT(m_isWaitingForDidSetSize); m_isWaitingForDidSetSize = false; if (m_size != updateInfo.viewSize) sendSetSize(); + if (layerTreeContext != m_layerTreeContext) { + if (!m_layerTreeContext.isEmpty()) { + exitAcceleratedCompositingMode(); + ASSERT(m_layerTreeContext.isEmpty()); + } + + if (!layerTreeContext.isEmpty()) { + enterAcceleratedCompositingMode(layerTreeContext); + ASSERT(layerTreeContext == m_layerTreeContext); + } + } + + if (isInAcceleratedCompositingMode()) { + ASSERT(!m_backingStore); + return; + } + m_backingStore = nullptr; + incorporateUpdate(updateInfo); +} + +void DrawingAreaProxyImpl::enterAcceleratedCompositingMode(uint64_t sequenceNumber, const LayerTreeContext& layerTreeContext) +{ + if (sequenceNumber < m_lastDidSetSizeSequenceNumber) + return; + + enterAcceleratedCompositingMode(layerTreeContext); +} + +void DrawingAreaProxyImpl::exitAcceleratedCompositingMode(uint64_t sequenceNumber, const UpdateInfo& updateInfo) +{ + if (sequenceNumber < m_lastDidSetSizeSequenceNumber) + return; + + exitAcceleratedCompositingMode(); incorporateUpdate(updateInfo); } void DrawingAreaProxyImpl::incorporateUpdate(const UpdateInfo& updateInfo) { + ASSERT(!isInAcceleratedCompositingMode()); + if (updateInfo.updateRectBounds.isEmpty()) return; @@ -164,7 +225,45 @@ void DrawingAreaProxyImpl::sendSetSize() return; m_isWaitingForDidSetSize = true; - m_webPageProxy->process()->send(Messages::DrawingArea::SetSize(m_size), m_webPageProxy->pageID()); + m_webPageProxy->process()->send(Messages::DrawingArea::SetSize(m_size, m_scrollOffset), m_webPageProxy->pageID()); + m_scrollOffset = IntSize(); + + if (!m_layerTreeContext.isEmpty()) { + // Wait for the DidSetSize message. Normally we don this in DrawingAreaProxyImpl::paint, but that + // function is never called when in accelerated compositing mode. + waitForAndDispatchDidSetSize(); + } +} + +void DrawingAreaProxyImpl::waitForAndDispatchDidSetSize() +{ + ASSERT(m_isWaitingForDidSetSize); + + if (!m_webPageProxy->isValid()) + return; + if (m_webPageProxy->process()->isLaunching()) + return; + + // The timeout, in seconds, we use when waiting for a DidSetSize message when we're asked to paint. + static const double didSetSizeTimeout = 0.5; + m_webPageProxy->process()->connection()->waitForAndDispatchImmediately<Messages::DrawingAreaProxy::DidSetSize>(m_webPageProxy->pageID(), didSetSizeTimeout); +} + +void DrawingAreaProxyImpl::enterAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext) +{ + ASSERT(!isInAcceleratedCompositingMode()); + + m_backingStore = nullptr; + m_layerTreeContext = layerTreeContext; + m_webPageProxy->enterAcceleratedCompositingMode(layerTreeContext); +} + +void DrawingAreaProxyImpl::exitAcceleratedCompositingMode() +{ + ASSERT(isInAcceleratedCompositingMode()); + + m_layerTreeContext = LayerTreeContext(); + m_webPageProxy->exitAcceleratedCompositingMode(); } } // namespace WebKit |