Changeset 148992 in webkit


Ignore:
Timestamp:
Apr 23, 2013 2:18:36 PM (11 years ago)
Author:
krit@webkit.org
Message:

Pick up color and mat values in custom shaders
https://bugs.webkit.org/show_bug.cgi?id=115046

Reviewed by Dean Jackson.

Source/WebCore:

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):

LayoutTests:

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.
Location:
trunk
Files:
6 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r148988 r148992  
     12013-04-23  Dirk Schulze  <krit@webkit.org>
     2
     3        Pick up color and mat values in custom shaders
     4        https://bugs.webkit.org/show_bug.cgi?id=115046
     5
     6        Reviewed by Dean Jackson.
     7
     8        Test that the CSS defined color values and mat2-4 functions get
     9        set as uniforms in shader programs.
     10
     11        * css3/filters/custom/custom-filter-color-expected.html: Added.
     12        * css3/filters/custom/custom-filter-color.html: Added.
     13        * css3/filters/custom/custom-filter-matN-expected.html: Added.
     14        * css3/filters/custom/custom-filter-matN.html: Added.
     15
    1162013-04-23  Simon Fraser  <simon.fraser@apple.com>
    217
  • trunk/Source/WebCore/ChangeLog

    r148990 r148992  
     12013-04-23  Dirk Schulze  <krit@webkit.org>
     2
     3        Pick up color and mat values in custom shaders
     4        https://bugs.webkit.org/show_bug.cgi?id=115046
     5
     6        Reviewed by Dean Jackson.
     7
     8        The custom filter functions accept color values and mat2-4 functions
     9        as parameter types. These were implemented in CSS already.
     10        This patch picks up the values and applies them as uniforms to the
     11        custom shader program.
     12
     13        Tests: css3/filters/custom/custom-filter-color.html
     14               css3/filters/custom/custom-filter-matN.html
     15
     16        * platform/graphics/filters/CustomFilterRenderer.cpp:
     17        (WebCore::CustomFilterRenderer::bindProgramColorParameters): Set uniform for color values.
     18        (WebCore):
     19        (WebCore::CustomFilterRenderer::bindProgramMatrixParameters): Set uniform for mat2-4 values.
     20        (WebCore::CustomFilterRenderer::bindProgramParameters): Call color and matrix functions.
     21        * platform/graphics/filters/CustomFilterRenderer.h:
     22        (WebCore):
     23        (CustomFilterRenderer):
     24
    1252013-04-23  Jacky Jiang  <zhajiang@blackberry.com>
    226
  • trunk/Source/WebCore/platform/graphics/filters/CustomFilterRenderer.cpp

    r148852 r148992  
    3636
    3737#include "CustomFilterArrayParameter.h"
     38#include "CustomFilterColorParameter.h"
    3839#include "CustomFilterCompiledProgram.h"
    3940#include "CustomFilterConstants.h"
     
    160161
    161162    m_context->uniform1fv(uniformLocation, parameterSize, floatVector.data());
     163}
     164
     165void CustomFilterRenderer::bindProgramColorParameters(int uniformLocation, CustomFilterColorParameter* colorParameter)
     166{
     167    float r, g, b, a;
     168    colorParameter->color().getRGBA(r, g, b, a);
     169
     170    m_context->uniform4f(uniformLocation, r, g, b, a);
     171}
     172
     173void CustomFilterRenderer::bindProgramMatrixParameters(int uniformLocation, CustomFilterArrayParameter* matrixParameter)
     174{
     175    unsigned parameterSize = matrixParameter->size();
     176    Vector<GC3Dfloat, 16> floatVector;
     177
     178    for (unsigned i = 0; i < parameterSize; ++i)
     179        floatVector.append(matrixParameter->valueAt(i));
     180
     181    switch (parameterSize) {
     182    case 4:
     183        m_context->uniformMatrix2fv(uniformLocation, 1, false, floatVector.data());
     184        break;
     185    case 9:
     186        m_context->uniformMatrix3fv(uniformLocation, 1, false, floatVector.data());
     187        break;
     188    case 16:
     189        m_context->uniformMatrix4fv(uniformLocation, 1, false, floatVector.data());
     190        break;
     191    default:
     192        ASSERT_NOT_REACHED();
     193    }
    162194}
    163195
     
    217249            break;
    218250        case CustomFilterParameter::COLOR:       
     251            bindProgramColorParameters(uniformLocation, static_cast<CustomFilterColorParameter*>(parameter));
     252            break;
    219253        case CustomFilterParameter::MATRIX:
    220             // FIXME: Bind color and matrix to context.
     254            bindProgramMatrixParameters(uniformLocation, static_cast<CustomFilterArrayParameter*>(parameter));
    221255            break;
    222256        case CustomFilterParameter::NUMBER:
  • trunk/Source/WebCore/platform/graphics/filters/CustomFilterRenderer.h

    r139837 r148992  
    4545
    4646class CustomFilterArrayParameter;
     47class CustomFilterColorParameter;
    4748class CustomFilterCompiledProgram;
    4849class CustomFilterMesh;
     
    7778    void unbindVertexAttribute(int attributeLocation);
    7879    void bindProgramArrayParameters(int uniformLocation, CustomFilterArrayParameter*);
     80    void bindProgramColorParameters(int uniformLocation, CustomFilterColorParameter*);
     81    void bindProgramMatrixParameters(int uniformLocation, CustomFilterArrayParameter*);
    7982    void bindProgramNumberParameters(int uniformLocation, CustomFilterNumberParameter*);
    8083    void bindProgramTransformParameter(int uniformLocation, CustomFilterTransformParameter*);
Note: See TracChangeset for help on using the changeset viewer.