Changeset 131357 in webkit


Ignore:
Timestamp:
Oct 15, 2012 2:23:53 PM (12 years ago)
Author:
Michelangelo De Simone
Message:

[CSS Shaders] Add CustomFilterProgramType to CustomFilterProgramInfo
https://bugs.webkit.org/show_bug.cgi?id=96448

Reviewed by Kenneth Rohde Christiansen.

CustomFilterProgramInfo has been refactored to decouple the CustomFilterProgramType from
the CustomFilterProgramMixSetting: m_mixSettings.enabled was redundant in light of the fact
that m_programType encoded the very same information. Dependencies have been updated to reflect
this change.

Current tests already cover this code.

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::CSSComputedStyleDeclaration::valueForFilter): The check for mixSettings.enabled has been replaced
by an explicit check for PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE program type.

  • css/StyleResolver.cpp:

(WebCore::StyleResolver::createCustomFilterOperation): Setting the program type explicitly while creating a
new filter program.

  • platform/graphics/filters/CustomFilterProgram.cpp:

(WebCore::CustomFilterProgram::CustomFilterProgram): CustomFilterProgram's constructor has been updated to
reflect the need of setting the program type explicitly.
(WebCore::CustomFilterProgram::programInfo): Updated to create new CustomFilterProgramInfo setting the program
type explicitly.

  • platform/graphics/filters/CustomFilterProgram.h:
  • platform/graphics/filters/CustomFilterProgramInfo.cpp:

(WebCore::CustomFilterProgramInfo::CustomFilterProgramInfo): Added m_programType and udpated the related getter.
(WebCore::CustomFilterProgramInfo::hash): ditto
(WebCore::CustomFilterProgramInfo::operator==): MixSettings' equality check is being performed only whether
the CustomFilterProgramInfo's program type is PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE.

  • platform/graphics/filters/CustomFilterProgramInfo.h:

(WebCore::CustomFilterProgramMixSettings::CustomFilterProgramMixSettings): Got rid of the redundant enabled flag.
(WebCore::CustomFilterProgramMixSettings::operator==): ditto
(CustomFilterProgramInfo):
(WebCore::CustomFilterProgramInfo::programType):

  • platform/graphics/filters/CustomFilterValidatedProgram.cpp: The right shader validator is now being

created according to the program type.
(WebCore::CustomFilterValidatedProgram::CustomFilterValidatedProgram):
(WebCore::CustomFilterValidatedProgram::rewriteMixVertexShader): The reference to MixSettings' enabled flag
has been replaced with a check for the program type.
(WebCore::CustomFilterValidatedProgram::rewriteMixFragmentShader): ditto

  • rendering/style/StyleCustomFilterProgram.h:

(WebCore::StyleCustomFilterProgram::create): Updated to be aware of the program type.
(WebCore::StyleCustomFilterProgram::StyleCustomFilterProgram): ditto

