[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
jamesr at google.com
jamesr at google.com
Wed Dec 22 11:47:30 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit d8c6157a0aeb3815f33ecdc644e14b79f9e8eebe
Author: jamesr at google.com <jamesr at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Aug 6 21:49:20 2010 +0000
2010-08-06 James Robinson <jamesr at chromium.org>
Reviewed by Simon Fraser.
Composited canvas should be treated the same by the compositor and not be WebGL specific
https://bugs.webkit.org/show_bug.cgi?id=43589
Initializes the platformLayer as a CanvasLayerChromium, not a WebGLLayerChromium.
The layer itself isn't WebGL-specific.
* src/GraphicsContext3D.cpp:
(WebCore::GraphicsContext3DInternal::initialize):
(WebCore::GraphicsContext3DInternal::platformLayer):
(WebCore::GraphicsContext3D::platformLayer):
2010-08-06 James Robinson <jamesr at chromium.org>
Reviewed by Simon Fraser.
Composited canvas should be treated the same by the compositor and not be WebGL specific
https://bugs.webkit.org/show_bug.cgi?id=43589
This treats all GraphicsContext3D-backed layers the same instead of special casing WebGL.
The cross-platform change is to rename GraphicsLayer::setContentsToWebGL() to
GraphicsLayer::setContentsToCanvas() and to rename all implementations.
This patch also renames the chromium class used for accelerating these layers.
Cross platform changes:
* WebCore.gypi:
* platform/graphics/GraphicsLayer.h:
(WebCore::GraphicsLayer::setContentsToCanvas):
Rename the function on the base class. GraphicsLayerCA and GraphicsLayerChromium implement this.
* rendering/RenderLayerBacking.cpp:
(WebCore::isAcceleratedCanvas):
Helper function to see if a renderer is associated with an accelerated compositing layer.
(WebCore::RenderLayerBacking::updateGraphicsLayerConfiguration):
(WebCore::RenderLayerBacking::containsPaintedContent):
(WebCore::RenderLayerBacking::rendererContentChanged):
Chromium specific changes:
* platform/graphics/chromium/CanvasLayerChromium.cpp: Added.
(WebCore::CanvasLayerChromium::create):
(WebCore::CanvasLayerChromium::CanvasLayerChromium):
(WebCore::CanvasLayerChromium::textureId):
(WebCore::CanvasLayerChromium::updateTextureContents):
(WebCore::CanvasLayerChromium::setContext):
* platform/graphics/chromium/CanvasLayerChromium.h: Added.
(WebCore::CanvasLayerChromium::drawsContent):
(WebCore::CanvasLayerChromium::ownsTexture):
(WebCore::CanvasLayerChromium::shaderProgramId):
(WebCore::CanvasLayerChromium::setShaderProgramId):
* platform/graphics/chromium/GraphicsLayerChromium.cpp:
(WebCore::GraphicsLayerChromium::setContentsNeedsDisplay):
(WebCore::GraphicsLayerChromium::setContentsToCanvas):
* platform/graphics/chromium/GraphicsLayerChromium.h:
(WebCore::GraphicsLayerChromium::):
* platform/graphics/chromium/LayerRendererChromium.cpp:
(WebCore::LayerRendererChromium::drawLayer):
(WebCore::LayerRendererChromium::initializeSharedGLObjects):
* platform/graphics/chromium/LayerRendererChromium.h:
(WebCore::LayerRendererChromium::):
* platform/graphics/chromium/WebGLLayerChromium.cpp: Removed.
* platform/graphics/chromium/WebGLLayerChromium.h: Removed.
Mac specific changes:
* platform/graphics/mac/GraphicsLayerCA.h:
(WebCore::GraphicsLayerCA::):
* platform/graphics/mac/GraphicsLayerCA.mm:
(WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers):
(WebCore::GraphicsLayerCA::updateContentsCanvasLayer):
(WebCore::GraphicsLayerCA::setContentsToCanvas):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64870 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 742c60f..54c5e1f 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,59 @@
+2010-08-06 James Robinson <jamesr at chromium.org>
+
+ Reviewed by Simon Fraser.
+
+ Composited canvas should be treated the same by the compositor and not be WebGL specific
+ https://bugs.webkit.org/show_bug.cgi?id=43589
+
+ This treats all GraphicsContext3D-backed layers the same instead of special casing WebGL.
+ The cross-platform change is to rename GraphicsLayer::setContentsToWebGL() to
+ GraphicsLayer::setContentsToCanvas() and to rename all implementations.
+
+ This patch also renames the chromium class used for accelerating these layers.
+
+ Cross platform changes:
+ * WebCore.gypi:
+ * platform/graphics/GraphicsLayer.h:
+ (WebCore::GraphicsLayer::setContentsToCanvas):
+ Rename the function on the base class. GraphicsLayerCA and GraphicsLayerChromium implement this.
+ * rendering/RenderLayerBacking.cpp:
+ (WebCore::isAcceleratedCanvas):
+ Helper function to see if a renderer is associated with an accelerated compositing layer.
+ (WebCore::RenderLayerBacking::updateGraphicsLayerConfiguration):
+ (WebCore::RenderLayerBacking::containsPaintedContent):
+ (WebCore::RenderLayerBacking::rendererContentChanged):
+ Chromium specific changes:
+ * platform/graphics/chromium/CanvasLayerChromium.cpp: Added.
+ (WebCore::CanvasLayerChromium::create):
+ (WebCore::CanvasLayerChromium::CanvasLayerChromium):
+ (WebCore::CanvasLayerChromium::textureId):
+ (WebCore::CanvasLayerChromium::updateTextureContents):
+ (WebCore::CanvasLayerChromium::setContext):
+ * platform/graphics/chromium/CanvasLayerChromium.h: Added.
+ (WebCore::CanvasLayerChromium::drawsContent):
+ (WebCore::CanvasLayerChromium::ownsTexture):
+ (WebCore::CanvasLayerChromium::shaderProgramId):
+ (WebCore::CanvasLayerChromium::setShaderProgramId):
+ * platform/graphics/chromium/GraphicsLayerChromium.cpp:
+ (WebCore::GraphicsLayerChromium::setContentsNeedsDisplay):
+ (WebCore::GraphicsLayerChromium::setContentsToCanvas):
+ * platform/graphics/chromium/GraphicsLayerChromium.h:
+ (WebCore::GraphicsLayerChromium::):
+ * platform/graphics/chromium/LayerRendererChromium.cpp:
+ (WebCore::LayerRendererChromium::drawLayer):
+ (WebCore::LayerRendererChromium::initializeSharedGLObjects):
+ * platform/graphics/chromium/LayerRendererChromium.h:
+ (WebCore::LayerRendererChromium::):
+ * platform/graphics/chromium/WebGLLayerChromium.cpp: Removed.
+ * platform/graphics/chromium/WebGLLayerChromium.h: Removed.
+ Mac specific changes:
+ * platform/graphics/mac/GraphicsLayerCA.h:
+ (WebCore::GraphicsLayerCA::):
+ * platform/graphics/mac/GraphicsLayerCA.mm:
+ (WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers):
+ (WebCore::GraphicsLayerCA::updateContentsCanvasLayer):
+ (WebCore::GraphicsLayerCA::setContentsToCanvas):
+
2010-08-06 Patrick Gansterer <paroga at paroga.com>
Reviewed by Eric Seidel.
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 9684c62..6ff4928 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -2190,6 +2190,8 @@
'platform/graphics/cg/PathCG.cpp',
'platform/graphics/cg/PatternCG.cpp',
'platform/graphics/cg/TransformationMatrixCG.cpp',
+ 'platform/graphics/chromium/CanvasLayerChromium.cpp',
+ 'platform/graphics/chromium/CanvasLayerChromium.h',
'platform/graphics/chromium/FontCacheChromiumWin.cpp',
'platform/graphics/chromium/FontCacheLinux.cpp',
'platform/graphics/chromium/FontChromiumWin.cpp',
@@ -2237,8 +2239,6 @@
'platform/graphics/chromium/UniscribeHelperTextRun.h',
'platform/graphics/chromium/VideoLayerChromium.cpp',
'platform/graphics/chromium/VideoLayerChromium.h',
- 'platform/graphics/chromium/WebGLLayerChromium.cpp',
- 'platform/graphics/chromium/WebGLLayerChromium.h',
'platform/graphics/filters/FEBlend.cpp',
'platform/graphics/filters/FEBlend.h',
'platform/graphics/filters/FEColorMatrix.cpp',
diff --git a/WebCore/platform/graphics/GraphicsLayer.h b/WebCore/platform/graphics/GraphicsLayer.h
index a5819f4..0f74cd5 100644
--- a/WebCore/platform/graphics/GraphicsLayer.h
+++ b/WebCore/platform/graphics/GraphicsLayer.h
@@ -298,9 +298,7 @@ public:
virtual void setContentsToImage(Image*) { }
virtual void setContentsToMedia(PlatformLayer*) { } // video or plug-in
virtual void setContentsBackgroundColor(const Color&) { }
-#if ENABLE(3D_CANVAS)
- virtual void setContentsToWebGL(PlatformLayer*) { }
-#endif
+ virtual void setContentsToCanvas(PlatformLayer*) { }
virtual bool hasContentsLayer() const { return false; }
// Callback from the underlying graphics system to draw layer contents.
diff --git a/WebCore/platform/graphics/chromium/CanvasLayerChromium.cpp b/WebCore/platform/graphics/chromium/CanvasLayerChromium.cpp
new file mode 100644
index 0000000..f290e68
--- /dev/null
+++ b/WebCore/platform/graphics/chromium/CanvasLayerChromium.cpp
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "CanvasLayerChromium.h"
+
+#include "GraphicsContext3D.h"
+#include <GLES2/gl2.h>
+
+namespace WebCore {
+
+unsigned CanvasLayerChromium::m_shaderProgramId = 0;
+
+PassRefPtr<CanvasLayerChromium> CanvasLayerChromium::create(GraphicsLayerChromium* owner)
+{
+ return adoptRef(new CanvasLayerChromium(owner));
+}
+
+CanvasLayerChromium::CanvasLayerChromium(GraphicsLayerChromium* owner)
+ : LayerChromium(owner)
+ , m_context(0)
+ , m_textureId(0)
+ , m_textureChanged(false)
+{
+}
+
+unsigned CanvasLayerChromium::textureId()
+{
+ return m_textureId;
+}
+
+void CanvasLayerChromium::updateTextureContents(unsigned textureId)
+{
+ ASSERT(textureId == m_textureId);
+ ASSERT(m_context);
+ if (m_textureChanged) {
+ glBindTexture(GL_TEXTURE_2D, m_textureId);
+ // Set the min-mag filters to linear and wrap modes to GL_CLAMP_TO_EDGE
+ // to get around NPOT texture limitations of GLES.
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ m_textureChanged = false;
+ }
+ // Update the contents of the texture used by the compositor.
+ if (m_contentsDirty) {
+ m_context->prepareTexture();
+ m_contentsDirty = false;
+ }
+}
+
+void CanvasLayerChromium::setContext(const GraphicsContext3D* context)
+{
+ m_context = const_cast<GraphicsContext3D*>(context);
+
+ unsigned int textureId = m_context->platformTexture();
+ if (textureId != m_textureId)
+ m_textureChanged = true;
+ m_textureId = textureId;
+}
+
+}
+#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/WebCore/platform/graphics/chromium/CanvasLayerChromium.h b/WebCore/platform/graphics/chromium/CanvasLayerChromium.h
new file mode 100644
index 0000000..a0025a4
--- /dev/null
+++ b/WebCore/platform/graphics/chromium/CanvasLayerChromium.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#ifndef CanvasLayerChromium_h
+#define CanvasLayerChromium_h
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "LayerChromium.h"
+
+namespace WebCore {
+
+class GraphicsContext3D;
+
+// A Layer containing a WebGL or accelerated 2d canvas
+class CanvasLayerChromium : public LayerChromium {
+public:
+ static PassRefPtr<CanvasLayerChromium> create(GraphicsLayerChromium* owner = 0);
+ virtual bool drawsContent() { return m_context; }
+ virtual bool ownsTexture() { return true; }
+ virtual void updateTextureContents(unsigned);
+ virtual unsigned textureId();
+ virtual unsigned shaderProgramId() { return m_shaderProgramId; }
+
+ void setContext(const GraphicsContext3D* context);
+
+ static void setShaderProgramId(unsigned shaderProgramId) { m_shaderProgramId = shaderProgramId; }
+
+private:
+ explicit CanvasLayerChromium(GraphicsLayerChromium* owner);
+ GraphicsContext3D* m_context;
+ unsigned m_textureId;
+ bool m_textureChanged;
+
+ static unsigned m_shaderProgramId;
+};
+
+}
+#endif // USE(ACCELERATED_COMPOSITING)
+
+#endif
diff --git a/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp b/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp
index e895cee..1d67857 100644
--- a/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp
+++ b/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp
@@ -53,7 +53,7 @@
#include "PlatformString.h"
#include "SystemTime.h"
#include "TransformLayerChromium.h"
-#include "WebGLLayerChromium.h"
+
#include <wtf/CurrentTime.h>
#include <wtf/StringExtras.h>
#include <wtf/text/CString.h>
@@ -285,6 +285,11 @@ void GraphicsLayerChromium::setOpacity(float opacity)
primaryLayer()->setOpacity(opacity);
}
+void GraphicsLayerChromium::setContentsNeedsDisplay()
+{
+ if (m_contentsLayer)
+ m_contentsLayer->setNeedsDisplay();
+}
void GraphicsLayerChromium::setNeedsDisplay()
{
if (drawsContent())
@@ -334,19 +339,17 @@ void GraphicsLayerChromium::setContentsToImage(Image* image)
updateSublayerList();
}
-#if ENABLE(3D_CANVAS)
-void GraphicsLayerChromium::setContentsToWebGL(PlatformLayer* platformLayer)
+void GraphicsLayerChromium::setContentsToCanvas(PlatformLayer* platformLayer)
{
bool childrenChanged = false;
if (platformLayer) {
- if (!m_contentsLayer.get() || m_contentsLayerPurpose != ContentsLayerForWebGL) {
- WebGLLayerChromium* webGLLayer = static_cast<WebGLLayerChromium*>(platformLayer);
- setupContentsLayer(webGLLayer);
- m_contentsLayer = webGLLayer;
- m_contentsLayerPurpose = ContentsLayerForWebGL;
+ platformLayer->setOwner(this);
+ if (!m_contentsLayer.get() || m_contentsLayerPurpose != ContentsLayerForCanvas) {
+ setupContentsLayer(platformLayer);
+ m_contentsLayer = platformLayer;
+ m_contentsLayerPurpose = ContentsLayerForCanvas;
childrenChanged = true;
}
- platformLayer->setOwner(this);
platformLayer->setNeedsDisplay();
updateContentsRect();
} else {
@@ -361,7 +364,6 @@ void GraphicsLayerChromium::setContentsToWebGL(PlatformLayer* platformLayer)
if (childrenChanged)
updateSublayerList();
}
-#endif
void GraphicsLayerChromium::setContentsToMedia(PlatformLayer* layer)
{
diff --git a/WebCore/platform/graphics/chromium/GraphicsLayerChromium.h b/WebCore/platform/graphics/chromium/GraphicsLayerChromium.h
index cd5e479..9dff66a 100644
--- a/WebCore/platform/graphics/chromium/GraphicsLayerChromium.h
+++ b/WebCore/platform/graphics/chromium/GraphicsLayerChromium.h
@@ -81,12 +81,13 @@ public:
virtual void setNeedsDisplay();
virtual void setNeedsDisplayInRect(const FloatRect&);
+ virtual void setContentsNeedsDisplay();
virtual void setContentsRect(const IntRect&);
virtual void setContentsToImage(Image*);
virtual void setContentsToMedia(PlatformLayer*);
- virtual void setContentsToWebGL(PlatformLayer*);
+ virtual void setContentsToCanvas(PlatformLayer*);
virtual PlatformLayer* platformLayer() const;
@@ -137,7 +138,7 @@ private:
NoContentsLayer = 0,
ContentsLayerForImage,
ContentsLayerForVideo,
- ContentsLayerForWebGL
+ ContentsLayerForCanvas
};
ContentsLayerPurpose m_contentsLayerPurpose;
diff --git a/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp b/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
index e98a65a..89d8907 100644
--- a/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
+++ b/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
@@ -34,11 +34,11 @@
#if USE(ACCELERATED_COMPOSITING)
#include "LayerRendererChromium.h"
+#include "CanvasLayerChromium.h"
#include "GLES2Context.h"
#include "LayerChromium.h"
#include "NotImplemented.h"
#include "TransformLayerChromium.h"
-#include "WebGLLayerChromium.h"
#if PLATFORM(SKIA)
#include "NativeImageSkia.h"
#include "PlatformContextSkia.h"
@@ -691,6 +691,7 @@ void LayerRendererChromium::drawLayer(LayerChromium* layer)
if (layer->contentsDirty()) {
// Update the backing texture contents for any dirty portion of the layer.
layer->updateTextureContents(textureId);
+ m_gles2Context->makeCurrent();
}
if (layer->doubleSided())
@@ -770,9 +771,9 @@ bool LayerRendererChromium::initializeSharedGLObjects()
" gl_FragColor = vec4(texColor.x, texColor.y, texColor.z, texColor.w); \n"
"} \n";
- // WebGL layers need to be flipped vertically and their colors shouldn't be
+ // Canvas layers need to be flipped vertically and their colors shouldn't be
// swizzled.
- char webGLFragmentShaderString[] =
+ char canvasFragmentShaderString[] =
"precision mediump float; \n"
"varying vec2 v_texCoord; \n"
"uniform sampler2D s_texture; \n"
@@ -819,11 +820,11 @@ bool LayerRendererChromium::initializeSharedGLObjects()
}
LayerChromium::setShaderProgramId(ContentLayerProgram);
- if (!createLayerShader(WebGLLayerProgram, vertexShaderString, webGLFragmentShaderString)) {
- LOG_ERROR("Failed to create shader program for WebGL layers");
+ if (!createLayerShader(CanvasLayerProgram, vertexShaderString, canvasFragmentShaderString)) {
+ LOG_ERROR("Failed to create shader program for Canvas layers");
return false;
}
- WebGLLayerChromium::setShaderProgramId(WebGLLayerProgram);
+ CanvasLayerChromium::setShaderProgramId(CanvasLayerProgram);
if (!createLayerShader(ScrollLayerProgram, vertexShaderString, scrollFragmentShaderString)) {
LOG_ERROR("Failed to create shader program for scrolling layer");
@@ -838,7 +839,7 @@ bool LayerRendererChromium::initializeSharedGLObjects()
// Specify the attrib location for the position and texCoord and make it the same for all programs to
// avoid binding re-binding the vertex attributes.
bindCommonAttribLocations(ContentLayerProgram);
- bindCommonAttribLocations(WebGLLayerProgram);
+ bindCommonAttribLocations(CanvasLayerProgram);
bindCommonAttribLocations(DebugBorderProgram);
bindCommonAttribLocations(ScrollLayerProgram);
diff --git a/WebCore/platform/graphics/chromium/LayerRendererChromium.h b/WebCore/platform/graphics/chromium/LayerRendererChromium.h
index 17e7e57..e4474b5 100644
--- a/WebCore/platform/graphics/chromium/LayerRendererChromium.h
+++ b/WebCore/platform/graphics/chromium/LayerRendererChromium.h
@@ -88,7 +88,7 @@ public:
GraphicsContext* rootLayerGraphicsContext() const { return m_rootLayerGraphicsContext.get(); }
private:
- enum ShaderProgramType { DebugBorderProgram, ScrollLayerProgram, ContentLayerProgram, WebGLLayerProgram, NumShaderProgramTypes };
+ enum ShaderProgramType { DebugBorderProgram, ScrollLayerProgram, ContentLayerProgram, CanvasLayerProgram, NumShaderProgramTypes };
void updateLayersRecursive(LayerChromium* layer, const TransformationMatrix& parentMatrix, float opacity, const IntRect& visibleRect);
diff --git a/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp b/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp
deleted file mode 100644
index ebd9ebe..0000000
--- a/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2010 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if USE(ACCELERATED_COMPOSITING)
-
-#include "WebGLLayerChromium.h"
-
-#include "GraphicsContext3D.h"
-#include <GLES2/gl2.h>
-
-namespace WebCore {
-
-unsigned WebGLLayerChromium::m_shaderProgramId = 0;
-
-PassRefPtr<WebGLLayerChromium> WebGLLayerChromium::create(GraphicsLayerChromium* owner)
-{
- return adoptRef(new WebGLLayerChromium(owner));
-}
-
-WebGLLayerChromium::WebGLLayerChromium(GraphicsLayerChromium* owner)
- : LayerChromium(owner)
- , m_context(0)
- , m_textureId(0)
- , m_textureChanged(false)
-{
-}
-
-unsigned WebGLLayerChromium::textureId()
-{
- return m_textureId;
-}
-
-void WebGLLayerChromium::updateTextureContents(unsigned textureId)
-{
- ASSERT(textureId == m_textureId);
- ASSERT(m_context);
- if (m_textureChanged) {
- glBindTexture(GL_TEXTURE_2D, m_textureId);
- // Set the min-mag filters to linear and wrap modes to GL_CLAMP_TO_EDGE
- // to get around NPOT texture limitations of GLES.
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- m_textureChanged = false;
- }
- // Update the contents of the texture used by the compositor.
- if (m_contentsDirty) {
- m_context->prepareTexture();
- m_contentsDirty = false;
- }
-}
-
-void WebGLLayerChromium::setContext(const GraphicsContext3D* context)
-{
- m_context = const_cast<GraphicsContext3D*>(context);
-
- unsigned int textureId = m_context->platformTexture();
- if (textureId != m_textureId)
- m_textureChanged = true;
- m_textureId = textureId;
-}
-
-}
-#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/WebCore/platform/graphics/chromium/WebGLLayerChromium.h b/WebCore/platform/graphics/chromium/WebGLLayerChromium.h
deleted file mode 100644
index abd0c93..0000000
--- a/WebCore/platform/graphics/chromium/WebGLLayerChromium.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2010 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-
-#ifndef WebGLLayerChromium_h
-#define WebGLLayerChromium_h
-
-#if USE(ACCELERATED_COMPOSITING)
-
-#include "LayerChromium.h"
-
-namespace WebCore {
-
-class GraphicsContext3D;
-
-// A Layer that contains a WebGL element.
-class WebGLLayerChromium : public LayerChromium {
-public:
- static PassRefPtr<WebGLLayerChromium> create(GraphicsLayerChromium* owner = 0);
- virtual bool drawsContent() { return m_context; }
- virtual bool ownsTexture() { return true; }
- virtual void updateTextureContents(unsigned);
- virtual unsigned textureId();
- virtual unsigned shaderProgramId() { return m_shaderProgramId; }
-
- void setContext(const GraphicsContext3D* context);
-
- static void setShaderProgramId(unsigned shaderProgramId) { m_shaderProgramId = shaderProgramId; }
-
-private:
- WebGLLayerChromium(GraphicsLayerChromium* owner);
- GraphicsContext3D* m_context;
- unsigned m_textureId;
- bool m_textureChanged;
-
- static unsigned m_shaderProgramId;
-};
-
-}
-#endif // USE(ACCELERATED_COMPOSITING)
-
-#endif
diff --git a/WebCore/platform/graphics/mac/GraphicsLayerCA.h b/WebCore/platform/graphics/mac/GraphicsLayerCA.h
index 80c822c..ee70338 100644
--- a/WebCore/platform/graphics/mac/GraphicsLayerCA.h
+++ b/WebCore/platform/graphics/mac/GraphicsLayerCA.h
@@ -103,9 +103,8 @@ public:
virtual void setContentsToImage(Image*);
virtual void setContentsToMedia(PlatformLayer*);
-#if ENABLE(3D_CANVAS)
- virtual void setContentsToWebGL(PlatformLayer*);
-#endif
+ virtual void setContentsToCanvas(PlatformLayer*);
+
virtual bool hasContentsLayer() const { return m_contentsLayer; }
virtual PlatformLayer* platformLayer() const;
@@ -258,9 +257,7 @@ private:
void updateContentsImage();
void updateContentsMediaLayer();
-#if ENABLE(3D_CANVAS)
- void updateContentsWebGLLayer();
-#endif
+ void updateContentsCanvasLayer();
void updateContentsRect();
void updateGeometryOrientation();
void updateMaskLayer();
@@ -305,9 +302,7 @@ private:
DirtyRectsChanged = 1 << 16,
ContentsImageChanged = 1 << 17,
ContentsMediaLayerChanged = 1 << 18,
-#if ENABLE(3D_CANVAS)
- ContentsWebGLLayerChanged = 1 << 19,
-#endif
+ ContentsCanvasLayerChanged = 1 << 19,
ContentsRectChanged = 1 << 20,
GeometryOrientationChanged = 1 << 21,
MaskLayerChanged = 1 << 22,
@@ -332,10 +327,8 @@ private:
enum ContentsLayerPurpose {
NoContentsLayer = 0,
ContentsLayerForImage,
- ContentsLayerForMedia
-#if ENABLE(3D_CANVAS)
- , ContentsLayerForWebGL
-#endif
+ ContentsLayerForMedia,
+ ContentsLayerForCanvas
};
ContentsLayerPurpose m_contentsLayerPurpose;
diff --git a/WebCore/platform/graphics/mac/GraphicsLayerCA.mm b/WebCore/platform/graphics/mac/GraphicsLayerCA.mm
index 9f1ac83..cb4ca58 100644
--- a/WebCore/platform/graphics/mac/GraphicsLayerCA.mm
+++ b/WebCore/platform/graphics/mac/GraphicsLayerCA.mm
@@ -917,10 +917,8 @@ void GraphicsLayerCA::commitLayerChangesBeforeSublayers()
if (m_uncommittedChanges & ContentsMediaLayerChanged) // Needs to happen before ChildrenChanged
updateContentsMediaLayer();
-#if ENABLE(3D_CANVAS)
- if (m_uncommittedChanges & ContentsWebGLLayerChanged) // Needs to happen before ChildrenChanged
- updateContentsWebGLLayer();
-#endif
+ if (m_uncommittedChanges & ContentsCanvasLayerChanged) // Needs to happen before ChildrenChanged
+ updateContentsCanvasLayer();
if (m_uncommittedChanges & BackgroundColorChanged) // Needs to happen before ChildrenChanged, and after updating image or video
updateLayerBackgroundColor();
@@ -1396,18 +1394,16 @@ void GraphicsLayerCA::updateContentsMediaLayer()
}
}
-#if ENABLE(3D_CANVAS)
-void GraphicsLayerCA::updateContentsWebGLLayer()
+void GraphicsLayerCA::updateContentsCanvasLayer()
{
- // WebGLLayer was set as m_contentsLayer, and will get parented in updateSublayerList().
+ // CanvasLayer was set as m_contentsLayer, and will get parented in updateSublayerList().
if (m_contentsLayer) {
setupContentsLayer(m_contentsLayer.get());
[m_contentsLayer.get() setNeedsDisplay];
updateContentsRect();
}
}
-#endif
-
+
void GraphicsLayerCA::updateContentsRect()
{
if (!m_contentsLayer)
@@ -1722,22 +1718,20 @@ void GraphicsLayerCA::pauseAnimationOnLayer(AnimatedPropertyID property, const S
}
}
-#if ENABLE(3D_CANVAS)
-void GraphicsLayerCA::setContentsToWebGL(PlatformLayer* webglLayer)
+void GraphicsLayerCA::setContentsToCanvas(PlatformLayer* canvasLayer)
{
- if (webglLayer == m_contentsLayer)
+ if (canvasLayer == m_contentsLayer)
return;
- m_contentsLayer = webglLayer;
+ m_contentsLayer = canvasLayer;
if (m_contentsLayer && [m_contentsLayer.get() respondsToSelector:@selector(setLayerOwner:)])
[(id)m_contentsLayer.get() setLayerOwner:this];
- m_contentsLayerPurpose = webglLayer ? ContentsLayerForWebGL : NoContentsLayer;
+ m_contentsLayerPurpose = canvasLayer ? ContentsLayerForCanvas : NoContentsLayer;
noteSublayersChanged();
- noteLayerPropertyChanged(ContentsWebGLLayerChanged);
+ noteLayerPropertyChanged(ContentsCanvasLayerChanged);
}
-#endif
void GraphicsLayerCA::repaintLayerDirtyRects()
{
diff --git a/WebCore/rendering/RenderLayerBacking.cpp b/WebCore/rendering/RenderLayerBacking.cpp
index 0e5933e..b3a7917 100644
--- a/WebCore/rendering/RenderLayerBacking.cpp
+++ b/WebCore/rendering/RenderLayerBacking.cpp
@@ -28,13 +28,12 @@
#if USE(ACCELERATED_COMPOSITING)
#include "AnimationController.h"
-#if ENABLE(3D_CANVAS)
-#include "WebGLRenderingContext.h"
-#endif
+#include "CanvasRenderingContext.h"
#include "CSSPropertyNames.h"
#include "CSSStyleSelector.h"
#include "FrameView.h"
#include "GraphicsContext.h"
+#include "GraphicsContext3D.h"
#include "GraphicsLayer.h"
#include "HTMLCanvasElement.h"
#include "HTMLElement.h"
@@ -66,11 +65,14 @@ static bool hasBoxDecorationsOrBackground(const RenderObject*);
static bool hasBoxDecorationsOrBackgroundImage(const RenderStyle*);
static IntRect clipBox(RenderBox* renderer);
-static inline bool is3DCanvas(RenderObject* renderer)
+static inline bool isAcceleratedCanvas(RenderObject* renderer)
{
-#if ENABLE(3D_CANVAS)
- if (renderer->isCanvas())
- return static_cast<HTMLCanvasElement*>(renderer->node())->is3D();
+#if ENABLE(3D_CANVAS) || ENABLE(ACCELERATED_2D_CANVAS)
+ if (renderer->isCanvas()) {
+ HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(renderer->node());
+ if (CanvasRenderingContext* context = canvas->renderingContext())
+ return context->isAccelerated();
+ }
#else
UNUSED_PARAM(renderer);
#endif
@@ -252,12 +254,13 @@ bool RenderLayerBacking::updateGraphicsLayerConfiguration()
m_graphicsLayer->setContentsToMedia(mediaElement->platformLayer());
}
#endif
-#if ENABLE(3D_CANVAS)
- else if (is3DCanvas(renderer())) {
+#if ENABLE(3D_CANVAS) || ENABLE(ACCELERATED_2D_CANVAS)
+ else if (isAcceleratedCanvas(renderer())) {
HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(renderer()->node());
- WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(canvas->renderingContext());
- if (context->graphicsContext3D()->platformLayer())
- m_graphicsLayer->setContentsToWebGL(context->graphicsContext3D()->platformLayer());
+ if (CanvasRenderingContext* context = canvas->renderingContext())
+ if (context->graphicsContext3D())
+ if (PlatformLayer* pl = context->graphicsContext3D()->platformLayer())
+ m_graphicsLayer->setContentsToCanvas(pl);
}
#endif
@@ -756,8 +759,12 @@ bool RenderLayerBacking::containsPaintedContent() const
// FIXME: we could optimize cases where the image, video or canvas is known to fill the border box entirely,
// and set background color on the layer in that case, instead of allocating backing store and painting.
- if (renderer()->isVideo() || is3DCanvas(renderer()))
+ if (renderer()->isVideo())
return hasBoxDecorationsOrBackground(renderer());
+#if ENABLE(3D_CANVAS) || ENABLE(ACCELERATED_2D_CANVAS)
+ if (isAcceleratedCanvas(renderer()))
+ return hasBoxDecorationsOrBackground(renderer());
+#endif
return true;
}
@@ -777,8 +784,8 @@ void RenderLayerBacking::rendererContentChanged()
return;
}
-#if ENABLE(3D_CANVAS)
- if (is3DCanvas(renderer())) {
+#if ENABLE(3D_CANVAS) || ENABLE(ACCELERATED_2D_CANVAS)
+ if (isAcceleratedCanvas(renderer())) {
m_graphicsLayer->setContentsNeedsDisplay();
return;
}
diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index b4102bf..4c68dd7 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,18 @@
+2010-08-06 James Robinson <jamesr at chromium.org>
+
+ Reviewed by Simon Fraser.
+
+ Composited canvas should be treated the same by the compositor and not be WebGL specific
+ https://bugs.webkit.org/show_bug.cgi?id=43589
+
+ Initializes the platformLayer as a CanvasLayerChromium, not a WebGLLayerChromium.
+ The layer itself isn't WebGL-specific.
+
+ * src/GraphicsContext3D.cpp:
+ (WebCore::GraphicsContext3DInternal::initialize):
+ (WebCore::GraphicsContext3DInternal::platformLayer):
+ (WebCore::GraphicsContext3D::platformLayer):
+
2010-08-06 Jessie Berlin <jberlin at apple.com>
Roll out http://trac.webkit.org/changeset/64801, which broke the Safari Windows Build.
diff --git a/WebKit/chromium/src/GraphicsContext3D.cpp b/WebKit/chromium/src/GraphicsContext3D.cpp
index d6ad1a3..a02872d 100644
--- a/WebKit/chromium/src/GraphicsContext3D.cpp
+++ b/WebKit/chromium/src/GraphicsContext3D.cpp
@@ -35,6 +35,7 @@
#include "GraphicsContext3D.h"
#include "CachedImage.h"
+#include "CanvasLayerChromium.h"
#include "CanvasRenderingContext.h"
#include "Chrome.h"
#include "ChromeClientImpl.h"
@@ -46,7 +47,6 @@
#include "Int32Array.h"
#include "Int8Array.h"
#include "Uint8Array.h"
-#include "WebGLLayerChromium.h"
#include "WebGraphicsContext3D.h"
#include "WebGraphicsContext3DDefaultImpl.h"
#include "WebKit.h"
@@ -111,7 +111,7 @@ public:
void prepareTexture();
#if USE(ACCELERATED_COMPOSITING)
- WebGLLayerChromium* platformLayer() const;
+ CanvasLayerChromium* platformLayer() const;
#endif
bool isGLES2Compliant() const;
@@ -304,7 +304,7 @@ public:
private:
OwnPtr<WebKit::WebGraphicsContext3D> m_impl;
#if USE(ACCELERATED_COMPOSITING)
- RefPtr<WebGLLayerChromium> m_compositingLayer;
+ RefPtr<CanvasLayerChromium> m_compositingLayer;
#endif
#if PLATFORM(SKIA)
// If the width and height of the Canvas's backing store don't
@@ -365,7 +365,7 @@ bool GraphicsContext3DInternal::initialize(GraphicsContext3D::Attributes attrs,
m_impl.set(webContext);
#if USE(ACCELERATED_COMPOSITING)
- m_compositingLayer = WebGLLayerChromium::create(0);
+ m_compositingLayer = CanvasLayerChromium::create(0);
#endif
return true;
}
@@ -386,7 +386,7 @@ void GraphicsContext3DInternal::prepareTexture()
}
#if USE(ACCELERATED_COMPOSITING)
-WebGLLayerChromium* GraphicsContext3DInternal::platformLayer() const
+CanvasLayerChromium* GraphicsContext3DInternal::platformLayer() const
{
return m_compositingLayer.get();
}
@@ -1046,9 +1046,9 @@ void GraphicsContext3D::prepareTexture()
#if USE(ACCELERATED_COMPOSITING)
PlatformLayer* GraphicsContext3D::platformLayer() const
{
- WebGLLayerChromium* webGLLayer = m_internal->platformLayer();
- webGLLayer->setContext(this);
- return webGLLayer;
+ CanvasLayerChromium* canvasLayer = m_internal->platformLayer();
+ canvasLayer->setContext(this);
+ return canvasLayer;
}
#endif
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list