[CSS Shaders] Get rid of internal tex coord attribute
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Nov 2012 23:58:59 +0000 (23:58 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Nov 2012 23:58:59 +0000 (23:58 +0000)
commitc5a7dd31085336a92e1ac8d06e210070aab781ec
tree4e7745fee39c1213f3c3e1088ba0ff72e972c110
parent5dca3dd5b00eb8351151f5661f9899b37366ae0a
[CSS Shaders] Get rid of internal tex coord attribute
https://bugs.webkit.org/show_bug.cgi?id=94358

Patch by Max Vujovic <mvujovic@adobe.com> on 2012-11-01
Reviewed by Dean Jackson.

Source/WebCore:

Remove the internal css_a_texCoord attribute that WebKit added to shaders in order to
sample the element texture by texture coordinate.

Now, the WebKit-added sampling code can leverage a_texCoord if the author defined it, or
WebKit can add its own a_texCoord definition to the author's shader.

Note that vertex attributes are read-only in GLSL. Also, note that we already reject the
shader if the author did not define a_texCoord with the correct type. Essentially, if
a_texCoord exists in the author's validated shader, we are guaranteed that it's the correct
type and that its value is unmodified.

Test: css3/filters/custom/custom-filter-a-tex-coord-optional.html

* platform/graphics/filters/CustomFilterCompiledProgram.cpp:
(WebCore::CustomFilterCompiledProgram::CustomFilterCompiledProgram):
    Remove the references to m_internalTexCoordAttribLocation.
(WebCore::CustomFilterCompiledProgram::initializeParameterLocations): Ditto.
* platform/graphics/filters/CustomFilterCompiledProgram.h: Ditto.
* platform/graphics/filters/CustomFilterRenderer.cpp:
(WebCore::CustomFilterRenderer::bindProgramAndBuffers): Ditto.
(WebCore::CustomFilterRenderer::unbindVertexAttributes): Ditto.
* platform/graphics/filters/CustomFilterValidatedProgram.cpp:
(WebCore::CustomFilterValidatedProgram::CustomFilterValidatedProgram):
    Pass the set of symbols found in the author's shaders to the rewriteMixVertexShader
    method.
(WebCore::CustomFilterValidatedProgram::rewriteMixVertexShader):
    If the author didn't define a_texCoord, add it to the end of the author's vertex
    shader, but before the shader's new main function. As before, the new main function
    will pass the texture coordinate to the fragment shader via the css_v_texCoord varying.
* platform/graphics/filters/CustomFilterValidatedProgram.h:
(WebCore):
    Add a forward declaration for ANGLEShaderSymbol.
(CustomFilterValidatedProgram):
    Update the method prototype for rewriteMixVertexShader.

LayoutTests:

Add a test which verifies that a custom filter executes regardless of whether the author
defines a_texCoord in the vertex shader. We check this because the implementation uses
the author's a_texCoord definition if it exists. If it doesn't exist, the implementation
adds its own a_texCoord definition to the author's shader.

* css3/filters/custom/custom-filter-a-tex-coord-optional-expected.html: Added.
* css3/filters/custom/custom-filter-a-tex-coord-optional.html: Added.
* css3/filters/resources/a-tex-coord-defined.vs: Added.
* css3/filters/resources/a-tex-coord-undefined.vs: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@133241 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/css3/filters/custom/custom-filter-a-tex-coord-optional-expected.html [new file with mode: 0644]
LayoutTests/css3/filters/custom/custom-filter-a-tex-coord-optional.html [new file with mode: 0644]
LayoutTests/css3/filters/resources/a-tex-coord-defined.vs [new file with mode: 0644]
LayoutTests/css3/filters/resources/a-tex-coord-undefined.vs [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/filters/CustomFilterCompiledProgram.cpp
Source/WebCore/platform/graphics/filters/CustomFilterCompiledProgram.h
Source/WebCore/platform/graphics/filters/CustomFilterRenderer.cpp
Source/WebCore/platform/graphics/filters/CustomFilterValidatedProgram.cpp
Source/WebCore/platform/graphics/filters/CustomFilterValidatedProgram.h