Location:
trunk/Source/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r131356 r131357  
     12012-10-15  Michelangelo De Simone  <michelangelo@webkit.org>
     2
     3        [CSS Shaders] Add CustomFilterProgramType to CustomFilterProgramInfo
     4        https://bugs.webkit.org/show_bug.cgi?id=96448
     5
     6        Reviewed by Kenneth Rohde Christiansen.
     7
     8        CustomFilterProgramInfo has been refactored to decouple the CustomFilterProgramType from
     9        the CustomFilterProgramMixSetting: m_mixSettings.enabled was redundant in light of the fact
     10        that m_programType encoded the very same information. Dependencies have been updated to reflect
     11        this change.
     12
     13        Current tests already cover this code.
     14
     15        * css/CSSComputedStyleDeclaration.cpp:
     16        (WebCore::CSSComputedStyleDeclaration::valueForFilter): The check for mixSettings.enabled has been replaced
     17        by an explicit check for PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE program type.
     18        * css/StyleResolver.cpp:
     19        (WebCore::StyleResolver::createCustomFilterOperation): Setting the program type explicitly while creating a
     20        new filter program.
     21        * platform/graphics/filters/CustomFilterProgram.cpp:
     22        (WebCore::CustomFilterProgram::CustomFilterProgram): CustomFilterProgram's constructor has been updated to
     23        reflect the need of setting the program type explicitly.
     24        (WebCore::CustomFilterProgram::programInfo): Updated to create new CustomFilterProgramInfo setting the program
     25        type explicitly.
     26        * platform/graphics/filters/CustomFilterProgram.h:
     27        * platform/graphics/filters/CustomFilterProgramInfo.cpp:
     28        (WebCore::CustomFilterProgramInfo::CustomFilterProgramInfo): Added m_programType and udpated the related getter.
     29        (WebCore::CustomFilterProgramInfo::hash): ditto
     30        (WebCore::CustomFilterProgramInfo::operator==): MixSettings' equality check is being performed only whether
     31        the CustomFilterProgramInfo's program type is PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE.
     32        * platform/graphics/filters/CustomFilterProgramInfo.h:
     33        (WebCore::CustomFilterProgramMixSettings::CustomFilterProgramMixSettings): Got rid of the redundant enabled flag.
     34        (WebCore::CustomFilterProgramMixSettings::operator==): ditto
     35        (CustomFilterProgramInfo):
     36        (WebCore::CustomFilterProgramInfo::programType):
     37        * platform/graphics/filters/CustomFilterValidatedProgram.cpp: The right shader validator is now being
     38        created according to the program type.
     39        (WebCore::CustomFilterValidatedProgram::CustomFilterValidatedProgram):
     40        (WebCore::CustomFilterValidatedProgram::rewriteMixVertexShader): The reference to MixSettings' enabled flag
     41        has been replaced with a check for the program type.
     42        (WebCore::CustomFilterValidatedProgram::rewriteMixFragmentShader): ditto
     43        * rendering/style/StyleCustomFilterProgram.h:
     44        (WebCore::StyleCustomFilterProgram::create): Updated to be aware of the program type.
     45        (WebCore::StyleCustomFilterProgram::StyleCustomFilterProgram): ditto
     46
    1472012-10-15  Joshua Bell  <jsbell@chromium.org>
    248
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r130829 r131357  
    922922
    923923            const CustomFilterProgramMixSettings mixSettings = program->mixSettings();
    924             if (mixSettings.enabled) {
     924            if (program->programType() == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE) {
    925925                RefPtr<WebKitCSSMixFunctionValue> mixFunction = WebKitCSSMixFunctionValue::create();
    926926                mixFunction->append(program->fragmentShader()->cssValue());
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r131136 r131357  
    48014801
    48024802    RefPtr<StyleShader> fragmentShader;
     4803    CustomFilterProgramType programType = PROGRAM_TYPE_NO_ELEMENT_TEXTURE;
    48034804    CustomFilterProgramMixSettings mixSettings;
    48044805    if (shadersList->length() > 1) {
    48054806        CSSValue* fragmentShaderOrMixFunction = shadersList->itemWithoutBoundsCheck(1);
    48064807        if (fragmentShaderOrMixFunction->isWebKitCSSMixFunctionValue()) {
    4807             mixSettings.enabled = true;
     4808            programType = PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE;
    48084809            WebKitCSSMixFunctionValue* mixFunction = static_cast<WebKitCSSMixFunctionValue*>(fragmentShaderOrMixFunction);
    48094810            CSSValueListIterator iterator(mixFunction);
     
    48954896        return 0;
    48964897   
    4897     RefPtr<StyleCustomFilterProgram> program = StyleCustomFilterProgram::create(vertexShader.release(), fragmentShader.release(), mixSettings);
     4898    RefPtr<StyleCustomFilterProgram> program = StyleCustomFilterProgram::create(vertexShader.release(), fragmentShader.release(), programType, mixSettings);
    48984899    return CustomFilterOperation::create(program.release(), parameterList, meshRows, meshColumns, meshBoxType, meshType);
    48994900}
  • trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgram.cpp

    r130612 r131357  
    3939namespace WebCore {
    4040
    41 CustomFilterProgram::CustomFilterProgram(CustomFilterProgramMixSettings mixSettings)
    42     : m_mixSettings(mixSettings)
     41CustomFilterProgram::CustomFilterProgram(CustomFilterProgramType programType, const CustomFilterProgramMixSettings& mixSettings)
     42    : m_programType(programType)
     43    , m_mixSettings(mixSettings)
    4344{
    4445    // Keep the constructor protected to prevent creating this object directly.
     
    8283{
    8384    ASSERT(isLoaded());
    84     return CustomFilterProgramInfo(vertexShaderString(), fragmentShaderString(), m_mixSettings);
     85    return CustomFilterProgramInfo(vertexShaderString(), fragmentShaderString(), m_programType, m_mixSettings);
    8586}
    8687
  • trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgram.h

    r125331 r131357  
    5959   
    6060    CustomFilterProgramInfo programInfo() const;
     61    CustomFilterProgramType programType() const { return m_programType; }
    6162
    6263    // StyleCustomFilterProgram has the only implementation for the following method. That means, it casts to StyleCustomFilterProgram
     
    7677
    7778    // Keep the constructor protected to prevent creating this object directly.
    78     CustomFilterProgram(CustomFilterProgramMixSettings);
     79    CustomFilterProgram(CustomFilterProgramType, const CustomFilterProgramMixSettings&);
    7980
    8081private:
    8182    typedef HashCountedSet<CustomFilterProgramClient*> CustomFilterProgramClientList;
    8283    CustomFilterProgramClientList m_clients;
     84    CustomFilterProgramType m_programType;
    8385    CustomFilterProgramMixSettings m_mixSettings;
    8486};
  • trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgramInfo.cpp

    r125331 r131357  
    6565}
    6666
    67 CustomFilterProgramInfo::CustomFilterProgramInfo(const String& vertexShader, const String& fragmentShader, const CustomFilterProgramMixSettings& mixSettings)
     67CustomFilterProgramInfo::CustomFilterProgramInfo(const String& vertexShader, const String& fragmentShader, CustomFilterProgramType programType, const CustomFilterProgramMixSettings& mixSettings)
    6868    : m_vertexShaderString(vertexShader)
    6969    , m_fragmentShaderString(fragmentShader)
     70    , m_programType(programType)
    7071    , m_mixSettings(mixSettings)
    7172{
     
    8182        hashPossiblyNullString(m_vertexShaderString),
    8283        hashPossiblyNullString(m_fragmentShaderString),
    83         m_mixSettings.enabled,
    84         m_mixSettings.enabled ? m_mixSettings.blendMode : 0,
    85         m_mixSettings.enabled ? m_mixSettings.compositeOperator : 0
     84        m_programType == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE,
     85        m_programType == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE ? m_mixSettings.blendMode : 0,
     86        m_programType == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE ? m_mixSettings.compositeOperator : 0
    8687    };
    8788    return StringHasher::hashMemory<sizeof(hashCodes)>(&hashCodes);
     
    9293    ASSERT(!isHashTableDeletedValue());
    9394    ASSERT(!o.isHashTableDeletedValue());
     95
     96    if (m_programType == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE)
     97        return m_vertexShaderString == o.m_vertexShaderString
     98            && m_fragmentShaderString == o.m_fragmentShaderString
     99            && m_programType == o.m_programType
     100            && m_mixSettings == o.m_mixSettings;
     101
    94102    return m_vertexShaderString == o.m_vertexShaderString
    95103        && m_fragmentShaderString == o.m_fragmentShaderString
    96         && m_mixSettings == o.m_mixSettings;
     104        && m_programType == o.m_programType;
    97105}
    98106
  • trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgramInfo.h

    r128334 r131357  
    4646struct CustomFilterProgramMixSettings {
    4747    CustomFilterProgramMixSettings()
    48         : enabled(false)
    49         , blendMode(BlendModeNormal)
     48        : blendMode(BlendModeNormal)
    5049        , compositeOperator(CompositeSourceOver)
    5150    {
     
    5453    bool operator==(const CustomFilterProgramMixSettings& o) const
    5554    {
    56         return (!enabled && !o.enabled)
    57             || (blendMode == o.blendMode && compositeOperator == o.compositeOperator);
     55        return blendMode == o.blendMode && compositeOperator == o.compositeOperator;
    5856    }
    5957   
    60     bool enabled;
    6158    BlendMode blendMode;
    6259    CompositeOperator compositeOperator;
     
    6865class CustomFilterProgramInfo {
    6966public:
    70     CustomFilterProgramInfo(const String&, const String&, const CustomFilterProgramMixSettings&);
     67    CustomFilterProgramInfo(const String&, const String&, CustomFilterProgramType, const CustomFilterProgramMixSettings&);
    7168
    7269    CustomFilterProgramInfo();
     
    8178    const String& vertexShaderString() const { return m_vertexShaderString; }
    8279    const String& fragmentShaderString() const { return m_fragmentShaderString; }
    83     // FIXME: We should add CustomFilterProgramType to CustomFilterProgramInfo and remove mixSettings.enabled.
    84     // https://bugs.webkit.org/show_bug.cgi?id=96448
    85     CustomFilterProgramType programType() const { return m_mixSettings.enabled ? PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE : PROGRAM_TYPE_NO_ELEMENT_TEXTURE; }
     80    CustomFilterProgramType programType() const { return m_programType; }
    8681    const CustomFilterProgramMixSettings& mixSettings() const { return m_mixSettings; }
    8782private:
    8883    String m_vertexShaderString;
    8984    String m_fragmentShaderString;
     85    CustomFilterProgramType m_programType;
    9086    CustomFilterProgramMixSettings m_mixSettings;
    9187};
  • trunk/Source/WebCore/platform/graphics/filters/CustomFilterValidatedProgram.cpp

    r131128 r131357  
    8484
    8585    // Shaders referenced from the CSS mix function use a different validator than regular WebGL shaders. See CustomFilterGlobalContext.h for more details.
    86     ANGLEWebKitBridge* validator = programInfo.mixSettings().enabled ? m_globalContext->mixShaderValidator() : m_globalContext->webglShaderValidator();
     86    bool blendsElementTexture = (programInfo.programType() == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE);
     87    ANGLEWebKitBridge* validator = blendsElementTexture ? m_globalContext->mixShaderValidator() : m_globalContext->webglShaderValidator();
    8788    String vertexShaderLog, fragmentShaderLog;
    8889    Vector<ANGLEShaderSymbol> symbols;
     
    108109
    109110    // We need to add texture access, blending, and compositing code to shaders that are referenced from the CSS mix function.
    110     if (programInfo.mixSettings().enabled) {
     111    if (blendsElementTexture) {
    111112        rewriteMixVertexShader();
    112113        rewriteMixFragmentShader();
     
    126127void CustomFilterValidatedProgram::rewriteMixVertexShader()
    127128{
    128     ASSERT(m_programInfo.mixSettings().enabled);
     129    ASSERT(m_programInfo.programType() == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE);
    129130
    130131    // During validation, ANGLE renamed the author's "main" function to "css_main".
     
    145146void CustomFilterValidatedProgram::rewriteMixFragmentShader()
    146147{
    147     ASSERT(m_programInfo.mixSettings().enabled);
     148    ASSERT(m_programInfo.programType() == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE);
    148149
    149150    StringBuilder builder;
  • trunk/Source/WebCore/rendering/style/StyleCustomFilterProgram.h

    r125128 r131357  
    4646    WTF_MAKE_FAST_ALLOCATED;
    4747public:
    48     static PassRefPtr<StyleCustomFilterProgram> create(PassRefPtr<StyleShader> vertexShader, PassRefPtr<StyleShader> fragmentShader, CustomFilterProgramMixSettings mixSettings)
     48    static PassRefPtr<StyleCustomFilterProgram> create(PassRefPtr<StyleShader> vertexShader, PassRefPtr<StyleShader> fragmentShader, CustomFilterProgramType programType, const CustomFilterProgramMixSettings& mixSettings)
    4949    {
    50         return adoptRef(new StyleCustomFilterProgram(vertexShader, fragmentShader, mixSettings));
     50        return adoptRef(new StyleCustomFilterProgram(vertexShader, fragmentShader, programType, mixSettings));
    5151    }
    5252   
     
    127127
    128128private:
    129     StyleCustomFilterProgram(PassRefPtr<StyleShader> vertexShader, PassRefPtr<StyleShader> fragmentShader, CustomFilterProgramMixSettings mixSettings)
    130         : CustomFilterProgram(mixSettings)
     129    StyleCustomFilterProgram(PassRefPtr<StyleShader> vertexShader, PassRefPtr<StyleShader> fragmentShader, CustomFilterProgramType programType, const CustomFilterProgramMixSettings& mixSettings)
     130        : CustomFilterProgram(programType, mixSettings)
    131131        , m_vertexShader(vertexShader)
    132132        , m_fragmentShader(fragmentShader)
Note: See TracChangeset for help on using the changeset viewer.