[BlackBerry] WebOverlay API

https://bugs.webkit.org/show_bug.cgi?id=87603

Patch by Arvid Nilsson <anilsson@rim.com> on 2012-05-29
Reviewed by Rob Buis.

Source/WebKit:

Add WebOverlay related files to the build system.

PR #156812

* PlatformBlackBerry.cmake:

Source/WebKit/blackberry:

This new API makes it possible to leverage the BlackBerry accelerated
compositing implementation to draw, transform and fluidly animate
overlays in the embedding library or application.

A WebOverlay has an affinity for the thread where it was created. If
the current thread is the WebKit thread, use WebPage::addOverlay() to
add it to the page, and manipulate it only from the WebKit thread, with
exception of the "override" functionality which can be used from the
compositing thread. If the current thread is the compositing thread,
use WebPage::addCompositingThreadOverlay() to add it to the page, and
only manipulate it on the compositing thread.

A WebOverlay can be painted using Skia, or its contents can be set to
an image or a solid color.

PR #156812

* Api/WebAnimation.cpp: Added.
(WebKit):
(BlackBerry::WebKit::WebAnimation::fadeAnimation):
(BlackBerry::WebKit::WebAnimation::name):
(BlackBerry::WebKit::WebAnimation::WebAnimation):
(BlackBerry::WebKit::WebAnimation::~WebAnimation):
(BlackBerry::WebKit::WebAnimation::operator=):
* Api/WebAnimation.h: Added.
(WebKit):
* Api/WebAnimation_p.h: Added.
(WebKit):
(WebAnimationPrivate):
(BlackBerry::WebKit::WebAnimationPrivate::WebAnimationPrivate):
* Api/WebOverlay.cpp: Added.
(WebKit):
(BlackBerry::WebKit::WebOverlay::WebOverlay):
(BlackBerry::WebKit::WebOverlay::~WebOverlay):
(BlackBerry::WebKit::WebOverlay::position):
(BlackBerry::WebKit::WebOverlay::setPosition):
(BlackBerry::WebKit::WebOverlay::anchorPoint):
(BlackBerry::WebKit::WebOverlay::setAnchorPoint):
(BlackBerry::WebKit::WebOverlay::size):
(BlackBerry::WebKit::WebOverlay::setSize):
(BlackBerry::WebKit::WebOverlay::sizeIsScaleInvariant):
(BlackBerry::WebKit::WebOverlay::setSizeIsScaleInvariant):
(BlackBerry::WebKit::WebOverlay::transform):
(BlackBerry::WebKit::WebOverlay::setTransform):
(BlackBerry::WebKit::WebOverlay::opacity):
(BlackBerry::WebKit::WebOverlay::setOpacity):
(BlackBerry::WebKit::WebOverlay::addAnimation):
(BlackBerry::WebKit::WebOverlay::removeAnimation):
(BlackBerry::WebKit::WebOverlay::parent):
(BlackBerry::WebKit::WebOverlay::addChild):
(BlackBerry::WebKit::WebOverlay::removeFromParent):
(BlackBerry::WebKit::WebOverlay::setContentsToImage):
(BlackBerry::WebKit::WebOverlay::setContentsToColor):
(BlackBerry::WebKit::WebOverlay::setDrawsContent):
(BlackBerry::WebKit::WebOverlay::invalidate):
(BlackBerry::WebKit::WebOverlay::setClient):
(BlackBerry::WebKit::WebOverlay::override):
(BlackBerry::WebKit::WebOverlay::resetOverrides):
(BlackBerry::WebKit::WebOverlayPrivate::page):
(BlackBerry::WebKit::WebOverlayPrivate::override):
(BlackBerry::WebKit::WebOverlayPrivate::drawContents):
(BlackBerry::WebKit::WebOverlayPrivate::scheduleCompositingRun):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::WebOverlayPrivateWebKitThread):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::override):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::position):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::setPosition):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::anchorPoint):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::setAnchorPoint):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::size):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::setSize):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::sizeIsScaleInvariant):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::setSizeIsScaleInvariant):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::transform):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::setTransform):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::opacity):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::setOpacity):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::addAnimation):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::removeAnimation):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::addChild):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::removeFromParent):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::setContentsToImage):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::setContentsToColor):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::setDrawsContent):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::clear):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::invalidate):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::resetOverrides):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::notifySyncRequired):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::paintContents):
(BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::WebOverlayLayerCompositingThreadClient):
(BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::~WebOverlayLayerCompositingThreadClient):
(BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::setDrawsContent):
(BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::invalidate):
(BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::setContents):
(BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::setContentsToColor):
(BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::layerCompositingThreadDestroyed):
(BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::layerVisibilityChanged):
(BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::uploadTexturesIfNeeded):
(BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::drawTextures):
(BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::deleteTextures):
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::WebOverlayPrivateCompositingThread):
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::~WebOverlayPrivateCompositingThread):
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::setClient):
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::override):
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::position):
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::setPosition):
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::anchorPoint):
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::setAnchorPoint):
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::size):
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::setSize):
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::sizeIsScaleInvariant):
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::setSizeIsScaleInvariant):
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::transform):
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::setTransform):
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::opacity):
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::setOpacity):
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::addAnimation):
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::removeAnimation):
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::addChild):
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::removeFromParent):
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::setContentsToImage):
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::setContentsToColor):
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::setDrawsContent):
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::clear):
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::invalidate):
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::resetOverrides):
* Api/WebOverlay.h: Added.
(WebCore):
(WebKit):
* Api/WebOverlayClient.h: Added.
(WebKit):
* Api/WebOverlayOverride.cpp: Added.
(WebKit):
(BlackBerry::WebKit::WebOverlayOverride::WebOverlayOverride):
(BlackBerry::WebKit::WebOverlayOverride::~WebOverlayOverride):
(BlackBerry::WebKit::WebOverlayOverride::setPosition):
(BlackBerry::WebKit::WebOverlayOverride::setAnchorPoint):
(BlackBerry::WebKit::WebOverlayOverride::setSize):
(BlackBerry::WebKit::WebOverlayOverride::setTransform):
(BlackBerry::WebKit::WebOverlayOverride::setOpacity):
(BlackBerry::WebKit::WebOverlayOverride::addAnimation):
(BlackBerry::WebKit::WebOverlayOverride::removeAnimation):
* Api/WebOverlayOverride.h: Added.
(WebKit):
* Api/WebOverlay_p.h: Added.
(WTF):
(WebCore):
(WebKit):
(WebOverlayPrivate):
(BlackBerry::WebKit::WebOverlayPrivate::WebOverlayPrivate):
(BlackBerry::WebKit::WebOverlayPrivate::~WebOverlayPrivate):
(BlackBerry::WebKit::WebOverlayPrivate::setPage):
(BlackBerry::WebKit::WebOverlayPrivate::setClient):
(BlackBerry::WebKit::WebOverlayPrivate::layerCompositingThread):
(BlackBerry::WebKit::WebOverlayPrivate::graphicsLayer):
(WebOverlayPrivateWebKitThread):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::graphicsLayer):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::notifyAnimationStarted):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::showDebugBorders):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::showRepaintCounter):
(BlackBerry::WebKit::WebOverlayPrivateWebKitThread::contentsVisible):
(WebOverlayLayerCompositingThreadClient):
(BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::setLayer):
(BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::setClient):
(BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::drawsContent):
(BlackBerry::WebKit::WebOverlayLayerCompositingThreadClient::contents):
(WebOverlayPrivateCompositingThread):
* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPage::addOverlay):
(WebKit):
(BlackBerry::WebKit::WebPage::removeOverlay):
(BlackBerry::WebKit::WebPage::addCompositingThreadOverlay):
(BlackBerry::WebKit::WebPage::removeCompositingThreadOverlay):
* Api/WebPage.h:
(WebKit):
* Api/WebPageCompositor.cpp:
(BlackBerry::WebKit::WebPageCompositorPrivate::prepareFrame):
(BlackBerry::WebKit::WebPageCompositorPrivate::render):
(WebKit):
(BlackBerry::WebKit::WebPageCompositorPrivate::compositeLayers):
(BlackBerry::WebKit::WebPageCompositorPrivate::drawLayers):
(BlackBerry::WebKit::WebPageCompositorPrivate::addOverlay):
(BlackBerry::WebKit::WebPageCompositorPrivate::removeOverlay):
* Api/WebPageCompositor_p.h:
(BlackBerry::WebKit::WebPageCompositorPrivate::compositingThreadOverlayLayer):
(WebPageCompositorPrivate):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@118750 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 65741ff3
2012-05-29 Arvid Nilsson <anilsson@rim.com>
[BlackBerry] WebOverlay API
https://bugs.webkit.org/show_bug.cgi?id=87603
Reviewed by Rob Buis.
Add WebOverlay related files to the build system.
PR #156812
* PlatformBlackBerry.cmake:
2012-05-28 Arvid Nilsson <anilsson@rim.com>
[BlackBerry] Add a default tap highlight
......
......@@ -47,13 +47,16 @@ ADD_DEFINITIONS(-DUSER_PROCESSES)
LIST(APPEND WebKit_SOURCES
blackberry/Api/BackingStore.cpp
blackberry/Api/BlackBerryGlobal.cpp
blackberry/Api/WebString.cpp
blackberry/Api/WebAnimation.cpp
blackberry/Api/WebKitMIMETypeConverter.cpp
blackberry/Api/WebKitTextCodec.cpp
blackberry/Api/WebOverlay.cpp
blackberry/Api/WebOverlayOverride.cpp
blackberry/Api/WebPage.cpp
blackberry/Api/WebPageCompositor.cpp
blackberry/Api/WebPageGroupLoadDeferrer.cpp
blackberry/Api/WebSettings.cpp
blackberry/Api/WebString.cpp
blackberry/Api/WebViewportArguments.cpp
blackberry/WebCoreSupport/AboutData.cpp
blackberry/WebCoreSupport/AutofillManager.cpp
......
/*
* Copyright (C) 2012 Research In Motion Limited. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
#include "WebAnimation.h"
#if USE(ACCELERATED_COMPOSITING)
#include "GraphicsLayer.h"
#include "LayerCompositingThread.h"
#include "LayerWebKitThread.h"
#include "WebAnimation_p.h"
#include "WebString.h"
#include <BlackBerryPlatformMessageClient.h>
namespace BlackBerry {
namespace WebKit {
using namespace WebCore;
WebAnimation WebAnimation::fadeAnimation(const WebString& name, float from, float to, double duration)
{
WebAnimation tmp;
tmp.d->name = String(name.impl());
tmp.d->animation = Animation::create();
tmp.d->animation->setDuration(duration);
tmp.d->keyframes = KeyframeValueList(AnimatedPropertyOpacity);
tmp.d->keyframes.insert(new FloatAnimationValue(0, from));
tmp.d->keyframes.insert(new FloatAnimationValue(1.0, to));
return tmp;
}
WebString WebAnimation::name() const
{
return d->name.impl();
}
WebAnimation::WebAnimation()
: d(new WebAnimationPrivate)
{
}
WebAnimation::WebAnimation(const WebAnimation& o)
: d(new WebAnimationPrivate)
{
*d = *o.d;
}
WebAnimation::~WebAnimation()
{
delete d;
}
WebAnimation& WebAnimation::operator=(const WebAnimation& o)
{
*d = *o.d;
return *this;
}
} // namespace WebKit
} // namespace BlackBerry
#endif // USE(ACCELERATED_COMPOSITING)
/*
* Copyright (C) 2012 Research In Motion Limited. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef WebAnimation_h
#define WebAnimation_h
#include "BlackBerryGlobal.h"
#include <BlackBerryPlatformPrimitives.h>
namespace BlackBerry {
namespace WebKit {
class WebAnimationPrivate;
/**
* Represents an animation running on an overlay.
*
* WebAnimation is not thread safe, but it is reentrant. This means that
* instances can be created on different threads, but must be used on the
* thread where they were created.
*/
class BLACKBERRY_EXPORT WebAnimation {
public:
static WebAnimation fadeAnimation(const WebString& name, float from, float to, double duration);
WebAnimation();
WebAnimation(const WebAnimation&);
~WebAnimation();
WebAnimation& operator=(const WebAnimation&);
WebString name() const;
protected:
friend class WebOverlay;
friend class WebOverlayOverride;
friend class WebOverlayPrivate;
WebAnimationPrivate* d;
};
}
}
#endif // WebAnimation_h
/*
* Copyright (C) 2012 Research In Motion Limited. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef WebAnimation_p_h
#define WebAnimation_p_h
#if USE(ACCELERATED_COMPOSITING)
#include "Animation.h"
#include "GraphicsLayer.h"
#include "GraphicsLayerClient.h"
#include "IntSize.h"
#include "LayerAnimation.h"
#include <wtf/text/WTFString.h>
namespace BlackBerry {
namespace WebKit {
class WebAnimation;
class WebAnimationPrivate {
public:
WebAnimationPrivate()
: keyframes(WebCore::AnimatedPropertyInvalid)
{
}
String name;
RefPtr<WebCore::Animation> animation;
WebCore::KeyframeValueList keyframes;
};
}
}
#endif // USE(ACCELERATED_COMPOSITING)
#endif // WebAnimation_p_h
/*
* Copyright (C) 2012 Research In Motion Limited. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
#include "WebOverlay.h"
#if USE(ACCELERATED_COMPOSITING)
#include "LayerWebKitThread.h"
#include "NotImplemented.h"
#include "PlatformContextSkia.h"
#include "TextureCacheCompositingThread.h"
#include "WebAnimation.h"
#include "WebAnimation_p.h"
#include "WebOverlayClient.h"
#include "WebOverlayOverride.h"
#include "WebOverlay_p.h"
#include "WebPageCompositorClient.h"
#include "WebPageCompositor_p.h"
#include "WebPage_p.h"
#include "WebString.h"
#include <BlackBerryPlatformMessageClient.h>
#include <GLES2/gl2.h>
#include <SkDevice.h>
namespace BlackBerry {
namespace WebKit {
using namespace WebCore;
WebOverlay::WebOverlay()
: d(0)
{
if (Platform::webKitThreadMessageClient()->isCurrentThread()) {
d = new WebOverlayPrivateWebKitThread;
d->q = this;
} else if (Platform::userInterfaceThreadMessageClient()->isCurrentThread()) {
d = new WebOverlayPrivateCompositingThread;
d->q = this;
}
}
WebOverlay::WebOverlay(GraphicsLayerClient* client)
: d(0)
{
d = new WebOverlayPrivateWebKitThread(client);
d->q = this;
}
WebOverlay::~WebOverlay()
{
delete d;
}
Platform::FloatPoint WebOverlay::position() const
{
return d->position();
}
void WebOverlay::setPosition(const Platform::FloatPoint& position)
{
d->setPosition(position);
}
Platform::FloatPoint WebOverlay::anchorPoint() const
{
return d->anchorPoint();
}
void WebOverlay::setAnchorPoint(const Platform::FloatPoint& anchor)
{
d->setAnchorPoint(anchor);
}
Platform::FloatSize WebOverlay::size() const
{
return d->size();
}
void WebOverlay::setSize(const Platform::FloatSize& size)
{
d->setSize(size);
}
bool WebOverlay::sizeIsScaleInvariant() const
{
return d->sizeIsScaleInvariant();
}
void WebOverlay::setSizeIsScaleInvariant(bool invariant)
{
d->setSizeIsScaleInvariant(invariant);
}
Platform::TransformationMatrix WebOverlay::transform() const
{
// FIXME: There is no WebCore::TranformationMatrix interoperability
// with Platform::TransformationMatrix
TransformationMatrix transform = d->transform();
return reinterpret_cast<const Platform::TransformationMatrix&>(transform);
}
void WebOverlay::setTransform(const Platform::TransformationMatrix& transform)
{
d->setTransform(reinterpret_cast<const TransformationMatrix&>(transform));
}
float WebOverlay::opacity() const
{
return d->opacity();
}
void WebOverlay::setOpacity(float opacity)
{
d->setOpacity(opacity);
}
void WebOverlay::addAnimation(const WebAnimation& animation)
{
d->addAnimation(animation.d->name, animation.d->animation.get(), animation.d->keyframes);
}
void WebOverlay::removeAnimation(const WebString& name)
{
d->removeAnimation(String(PassRefPtr<StringImpl>(name.impl())));
}
WebOverlay* WebOverlay::parent() const
{
return d->parent;
}
bool WebOverlay::addChild(WebOverlay* overlay)
{
if (overlay->d->nativeThread != d->nativeThread)
return false;
overlay->d->parent = this;
d->addChild(overlay->d);
return true;
}
void WebOverlay::removeFromParent()
{
d->removeFromParent();
d->parent = 0;
}
void WebOverlay::setContentsToImage(const unsigned char* data, const Platform::IntSize& imageSize)
{
d->setContentsToImage(data, imageSize);
}
void WebOverlay::setContentsToColor(int r, int g, int b, int a)
{
d->setContentsToColor(Color(r, g, b, a));
}
void WebOverlay::setDrawsContent(bool drawsContent)
{
d->setDrawsContent(drawsContent);
}
void WebOverlay::invalidate()
{
d->invalidate();
}
void WebOverlay::setClient(WebOverlayClient* client)
{
d->setClient(client);
}
WebOverlayOverride* WebOverlay::override()
{
// Must be called on UI thread
if (!Platform::userInterfaceThreadMessageClient()->isCurrentThread())
return 0;
return d->override();
}
void WebOverlay::resetOverrides()
{
d->resetOverrides();
}
WebPagePrivate* WebOverlayPrivate::page() const
{
if (m_page)
return m_page;
if (parent)
return parent->d->page();
return 0;
}
WebOverlayOverride* WebOverlayPrivate::override()
{
// Page might have changed if we were removed from the page and added to
// some other page.
if (m_override)
m_override->d->setPage(page());
return m_override.get();
}
void WebOverlayPrivate::drawContents(SkCanvas* canvas)
{
if (!client)
return;
client->drawOverlayContents(q, canvas);
}
void WebOverlayPrivate::scheduleCompositingRun()
{
if (WebPagePrivate* page = this->page()) {
if (WebPageCompositorClient* compositorClient = page->compositor()->client()) {
double animationTime = compositorClient->requestAnimationFrame();
compositorClient->invalidate(animationTime);
return;
}
page->blitVisibleContents();
}
}
WebOverlayPrivateWebKitThread::WebOverlayPrivateWebKitThread(GraphicsLayerClient* client)
: m_layer(GraphicsLayer::create(client ? client : this))
{
m_layerCompositingThread = m_layer->platformLayer()->layerCompositingThread();
}
WebOverlayOverride* WebOverlayPrivateWebKitThread::override()
{
if (!m_override) {
WebOverlayPrivate* tmp = new WebOverlayPrivateCompositingThread(m_layerCompositingThread.get());
m_override = adoptPtr(new WebOverlayOverride(tmp, true));
}
return WebOverlayPrivate::override();
}
FloatPoint WebOverlayPrivateWebKitThread::position() const
{
return m_layer->position();
}
void WebOverlayPrivateWebKitThread::setPosition(const FloatPoint& position)
{
m_layer->setPosition(position);
}
FloatPoint WebOverlayPrivateWebKitThread::anchorPoint() const
{
FloatPoint3D anchor = m_layer->anchorPoint();
return FloatPoint(anchor.x(), anchor.y());
}
void WebOverlayPrivateWebKitThread::setAnchorPoint(const FloatPoint& anchor)
{
m_layer->setAnchorPoint(FloatPoint3D(anchor.x(), anchor.y(), 0));
}
FloatSize WebOverlayPrivateWebKitThread::size() const
{
return m_layer->size();
}
void WebOverlayPrivateWebKitThread::setSize(const FloatSize& size)
{
m_layer->setSize(size);
}
bool WebOverlayPrivateWebKitThread::sizeIsScaleInvariant() const
{
return m_layer->platformLayer()->sizeIsScaleInvariant();
}
void WebOverlayPrivateWebKitThread::setSizeIsScaleInvariant(bool invariant)
{
m_layer->platformLayer()->setSizeIsScaleInvariant(invariant);
}
TransformationMatrix WebOverlayPrivateWebKitThread::transform() const
{
return m_layer->transform();
}
void WebOverlayPrivateWebKitThread::setTransform(const TransformationMatrix& transform)
{
m_layer->setTransform(transform);
}
float WebOverlayPrivateWebKitThread::opacity() const
{
return m_layer->opacity();
}
void WebOverlayPrivateWebKitThread::setOpacity(float opacity)
{
m_layer->setOpacity(opacity);
}
void WebOverlayPrivateWebKitThread::addAnimation(const String& name, Animation* animation, const KeyframeValueList& keyframes)
{
IntSize size(m_layer->size().width(), m_layer->size().height());
m_layer->addAnimation(keyframes, size, animation, name, 0);
}
void WebOverlayPrivateWebKitThread::removeAnimation(const String& name)
{
m_layer->removeAnimation(name);
}
void WebOverlayPrivateWebKitThread::addChild(WebOverlayPrivate* overlay)
{
m_layer->addChild(static_cast<WebOverlayPrivateWebKitThread*>(overlay)->m_layer.get());
}
void WebOverlayPrivateWebKitThread::removeFromParent()
{
m_layer->removeFromParent();
}
void WebOverlayPrivateWebKitThread::setContentsToImage(const unsigned char* data, const WebCore::IntSize& imageSize)
{
notImplemented();
}
void WebOverlayPrivateWebKitThread::setContentsToColor(const Color&)
{
notImplemented();
}
void WebOverlayPrivateWebKitThread::setDrawsContent(bool drawsContent)
{
m_layer->setDrawsContent(drawsContent);
}
void WebOverlayPrivateWebKitThread::clear()
{
setSize(FloatSize(0, 0));
}
void WebOverlayPrivateWebKitThread::invalidate()
{
m_layer->setNeedsDisplay();
}
void WebOverlayPrivateWebKitThread::resetOverrides()
{
if (Platform::webKitThreadMessageClient()->isCurrentThread())
m_layer->platformLayer()->clearOverride();
else if (Platform::userInterfaceThreadMessageClient()->isCurrentThread()) {
m_layerCompositingThread->clearOverride();
scheduleCompositingRun();
}
}
void WebOverlayPrivateWebKitThread::notifySyncRequired(const WebCore::GraphicsLayer*)
{
if (WebPagePrivate* page = this->page())
page->scheduleRootLayerCommit();
}
void WebOverlayPrivateWebKitThread::paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext& c, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect&)
{
drawContents(c.platformContext()->canvas());
}
WebOverlayLayerCompositingThreadClient::WebOverlayLayerCompositingThreadClient()
: m_drawsContent(false)
, m_layerCompositingThread(0)