[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.17-1283-gcf603cf
simon.fraser at apple.com
simon.fraser at apple.com
Tue Jan 5 23:47:48 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 2875079ec9ef98934648d02ad8cd8aebddde03dc
Author: simon.fraser at apple.com <simon.fraser at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Dec 11 23:49:00 2009 +0000
2009-12-11 Simon Fraser <simon.fraser at apple.com>
Reviewed by Darin Adler.
Support reflections on composited layers
https://bugs.webkit.org/show_bug.cgi?id=31885
First part of supporting composited reflections on compositing layers.
Rename the m_transformLayer member variable to m_structuralLayer, since it
will get used both for transform layers (for preserve-3d) and to hold a flattening
layer related to reflections, both of which have similar requirements, and are
mutually exclusive.
* platform/graphics/mac/GraphicsLayerCA.h:
primaryLayer(), hostLayerForSublayers() and layerForSuperlayer() all now return
a CALayer, since m_structuralLayer isn't always a WebLayer.
* platform/graphics/mac/GraphicsLayerCA.mm:
(WebCore::GraphicsLayerCA::commitLayerChanges):
updateLayerPreserves3D() renamed to updateStructuralLayer()
(WebCore::GraphicsLayerCA::updateLayerNames):
New "update" method for updating layer names.
(WebCore::GraphicsLayerCA::updateSublayerList):
m_transformLayer -> m_structuralLayer. Also minor refactor to only
allocate newSublayers in one place.
(WebCore::GraphicsLayerCA::updateLayerSize):
(WebCore::GraphicsLayerCA::removeAnimationFromLayer):
(WebCore::GraphicsLayerCA::hostLayerForSublayers):
(WebCore::GraphicsLayerCA::layerForSuperlayer):
m_transformLayer -> m_structuralLayer
(WebCore::GraphicsLayerCA::updateStructuralLayer):
Call ensureStructuralLayer() which handles any deltas to the
structural layer type.
(WebCore::GraphicsLayerCA::ensureStructuralLayer):
Handle changes to the structural layer requirements
(WebCore::GraphicsLayerCA::structuralLayerPurpose):
Return an enum describing the purpose of the structural layer; for now
this only returns NoStructuralLayer or StructuralLayerForPreserves3D, but
will in future also have a value related to reflections.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52029 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 6c871ed..24bc842 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,5 +1,52 @@
2009-12-11 Simon Fraser <simon.fraser at apple.com>
+ Reviewed by Darin Adler.
+
+ Support reflections on composited layers
+ https://bugs.webkit.org/show_bug.cgi?id=31885
+
+ First part of supporting composited reflections on compositing layers.
+
+ Rename the m_transformLayer member variable to m_structuralLayer, since it
+ will get used both for transform layers (for preserve-3d) and to hold a flattening
+ layer related to reflections, both of which have similar requirements, and are
+ mutually exclusive.
+
+ * platform/graphics/mac/GraphicsLayerCA.h:
+ primaryLayer(), hostLayerForSublayers() and layerForSuperlayer() all now return
+ a CALayer, since m_structuralLayer isn't always a WebLayer.
+
+ * platform/graphics/mac/GraphicsLayerCA.mm:
+ (WebCore::GraphicsLayerCA::commitLayerChanges):
+ updateLayerPreserves3D() renamed to updateStructuralLayer()
+
+ (WebCore::GraphicsLayerCA::updateLayerNames):
+ New "update" method for updating layer names.
+
+ (WebCore::GraphicsLayerCA::updateSublayerList):
+ m_transformLayer -> m_structuralLayer. Also minor refactor to only
+ allocate newSublayers in one place.
+
+ (WebCore::GraphicsLayerCA::updateLayerSize):
+ (WebCore::GraphicsLayerCA::removeAnimationFromLayer):
+ (WebCore::GraphicsLayerCA::hostLayerForSublayers):
+ (WebCore::GraphicsLayerCA::layerForSuperlayer):
+ m_transformLayer -> m_structuralLayer
+
+ (WebCore::GraphicsLayerCA::updateStructuralLayer):
+ Call ensureStructuralLayer() which handles any deltas to the
+ structural layer type.
+
+ (WebCore::GraphicsLayerCA::ensureStructuralLayer):
+ Handle changes to the structural layer requirements
+
+ (WebCore::GraphicsLayerCA::structuralLayerPurpose):
+ Return an enum describing the purpose of the structural layer; for now
+ this only returns NoStructuralLayer or StructuralLayerForPreserves3D, but
+ will in future also have a value related to reflections.
+
+2009-12-11 Simon Fraser <simon.fraser at apple.com>
+
Build fix for platforms where ACCELERATED_COMPOSITING is not defined.
* page/animation/KeyframeAnimation.cpp:
diff --git a/WebCore/platform/graphics/mac/GraphicsLayerCA.h b/WebCore/platform/graphics/mac/GraphicsLayerCA.h
index 5f6161c..9ad7f04 100644
--- a/WebCore/platform/graphics/mac/GraphicsLayerCA.h
+++ b/WebCore/platform/graphics/mac/GraphicsLayerCA.h
@@ -30,16 +30,15 @@
#include "GraphicsLayer.h"
#include "StringHash.h"
+#include "WebLayer.h"
#include <wtf/HashSet.h>
#include <wtf/RetainPtr.h>
@class CABasicAnimation;
@class CAKeyframeAnimation;
- at class CALayer;
@class CAMediaTimingFunction;
@class CAPropertyAnimation;
@class WebAnimationDelegate;
- at class WebLayer;
namespace WebCore {
@@ -127,9 +126,9 @@ protected:
private:
void updateOpacityOnLayer();
- WebLayer* primaryLayer() const { return m_transformLayer.get() ? m_transformLayer.get() : m_layer.get(); }
- WebLayer* hostLayerForSublayers() const;
- WebLayer* layerForSuperlayer() const;
+ CALayer* primaryLayer() const { return m_structuralLayer.get() ? m_structuralLayer.get() : m_layer.get(); }
+ CALayer* hostLayerForSublayers() const;
+ CALayer* layerForSuperlayer() const;
CALayer* animatedLayer(AnimatedPropertyID property) const;
bool createAnimationFromKeyframes(const KeyframeValueList&, const Animation*, const String& keyframesName, double timeOffset);
@@ -163,6 +162,7 @@ private:
CALayer* contentsLayer() const { return m_contentsLayer.get(); }
// All these "update" methods will be called inside a BEGIN_BLOCK_OBJC_EXCEPTIONS/END_BLOCK_OBJC_EXCEPTIONS block.
+ void updateLayerNames();
void updateSublayerList();
void updateLayerPosition();
void updateLayerSize();
@@ -172,7 +172,7 @@ private:
void updateMasksToBounds();
void updateContentsOpaque();
void updateBackfaceVisibility();
- void updateLayerPreserves3D();
+ void updateStructuralLayer();
void updateLayerDrawsContent();
void updateLayerBackgroundColor();
@@ -186,6 +186,14 @@ private:
void updateMaskLayer();
void updateLayerAnimations();
+
+ enum StructuralLayerPurpose {
+ NoStructuralLayer = 0,
+ StructuralLayerForPreserves3D,
+ StructuralLayerForReplicaFlattening
+ };
+ void ensureStructuralLayer(StructuralLayerPurpose);
+ StructuralLayerPurpose structuralLayerPurpose() const;
void setAnimationOnLayer(CAPropertyAnimation*, AnimatedPropertyID, int index, double timeOffset);
bool removeAnimationFromLayer(AnimatedPropertyID, int index);
@@ -223,10 +231,10 @@ private:
void repaintLayerDirtyRects();
- RetainPtr<WebLayer> m_layer;
- RetainPtr<WebLayer> m_transformLayer;
- RetainPtr<CALayer> m_contentsLayer;
-
+ RetainPtr<WebLayer> m_layer; // The main layer
+ RetainPtr<CALayer> m_structuralLayer; // A layer used for structual reasons, like preserves-3d or replica-flattening. Is the parent of m_layer.
+ RetainPtr<CALayer> m_contentsLayer; // A layer used for inner content, like image and video
+
enum ContentsLayerPurpose {
NoContentsLayer = 0,
ContentsLayerForImage,
diff --git a/WebCore/platform/graphics/mac/GraphicsLayerCA.mm b/WebCore/platform/graphics/mac/GraphicsLayerCA.mm
index a38a728..e32f3e7 100644
--- a/WebCore/platform/graphics/mac/GraphicsLayerCA.mm
+++ b/WebCore/platform/graphics/mac/GraphicsLayerCA.mm
@@ -790,13 +790,10 @@ void GraphicsLayerCA::commitLayerChanges()
// Need to handle Preserves3DChanged first, because it affects which layers subsequent properties are applied to
if (m_uncommittedChanges & Preserves3DChanged)
- updateLayerPreserves3D();
+ updateStructuralLayer();
- if (m_uncommittedChanges & NameChanged) {
- if (m_transformLayer)
- [m_transformLayer.get() setName:("Transform layer " + name())];
- [m_layer.get() setName:name()];
- }
+ if (m_uncommittedChanges & NameChanged)
+ updateLayerNames();
if (m_uncommittedChanges & ContentsImageChanged) // Needs to happen before ChildrenChanged
updateContentsImage();
@@ -864,36 +861,52 @@ void GraphicsLayerCA::commitLayerChanges()
END_BLOCK_OBJC_EXCEPTIONS
}
+void GraphicsLayerCA::updateLayerNames()
+{
+ switch (structuralLayerPurpose()) {
+ case StructuralLayerForPreserves3D:
+ [m_structuralLayer.get() setName:("Transform layer " + name())];
+ break;
+ case StructuralLayerForReplicaFlattening:
+ [m_structuralLayer.get() setName:("Replica flattening layer " + name())];
+ break;
+ case NoStructuralLayer:
+ break;
+ }
+ [m_layer.get() setName:name()];
+}
+
void GraphicsLayerCA::updateSublayerList()
{
NSMutableArray* newSublayers = nil;
- if (m_transformLayer) {
- // Add the primary layer first. Even if we have negative z-order children, the primary layer always comes behind.
- newSublayers = [[NSMutableArray alloc] initWithObjects:m_layer.get(), nil];
- } else if (m_contentsLayer) {
- // FIXME: add the contents layer in the correct order with negative z-order children.
- // This does not cause visible rendering issues because currently contents layers are only used
- // for replaced elements that don't have children.
- newSublayers = [[NSMutableArray alloc] initWithObjects:m_contentsLayer.get(), nil];
- }
-
const Vector<GraphicsLayer*>& childLayers = children();
- size_t numChildren = childLayers.size();
- for (size_t i = 0; i < numChildren; ++i) {
- GraphicsLayerCA* curChild = static_cast<GraphicsLayerCA*>(childLayers[i]);
-
- CALayer* childLayer = curChild->layerForSuperlayer();
- if (!newSublayers)
- newSublayers = [[NSMutableArray alloc] initWithObjects:childLayer, nil];
- else
+
+ if (m_structuralLayer || m_contentsLayer || childLayers.size() > 0) {
+ newSublayers = [[NSMutableArray alloc] init];
+
+ if (m_structuralLayer) {
+ // Add the primary layer. Even if we have negative z-order children, the primary layer always comes behind.
+ [newSublayers addObject:m_layer.get()];
+ } else if (m_contentsLayer) {
+ // FIXME: add the contents layer in the correct order with negative z-order children.
+ // This does not cause visible rendering issues because currently contents layers are only used
+ // for replaced elements that don't have children.
+ [newSublayers addObject:m_contentsLayer.get()];
+ }
+
+ size_t numChildren = childLayers.size();
+ for (size_t i = 0; i < numChildren; ++i) {
+ GraphicsLayerCA* curChild = static_cast<GraphicsLayerCA*>(childLayers[i]);
+ CALayer* childLayer = curChild->layerForSuperlayer();
[newSublayers addObject:childLayer];
- }
+ }
- [newSublayers makeObjectsPerformSelector:@selector(removeFromSuperlayer)];
+ [newSublayers makeObjectsPerformSelector:@selector(removeFromSuperlayer)];
+ }
- if (m_transformLayer) {
- safeSetSublayers(m_transformLayer.get(), newSublayers);
+ if (m_structuralLayer) {
+ safeSetSublayers(m_structuralLayer.get(), newSublayers);
if (m_contentsLayer) {
// If we have a transform layer, then the contents layer is parented in the
@@ -919,8 +932,9 @@ void GraphicsLayerCA::updateLayerPosition()
void GraphicsLayerCA::updateLayerSize()
{
CGRect rect = CGRectMake(0, 0, m_size.width(), m_size.height());
- if (m_transformLayer) {
- [m_transformLayer.get() setBounds:rect];
+ if (m_structuralLayer) {
+ [m_structuralLayer.get() setBounds:rect];
+
// The anchor of the contents layer is always at 0.5, 0.5, so the position is center-relative.
CGPoint centerPoint = CGPointMake(m_size.width() / 2.0f, m_size.height() / 2.0f);
[m_layer.get() setPosition:centerPoint];
@@ -981,67 +995,103 @@ void GraphicsLayerCA::updateBackfaceVisibility()
[m_layer.get() setDoubleSided:m_backfaceVisibility];
}
-void GraphicsLayerCA::updateLayerPreserves3D()
+void GraphicsLayerCA::updateStructuralLayer()
{
- Class transformLayerClass = NSClassFromString(@"CATransformLayer");
- if (!transformLayerClass)
- return;
+ ensureStructuralLayer(structuralLayerPurpose());
+}
- if (m_preserves3D && !m_transformLayer) {
- // Create the transform layer.
- m_transformLayer.adoptNS([[transformLayerClass alloc] init]);
+void GraphicsLayerCA::ensureStructuralLayer(StructuralLayerPurpose purpose)
+{
+ if (purpose == NoStructuralLayer) {
+ if (m_structuralLayer) {
+ // Relace the transformLayer in the parent with this layer.
+ [m_layer.get() removeFromSuperlayer];
+ [[m_structuralLayer.get() superlayer] replaceSublayer:m_structuralLayer.get() with:m_layer.get()];
- // Turn off default animations.
- [m_transformLayer.get() setStyle:[NSDictionary dictionaryWithObject:nullActionsDictionary() forKey:@"actions"]];
+ moveAnimation(AnimatedPropertyWebkitTransform, m_structuralLayer.get(), m_layer.get());
-#ifndef NDEBUG
- [m_transformLayer.get() setName:[NSString stringWithFormat:@"Transform Layer CATransformLayer(%p) GraphicsLayer(%p)", m_transformLayer.get(), this]];
-#endif
- // Copy the position from this layer.
- updateLayerPosition();
- updateLayerSize();
- updateAnchorPoint();
- updateTransform();
- updateChildrenTransform();
-
- CGPoint point = CGPointMake(m_size.width() / 2.0f, m_size.height() / 2.0f);
- [m_layer.get() setPosition:point];
+ // Release the structural layer.
+ m_structuralLayer = 0;
- [m_layer.get() setAnchorPoint:CGPointMake(0.5f, 0.5f)];
- [m_layer.get() setTransform:CATransform3DIdentity];
-
- // Set the old layer to opacity of 1. Further down we will set the opacity on the transform layer.
- [m_layer.get() setOpacity:1];
+ updateLayerPosition();
+ updateLayerSize();
+ updateAnchorPoint();
+ updateTransform();
+ updateChildrenTransform();
- // Move this layer to be a child of the transform layer.
- [[m_layer.get() superlayer] replaceSublayer:m_layer.get() with:m_transformLayer.get()];
- [m_transformLayer.get() addSublayer:m_layer.get()];
+ updateSublayerList();
+ updateOpacityOnLayer();
+ }
+ return;
+ }
+
+ bool structuralLayerChanged = false;
+
+ if (purpose == StructuralLayerForPreserves3D) {
+ Class transformLayerClass = NSClassFromString(@"CATransformLayer");
+ if (!transformLayerClass)
+ return;
- moveAnimation(AnimatedPropertyWebkitTransform, m_layer.get(), m_transformLayer.get());
+ if (m_structuralLayer && ![m_structuralLayer.get() isKindOfClass:transformLayerClass])
+ m_structuralLayer = 0;
- updateSublayerList();
- } else if (!m_preserves3D && m_transformLayer) {
- // Relace the transformLayer in the parent with this layer.
- [m_layer.get() removeFromSuperlayer];
- [[m_transformLayer.get() superlayer] replaceSublayer:m_transformLayer.get() with:m_layer.get()];
+ if (!m_structuralLayer) {
+ m_structuralLayer.adoptNS([[transformLayerClass alloc] init]);
+ structuralLayerChanged = true;
+ }
+ } else {
+ if (m_structuralLayer && ![m_structuralLayer.get() isMemberOfClass:[CALayer self]])
+ m_structuralLayer = 0;
- moveAnimation(AnimatedPropertyWebkitTransform, m_transformLayer.get(), m_layer.get());
+ if (!m_structuralLayer) {
+ m_structuralLayer.adoptNS([[CALayer alloc] init]);
+ structuralLayerChanged = true;
+ }
+ }
+
+ if (!structuralLayerChanged)
+ return;
+
+ // Turn off default animations.
+ [m_structuralLayer.get() setStyle:[NSDictionary dictionaryWithObject:nullActionsDictionary() forKey:@"actions"]];
- // Release the transform layer.
- m_transformLayer = 0;
+ updateLayerNames();
- updateLayerPosition();
- updateLayerSize();
- updateAnchorPoint();
- updateTransform();
- updateChildrenTransform();
+ // Copy the position from this layer.
+ updateLayerPosition();
+ updateLayerSize();
+ updateAnchorPoint();
+ updateTransform();
+ updateChildrenTransform();
+
+ CGPoint point = CGPointMake(m_size.width() / 2.0f, m_size.height() / 2.0f);
+ [m_layer.get() setPosition:point];
- updateSublayerList();
- }
+ [m_layer.get() setAnchorPoint:CGPointMake(0.5f, 0.5f)];
+ [m_layer.get() setTransform:CATransform3DIdentity];
+
+ // Set the old layer to opacity of 1. Further down we will set the opacity on the transform layer.
+ [m_layer.get() setOpacity:1];
+
+ // Move this layer to be a child of the transform layer.
+ [[m_layer.get() superlayer] replaceSublayer:m_layer.get() with:m_structuralLayer.get()];
+ [m_structuralLayer.get() addSublayer:m_layer.get()];
+
+ moveAnimation(AnimatedPropertyWebkitTransform, m_layer.get(), m_structuralLayer.get());
+
+ updateSublayerList();
updateOpacityOnLayer();
}
+GraphicsLayerCA::StructuralLayerPurpose GraphicsLayerCA::structuralLayerPurpose() const
+{
+ if (preserves3D())
+ return StructuralLayerForPreserves3D;
+
+ return NoStructuralLayer;
+}
+
void GraphicsLayerCA::updateLayerDrawsContent()
{
bool needTiledLayer = requiresTiledLayer(m_size);
@@ -1267,8 +1317,7 @@ bool GraphicsLayerCA::removeAnimationFromLayer(AnimatedPropertyID property, int
return false;
[layer removeAnimationForKey:animationName];
-
- bug7311367Workaround(m_transformLayer.get(), m_transform);
+ bug7311367Workaround(m_structuralLayer.get(), m_transform);
return true;
}
@@ -1670,17 +1719,14 @@ void GraphicsLayerCA::resumeAnimations()
[primaryLayer() setTimeOffset:0];
}
-WebLayer* GraphicsLayerCA::hostLayerForSublayers() const
+CALayer* GraphicsLayerCA::hostLayerForSublayers() const
{
- return m_transformLayer ? m_transformLayer.get() : m_layer.get();
+ return m_structuralLayer.get() ? m_structuralLayer.get() : m_layer.get();
}
-WebLayer* GraphicsLayerCA::layerForSuperlayer() const
+CALayer* GraphicsLayerCA::layerForSuperlayer() const
{
- if (m_transformLayer)
- return m_transformLayer.get();
-
- return m_layer.get();
+ return m_structuralLayer ? m_structuralLayer.get() : m_layer.get();
}
CALayer* GraphicsLayerCA::animatedLayer(AnimatedPropertyID property) const
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list