Diff
Modified: trunk/LayoutTests/ChangeLog (148991 => 148992)
--- trunk/LayoutTests/ChangeLog 2013-04-23 21:04:53 UTC (rev 148991)
+++ trunk/LayoutTests/ChangeLog 2013-04-23 21:18:36 UTC (rev 148992)
@@ -1,3 +1,18 @@
+2013-04-23 Dirk Schulze <[email protected]>
+
+ Pick up color and mat values in custom shaders
+ https://bugs.webkit.org/show_bug.cgi?id=115046
+
+ Reviewed by Dean Jackson.
+
+ Test that the CSS defined color values and mat2-4 functions get
+ set as uniforms in shader programs.
+
+ * css3/filters/custom/custom-filter-color-expected.html: Added.
+ * css3/filters/custom/custom-filter-color.html: Added.
+ * css3/filters/custom/custom-filter-matN-expected.html: Added.
+ * css3/filters/custom/custom-filter-matN.html: Added.
+
2013-04-23 Simon Fraser <[email protected]>
Tiled layers clipped inside nested transform/preserve-3d hierarchies
Added: trunk/LayoutTests/css3/filters/custom/custom-filter-color-expected.html (0 => 148992)
--- trunk/LayoutTests/css3/filters/custom/custom-filter-color-expected.html (rev 0)
+++ trunk/LayoutTests/css3/filters/custom/custom-filter-color-expected.html 2013-04-23 21:18:36 UTC (rev 148992)
@@ -0,0 +1,16 @@
+<!doctype html>
+<html>
+ <head>
+ <title>Tests color values in custom filters</title>
+ <style>
+ #filtertestbox {
+ height: 100px;
+ width: 100px;
+ background-color: rgb(0, 255, 0);
+ }
+ </style>
+ </head>
+ <body _onload_="runTest()">
+ <div id="filtertestbox"></div>
+ </body>
+</html>
Added: trunk/LayoutTests/css3/filters/custom/custom-filter-color.html (0 => 148992)
--- trunk/LayoutTests/css3/filters/custom/custom-filter-color.html (rev 0)
+++ trunk/LayoutTests/css3/filters/custom/custom-filter-color.html 2013-04-23 21:18:36 UTC (rev 148992)
@@ -0,0 +1,42 @@
+<!doctype html>
+<html>
+ <head>
+ <title>Tests color values in custom filters</title>
+ <script>
+ if (window.testRunner) {
+ window.testRunner.overridePreference("WebKitCSSCustomFilterEnabled", "1");
+ window.testRunner.overridePreference("WebKitWebGLEnabled", "1");
+ window.testRunner.waitUntilDone();
+ }
+
+ function runTest()
+ {
+ // We need to run the tests after the downloading succeeded.
+ if (window.testRunner)
+ window.testRunner.notifyDone();
+ }
+ </script>
+ <style>
+ #filtertestbox {
+ height: 100px;
+ width: 100px;
+ background-color: red;
+ -webkit-filter: custom(none url('../resources/fragment-colors.fs'),
+ c1 rgb(0, 255, 0),
+ c2 rgba(0, 255, 0, 1.0),
+ c3 lime,
+ c4 hsl(120, 100%, 50%),
+ c5 hsla(120, 100%, 50%, 1.0),
+ c6 #00FF00
+ );
+ }
+ </style>
+ </head>
+ <body _onload_="runTest()">
+ <!--
+ A 100x100px red div is coloured lime by fragment-colors.fs, a fragment shader.
+ Fails if the div stays red.
+ -->
+ <div id="filtertestbox"></div>
+ </body>
+</html>
Added: trunk/LayoutTests/css3/filters/custom/custom-filter-matN-expected.html (0 => 148992)
--- trunk/LayoutTests/css3/filters/custom/custom-filter-matN-expected.html (rev 0)
+++ trunk/LayoutTests/css3/filters/custom/custom-filter-matN-expected.html 2013-04-23 21:18:36 UTC (rev 148992)
@@ -0,0 +1,16 @@
+<!doctype html>
+<html>
+ <head>
+ <title>Tests matN() functions in custom filters</title>
+ <style>
+ #filtertestbox {
+ height: 100px;
+ width: 100px;
+ background-color: rgb(0, 255, 0);
+ }
+ </style>
+ </head>
+ <body _onload_="runTest()">
+ <div id="filtertestbox"></div>
+ </body>
+</html>
Added: trunk/LayoutTests/css3/filters/custom/custom-filter-matN.html (0 => 148992)
--- trunk/LayoutTests/css3/filters/custom/custom-filter-matN.html (rev 0)
+++ trunk/LayoutTests/css3/filters/custom/custom-filter-matN.html 2013-04-23 21:18:36 UTC (rev 148992)
@@ -0,0 +1,39 @@
+<!doctype html>
+<html>
+ <head>
+ <title>Tests matN() functions in custom filters</title>
+ <script>
+ if (window.testRunner) {
+ window.testRunner.overridePreference("WebKitCSSCustomFilterEnabled", "1");
+ window.testRunner.overridePreference("WebKitWebGLEnabled", "1");
+ window.testRunner.waitUntilDone();
+ }
+
+ function runTest()
+ {
+ // We need to run the tests after the downloading succeeded.
+ if (window.testRunner)
+ window.testRunner.notifyDone();
+ }
+ </script>
+ <style>
+ #filtertestbox {
+ height: 100px;
+ width: 100px;
+ background-color: red;
+ -webkit-filter: custom(none url('../resources/fragment-matN.fs'),
+ m1 mat2(1, 1, 0, 0),
+ m2 mat3(1, 0, 1, 0, 1, 1, 0, 1, 0),
+ m3 mat4(1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1)
+ );
+ }
+ </style>
+ </head>
+ <body _onload_="runTest()">
+ <!--
+ A 100x100px red div is coloured lime by fragment-matN.fs, a fragment shader.
+ Fails if the div stays red.
+ -->
+ <div id="filtertestbox"></div>
+ </body>
+</html>
Added: trunk/LayoutTests/css3/filters/resources/fragment-colors.fs (0 => 148992)
--- trunk/LayoutTests/css3/filters/resources/fragment-colors.fs (rev 0)
+++ trunk/LayoutTests/css3/filters/resources/fragment-colors.fs 2013-04-23 21:18:36 UTC (rev 148992)
@@ -0,0 +1,15 @@
+precision mediump float;
+uniform vec4 c1;
+uniform vec4 c2;
+uniform vec4 c3;
+uniform vec4 c4;
+uniform vec4 c5;
+uniform vec4 c6;
+
+void main()
+{
+ if (c1 == c2 && c1 == c3 && c1 == c4 && c1 == c5 && c1 == c6)
+ gl_FragColor = c1;
+ else
+ gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
+}
Added: trunk/LayoutTests/css3/filters/resources/fragment-matN.fs (0 => 148992)
--- trunk/LayoutTests/css3/filters/resources/fragment-matN.fs (rev 0)
+++ trunk/LayoutTests/css3/filters/resources/fragment-matN.fs 2013-04-23 21:18:36 UTC (rev 148992)
@@ -0,0 +1,23 @@
+precision mediump float;
+uniform mat2 m1;
+uniform mat3 m2;
+uniform mat4 m3;
+
+void main()
+{
+ // Testing individual entries to check correct order.
+ if (m1[0][0] == 1. && m1[0][1] == 1.
+ && m1[1][0] == 0. && m1[1][1] == 0.
+ &&
+ m2[0][0] == 1. && m2[0][1] == 0. && m2[0][2] == 1.
+ && m2[1][0] == 0. && m2[1][1] == 1. && m2[1][2] == 1.
+ && m2[2][0] == 0. && m2[2][1] == 1. && m2[2][2] == 0.
+ &&
+ m3[0][0] == 1. && m3[0][1] == 1. && m3[0][2] == 0. && m3[0][3] == 0.
+ && m3[1][0] == 0. && m3[1][1] == 1. && m3[1][2] == 1. && m3[1][3] == 0.
+ && m3[2][0] == 1. && m3[2][1] == 0. && m3[2][2] == 0. && m3[2][3] == 1.
+ && m3[3][0] == 1. && m3[3][1] == 1. && m3[3][2] == 1. && m3[3][3] == 1.)
+ gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
+ else
+ gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
+}
Modified: trunk/Source/WebCore/ChangeLog (148991 => 148992)
--- trunk/Source/WebCore/ChangeLog 2013-04-23 21:04:53 UTC (rev 148991)
+++ trunk/Source/WebCore/ChangeLog 2013-04-23 21:18:36 UTC (rev 148992)
@@ -1,3 +1,27 @@
+2013-04-23 Dirk Schulze <[email protected]>
+
+ Pick up color and mat values in custom shaders
+ https://bugs.webkit.org/show_bug.cgi?id=115046
+
+ Reviewed by Dean Jackson.
+
+ The custom filter functions accept color values and mat2-4 functions
+ as parameter types. These were implemented in CSS already.
+ This patch picks up the values and applies them as uniforms to the
+ custom shader program.
+
+ Tests: css3/filters/custom/custom-filter-color.html
+ css3/filters/custom/custom-filter-matN.html
+
+ * platform/graphics/filters/CustomFilterRenderer.cpp:
+ (WebCore::CustomFilterRenderer::bindProgramColorParameters): Set uniform for color values.
+ (WebCore):
+ (WebCore::CustomFilterRenderer::bindProgramMatrixParameters): Set uniform for mat2-4 values.
+ (WebCore::CustomFilterRenderer::bindProgramParameters): Call color and matrix functions.
+ * platform/graphics/filters/CustomFilterRenderer.h:
+ (WebCore):
+ (CustomFilterRenderer):
+
2013-04-23 Jacky Jiang <[email protected]>
Remove redundant code in ViewportArguments::resolve
Modified: trunk/Source/WebCore/platform/graphics/filters/CustomFilterRenderer.cpp (148991 => 148992)
--- trunk/Source/WebCore/platform/graphics/filters/CustomFilterRenderer.cpp 2013-04-23 21:04:53 UTC (rev 148991)
+++ trunk/Source/WebCore/platform/graphics/filters/CustomFilterRenderer.cpp 2013-04-23 21:18:36 UTC (rev 148992)
@@ -35,6 +35,7 @@
#include "CustomFilterRenderer.h"
#include "CustomFilterArrayParameter.h"
+#include "CustomFilterColorParameter.h"
#include "CustomFilterCompiledProgram.h"
#include "CustomFilterConstants.h"
#include "CustomFilterMesh.h"
@@ -161,6 +162,37 @@
m_context->uniform1fv(uniformLocation, parameterSize, floatVector.data());
}
+void CustomFilterRenderer::bindProgramColorParameters(int uniformLocation, CustomFilterColorParameter* colorParameter)
+{
+ float r, g, b, a;
+ colorParameter->color().getRGBA(r, g, b, a);
+
+ m_context->uniform4f(uniformLocation, r, g, b, a);
+}
+
+void CustomFilterRenderer::bindProgramMatrixParameters(int uniformLocation, CustomFilterArrayParameter* matrixParameter)
+{
+ unsigned parameterSize = matrixParameter->size();
+ Vector<GC3Dfloat, 16> floatVector;
+
+ for (unsigned i = 0; i < parameterSize; ++i)
+ floatVector.append(matrixParameter->valueAt(i));
+
+ switch (parameterSize) {
+ case 4:
+ m_context->uniformMatrix2fv(uniformLocation, 1, false, floatVector.data());
+ break;
+ case 9:
+ m_context->uniformMatrix3fv(uniformLocation, 1, false, floatVector.data());
+ break;
+ case 16:
+ m_context->uniformMatrix4fv(uniformLocation, 1, false, floatVector.data());
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+}
+
void CustomFilterRenderer::bindProgramNumberParameters(int uniformLocation, CustomFilterNumberParameter* numberParameter)
{
switch (numberParameter->size()) {
@@ -216,8 +248,10 @@
bindProgramArrayParameters(uniformLocation, static_cast<CustomFilterArrayParameter*>(parameter));
break;
case CustomFilterParameter::COLOR:
+ bindProgramColorParameters(uniformLocation, static_cast<CustomFilterColorParameter*>(parameter));
+ break;
case CustomFilterParameter::MATRIX:
- // FIXME: Bind color and matrix to context.
+ bindProgramMatrixParameters(uniformLocation, static_cast<CustomFilterArrayParameter*>(parameter));
break;
case CustomFilterParameter::NUMBER:
bindProgramNumberParameters(uniformLocation, static_cast<CustomFilterNumberParameter*>(parameter));
Modified: trunk/Source/WebCore/platform/graphics/filters/CustomFilterRenderer.h (148991 => 148992)
--- trunk/Source/WebCore/platform/graphics/filters/CustomFilterRenderer.h 2013-04-23 21:04:53 UTC (rev 148991)
+++ trunk/Source/WebCore/platform/graphics/filters/CustomFilterRenderer.h 2013-04-23 21:18:36 UTC (rev 148992)
@@ -44,6 +44,7 @@
namespace WebCore {
class CustomFilterArrayParameter;
+class CustomFilterColorParameter;
class CustomFilterCompiledProgram;
class CustomFilterMesh;
class CustomFilterNumberParameter;
@@ -76,6 +77,8 @@
void bindVertexAttribute(int attributeLocation, unsigned size, unsigned offset);
void unbindVertexAttribute(int attributeLocation);
void bindProgramArrayParameters(int uniformLocation, CustomFilterArrayParameter*);
+ void bindProgramColorParameters(int uniformLocation, CustomFilterColorParameter*);
+ void bindProgramMatrixParameters(int uniformLocation, CustomFilterArrayParameter*);
void bindProgramNumberParameters(int uniformLocation, CustomFilterNumberParameter*);
void bindProgramTransformParameter(int uniformLocation, CustomFilterTransformParameter*);
void bindProgramParameters();