Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (134947 => 134948)
--- trunk/Source/WebCore/CMakeLists.txt 2012-11-16 15:21:40 UTC (rev 134947)
+++ trunk/Source/WebCore/CMakeLists.txt 2012-11-16 15:39:12 UTC (rev 134948)
@@ -51,6 +51,7 @@
"${WEBCORE_DIR}/platform/graphics/cpu/arm"
"${WEBCORE_DIR}/platform/graphics/cpu/arm/filters"
"${WEBCORE_DIR}/platform/graphics/filters"
+ "${WEBCORE_DIR}/platform/graphics/filters/texmap"
"${WEBCORE_DIR}/platform/graphics/harfbuzz"
"${WEBCORE_DIR}/platform/graphics/harfbuzz/ng"
"${WEBCORE_DIR}/platform/graphics/opentype"
@@ -1908,6 +1909,7 @@
platform/graphics/cpu/arm/filters/FELightingNEON.cpp
+ platform/graphics/filters/texmap/CustomFilterValidatedProgramTextureMapper.cpp
platform/graphics/filters/CustomFilterCompiledProgram.cpp
platform/graphics/filters/CustomFilterGlobalContext.cpp
platform/graphics/filters/CustomFilterMesh.cpp
Modified: trunk/Source/WebCore/ChangeLog (134947 => 134948)
--- trunk/Source/WebCore/ChangeLog 2012-11-16 15:21:40 UTC (rev 134947)
+++ trunk/Source/WebCore/ChangeLog 2012-11-16 15:39:12 UTC (rev 134948)
@@ -1,3 +1,49 @@
+2012-11-16 Alexandru Chiculita <[email protected]>
+
+ [Texmap][CSS Shaders] Make the CustomFilterValidatedProgram maintain the platform compiled program
+ https://bugs.webkit.org/show_bug.cgi?id=102414
+
+ Reviewed by Noam Rosenthal.
+
+ Added WebCore classes needed for the WebKit2 implementation of Texture Mapper to keep a reference to the
+ platform compiled custom filter. It is just used to maintain the life-time of the objects. WebKit2 injects a
+ client in TextureMapperPlatformCompiledProgram and receives a callback when the custom filter program is not
+ used to render any layer on the page.
+
+ Note that CustomFilterValidatedProgram are reused across multiple elements of the same page. Also, the instances
+ are reused across frames, so animations should reuse the same pre-validated program. In this case, the mechanism is
+ extended and reused in the platform compositor.
+
+ No new tests, existing tests for CSS Custom Filters already cover this path.
+
+ * CMakeLists.txt:
+ * GNUmakefile.am:
+ * GNUmakefile.list.am:
+ * Target.pri:
+ * WebCore.pri:
+ * platform/graphics/filters/CustomFilterValidatedProgram.cpp:
+ (WebCore):
+ * platform/graphics/filters/CustomFilterValidatedProgram.h:
+ (WebCore):
+ (CustomFilterValidatedProgram):
+ * platform/graphics/filters/texmap/CustomFilterValidatedProgramTextureMapper.cpp: Added.
+ (WebCore):
+ (WebCore::CustomFilterValidatedProgram::platformCompiledProgram): Platform implementation for creating and deleting the reference.
+ (WebCore::CustomFilterValidatedProgram::platformInit):
+ (WebCore::CustomFilterValidatedProgram::platformDestroy):
+ * platform/graphics/filters/texmap/TextureMapperPlatformCompiledProgram.h: Added.
+ (WebCore):
+ (TextureMapperPlatformCompiledProgramClient):
+ (WebCore::TextureMapperPlatformCompiledProgramClient::ref):
+ (WebCore::TextureMapperPlatformCompiledProgramClient::deref):
+ (TextureMapperPlatformCompiledProgram):
+ Stores a link to a TextureMapperPlatformCompiledProgramClient. It's main purpose is to call unref on the client when
+ the shader is not needed anymore. WebKit2 can use that to delete the corresponding shader from the compositor side.
+ (WebCore::TextureMapperPlatformCompiledProgram::create):
+ (WebCore::TextureMapperPlatformCompiledProgram::setClient): Used by WebKit2 to inject the platform client.
+ (WebCore::TextureMapperPlatformCompiledProgram::client):
+ (WebCore::TextureMapperPlatformCompiledProgram::TextureMapperPlatformCompiledProgram):
+
2012-11-16 Andreas Kling <[email protected]>
Short-circuit Element::hasEquivalentAttributes() if elements share attribute data.
Modified: trunk/Source/WebCore/GNUmakefile.am (134947 => 134948)
--- trunk/Source/WebCore/GNUmakefile.am 2012-11-16 15:21:40 UTC (rev 134947)
+++ trunk/Source/WebCore/GNUmakefile.am 2012-11-16 15:39:12 UTC (rev 134948)
@@ -57,6 +57,7 @@
-I$(srcdir)/Source/WebCore/platform/graphics/cpu/arm \
-I$(srcdir)/Source/WebCore/platform/graphics/cpu/arm/filters/ \
-I$(srcdir)/Source/WebCore/platform/graphics/filters \
+ -I$(srcdir)/Source/WebCore/platform/graphics/filters/texmap \
-I$(srcdir)/Source/WebCore/platform/graphics/gpu \
-I$(srcdir)/Source/WebCore/platform/graphics/opengl \
-I$(srcdir)/Source/WebCore/platform/graphics/opentype \
Modified: trunk/Source/WebCore/GNUmakefile.list.am (134947 => 134948)
--- trunk/Source/WebCore/GNUmakefile.list.am 2012-11-16 15:21:40 UTC (rev 134947)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2012-11-16 15:39:12 UTC (rev 134948)
@@ -6339,6 +6339,8 @@
if USE_TEXTURE_MAPPER_CAIRO
webcore_sources += \
+ Source/WebCore//platform/graphics/filters/texmap/CustomFilterValidatedProgramTextureMapper.cpp \
+ Source/WebCore//platform/graphics/filters/texmap/TextureMapperPlatformCompiledProgram.h \
Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.cpp \
Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.h \
Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp \
@@ -6360,6 +6362,8 @@
if USE_TEXTURE_MAPPER_GL
webcore_sources += \
+ Source/WebCore//platform/graphics/filters/texmap/CustomFilterValidatedProgramTextureMapper.cpp \
+ Source/WebCore//platform/graphics/filters/texmap/TextureMapperPlatformCompiledProgram.h \
Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp \
Source/WebCore/platform/graphics/texmap/TextureMapperGL.h \
Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.cpp \
Modified: trunk/Source/WebCore/Target.pri (134947 => 134948)
--- trunk/Source/WebCore/Target.pri 2012-11-16 15:21:40 UTC (rev 134947)
+++ trunk/Source/WebCore/Target.pri 2012-11-16 15:39:12 UTC (rev 134948)
@@ -2087,6 +2087,7 @@
platform/graphics/cpu/arm/filters/FEGaussianBlurNEON.h \
platform/graphics/cpu/arm/filters/FELightingNEON.h \
platform/graphics/CrossfadeGeneratedImage.h \
+ platform/graphics/filters/texmap/TextureMapperPlatformCompiledProgram.h \
platform/graphics/filters/CustomFilterArrayParameter.h \
platform/graphics/filters/CustomFilterConstants.h \
platform/graphics/filters/CustomFilterGlobalContext.h \
@@ -3509,6 +3510,7 @@
enable?(FILTERS) {
SOURCES += \
platform/graphics/cpu/arm/filters/FELightingNEON.cpp \
+ platform/graphics/filters/texmap/CustomFilterValidatedProgramTextureMapper.cpp \
platform/graphics/filters/CustomFilterGlobalContext.cpp \
platform/graphics/filters/CustomFilterOperation.cpp \
platform/graphics/filters/CustomFilterParameterList.cpp \
Modified: trunk/Source/WebCore/WebCore.pri (134947 => 134948)
--- trunk/Source/WebCore/WebCore.pri 2012-11-16 15:21:40 UTC (rev 134947)
+++ trunk/Source/WebCore/WebCore.pri 2012-11-16 15:39:12 UTC (rev 134948)
@@ -56,6 +56,7 @@
$$SOURCE_DIR/platform/graphics/cpu/arm \
$$SOURCE_DIR/platform/graphics/cpu/arm/filters \
$$SOURCE_DIR/platform/graphics/filters \
+ $$SOURCE_DIR/platform/graphics/filters/texmap \
$$SOURCE_DIR/platform/graphics/opengl \
$$SOURCE_DIR/platform/graphics/opentype \
$$SOURCE_DIR/platform/graphics/qt \
Modified: trunk/Source/WebCore/platform/graphics/filters/CustomFilterValidatedProgram.cpp (134947 => 134948)
--- trunk/Source/WebCore/platform/graphics/filters/CustomFilterValidatedProgram.cpp 2012-11-16 15:21:40 UTC (rev 134947)
+++ trunk/Source/WebCore/platform/graphics/filters/CustomFilterValidatedProgram.cpp 2012-11-16 15:39:12 UTC (rev 134948)
@@ -512,7 +512,7 @@
m_globalContext->removeValidatedProgram(this);
}
-#if !PLATFORM(BLACKBERRY)
+#if !PLATFORM(BLACKBERRY) && !USE(TEXTURE_MAPPER)
void CustomFilterValidatedProgram::platformInit()
{
}
Modified: trunk/Source/WebCore/platform/graphics/filters/CustomFilterValidatedProgram.h (134947 => 134948)
--- trunk/Source/WebCore/platform/graphics/filters/CustomFilterValidatedProgram.h 2012-11-16 15:21:40 UTC (rev 134947)
+++ trunk/Source/WebCore/platform/graphics/filters/CustomFilterValidatedProgram.h 2012-11-16 15:39:12 UTC (rev 134948)
@@ -53,6 +53,11 @@
class CustomFilterCompiledProgram;
class CustomFilterGlobalContext;
+#if USE(TEXTURE_MAPPER)
+class TextureMapperPlatformCompiledProgram;
+typedef TextureMapperPlatformCompiledProgram PlatformCompiledProgram;
+#endif
+
//
// A unique combination of vertex shader and fragment shader is only validated and compiled once.
// All shaders are validated through ANGLE in CustomFilterValidatedProgram before being compiled by the GraphicsContext3D in CustomFilterCompiledProgram.
@@ -91,7 +96,7 @@
return m_validatedFragmentShader;
}
-#if PLATFORM(BLACKBERRY)
+#if PLATFORM(BLACKBERRY) || USE(TEXTURE_MAPPER)
PlatformCompiledProgram* platformCompiledProgram();
#endif
@@ -124,7 +129,7 @@
String m_validatedFragmentShader;
RefPtr<CustomFilterCompiledProgram> m_compiledProgram;
-#if PLATFORM(BLACKBERRY)
+#if PLATFORM(BLACKBERRY) || USE(TEXTURE_MAPPER)
PlatformCompiledProgram* m_platformCompiledProgram;
#endif
Added: trunk/Source/WebCore/platform/graphics/filters/texmap/CustomFilterValidatedProgramTextureMapper.cpp (0 => 134948)
--- trunk/Source/WebCore/platform/graphics/filters/texmap/CustomFilterValidatedProgramTextureMapper.cpp (rev 0)
+++ trunk/Source/WebCore/platform/graphics/filters/texmap/CustomFilterValidatedProgramTextureMapper.cpp 2012-11-16 15:39:12 UTC (rev 134948)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "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 HOLDER 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 ENABLE(CSS_SHADERS) && USE(TEXTURE_MAPPER)
+#include "CustomFilterValidatedProgram.h"
+
+#include "TextureMapperPlatformCompiledProgram.h"
+
+namespace WebCore {
+
+PlatformCompiledProgram* CustomFilterValidatedProgram::platformCompiledProgram()
+{
+ if (!m_platformCompiledProgram)
+ m_platformCompiledProgram = TextureMapperPlatformCompiledProgram::create().leakRef();
+ return m_platformCompiledProgram;
+}
+
+void CustomFilterValidatedProgram::platformInit()
+{
+ m_platformCompiledProgram = 0;
+}
+
+void CustomFilterValidatedProgram::platformDestroy()
+{
+ derefIfNotNull(m_platformCompiledProgram);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(CSS_SHADERS) && USE(TEXTURE_MAPPER)
Added: trunk/Source/WebCore/platform/graphics/filters/texmap/TextureMapperPlatformCompiledProgram.h (0 => 134948)
--- trunk/Source/WebCore/platform/graphics/filters/texmap/TextureMapperPlatformCompiledProgram.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/filters/texmap/TextureMapperPlatformCompiledProgram.h 2012-11-16 15:39:12 UTC (rev 134948)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "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 HOLDER 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 TextureMapperPlatformCompiledProgram_h
+#define TextureMapperPlatformCompiledProgram_h
+
+#if ENABLE(CSS_SHADERS)
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class TextureMapperPlatformCompiledProgramClient {
+public:
+ void ref() { refFromValidatedProgram(); }
+ void deref() { derefFromValidatedProgram(); }
+
+ virtual void refFromValidatedProgram() = 0;
+ virtual void derefFromValidatedProgram() = 0;
+};
+
+class TextureMapperPlatformCompiledProgram : public RefCounted<TextureMapperPlatformCompiledProgram> {
+public:
+ static PassRefPtr<TextureMapperPlatformCompiledProgram> create()
+ {
+ return adoptRef(new TextureMapperPlatformCompiledProgram());
+ }
+
+ void setClient(PassRefPtr<TextureMapperPlatformCompiledProgramClient> client) { m_client = client; }
+ TextureMapperPlatformCompiledProgramClient* client() const { return m_client.get(); }
+
+private:
+ TextureMapperPlatformCompiledProgram()
+ {
+ }
+
+ RefPtr<TextureMapperPlatformCompiledProgramClient> m_client;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(CSS_SHADERS)
+
+#endif // TextureMapperPlatformCompiledProgram_h
Modified: trunk/Source/WebKit2/CMakeLists.txt (134947 => 134948)
--- trunk/Source/WebKit2/CMakeLists.txt 2012-11-16 15:21:40 UTC (rev 134947)
+++ trunk/Source/WebKit2/CMakeLists.txt 2012-11-16 15:39:12 UTC (rev 134948)
@@ -218,6 +218,7 @@
Shared/API/c/WKUserContentURLPattern.cpp
Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp
+ Shared/CoordinatedGraphics/WebCustomFilterProgramProxy.cpp
Shared/Plugins/NPIdentifierData.cpp
Shared/Plugins/NPObjectMessageReceiver.cpp
Modified: trunk/Source/WebKit2/ChangeLog (134947 => 134948)
--- trunk/Source/WebKit2/ChangeLog 2012-11-16 15:21:40 UTC (rev 134947)
+++ trunk/Source/WebKit2/ChangeLog 2012-11-16 15:39:12 UTC (rev 134948)
@@ -1,3 +1,46 @@
+2012-11-16 Alexandru Chiculita <[email protected]>
+
+ [Texmap][CSS Shaders] Make the CustomFilterValidatedProgram maintain the platform compiled program
+ https://bugs.webkit.org/show_bug.cgi?id=102414
+
+ Reviewed by Noam Rosenthal.
+
+ This is the first part of shader caching implementation for the Custom Filters in WK2 LayerTreeCoordinator.
+ In this patch it will just make the LayerTreeCoordinator knowledgeable about the life-time
+ of the custom filter programs. It can allocate IDs for the filters and it also gets a callback when the
+ filters are not needed anymore.
+
+ The UI process is still recreating the shader every time, but https://bugs.webkit.org/show_bug.cgi?id=101801
+ will fix that and try to reuse existing custom filters.
+
+ * CMakeLists.txt:
+ * Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp:
+ (CoreIPC::::encode):
+ * Shared/CoordinatedGraphics/WebCustomFilterProgramProxy.cpp: Added.
+ (WebKit):
+ (WebKit::WebCustomFilterProgramProxy::~WebCustomFilterProgramProxy):
+ * Shared/CoordinatedGraphics/WebCustomFilterProgramProxy.h: Added.
+ (WebKit):
+ (WebCustomFilterProgramProxyClient):
+ (WebCustomFilterProgramProxy):
+ (WebKit::WebCustomFilterProgramProxy::create):
+ (WebKit::WebCustomFilterProgramProxy::id):
+ (WebKit::WebCustomFilterProgramProxy::refFromValidatedProgram):
+ (WebKit::WebCustomFilterProgramProxy::derefFromValidatedProgram):
+ (WebKit::WebCustomFilterProgramProxy::setClient):
+ (WebKit::WebCustomFilterProgramProxy::client):
+ (WebKit::WebCustomFilterProgramProxy::WebCustomFilterProgramProxy):
+ * Target.pri:
+ * WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp:
+ (WebKit::LayerTreeCoordinator::~LayerTreeCoordinator):
+ (WebKit::LayerTreeCoordinator::syncLayerFilters):
+ (WebKit):
+ (WebKit::LayerTreeCoordinator::checkCustomFilterProgramProxies):
+ (WebKit::LayerTreeCoordinator::removeCustomFilterProgramProxy):
+ (WebKit::LayerTreeCoordinator::disconnectCustomFilterPrograms):
+ * WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h:
+ (LayerTreeCoordinator):
+
2012-11-16 Peter Gal <[email protected]>
[Qt][Mac] Fix the build after r124873
Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp (134947 => 134948)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp 2012-11-16 15:21:40 UTC (rev 134947)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp 2012-11-16 15:39:12 UTC (rev 134948)
@@ -146,6 +146,10 @@
ASSERT(customOperation->validatedProgram());
RefPtr<CustomFilterValidatedProgram> program = customOperation->validatedProgram();
ASSERT(program->isInitialized());
+ ASSERT(program->platformCompiledProgram());
+ // FIXME: We should only serialize the object if it was not serialized before,
+ // otherwise only the ID of the program should be written to the stream.
+ // https://bugs.webkit.org/show_bug.cgi?id=101801
encoder << program->validatedVertexShader();
encoder << program->validatedFragmentShader();
const CustomFilterProgramInfo& programInfo = program->programInfo();
Added: trunk/Source/WebKit2/Shared/CoordinatedGraphics/WebCustomFilterProgramProxy.cpp (0 => 134948)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/WebCustomFilterProgramProxy.cpp (rev 0)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/WebCustomFilterProgramProxy.cpp 2012-11-16 15:39:12 UTC (rev 134948)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "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 HOLDER 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 ENABLE(CSS_SHADERS)
+#include "WebCustomFilterProgramProxy.h"
+
+namespace WebKit {
+
+int WebCustomFilterProgramProxy::s_nextId = 1;
+
+WebCustomFilterProgramProxy::~WebCustomFilterProgramProxy()
+{
+ if (m_client) {
+ m_client->removeCustomFilterProgramProxy(this);
+ m_client = 0;
+ }
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(CSS_SHADERS)
Added: trunk/Source/WebKit2/Shared/CoordinatedGraphics/WebCustomFilterProgramProxy.h (0 => 134948)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/WebCustomFilterProgramProxy.h (rev 0)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/WebCustomFilterProgramProxy.h 2012-11-16 15:39:12 UTC (rev 134948)
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "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 HOLDER 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 WebCustomFilterProgramProxy_h
+#define WebCustomFilterProgramProxy_h
+
+#if USE(COORDINATED_GRAPHICS) && ENABLE(CSS_SHADERS)
+
+#include "TextureMapperPlatformCompiledProgram.h"
+#include <wtf/RefCounted.h>
+
+namespace WebKit {
+
+class WebCustomFilterProgramProxy;
+
+class WebCustomFilterProgramProxyClient {
+public:
+ virtual void removeCustomFilterProgramProxy(WebCustomFilterProgramProxy*) = 0;
+};
+
+// This is a proxy class used to store the ID of the custom filter program serialized to the other process.
+// It lives in the WebProcess and is referenced from the CustomFilterValidatedProgram meaning that it will be kept alive as
+// long as a layer on the page will render with this program. It will call removeCustomFilterProgramProxy on the m_client
+// when the program is no longer needed to render the filter. The client can then send a message to the UI process
+// to destroy the associated reference. Note that more layers can share the same program and there's
+// no need to implement a caching mechanism in the compositor side.
+
+class WebCustomFilterProgramProxy : public RefCounted<WebCustomFilterProgramProxy>, public WebCore::TextureMapperPlatformCompiledProgramClient {
+public:
+ using RefCounted<WebCustomFilterProgramProxy>::ref;
+ using RefCounted<WebCustomFilterProgramProxy>::deref;
+
+ static PassRefPtr<WebCustomFilterProgramProxy> create(WebCustomFilterProgramProxyClient* client)
+ {
+ return adoptRef(new WebCustomFilterProgramProxy(client));
+ }
+
+ int id() const { return m_id; }
+
+ // Needed to make TextureMapperPlatformCompiledProgramClient look like a RefCounted object.
+ virtual void refFromValidatedProgram() { ref(); }
+ virtual void derefFromValidatedProgram() { deref(); }
+
+ ~WebCustomFilterProgramProxy();
+
+ void setClient(WebCustomFilterProgramProxyClient* client) { m_client = client; }
+ WebCustomFilterProgramProxyClient* client() const { return m_client; }
+
+private:
+ WebCustomFilterProgramProxy(WebCustomFilterProgramProxyClient* client)
+ : m_client(client)
+ , m_id(s_nextId++)
+ {
+ }
+
+ WebCustomFilterProgramProxyClient* m_client;
+ int m_id;
+
+ static int s_nextId;
+};
+
+} // namespace WebKit
+
+#endif // USE(COORDINATED_GRAPHICS) && ENABLE(CSS_SHADERS)
+
+#endif // WebCustomFilterProgramProxy_h
+
Modified: trunk/Source/WebKit2/Target.pri (134947 => 134948)
--- trunk/Source/WebKit2/Target.pri 2012-11-16 15:21:40 UTC (rev 134947)
+++ trunk/Source/WebKit2/Target.pri 2012-11-16 15:39:12 UTC (rev 134948)
@@ -503,6 +503,7 @@
Shared/WebURLResponse.cpp \
Shared/WebWheelEvent.cpp \
Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp \
+ Shared/CoordinatedGraphics/WebCustomFilterProgramProxy.cpp \
Shared/qt/ArgumentCodersQt.cpp \
Shared/qt/LayerTreeContextQt.cpp \
Shared/qt/ShareableBitmapQt.cpp \
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp (134947 => 134948)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp 2012-11-16 15:21:40 UTC (rev 134947)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp 2012-11-16 15:39:12 UTC (rev 134948)
@@ -49,6 +49,11 @@
#include <WebCore/Settings.h>
#include <wtf/TemporaryChange.h>
+#if ENABLE(CSS_SHADERS)
+#include "CustomFilterValidatedProgram.h"
+#include "ValidatedCustomFilterOperation.h"
+#endif
+
using namespace WebCore;
namespace WebKit {
@@ -60,6 +65,10 @@
LayerTreeCoordinator::~LayerTreeCoordinator()
{
+#if ENABLE(CSS_SHADERS)
+ disconnectCustomFilterPrograms();
+#endif
+
// Prevent setCoordinatedGraphicsLayerClient(0) -> detachLayer() from modifying the set while we iterate it.
HashSet<WebCore::CoordinatedGraphicsLayer*> registeredLayers;
registeredLayers.swap(m_registeredLayers);
@@ -323,10 +332,62 @@
void LayerTreeCoordinator::syncLayerFilters(WebLayerID id, const FilterOperations& filters)
{
m_shouldSyncFrame = true;
+#if ENABLE(CSS_SHADERS)
+ checkCustomFilterProgramProxies(filters);
+#endif
m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetCompositingLayerFilters(id, filters));
}
#endif
+#if ENABLE(CSS_SHADERS)
+void LayerTreeCoordinator::checkCustomFilterProgramProxies(const FilterOperations& filters)
+{
+ // We need to create the WebCustomFilterProgramProxy objects before we get to serialize the
+ // custom filters to the other process. That's because WebCustomFilterProgramProxy needs
+ // to link back to the coordinator, so that we can send a message to the UI process when
+ // the program is not needed anymore.
+ // Note that the serialization will only happen at a later time in ArgumentCoder<WebCore::FilterOperations>::encode.
+ // At that point the program will only be serialized once. All the other times it will only use the ID of the program.
+ for (size_t i = 0; i < filters.size(); ++i) {
+ const FilterOperation* operation = filters.at(i);
+ if (operation->getOperationType() != FilterOperation::VALIDATED_CUSTOM)
+ continue;
+ const ValidatedCustomFilterOperation* customOperation = static_cast<const ValidatedCustomFilterOperation*>(operation);
+ ASSERT(customOperation->validatedProgram()->isInitialized());
+ TextureMapperPlatformCompiledProgram* program = customOperation->validatedProgram()->platformCompiledProgram();
+ if (!program->client())
+ program->setClient(WebCustomFilterProgramProxy::create(this));
+ else {
+ WebCustomFilterProgramProxy* customFilterProgramProxy = static_cast<WebCustomFilterProgramProxy*>(program->client());
+ if (!customFilterProgramProxy->client()) {
+ // Just in case the LayerTreeCoordinator was destroyed and recreated.
+ customFilterProgramProxy->setClient(this);
+ } else {
+ // If the client was not disconnected then this coordinator must be the client for it.
+ ASSERT(customFilterProgramProxy->client() == this);
+ }
+ }
+ }
+}
+
+void LayerTreeCoordinator::removeCustomFilterProgramProxy(WebCustomFilterProgramProxy* customFilterProgramProxy)
+{
+ // At this time the shader is not needed anymore, so we remove it from our set and
+ // send a message to the other process to delete it.
+ m_customFilterPrograms.remove(customFilterProgramProxy);
+ // FIXME: Send a message to delete the object on the UI process.
+ // https://bugs.webkit.org/show_bug.cgi?id=101801
+}
+
+void LayerTreeCoordinator::disconnectCustomFilterPrograms()
+{
+ // Make sure that WebCore will not call into this coordinator anymore.
+ HashSet<WebCustomFilterProgramProxy*>::iterator iter = m_customFilterPrograms.begin();
+ for (; iter != m_customFilterPrograms.end(); ++iter)
+ (*iter)->setClient(0);
+}
+#endif
+
void LayerTreeCoordinator::detachLayer(CoordinatedGraphicsLayer* layer)
{
m_registeredLayers.remove(layer);
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h (134947 => 134948)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h 2012-11-16 15:21:40 UTC (rev 134947)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h 2012-11-16 15:39:12 UTC (rev 134948)
@@ -33,6 +33,10 @@
#include <WebCore/GraphicsSurface.h>
#include <wtf/OwnPtr.h>
+#if ENABLE(CSS_SHADERS)
+#include "WebCustomFilterProgramProxy.h"
+#endif
+
namespace WebKit {
class UpdateInfo;
@@ -42,7 +46,11 @@
, public CoordinatedGraphicsLayerClient
, public CoordinatedImageBacking::Coordinator
, public UpdateAtlasClient
- , public WebCore::GraphicsLayerFactory {
+ , public WebCore::GraphicsLayerFactory
+#if ENABLE(CSS_SHADERS)
+ , WebCustomFilterProgramProxyClient
+#endif
+{
public:
static PassRefPtr<LayerTreeCoordinator> create(WebPage*);
virtual ~LayerTreeCoordinator();
@@ -143,6 +151,14 @@
void releaseInactiveAtlasesTimerFired(WebCore::Timer<LayerTreeCoordinator>*);
+#if ENABLE(CSS_SHADERS)
+ // WebCustomFilterProgramProxyClient
+ void removeCustomFilterProgramProxy(WebCustomFilterProgramProxy*);
+
+ void checkCustomFilterProgramProxies(const WebCore::FilterOperations&);
+ void disconnectCustomFilterPrograms();
+#endif
+
OwnPtr<WebCore::GraphicsLayer> m_rootLayer;
// The layer which contains all non-composited content.
@@ -157,6 +173,10 @@
ImageBackingMap m_imageBackings;
Vector<OwnPtr<UpdateAtlas> > m_updateAtlases;
+#if ENABLE(CSS_SHADERS)
+ HashSet<WebCustomFilterProgramProxy*> m_customFilterPrograms;
+#endif
+
bool m_notifyAfterScheduledLayerFlush;
bool m_isValid;
// We don't send the messages related to releasing resources to UI Process during purging, because UI Process already had removed all resources.