Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
2011-02-03 Anders Carlsson <andersca@apple.com>
        Reviewed by Dan Bernstein.

        Change DidSetSize to take a LayerTreeContext parameter
        https://bugs.webkit.org/show_bug.cgi?id=53724

        Since SetSize can cause layout to happen, we need to pass along a layer tree context to
        the DidSetSize message so the UI process can enter/exit accelerated compositing mode appropriately.

        * Shared/LayerTreeContext.h:
        * Shared/mac/LayerTreeContextMac.mm:
        Add equality operators to LayerTreeContext.

        * UIProcess/DrawingAreaProxy.h:
        (WebKit::DrawingAreaProxy::didSetSize):
        This now takes a LayerTreeContext parameter.

        * UIProcess/DrawingAreaProxy.messages.in:
        Add LayerTreeContext parameter.

        * UIProcess/DrawingAreaProxyImpl.cpp:
        Get rid of m_isInAcceleratedCompositingMode and use the current layer context instead.

        (WebKit::DrawingAreaProxyImpl::paint):
        Bail if the call to DidSetSize ended up entering accelerated compositing mode.

        (WebKit::DrawingAreaProxyImpl::didSetSize):
        If the new layer tree context is different, enter/exit accelerated compositing mode accordingly.

        (WebKit::DrawingAreaProxyImpl::enterAcceleratedCompositingMode):
        (WebKit::DrawingAreaProxyImpl::exitAcceleratedCompositingMode):
        Update the layer tree context.

        * UIProcess/DrawingAreaProxyImpl.h:
        (WebKit::DrawingAreaProxyImpl::isInAcceleratedCompositingMode):
        Add simple getter.

        * WebProcess/WebPage/DrawingAreaImpl.cpp:
        (WebKit::DrawingAreaImpl::setSize):
        Pass along the layer tree context.


Canonical link: https://commits.webkit.org/67625@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@77546 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Anders Carlsson committed Feb 3, 2011
1 parent d5e84dc commit 220e78d
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 18 deletions.
42 changes: 42 additions & 0 deletions Source/WebKit2/ChangeLog
@@ -1,3 +1,45 @@
2011-02-03 Anders Carlsson <andersca@apple.com>

Reviewed by Dan Bernstein.

Change DidSetSize to take a LayerTreeContext parameter
https://bugs.webkit.org/show_bug.cgi?id=53724

Since SetSize can cause layout to happen, we need to pass along a layer tree context to
the DidSetSize message so the UI process can enter/exit accelerated compositing mode appropriately.

* Shared/LayerTreeContext.h:
* Shared/mac/LayerTreeContextMac.mm:
Add equality operators to LayerTreeContext.

* UIProcess/DrawingAreaProxy.h:
(WebKit::DrawingAreaProxy::didSetSize):
This now takes a LayerTreeContext parameter.

* UIProcess/DrawingAreaProxy.messages.in:
Add LayerTreeContext parameter.

* UIProcess/DrawingAreaProxyImpl.cpp:
Get rid of m_isInAcceleratedCompositingMode and use the current layer context instead.

(WebKit::DrawingAreaProxyImpl::paint):
Bail if the call to DidSetSize ended up entering accelerated compositing mode.

(WebKit::DrawingAreaProxyImpl::didSetSize):
If the new layer tree context is different, enter/exit accelerated compositing mode accordingly.

(WebKit::DrawingAreaProxyImpl::enterAcceleratedCompositingMode):
(WebKit::DrawingAreaProxyImpl::exitAcceleratedCompositingMode):
Update the layer tree context.

* UIProcess/DrawingAreaProxyImpl.h:
(WebKit::DrawingAreaProxyImpl::isInAcceleratedCompositingMode):
Add simple getter.

* WebProcess/WebPage/DrawingAreaImpl.cpp:
(WebKit::DrawingAreaImpl::setSize):
Pass along the layer tree context.

2011-02-03 Anders Carlsson <andersca@apple.com>

Reviewed by Dan Bernstein.
Expand Down
7 changes: 7 additions & 0 deletions Source/WebKit2/Shared/LayerTreeContext.h
Expand Up @@ -50,6 +50,13 @@ class LayerTreeContext {
#endif
};

bool operator==(const LayerTreeContext&, const LayerTreeContext&);

