- Revision
- 118709
- Author
- commit-qu...@webkit.org
- Date
- 2012-05-28 15:22:36 -0700 (Mon, 28 May 2012)
Log Message
[BlackBerry] Make it possible to manipulate layers on the compositing thread
https://bugs.webkit.org/show_bug.cgi?id=87602
Patch by Arvid Nilsson <anils...@rim.com> on 2012-05-28
Reviewed by Rob Buis.
Normally, layers are manipulated on the WebKit thread, and the changes are
synced to the compositing thread during the next accelerated compositing commit
operation.
However, for overlay layers the ability to manipulate layers on the compositing
thread is necessary for adequate user interface responsiveness.
Two mechanisms are added:
1. For a layer with a WebKit-thread counterpart, you can temporarily override
attributes or add animations whose output override attributes.
2. For a layer with no WebKit-thread counterpart, you can now directly set the
compositing thread values for attributes. If you attempt to do this for layers
that do have a WebKit-thread counterpart, the compositing thread values will
be overwritten at the time of the next commit, which makes the override
mechanism more useful there.
PR #156812
* platform/graphics/blackberry/LayerCompositingThread.cpp:
(WebCore::LayerCompositingThread::addSublayer):
(WebCore):
(WebCore::LayerCompositingThread::updateAnimations):
(WebCore::LayerCompositingThread::removeAnimation):
(WebCore::LayerCompositingThread::override):
(WebCore::LayerCompositingThread::clearOverride):
* platform/graphics/blackberry/LayerCompositingThread.h:
(LayerOverride):
(WebCore::LayerOverride::create):
(WebCore::LayerOverride::setPosition):
(WebCore::LayerOverride::setAnchorPoint):
(WebCore::LayerOverride::setBounds):
(WebCore::LayerOverride::setTransform):
(WebCore::LayerOverride::setOpacity):
(WebCore::LayerOverride::addAnimation):
(WebCore::LayerOverride::LayerOverride):
(WebCore):
(LayerCompositingThread):
(WebCore::LayerCompositingThread::setPosition):
(WebCore::LayerCompositingThread::setAnchorPoint):
(WebCore::LayerCompositingThread::setBounds):
(WebCore::LayerCompositingThread::setSizeIsScaleInvariant):
(WebCore::LayerCompositingThread::setTransform):
(WebCore::LayerCompositingThread::setOpacity):
(WebCore::LayerCompositingThread::setNeedsTexture):
* platform/graphics/blackberry/LayerWebKitThread.cpp:
(WebCore::LayerWebKitThread::LayerWebKitThread):
(WebCore::LayerWebKitThread::commitOnCompositingThread):
* platform/graphics/blackberry/LayerWebKitThread.h:
(LayerWebKitThread):
(WebCore::LayerWebKitThread::clearOverride):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (118708 => 118709)
--- trunk/Source/WebCore/ChangeLog 2012-05-28 22:22:19 UTC (rev 118708)
+++ trunk/Source/WebCore/ChangeLog 2012-05-28 22:22:36 UTC (rev 118709)
@@ -1,3 +1,61 @@
+2012-05-28 Arvid Nilsson <anils...@rim.com>
+
+ [BlackBerry] Make it possible to manipulate layers on the compositing thread
+ https://bugs.webkit.org/show_bug.cgi?id=87602
+
+ Reviewed by Rob Buis.
+
+ Normally, layers are manipulated on the WebKit thread, and the changes are
+ synced to the compositing thread during the next accelerated compositing commit
+ operation.
+
+ However, for overlay layers the ability to manipulate layers on the compositing
+ thread is necessary for adequate user interface responsiveness.
+
+ Two mechanisms are added:
+ 1. For a layer with a WebKit-thread counterpart, you can temporarily override
+ attributes or add animations whose output override attributes.
+ 2. For a layer with no WebKit-thread counterpart, you can now directly set the
+ compositing thread values for attributes. If you attempt to do this for layers
+ that do have a WebKit-thread counterpart, the compositing thread values will
+ be overwritten at the time of the next commit, which makes the override
+ mechanism more useful there.
+
+ PR #156812
+
+ * platform/graphics/blackberry/LayerCompositingThread.cpp:
+ (WebCore::LayerCompositingThread::addSublayer):
+ (WebCore):
+ (WebCore::LayerCompositingThread::updateAnimations):
+ (WebCore::LayerCompositingThread::removeAnimation):
+ (WebCore::LayerCompositingThread::override):
+ (WebCore::LayerCompositingThread::clearOverride):
+ * platform/graphics/blackberry/LayerCompositingThread.h:
+ (LayerOverride):
+ (WebCore::LayerOverride::create):
+ (WebCore::LayerOverride::setPosition):
+ (WebCore::LayerOverride::setAnchorPoint):
+ (WebCore::LayerOverride::setBounds):
+ (WebCore::LayerOverride::setTransform):
+ (WebCore::LayerOverride::setOpacity):
+ (WebCore::LayerOverride::addAnimation):
+ (WebCore::LayerOverride::LayerOverride):
+ (WebCore):
+ (LayerCompositingThread):
+ (WebCore::LayerCompositingThread::setPosition):
+ (WebCore::LayerCompositingThread::setAnchorPoint):
+ (WebCore::LayerCompositingThread::setBounds):
+ (WebCore::LayerCompositingThread::setSizeIsScaleInvariant):
+ (WebCore::LayerCompositingThread::setTransform):
+ (WebCore::LayerCompositingThread::setOpacity):
+ (WebCore::LayerCompositingThread::setNeedsTexture):
+ * platform/graphics/blackberry/LayerWebKitThread.cpp:
+ (WebCore::LayerWebKitThread::LayerWebKitThread):
+ (WebCore::LayerWebKitThread::commitOnCompositingThread):
+ * platform/graphics/blackberry/LayerWebKitThread.h:
+ (LayerWebKitThread):
+ (WebCore::LayerWebKitThread::clearOverride):
+
2012-05-28 Rob Flack <fla...@chromium.org>
[chromium] Only increase size of Combo Box Options when displayed on touch screen
Modified: trunk/Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.cpp (118708 => 118709)
--- trunk/Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.cpp 2012-05-28 22:22:19 UTC (rev 118708)
+++ trunk/Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.cpp 2012-05-28 22:22:36 UTC (rev 118709)
@@ -55,6 +55,16 @@
namespace WebCore {
+void LayerOverride::removeAnimation(const String& name)
+{
+ for (size_t i = 0; i < m_animations.size(); ++i) {
+ if (m_animations[i]->name() == name) {
+ m_animations.remove(i);
+ return;
+ }
+ }
+}
+
PassRefPtr<LayerCompositingThread> LayerCompositingThread::create(LayerType type, LayerCompositingThreadClient* client)
{
return adoptRef(new LayerCompositingThread(type, client));
@@ -382,6 +392,13 @@
return layer;
}
+void LayerCompositingThread::addSublayer(LayerCompositingThread* layer)
+{
+ layer->removeFromSuperlayer();
+ layer->setSuperlayer(this);
+ m_sublayers.append(layer);
+}
+
void LayerCompositingThread::removeFromSuperlayer()
{
if (m_superlayer)
@@ -479,7 +496,30 @@
animation->apply(this, elapsedTime);
}
- return !m_runningAnimations.isEmpty();
+ bool hasRunningAnimations = !m_runningAnimations.isEmpty();
+
+ // If there are any overrides, apply them
+ if (m_override) {
+ if (m_override->isPositionSet())
+ m_position = m_override->position();
+ if (m_override->isAnchorPointSet())
+ m_anchorPoint = m_override->anchorPoint();
+ if (m_override->isBoundsSet())
+ m_bounds = m_override->bounds();
+ if (m_override->isTransformSet())
+ m_transform = m_override->transform();
+ if (m_override->isOpacitySet())
+ m_opacity = m_override->opacity();
+
+ for (size_t i = 0; i < m_override->animations().size(); ++i) {
+ LayerAnimation* animation = m_override->animations()[i].get();
+ double elapsedTime = (m_suspendTime ? m_suspendTime : currentTime) - animation->startTime() + animation->timeOffset();
+ animation->apply(this, elapsedTime);
+ hasRunningAnimations |= true;
+ }
+ }
+
+ return hasRunningAnimations;
}
bool LayerCompositingThread::hasVisibleHolePunchRect() const
@@ -501,6 +541,28 @@
m_layerRendererSurface = adoptPtr(new LayerRendererSurface(m_layerRenderer, this));
}
+void LayerCompositingThread::removeAnimation(const String& name)
+{
+ for (size_t i = 0; i < m_runningAnimations.size(); ++i) {
+ if (m_runningAnimations[i]->name() == name) {
+ m_runningAnimations.remove(i);
+ return;
+ }
+ }
}
+LayerOverride* LayerCompositingThread::override()
+{
+ if (!m_override)
+ m_override = LayerOverride::create();
+ return m_override.get();
+}
+
+void LayerCompositingThread::clearOverride()
+{
+ m_override.clear();
+}
+
+}
+
#endif // USE(ACCELERATED_COMPOSITING)
Modified: trunk/Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.h (118708 => 118709)
--- trunk/Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.h 2012-05-28 22:22:19 UTC (rev 118708)
+++ trunk/Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.h 2012-05-28 22:22:36 UTC (rev 118709)
@@ -57,6 +57,59 @@
class LayerCompositingThreadClient;
class LayerRenderer;
+class LayerOverride {
+public:
+ static PassOwnPtr<LayerOverride> create() { return adoptPtr(new LayerOverride()); }
+
+ bool isPositionSet() const { return m_positionSet; }
+ FloatPoint position() const { return m_position; }
+ void setPosition(const FloatPoint& position) { m_position = position; m_positionSet = true; }
+
+ bool isAnchorPointSet() const { return m_anchorPointSet; }
+ FloatPoint anchorPoint() const { return m_anchorPoint; }
+ void setAnchorPoint(const FloatPoint& anchorPoint) { m_anchorPoint = anchorPoint; m_anchorPointSet = true; }
+
+ bool isBoundsSet() const { return m_boundsSet; }
+ IntSize bounds() const { return m_bounds; }
+ void setBounds(const IntSize&) { m_bounds = bounds; m_boundsSet = true; }
+
+ bool isTransformSet() const { return m_transformSet; }
+ const TransformationMatrix& transform() const { return m_transform; }
+ void setTransform(const TransformationMatrix& transform) { m_transform = transform; m_transformSet = true; }
+
+ bool isOpacitySet() const { return m_opacitySet; }
+ float opacity() const { return m_opacity; }
+ void setOpacity(float) { m_opacity = opacity; m_opacitySet = true; }
+
+ const Vector<RefPtr<LayerAnimation> >& animations() const { return m_animations; }
+ void addAnimation(PassRefPtr<LayerAnimation> animation) { m_animations.append(animation); }
+ void removeAnimation(const String& name);
+
+private:
+ LayerOverride()
+ : m_opacity(1.0)
+ , m_positionSet(false)
+ , m_anchorPointSet(false)
+ , m_boundsSet(false)
+ , m_transformSet(false)
+ , m_opacitySet(false)
+ {
+ }
+
+ FloatPoint m_position;
+ FloatPoint m_anchorPoint;
+ IntSize m_bounds;
+ TransformationMatrix m_transform;
+ float m_opacity;
+ Vector<RefPtr<LayerAnimation> > m_animations;
+
+ unsigned m_positionSet : 1;
+ unsigned m_anchorPointSet : 1;
+ unsigned m_boundsSet : 1;
+ unsigned m_transformSet : 1;
+ unsigned m_opacitySet : 1;
+};
+
class LayerCompositingThread : public ThreadSafeRefCounted<LayerCompositingThread>, public LayerData, public BlackBerry::Platform::GuardedPointerBase {
public:
static PassRefPtr<LayerCompositingThread> create(LayerType, LayerCompositingThreadClient*);
@@ -70,6 +123,19 @@
// Not thread safe
+ // These will be overwritten on the next commit if this layer has a LayerWebKitThread counterpart.
+ // Useful for stand-alone layers that are created and managed on the compositing thread.
+ // These functions can also be used to update animated properties in LayerAnimation.
+ void setPosition(const FloatPoint& position) { m_position = position; }
+ void setAnchorPoint(const FloatPoint& anchorPoint) { m_anchorPoint = anchorPoint; }
+ void setBounds(const IntSize& bounds) { m_bounds = bounds; }
+ void setSizeIsScaleInvariant(bool invariant) { m_sizeIsScaleInvariant = invariant; }
+ void setTransform(const TransformationMatrix& matrix) { m_transform = matrix; }
+ void setOpacity(float opacity) { m_opacity = opacity; }
+ void addSublayer(LayerCompositingThread*);
+ void removeFromSuperlayer();
+ void setNeedsTexture(bool needsTexture) { m_needsTexture = needsTexture; }
+
// Returns true if we have an animation
bool updateAnimations(double currentTime);
void updateTextureContentsIfNeeded();
@@ -128,18 +194,19 @@
// this allows you to do it from the compositing thread.
void scheduleCommit();
- // These two functions are used to update animated properties in LayerAnimation.
- void setOpacity(float opacity) { m_opacity = opacity; }
- void setTransform(const TransformationMatrix& matrix) { m_transform = matrix; }
-
bool hasRunningAnimations() const { return !m_runningAnimations.isEmpty(); }
bool hasVisibleHolePunchRect() const;
void addAnimation(LayerAnimation* animation) { m_runningAnimations.append(animation); }
+ void removeAnimation(const String& name);
+
void setRunningAnimations(const Vector<RefPtr<LayerAnimation> >& animations) { m_runningAnimations = animations; }
void setSuspendedAnimations(const Vector<RefPtr<LayerAnimation> >& animations) { m_suspendedAnimations = animations; }
+ LayerOverride* override();
+ void clearOverride();
+
protected:
virtual ~LayerCompositingThread();
@@ -148,10 +215,6 @@
void updateTileContents(const IntRect& tile);
- void removeFromSuperlayer();
-
- size_t numSublayers() const { return m_sublayers.size(); }
-
// Returns the index of the sublayer or -1 if not found.
int indexOfSublayer(const LayerCompositingThread*);
@@ -186,6 +249,7 @@
Vector<RefPtr<LayerAnimation> > m_runningAnimations;
Vector<RefPtr<LayerAnimation> > m_suspendedAnimations;
+ OwnPtr<LayerOverride> m_override;
LayerCompositingThreadClient* m_client;
};
Modified: trunk/Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.cpp (118708 => 118709)
--- trunk/Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.cpp 2012-05-28 22:22:19 UTC (rev 118708)
+++ trunk/Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.cpp 2012-05-28 22:22:36 UTC (rev 118709)
@@ -64,6 +64,7 @@
, m_isDrawable(false)
, m_isMask(false)
, m_animationsChanged(false)
+ , m_clearOverrideOnCommit(false)
{
if (type == Layer)
m_tiler = LayerTiler::create(this);
@@ -288,6 +289,10 @@
m_layerCompositingThread->setSuspendedAnimations(m_suspendedAnimations);
m_animationsChanged = false;
}
+ if (m_clearOverrideOnCommit) {
+ m_layerCompositingThread->clearOverride();
+ m_clearOverrideOnCommit = false;
+ }
m_position = oldPosition;
updateLayerHierarchy();
if (m_tiler)
Modified: trunk/Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.h (118708 => 118709)
--- trunk/Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.h 2012-05-28 22:22:19 UTC (rev 118708)
+++ trunk/Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.h 2012-05-28 22:22:36 UTC (rev 118709)
@@ -146,6 +146,9 @@
void setRunningAnimations(const Vector<RefPtr<LayerAnimation> >&);
void setSuspendedAnimations(const Vector<RefPtr<LayerAnimation> >&);
+ // Allows you to clear the LayerCompositingThread::overrides from the WK thread
+ void clearOverride() { m_clearOverrideOnCommit = true; setNeedsCommit(); }
+
protected:
LayerWebKitThread(LayerType, GraphicsLayerBlackBerry* owner);
@@ -196,6 +199,7 @@
unsigned m_isDrawable : 1;
unsigned m_isMask : 1;
unsigned m_animationsChanged : 1;
+ unsigned m_clearOverrideOnCommit : 1;
};
}