[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.19-706-ge5415e9
simon.fraser at apple.com
simon.fraser at apple.com
Thu Feb 4 21:20:50 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 6c538c9b991602ddf774a52f79745d80f488cd9c
Author: simon.fraser at apple.com <simon.fraser at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Jan 20 01:10:15 2010 +0000
2010-01-19 Simon Fraser <simon.fraser at apple.com>
Reviewed by Dan Bernstein.
Support reflections on WebGL
https://bugs.webkit.org/show_bug.cgi?id=33754
Support reflections of WebGL content, by ensuring that when the Canvas3DLayer containing the
WebGL content gets displayed, we correctly copy its content to the clone layers.
Test: compositing/webgl/webgl-reflection.html
* platform/graphics/GraphicsLayer.h:
(WebCore::GraphicsLayer::didDisplay): Give the didDisplay() client method a parameter
which is the layer that displayed.
* platform/graphics/mac/Canvas3DLayer.mm:
(-[Canvas3DLayer display]): Override -[CALayer display], and call the client didDisplay().
* platform/graphics/mac/GraphicsLayerCA.h: didDisplay() takes a PlatformLayer parameter.
* platform/graphics/mac/GraphicsLayerCA.mm:
(WebCore::GraphicsLayerCA::~GraphicsLayerCA): We need to clear the layer owner on the content
layer, since we're setting it for WebGL layers now.
(WebCore::GraphicsLayerCA::didDisplay): Handle didDisplay() calls for the content layer,
as well as the main layer now, getting the correct layer to copy contents from, and using
the correct clone map.
(WebCore::GraphicsLayerCA::setContentsToGraphicsContext3D): Set the layer owner for WebGL
layers, because we need the didDisplay() callback.
* platform/graphics/mac/WebLayer.mm:
(-[WebLayer display]): didDisplay() takes a layer argument.
* platform/graphics/mac/WebTiledLayer.mm:
(-[WebTiledLayer display]): ditto.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53510 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index f219086..6887832 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,17 @@
+2010-01-19 Simon Fraser <simon.fraser at apple.com>
+
+ Reviewed by Dan Bernstein.
+
+ Support reflections on WebGL
+ https://bugs.webkit.org/show_bug.cgi?id=33754
+
+ Testcase for WebGL with a reflection.
+
+ * compositing/webgl/webgl-reflection.html: Added.
+ * platform/mac/compositing/webgl/webgl-reflection-expected.checksum: Added.
+ * platform/mac/compositing/webgl/webgl-reflection-expected.png: Added.
+ * platform/mac/compositing/webgl/webgl-reflection-expected.txt: Added.
+
2010-01-19 Carol Szabo <carol.szabo at nokia.com>
Reviewed by Darin Adler.
diff --git a/LayoutTests/compositing/webgl/webgl-reflection.html b/LayoutTests/compositing/webgl/webgl-reflection.html
new file mode 100644
index 0000000..012dc80
--- /dev/null
+++ b/LayoutTests/compositing/webgl/webgl-reflection.html
@@ -0,0 +1,115 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <style type="text/css" media="screen">
+ canvas {
+ margin: 20px;
+ width: 200px;
+ height: 200px;
+ padding: 0 20px;
+ border: 2px solid black;
+ -webkit-box-reflect: below 20px;
+ outline: 10px solid transparent; /* affects layer sizes */
+ }
+
+ </style>
+ <script id="vertexShader" type="x-shader/x-vertex">
+ attribute vec4 vPosition;
+
+ void main() {
+ gl_Position = vPosition;
+ }
+ </script>
+
+ <script id="fragmentShader" type="x-shader/x-fragment">
+ void main() {
+ gl_FragColor = vec4(0.0, 0.5, 0.0, 1.0);
+ }
+ </script>
+ <script>
+ var gl = null;
+
+ function draw()
+ {
+ var vertices = [ 0.0, 0.8, 0.0,
+ -0.8, -0.8, 0.0,
+ 0.8, -0.8, 0.0 ];
+ gl.bufferData(gl.ARRAY_BUFFER, new WebGLFloatArray(vertices), gl.STATIC_DRAW);
+
+ gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0); // Load the vertex data
+ gl.enableVertexAttribArray(0);
+ gl.drawArrays(gl.TRIANGLES, 0, 3);
+ gl.flush();
+ }
+
+ function getFragmentShader()
+ {
+ var shaderNode = document.getElementById("fragmentShader"); // fragmentShader has been defined at the top
+ var shaderSource = getShaderSource(shaderNode);
+
+ var shader = gl.createShader(gl.FRAGMENT_SHADER);
+ gl.shaderSource(shader, shaderSource);
+ gl.compileShader(shader);
+
+ return shader;
+ }
+
+ function getShaderSource(shaderNode)
+ {
+ var shaderSource = "";
+ var node = shaderNode.firstChild;
+ while (node) {
+ if (node.nodeType == 3) // Node.TEXT_NODE
+ shaderSource += node.textContent;
+ node = node.nextSibling;
+ }
+
+ return shaderSource;
+ }
+
+ function getVertexShader()
+ {
+ var shaderNode = document.getElementById("vertexShader");
+ var shaderSource = getShaderSource(shaderNode);
+
+ var shader = gl.createShader(gl.VERTEX_SHADER);
+ gl.shaderSource(shader, shaderSource);
+ gl.compileShader(shader);
+
+ return shader;
+ }
+
+ function initialize()
+ {
+ var theCanvas = document.getElementById("canvas");
+ gl = theCanvas.getContext("experimental-webgl");
+
+ var vertexShader = getVertexShader();
+ var fragmentShader = getFragmentShader();
+
+ var shaderProgram = gl.createProgram();
+ gl.attachShader(shaderProgram, vertexShader);
+ gl.attachShader(shaderProgram, fragmentShader);
+ gl.bindAttribLocation(shaderProgram, 0, "vPosition"); // vPosition has been defined at the top
+ gl.linkProgram(shaderProgram);
+
+ gl.useProgram(shaderProgram);
+
+ var buffer = gl.createBuffer();
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
+ }
+
+ function drawCanvas()
+ {
+ initialize();
+ draw();
+ }
+ </script>
+ </head>
+ <body onload="drawCanvas()">
+
+ <p>You should see a green triangle and its reflection.</p>
+ <canvas id="canvas" style="left: 20px" width="200" height="200"></canvas>
+
+ </body>
+</html>
diff --git a/LayoutTests/platform/mac/compositing/webgl/webgl-reflection-expected.checksum b/LayoutTests/platform/mac/compositing/webgl/webgl-reflection-expected.checksum
new file mode 100644
index 0000000..4d5499a
--- /dev/null
+++ b/LayoutTests/platform/mac/compositing/webgl/webgl-reflection-expected.checksum
@@ -0,0 +1 @@
+1acf0ce447f7f581e52d02cdaf7d1ab0
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/compositing/webgl/webgl-reflection-expected.png b/LayoutTests/platform/mac/compositing/webgl/webgl-reflection-expected.png
new file mode 100644
index 0000000..7fd9aed
Binary files /dev/null and b/LayoutTests/platform/mac/compositing/webgl/webgl-reflection-expected.png differ
diff --git a/LayoutTests/platform/mac/compositing/webgl/webgl-reflection-expected.txt b/LayoutTests/platform/mac/compositing/webgl/webgl-reflection-expected.txt
new file mode 100644
index 0000000..cc1e622
--- /dev/null
+++ b/LayoutTests/platform/mac/compositing/webgl/webgl-reflection-expected.txt
@@ -0,0 +1,14 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x306
+ RenderBlock {HTML} at (0,0) size 800x306
+ RenderBody {BODY} at (8,16) size 784x282
+ RenderBlock {P} at (0,0) size 784x18
+ RenderText {#text} at (0,0) size 311x18
+ text run at (0,0) width 311: "You should see a green triangle and its reflection."
+ RenderBlock (anonymous) at (0,34) size 784x248
+ RenderText {#text} at (0,0) size 0x0
+ RenderText {#text} at (0,0) size 0x0
+ RenderText {#text} at (0,0) size 0x0
+layer at (28,70) size 244x204
+ RenderHTMLCanvas {CANVAS} at (20,20) size 244x204 [border: (2px solid #000000)]
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 6711107..c098af7 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,38 @@
+2010-01-19 Simon Fraser <simon.fraser at apple.com>
+
+ Reviewed by Dan Bernstein.
+
+ Support reflections on WebGL
+ https://bugs.webkit.org/show_bug.cgi?id=33754
+
+ Support reflections of WebGL content, by ensuring that when the Canvas3DLayer containing the
+ WebGL content gets displayed, we correctly copy its content to the clone layers.
+
+ Test: compositing/webgl/webgl-reflection.html
+
+ * platform/graphics/GraphicsLayer.h:
+ (WebCore::GraphicsLayer::didDisplay): Give the didDisplay() client method a parameter
+ which is the layer that displayed.
+ * platform/graphics/mac/Canvas3DLayer.mm:
+ (-[Canvas3DLayer display]): Override -[CALayer display], and call the client didDisplay().
+ * platform/graphics/mac/GraphicsLayerCA.h: didDisplay() takes a PlatformLayer parameter.
+
+ * platform/graphics/mac/GraphicsLayerCA.mm:
+ (WebCore::GraphicsLayerCA::~GraphicsLayerCA): We need to clear the layer owner on the content
+ layer, since we're setting it for WebGL layers now.
+
+ (WebCore::GraphicsLayerCA::didDisplay): Handle didDisplay() calls for the content layer,
+ as well as the main layer now, getting the correct layer to copy contents from, and using
+ the correct clone map.
+
+ (WebCore::GraphicsLayerCA::setContentsToGraphicsContext3D): Set the layer owner for WebGL
+ layers, because we need the didDisplay() callback.
+
+ * platform/graphics/mac/WebLayer.mm:
+ (-[WebLayer display]): didDisplay() takes a layer argument.
+ * platform/graphics/mac/WebTiledLayer.mm:
+ (-[WebTiledLayer display]): ditto.
+
2010-01-19 Mark Rowe <mrowe at apple.com>
Reviewed by Oliver Hunt.
diff --git a/WebCore/platform/graphics/GraphicsLayer.h b/WebCore/platform/graphics/GraphicsLayer.h
index 9bc4174..80e9378 100644
--- a/WebCore/platform/graphics/GraphicsLayer.h
+++ b/WebCore/platform/graphics/GraphicsLayer.h
@@ -290,7 +290,7 @@ public:
// Callback from the underlying graphics system to draw layer contents.
void paintGraphicsLayerContents(GraphicsContext&, const IntRect& clip);
// Callback from the underlying graphics system when the layer has been displayed
- virtual void didDisplay() { }
+ virtual void didDisplay(PlatformLayer*) { }
virtual PlatformLayer* platformLayer() const { return 0; }
diff --git a/WebCore/platform/graphics/mac/Canvas3DLayer.mm b/WebCore/platform/graphics/mac/Canvas3DLayer.mm
index 01b5325..59a7384 100644
--- a/WebCore/platform/graphics/mac/Canvas3DLayer.mm
+++ b/WebCore/platform/graphics/mac/Canvas3DLayer.mm
@@ -141,6 +141,13 @@ static void freeData(void *, const void *data, size_t /* size */)
return image;
}
+- (void)display
+{
+ [super display];
+ if (m_layerOwner)
+ m_layerOwner->didDisplay(self);
+}
+
@end
@implementation Canvas3DLayer(WebLayerAdditions)
diff --git a/WebCore/platform/graphics/mac/GraphicsLayerCA.h b/WebCore/platform/graphics/mac/GraphicsLayerCA.h
index 3ca92e3..b811984 100644
--- a/WebCore/platform/graphics/mac/GraphicsLayerCA.h
+++ b/WebCore/platform/graphics/mac/GraphicsLayerCA.h
@@ -117,7 +117,7 @@ public:
virtual void setGeometryOrientation(CompositingCoordinatesOrientation);
- virtual void didDisplay();
+ virtual void didDisplay(PlatformLayer*);
void recursiveCommitChanges();
diff --git a/WebCore/platform/graphics/mac/GraphicsLayerCA.mm b/WebCore/platform/graphics/mac/GraphicsLayerCA.mm
index 958722a..801f583 100644
--- a/WebCore/platform/graphics/mac/GraphicsLayerCA.mm
+++ b/WebCore/platform/graphics/mac/GraphicsLayerCA.mm
@@ -405,6 +405,11 @@ GraphicsLayerCA::~GraphicsLayerCA()
[layer setLayerOwner:nil];
}
+ if (m_contentsLayer) {
+ if ([m_contentsLayer.get() respondsToSelector:@selector(setLayerOwner:)])
+ [(id)m_contentsLayer.get() setLayerOwner:nil];
+ }
+
// animationDidStart: can fire after this, so we need to clear out the layer on the delegate.
[m_animationDelegate.get() setLayer:0];
@@ -820,17 +825,29 @@ void GraphicsLayerCA::setGeometryOrientation(CompositingCoordinatesOrientation o
#endif
}
-void GraphicsLayerCA::didDisplay()
+void GraphicsLayerCA::didDisplay(PlatformLayer* layer)
{
- if (LayerMap* layerCloneMap = m_layerClones.get()) {
+ CALayer* sourceLayer;
+ LayerMap* layerCloneMap;
+
+ if (layer == m_layer) {
+ sourceLayer = m_layer.get();
+ layerCloneMap = m_layerClones.get();
+ } else if (layer == m_contentsLayer) {
+ sourceLayer = m_contentsLayer.get();
+ layerCloneMap = m_contentsLayerClones.get();
+ } else
+ return;
+
+ if (layerCloneMap) {
LayerMap::const_iterator end = layerCloneMap->end();
for (LayerMap::const_iterator it = layerCloneMap->begin(); it != end; ++it) {
CALayer *currClone = it->second.get();
if (!currClone)
continue;
- if ([currClone contents] != [m_layer.get() contents])
- [currClone setContents:[m_layer.get() contents]];
+ if ([currClone contents] != [sourceLayer contents])
+ [currClone setContents:[sourceLayer contents]];
else
[currClone setContentsChanged];
}
@@ -1701,9 +1718,11 @@ void GraphicsLayerCA::setContentsToGraphicsContext3D(const GraphicsContext3D* gr
m_contentsLayer.adoptNS([[Canvas3DLayer alloc] initWithContext:static_cast<CGLContextObj>(m_platformGraphicsContext3D) texture:static_cast<GLuint>(m_platformTexture)]);
#ifndef NDEBUG
[m_contentsLayer.get() setName:@"3D Layer"];
-#endif
+#endif
+ [m_contentsLayer.get() setLayerOwner:this];
} else {
// remove the inner layer
+ [m_contentsLayer.get() setLayerOwner:0];
m_contentsLayer = 0;
}
diff --git a/WebCore/platform/graphics/mac/WebLayer.mm b/WebCore/platform/graphics/mac/WebLayer.mm
index eb57e33..641d421 100644
--- a/WebCore/platform/graphics/mac/WebLayer.mm
+++ b/WebCore/platform/graphics/mac/WebLayer.mm
@@ -157,7 +157,7 @@ using namespace WebCore;
{
[super display];
if (m_layerOwner)
- m_layerOwner->didDisplay();
+ m_layerOwner->didDisplay(self);
}
- (void)drawInContext:(CGContextRef)context
diff --git a/WebCore/platform/graphics/mac/WebTiledLayer.mm b/WebCore/platform/graphics/mac/WebTiledLayer.mm
index 6b2d035..97ba233 100644
--- a/WebCore/platform/graphics/mac/WebTiledLayer.mm
+++ b/WebCore/platform/graphics/mac/WebTiledLayer.mm
@@ -96,7 +96,7 @@ using namespace WebCore;
{
[super display];
if (m_layerOwner)
- m_layerOwner->didDisplay();
+ m_layerOwner->didDisplay(self);
}
- (void)drawInContext:(CGContextRef)ctx
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list