Bug 96448 - [CSS Shaders] Add CustomFilterProgramType to CustomFilterProgramInfo
Summary: [CSS Shaders] Add CustomFilterProgramType to CustomFilterProgramInfo
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Michelangelo De Simone
URL:
Keywords:
Depends on:
Blocks: 71392
  Show dependency treegraph
 
Reported: 2012-09-11 16:34 PDT by Max Vujovic
Modified: 2012-10-15 14:24 PDT (History)
12 users (show)

See Also:


Attachments
Not for review (15.94 KB, patch)
2012-10-10 16:08 PDT, Michelangelo De Simone
no flags Details | Formatted Diff | Diff
Patch (17.00 KB, patch)
2012-10-11 16:09 PDT, Michelangelo De Simone
no flags Details | Formatted Diff | Diff
Patch (17.91 KB, patch)
2012-10-12 15:34 PDT, Michelangelo De Simone
no flags Details | Formatted Diff | Diff
Patch for landing (17.92 KB, patch)
2012-10-15 09:39 PDT, Michelangelo De Simone
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Max Vujovic 2012-09-11 16:34:25 PDT
In the CSS Shaders implementation, we frequently make a decision based on programInfo.mixSettings.enabled. It would be nice if we used a CustomFilterProgramType enum in CustomFilterProgramInfo instead. Then, we could remove mixSettings.enabled. The enum would look something like:

enum CustomFilterProgramType {
    PROGRAM_TYPE_NO_ELEMENT_TEXTURE,
    PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE
}
Comment 1 Michelangelo De Simone 2012-10-10 16:08:23 PDT
Created attachment 168083 [details]
Not for review
Comment 2 Max Vujovic 2012-10-10 16:48:14 PDT
Comment on attachment 168083 [details]
Not for review

Looks good! Here's my informal review- just a couple of nits.

View in context: https://bugs.webkit.org/attachment.cgi?id=168083&action=review

> Source/WebCore/ChangeLog:8
> +        Refactor of CustomFilterProgramInfo: MixSettings and related program type

Can you be more specific? For example:
Remove CustomFilterProgramMixSettings.enabled and check against CustomFilterProgram.programType() instead. Add m_programType to CustomFilterProgram and CustomFilterProgramInfo.