inline bool operator!=(const LayerTreeContext& a, const LayerTreeContext& b)
{
return !(a == b);
}

};

#endif // USE(ACCELERATED_COMPOSITING)
Expand Down
5 changes: 5 additions & 0 deletions Source/WebKit2/Shared/mac/LayerTreeContextMac.mm
Expand Up @@ -58,4 +58,9 @@
return !contextID;
}

bool operator==(const LayerTreeContext& a, const LayerTreeContext& b)
{
return a.contextID == b.contextID;
}

} // namespace WebKit
2 changes: 1 addition & 1 deletion Source/WebKit2/UIProcess/DrawingAreaProxy.h
Expand Up @@ -97,7 +97,7 @@ class DrawingAreaProxy {
// CoreIPC message handlers.
// FIXME: These should be pure virtual.
virtual void update(uint64_t sequenceNumber, const UpdateInfo&) { }
virtual void didSetSize(uint64_t sequenceNumber, const UpdateInfo&) { }
virtual void didSetSize(uint64_t sequenceNumber, const UpdateInfo&, const LayerTreeContext&) { }
#if USE(ACCELERATED_COMPOSITING)
virtual void enterAcceleratedCompositingMode(uint64_t sequenceNumber, const LayerTreeContext&) { }
virtual void exitAcceleratedCompositingMode(uint64_t sequenceNumber) { }
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in
Expand Up @@ -22,7 +22,7 @@

messages -> DrawingAreaProxy {
Update(uint64_t sequenceNumber, WebKit::UpdateInfo updateInfo)
DidSetSize(uint64_t sequenceNumber, WebKit::UpdateInfo updateInfo)
DidSetSize(uint64_t sequenceNumber, WebKit::UpdateInfo updateInfo, WebKit::LayerTreeContext context)

#if USE(ACCELERATED_COMPOSITING)
EnterAcceleratedCompositingMode(uint64_t sequenceNumber, WebKit::LayerTreeContext context)
Expand Down
37 changes: 26 additions & 11 deletions Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp
Expand Up @@ -50,7 +50,6 @@ PassOwnPtr<DrawingAreaProxyImpl> DrawingAreaProxyImpl::create(WebPageProxy* webP
DrawingAreaProxyImpl::DrawingAreaProxyImpl(WebPageProxy* webPageProxy)
: DrawingAreaProxy(DrawingAreaInfo::Impl, webPageProxy)
, m_isWaitingForDidSetSize(false)
, m_isInAcceleratedCompositingMode(false)
, m_lastDidSetSizeSequenceNumber(0)
{
}
Expand All @@ -66,7 +65,7 @@ void DrawingAreaProxyImpl::paint(BackingStore::PlatformGraphicsContext context,
if (!m_backingStore)
return;

ASSERT(!m_isInAcceleratedCompositingMode);
ASSERT(!isInAcceleratedCompositingMode());

if (m_isWaitingForDidSetSize) {
if (!m_webPageProxy->isValid())
Expand All @@ -79,6 +78,10 @@ void DrawingAreaProxyImpl::paint(BackingStore::PlatformGraphicsContext context,
m_webPageProxy->process()->connection()->waitForAndDispatchImmediately<Messages::DrawingAreaProxy::DidSetSize>(m_webPageProxy->pageID(), didSetSizeTimeout);
}

// Dispatching DidSetSize could change the compositing mode, return if that happens.
if (isInAcceleratedCompositingMode())
return;

m_backingStore->paint(context, rect);
unpaintedRegion.subtract(IntRect(IntPoint(), m_backingStore->size()));
}
Expand Down Expand Up @@ -141,7 +144,7 @@ void DrawingAreaProxyImpl::update(uint64_t sequenceNumber, const UpdateInfo& upd
m_webPageProxy->process()->send(Messages::DrawingArea::DidUpdate(), m_webPageProxy->pageID());
}

void DrawingAreaProxyImpl::didSetSize(uint64_t sequenceNumber, const UpdateInfo& updateInfo)
void DrawingAreaProxyImpl::didSetSize(uint64_t sequenceNumber, const UpdateInfo& updateInfo, const LayerTreeContext& layerTreeContext)
{
ASSERT(sequenceNumber > m_lastDidSetSizeSequenceNumber);
m_lastDidSetSizeSequenceNumber = sequenceNumber;
Expand All @@ -152,7 +155,19 @@ void DrawingAreaProxyImpl::didSetSize(uint64_t sequenceNumber, const UpdateInfo&
if (m_size != updateInfo.viewSize)
sendSetSize();

if (m_isInAcceleratedCompositingMode) {
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;
}
Expand All @@ -179,7 +194,7 @@ void DrawingAreaProxyImpl::exitAcceleratedCompositingMode(uint64_t sequenceNumbe

void DrawingAreaProxyImpl::incorporateUpdate(const UpdateInfo& updateInfo)
{
ASSERT(!m_isInAcceleratedCompositingMode);
ASSERT(!isInAcceleratedCompositingMode());

if (updateInfo.updateRectBounds.isEmpty())
return;
Expand Down Expand Up @@ -215,18 +230,18 @@ void DrawingAreaProxyImpl::sendSetSize()

void DrawingAreaProxyImpl::enterAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
{
ASSERT(!m_isInAcceleratedCompositingMode);
m_isInAcceleratedCompositingMode = true;

ASSERT(!isInAcceleratedCompositingMode());

m_backingStore = nullptr;
m_layerTreeContext = layerTreeContext;
m_webPageProxy->enterAcceleratedCompositingMode(layerTreeContext);
}

void DrawingAreaProxyImpl::exitAcceleratedCompositingMode()
{
ASSERT(m_isInAcceleratedCompositingMode);
m_isInAcceleratedCompositingMode = false;

ASSERT(isInAcceleratedCompositingMode());

m_layerTreeContext = LayerTreeContext();
m_webPageProxy->exitAcceleratedCompositingMode();
}

Expand Down
11 changes: 7 additions & 4 deletions Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h
Expand Up @@ -28,6 +28,7 @@

#include "BackingStore.h"
#include "DrawingAreaProxy.h"
#include "LayerTreeContext.h"

namespace WebKit {

Expand Down Expand Up @@ -55,7 +56,7 @@ class DrawingAreaProxyImpl : public DrawingAreaProxy {

// CoreIPC message handlers
virtual void update(uint64_t sequenceNumber, const UpdateInfo&);
virtual void didSetSize(uint64_t sequenceNumber, const UpdateInfo&);
virtual void didSetSize(uint64_t sequenceNumber, const UpdateInfo&, const LayerTreeContext&);
virtual void enterAcceleratedCompositingMode(uint64_t sequenceNumber, const LayerTreeContext&);
virtual void exitAcceleratedCompositingMode(uint64_t sequenceNumber);

Expand All @@ -65,13 +66,15 @@ class DrawingAreaProxyImpl : public DrawingAreaProxy {
void enterAcceleratedCompositingMode(const LayerTreeContext&);
void exitAcceleratedCompositingMode();

bool isInAcceleratedCompositingMode() const { return !m_layerTreeContext.isEmpty(); }

// The current layer tree context.
LayerTreeContext m_layerTreeContext;

// Whether we've sent a SetSize message and are now waiting for a DidSetSize message.
// Used to throttle SetSize messages so we don't send them faster than the Web process can handle.
bool m_isWaitingForDidSetSize;

// Whether we're in accelerated compositing mode or not.
bool m_isInAcceleratedCompositingMode;

// The sequence number of the last DidSetSize message
uint64_t m_lastDidSetSizeSequenceNumber;

Expand Down
6 changes: 5 additions & 1 deletion Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp
Expand Up @@ -183,13 +183,17 @@ void DrawingAreaImpl::setSize(const IntSize& size)
m_webPage->layoutIfNeeded();

UpdateInfo updateInfo;
LayerTreeContext layerTreeContext;

if (m_layerTreeHost)
layerTreeContext = m_layerTreeHost->layerTreeContext();

if (m_isPaintingSuspended || m_layerTreeHost) {
updateInfo.viewSize = m_webPage->size();
} else
display(updateInfo);

m_webPage->send(Messages::DrawingAreaProxy::DidSetSize(generateSequenceNumber(), updateInfo));
m_webPage->send(Messages::DrawingAreaProxy::DidSetSize(generateSequenceNumber(), updateInfo, layerTreeContext));

m_inSetSize = false;
}
Expand Down

0 comments on commit 220e78d

Please sign in to comment.