Skip to content
Permalink
Browse files
Add basic page overlay support to TiledCoreAnimationDrawingArea
https://bugs.webkit.org/show_bug.cgi?id=79716
<rdar://problem/10923079>

Reviewed by Sam Weinig.

* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
Make TiledCoreAnimationDrawingArea a GraphicsLayerClient.

* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::didInstallPageOverlay):
Create the page overlay layer.

(WebKit::TiledCoreAnimationDrawingArea::didUninstallPageOverlay):
Destroy the page overlay layer.

(WebKit::TiledCoreAnimationDrawingArea::setPageOverlayNeedsDisplay):
Mark the page overlay layer as needing display.

(WebKit::TiledCoreAnimationDrawingArea::notifyAnimationStarted):
(WebKit::TiledCoreAnimationDrawingArea::notifySyncRequired):
Add empty GraphisLayerClient member function implementations.

(WebKit::TiledCoreAnimationDrawingArea::paintContents):
Ask the page overlay to paint itself.

(WebKit::TiledCoreAnimationDrawingArea::flushLayers):
Flush the page overlay layer.

(WebKit::TiledCoreAnimationDrawingArea::updateGeometry):
Resize the page overlay layer.

(WebKit::TiledCoreAnimationDrawingArea::setRootCompositingLayer):
If we have a page overlay layer, add it as a sublayer of the root layer.

(WebKit::TiledCoreAnimationDrawingArea::createPageOverlayLayer):
Create the page overlay layer and add it as a sublayer of the root layer.

(WebKit::TiledCoreAnimationDrawingArea::destroyPageOverlayLayer):
Remove the page overlay layer and destroy it.

Canonical link: https://commits.webkit.org/96879@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@109118 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Anders Carlsson committed Feb 28, 2012
1 parent f069d6f commit e45e43b303b61bfb3f33b19265ad5471935f0594
@@ -1,3 +1,46 @@
2012-02-27 Anders Carlsson <andersca@apple.com>

Add basic page overlay support to TiledCoreAnimationDrawingArea
https://bugs.webkit.org/show_bug.cgi?id=79716
<rdar://problem/10923079>

Reviewed by Sam Weinig.

* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
Make TiledCoreAnimationDrawingArea a GraphicsLayerClient.

* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::didInstallPageOverlay):
Create the page overlay layer.

(WebKit::TiledCoreAnimationDrawingArea::didUninstallPageOverlay):
Destroy the page overlay layer.

(WebKit::TiledCoreAnimationDrawingArea::setPageOverlayNeedsDisplay):
Mark the page overlay layer as needing display.

(WebKit::TiledCoreAnimationDrawingArea::notifyAnimationStarted):
(WebKit::TiledCoreAnimationDrawingArea::notifySyncRequired):
Add empty GraphisLayerClient member function implementations.

(WebKit::TiledCoreAnimationDrawingArea::paintContents):
Ask the page overlay to paint itself.

(WebKit::TiledCoreAnimationDrawingArea::flushLayers):
Flush the page overlay layer.

(WebKit::TiledCoreAnimationDrawingArea::updateGeometry):
Resize the page overlay layer.

(WebKit::TiledCoreAnimationDrawingArea::setRootCompositingLayer):
If we have a page overlay layer, add it as a sublayer of the root layer.

(WebKit::TiledCoreAnimationDrawingArea::createPageOverlayLayer):
Create the page overlay layer and add it as a sublayer of the root layer.

(WebKit::TiledCoreAnimationDrawingArea::destroyPageOverlayLayer):
Remove the page overlay layer and destroy it.

2012-02-28 Carlos Garcia Campos <cgarcia@igalia.com>

[GTK] Remove virtual methods of WebKitDownload signals in WebKit2 GTK+ API
@@ -27,6 +27,7 @@
#define TiledCoreAnimationDrawingArea_h