> Source/WebCore/css/CSSComputedStyleDeclaration.cpp:925
> +            if (isMixEnabled) {

I would put the boolean expression in here without the extra variable.

> Source/WebCore/platform/graphics/filters/CustomFilterProgram.cpp:41
> +CustomFilterProgram::CustomFilterProgram(CustomFilterProgramType programType, CustomFilterProgramMixSettings mixSettings)

While you're touching this line, can you make CustomFilterProgramMixSettings a const reference?

> Source/WebCore/platform/graphics/filters/CustomFilterProgram.h:78
> +    CustomFilterProgram(CustomFilterProgramType, CustomFilterProgramMixSettings);

Ditto.

> Source/WebCore/platform/graphics/filters/CustomFilterProgramInfo.cpp:84
> +        m_programType == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE,

Can you factor out this expression as a local boolean since we check it multiple times? Maybe like this:
bool blendsElementTexture = (m_programType == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE);

> Source/WebCore/platform/graphics/filters/CustomFilterProgramInfo.cpp:98
>          && m_mixSettings == o.m_mixSettings;

We should only check m_mixSettings for equality if m_programType is PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE.

> Source/WebCore/platform/graphics/filters/CustomFilterValidatedProgram.cpp:86
> +    bool isMixEnabled = programInfo.programType() == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE;

Instead of "isMixEnabled", can we call this boolean "blendsElementTexture"?

> Source/WebCore/rendering/style/StyleCustomFilterProgram.h:48
> +    static PassRefPtr<StyleCustomFilterProgram> create(PassRefPtr<StyleShader> vertexShader, PassRefPtr<StyleShader> fragmentShader, CustomFilterProgramType programType, CustomFilterProgramMixSettings mixSettings)

const CustomFilterProgramMixSettings&

> Source/WebCore/rendering/style/StyleCustomFilterProgram.h:129
> +    StyleCustomFilterProgram(PassRefPtr<StyleShader> vertexShader, PassRefPtr<StyleShader> fragmentShader, CustomFilterProgramType programType, CustomFilterProgramMixSettings mixSettings)

const CustomFilterProgramMixSettings&
Comment 3 Michelangelo De Simone 2012-10-11 16:09:34 PDT
Created attachment 168304 [details]
Patch
Comment 4 Kenneth Rohde Christiansen 2012-10-11 16:14:35 PDT
Comment on attachment 168304 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=168304&action=review

> Source/WebCore/ChangeLog:11
> +        CustomFilterProgramInfo has been refactored to decouple the CustomFilterProgramType from
> +        the CustomFilterProgramMixSettings, therefore CustomFilterProgramSettings.enabled has been
> +        removed, now we explicitely check for the programType(). m_program has also been added to
> +        CustomFilterProgram (and CustomFilterProgramInfo).

would be good if you told why, and why this is an improvement, instead of what you just did

> Source/WebCore/ChangeLog:13
> +        No test necessary. 

Why? covered by existing tests? Just refactoring?

> Source/WebCore/ChangeLog:38
> +        * css/CSSComputedStyleDeclaration.cpp:
> +        (WebCore::CSSComputedStyleDeclaration::valueForFilter):
> +        * css/StyleResolver.cpp:
> +        (WebCore::StyleResolver::createCustomFilterOperation):
> +        * platform/graphics/filters/CustomFilterProgram.cpp:
> +        (WebCore::CustomFilterProgram::CustomFilterProgram):
> +        (WebCore::CustomFilterProgram::programInfo):
> +        * platform/graphics/filters/CustomFilterProgram.h:
> +        * platform/graphics/filters/CustomFilterProgramInfo.cpp:
> +        (WebCore::CustomFilterProgramInfo::CustomFilterProgramInfo):
> +        (WebCore::CustomFilterProgramInfo::hash):
> +        (WebCore::CustomFilterProgramInfo::operator==):
> +        * platform/graphics/filters/CustomFilterProgramInfo.h:
> +        (WebCore::CustomFilterProgramMixSettings::CustomFilterProgramMixSettings):
> +        (WebCore::CustomFilterProgramMixSettings::operator==):
> +        (CustomFilterProgramInfo):
> +        (WebCore::CustomFilterProgramInfo::programType):
> +        * platform/graphics/filters/CustomFilterValidatedProgram.cpp:
> +        (WebCore::CustomFilterValidatedProgram::CustomFilterValidatedProgram):
> +        (WebCore::CustomFilterValidatedProgram::rewriteMixVertexShader):
> +        (WebCore::CustomFilterValidatedProgram::rewriteMixFragmentShader):
> +        * rendering/style/StyleCustomFilterProgram.h:
> +        (WebCore::StyleCustomFilterProgram::create):
> +        (WebCore::StyleCustomFilterProgram::StyleCustomFilterProgram):

Some times it can be good adding more detailed comments here
Comment 5 Max Vujovic 2012-10-11 16:29:07 PDT
Comment on attachment 168304 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=168304&action=review

> Source/WebCore/ChangeLog:10
> +        removed, now we explicitely check for the programType(). m_program has also been added to

Nit: I think you meant "m_programType", not "m_program".
Comment 6 Michelangelo De Simone 2012-10-12 15:34:25 PDT
Created attachment 168498 [details]
Patch
Comment 7 Kenneth Rohde Christiansen 2012-10-15 02:15:08 PDT
Comment on attachment 168498 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=168498&action=review

LGTM but others might have comments

> Source/WebCore/ChangeLog:23
> +        reflect the need of setting the program type explicitely.

spelling

> Source/WebCore/ChangeLog:25
> +        type explicitely.

explicitly*

> Source/WebCore/ChangeLog:30
> +        (WebCore::CustomFilterProgramInfo::operator==): MixSetings' equality check is being performed only whether

Settings*
Comment 8 Michelangelo De Simone 2012-10-15 09:37:38 PDT
(In reply to comment #7)

> LGTM but others might have comments

Cool, thanks a lot!
Comment 9 Michelangelo De Simone 2012-10-15 09:39:40 PDT
Created attachment 168729 [details]
Patch for landing
Comment 10 WebKit Review Bot 2012-10-15 14:23:56 PDT
Comment on attachment 168729 [details]
Patch for landing

Clearing flags on attachment: 168729

Committed r131357: <http://trac.webkit.org/changeset/131357>
Comment 11 WebKit Review Bot 2012-10-15 14:24:00 PDT
All reviewed patches have been landed.  Closing bug.