#include "DrawingArea.h"
#include <WebCore/GraphicsLayerClient.h>
#include <WebCore/LayerFlushScheduler.h>
#include <WebCore/LayerFlushSchedulerClient.h>
#include <wtf/RetainPtr.h>
@@ -38,7 +39,7 @@ namespace WebKit {

class RemoteLayerClient;

class TiledCoreAnimationDrawingArea : public DrawingArea, private WebCore::LayerFlushSchedulerClient {
class TiledCoreAnimationDrawingArea : public DrawingArea, WebCore::GraphicsLayerClient, WebCore::LayerFlushSchedulerClient {
public:
static PassOwnPtr<TiledCoreAnimationDrawingArea> create(WebPage*, const WebPageCreationParameters&);
virtual ~TiledCoreAnimationDrawingArea();
@@ -56,6 +57,18 @@ class TiledCoreAnimationDrawingArea : public DrawingArea, private WebCore::Layer
virtual void setRootCompositingLayer(WebCore::GraphicsLayer*) OVERRIDE;
virtual void scheduleCompositingLayerSync() OVERRIDE;

virtual void didInstallPageOverlay() OVERRIDE;
virtual void didUninstallPageOverlay() OVERRIDE;
virtual void setPageOverlayNeedsDisplay(const WebCore::IntRect&) OVERRIDE;

// WebCore::GraphicsLayerClient
virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double time) OVERRIDE;
virtual void notifySyncRequired(const WebCore::GraphicsLayer*) OVERRIDE;
virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect) OVERRIDE;
virtual bool showDebugBorders(const WebCore::GraphicsLayer*) const OVERRIDE;
virtual bool showRepaintCounter(const WebCore::GraphicsLayer*) const OVERRIDE;
virtual float deviceScaleFactor() const OVERRIDE;

// WebCore::LayerFlushSchedulerClient
virtual bool flushLayers() OVERRIDE;

@@ -65,12 +78,17 @@ class TiledCoreAnimationDrawingArea : public DrawingArea, private WebCore::Layer

void setRootCompositingLayer(CALayer *);

void createPageOverlayLayer();
void destroyPageOverlayLayer();

bool m_layerTreeStateIsFrozen;
WebCore::LayerFlushScheduler m_layerFlushScheduler;

OwnPtr<RemoteLayerClient> m_remoteLayerClient;
RetainPtr<CALayer> m_rootLayer;
RetainPtr<CALayer> m_pendingRootCompositingLayer;

OwnPtr<WebCore::GraphicsLayer> m_pageOverlayLayer;
};

} // namespace WebKit
@@ -144,6 +144,55 @@ + (void)synchronize;
m_layerFlushScheduler.schedule();
}

void TiledCoreAnimationDrawingArea::didInstallPageOverlay()
{
createPageOverlayLayer();
scheduleCompositingLayerSync();
}

void TiledCoreAnimationDrawingArea::didUninstallPageOverlay()
{
destroyPageOverlayLayer();
scheduleCompositingLayerSync();
}

void TiledCoreAnimationDrawingArea::setPageOverlayNeedsDisplay(const IntRect& rect)
{
ASSERT(m_pageOverlayLayer);
m_pageOverlayLayer->setNeedsDisplayInRect(rect);
scheduleCompositingLayerSync();
}

void TiledCoreAnimationDrawingArea::notifyAnimationStarted(const GraphicsLayer*, double)
{
}

void TiledCoreAnimationDrawingArea::notifySyncRequired(const GraphicsLayer*)
{
}

void TiledCoreAnimationDrawingArea::paintContents(const GraphicsLayer* graphicsLayer, GraphicsContext& graphicsContext, GraphicsLayerPaintingPhase, const IntRect& clipRect)
{
ASSERT_UNUSED(graphicsLayer, graphicsLayer == m_pageOverlayLayer);

m_webPage->drawPageOverlay(graphicsContext, clipRect);
}

bool TiledCoreAnimationDrawingArea::showDebugBorders(const GraphicsLayer*) const
{
return m_webPage->corePage()->settings()->showDebugBorders();
}

bool TiledCoreAnimationDrawingArea::showRepaintCounter(const GraphicsLayer*) const
{
return m_webPage->corePage()->settings()->showRepaintCounter();
}

float TiledCoreAnimationDrawingArea::deviceScaleFactor() const
{
return m_webPage->corePage()->deviceScaleFactor();
}

bool TiledCoreAnimationDrawingArea::flushLayers()
{
ASSERT(!m_layerTreeStateIsFrozen);
@@ -158,6 +207,9 @@ + (void)synchronize;
m_pendingRootCompositingLayer = nullptr;
}

if (m_pageOverlayLayer)
m_pageOverlayLayer->syncCompositingStateForThisLayerOnly();

bool returnValue = m_webPage->corePage()->mainFrame()->view()->syncCompositingStateIncludingSubframes();

[pool drain];
@@ -169,6 +221,9 @@ + (void)synchronize;
m_webPage->setSize(viewSize);
m_webPage->layoutIfNeeded();

if (m_pageOverlayLayer)
m_pageOverlayLayer->setSize(viewSize);

if (!m_layerTreeStateIsFrozen)
flushLayers();

@@ -199,10 +254,37 @@ + (void)synchronize;

if (!layer)
m_rootLayer.get().sublayers = nil;
else
else {
m_rootLayer.get().sublayers = [NSArray arrayWithObject:layer];

if (m_pageOverlayLayer)
[m_rootLayer.get() addSublayer:m_pageOverlayLayer->platformLayer()];
}

[CATransaction commit];
}

void TiledCoreAnimationDrawingArea::createPageOverlayLayer()
{
ASSERT(!m_pageOverlayLayer);

m_pageOverlayLayer = GraphicsLayer::create(this);
#ifndef NDEBUG
m_pageOverlayLayer->setName("page overlay content");
#endif

m_pageOverlayLayer->setDrawsContent(true);
m_pageOverlayLayer->setSize(m_webPage->size());

[m_rootLayer.get() addSublayer:m_pageOverlayLayer->platformLayer()];
}

void TiledCoreAnimationDrawingArea::destroyPageOverlayLayer()
{
ASSERT(m_pageOverlayLayer);

[m_pageOverlayLayer->platformLayer() removeFromSuperlayer];
m_pageOverlayLayer = nullptr;
}

} // namespace WebKit

0 comments on commit e45e43b

Please sign in to comment.