Changeset 170433 in webkit


Ignore:
Timestamp:
Jun 25, 2014 12:03:47 PM (10 years ago)
Author:
krit@webkit.org
Message:

Add all blend modes to feBlend

feBlend should support all blend modes from CSS and Canvas
https://bugs.webkit.org/show_bug.cgi?id=134296

Source/WebCore:
Reviewed by Dean Jackson.

Add all blend modes to <feBlend> (the SVG filter primitive) that are also
supported by HTML Canvas and CSS.

In addition, add "normal" blend mode to HTML Canvas as requested by the
CSS Compositing and Blending specification. (Referenced from HTML Canvas.)
With this change, SVG, CSS and Canvas truly share the same blend modes and
even the same keywords. This is much easier to for web authors.

http://www.w3.org/TR/2014/CR-compositing-1-20140220/#ltblendmodegt

Test: svg/filters/feBlend-all-blendmodes.svg

  • platform/graphics/GraphicsTypes.cpp: Reorder blend mode text streams to match

enumeration order. Add a new function to parse blend modes independent of
compositing modes. Add a string "normal" that is supported by CSS, feBlend and
HTML Canvas now.

(WebCore::parseBlendMode):
(WebCore::parseCompositeAndBlendOperator):

  • platform/graphics/GraphicsTypes.h: Reorder BlendMode enumeration values to match the SVG JS enumeration for blend modes.
  • platform/graphics/cpu/arm/filters/FEBlendNEON.h: Move all software code that is no

longer required by the software path but still used by NEON here.

(WebCore::FEBlend::platformApplySoftware):
(WebCore::FEBlend::platformApplyNEON):

  • platform/graphics/filters/FEBlend.cpp:

Use drawImageBuffer() to blend the results of previous filter primitives. This
allows removing more than 60% of the code.

(WebCore::FEBlend::FEBlend):
(WebCore::FEBlend::create):
(WebCore::FEBlend::blendMode):
(WebCore::FEBlend::setBlendMode):
(WebCore::FEBlend::platformApplySoftware):
(WebCore::FEBlend::dump):
(WebCore::FEBlend::externalRepresentation):
(WebCore::feBlendNormal): Deleted.
(WebCore::feBlendMultiply): Deleted.
(WebCore::feBlendScreen): Deleted.
(WebCore::feBlendDarken): Deleted.
(WebCore::feBlendLighten): Deleted.
(WebCore::feBlendUnknown): Deleted.
(WebCore::platformApply): Deleted.
(WebCore::FEBlend::platformApplyGeneric): Deleted.
(WebCore::operator<<): Deleted.

  • platform/graphics/filters/FEBlend.h:
  • svg/SVGAnimatedEnumeration.cpp: Use the global BlendMode enumeration.

(WebCore::enumerationValueForTargetAttribute):

  • svg/SVGFEBlendElement.cpp:

(WebCore::SVGFEBlendElement::SVGFEBlendElement): Use the global BlendMode enumeration.

No new enumeration values added or exposed to SVG DOM as requested by SVG WG.

(WebCore::SVGFEBlendElement::parseAttribute):

  • svg/SVGFEBlendElement.h: Replace BlendModeType with global BlendMode enumeration. Remove

blend mode parsing code and use the code in GraphicsTypes instead.

(WebCore::SVGPropertyTraits<BlendMode>::highestEnumValue):
(WebCore::SVGPropertyTraits<BlendMode>::toString):
(WebCore::SVGPropertyTraits<BlendModeType>::highestEnumValue): Deleted.
(WebCore::SVGPropertyTraits<BlendModeType>::toString): Deleted.
(WebCore::SVGPropertyTraits<BlendModeType>::fromString): Deleted.

LayoutTests:
Added tests for new blend modes in feBlend as well as a test for 'normal' blend mode
on HTML Canvas.

Reviewed by Dean Jackson.

  • fast/canvas/canvas-blend-image-expected.txt:
  • fast/canvas/canvas-blend-solid-expected.txt:
  • fast/canvas/script-tests/canvas-blend-image.js: Test 'normal' blend mode in Canvas.

(prepareTestScenario):

  • fast/canvas/script-tests/canvas-blend-solid.js: Ditto.

(prepareTestScenario):

  • platform/mac/svg/W3C-SVG-1.1/filters-blend-01-b-expected.png:
  • platform/mac/svg/W3C-SVG-1.1/filters-blend-01-b-expected.txt: DRT output is lowercase now.
  • platform/mac/svg/filters/feBlend-all-blendmodes-expected.png: Added.
  • platform/mac/svg/filters/feBlend-all-blendmodes-expected.txt: Added.
  • svg/filters/feBlend-all-blendmodes.svg: Added. Tests all blend modes now supported by feBlend.
  • svg/filters/feBlend-invalid-mode.xhtml: Add an upper bound check as well.
Location:
trunk
Files:
3 added
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r170429 r170433  
     12014-06-25  Dirk Schulze  <krit@webkit.org>
     2
     3        Add all blend modes to feBlend
     4
     5        feBlend should support all blend modes from CSS and Canvas
     6        https://bugs.webkit.org/show_bug.cgi?id=134296
     7
     8        Added tests for new blend modes in feBlend as well as a test for 'normal' blend mode
     9        on HTML Canvas.
     10
     11        Reviewed by Dean Jackson.
     12
     13        * fast/canvas/canvas-blend-image-expected.txt:
     14        * fast/canvas/canvas-blend-solid-expected.txt:
     15        * fast/canvas/script-tests/canvas-blend-image.js: Test 'normal' blend mode in Canvas.
     16        (prepareTestScenario):
     17        * fast/canvas/script-tests/canvas-blend-solid.js: Ditto.
     18        (prepareTestScenario):
     19        * platform/mac/svg/W3C-SVG-1.1/filters-blend-01-b-expected.png:
     20        * platform/mac/svg/W3C-SVG-1.1/filters-blend-01-b-expected.txt: DRT output is lowercase now.
     21        * platform/mac/svg/filters/feBlend-all-blendmodes-expected.png: Added.
     22        * platform/mac/svg/filters/feBlend-all-blendmodes-expected.txt: Added.
     23        * svg/filters/feBlend-all-blendmodes.svg: Added. Tests all blend modes now supported by feBlend.
     24        * svg/filters/feBlend-invalid-mode.xhtml: Add an upper bound check as well.
     25
    1262014-06-25  Chris Fleizach  <cfleizach@apple.com>
    227
  • trunk/LayoutTests/css3/filters/effect-reference-expected.txt

    r149088 r170433  
    2323              [SourceGraphic]
    2424          RenderSVGResourceFilter {filter} [id="blend"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
    25             [feBlend mode="SCREEN"]
     25            [feBlend mode="screen"]
    2626              [feGaussianBlur stdDeviation="5.00, 5.00"]
    2727                [SourceGraphic]
    2828              [SourceGraphic]
    2929          RenderSVGResourceFilter {filter} [id="lighting"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
    30             [feBlend mode="MULTIPLY"]
     30            [feBlend mode="multiply"]
    3131              [feColorMatrix type="MATRIX" values="0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 1.00"]
    3232                [feSpecularLighting surfaceScale="1.00" specualConstant="1.00" specularExponent="1.00"]
  • trunk/LayoutTests/css3/filters/effect-reference-hw-expected.txt

    r149088 r170433  
    2323              [SourceGraphic]
    2424          RenderSVGResourceFilter {filter} [id="blend"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
    25             [feBlend mode="SCREEN"]
     25            [feBlend mode="screen"]
    2626              [feGaussianBlur stdDeviation="5.00, 5.00"]
    2727                [SourceGraphic]
    2828              [SourceGraphic]
    2929          RenderSVGResourceFilter {filter} [id="lighting"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
    30             [feBlend mode="MULTIPLY"]
     30            [feBlend mode="multiply"]
    3131              [feColorMatrix type="MATRIX" values="0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 1.00"]
    3232                [feSpecularLighting surfaceScale="1.00" specualConstant="1.00" specularExponent="1.00"]
  • trunk/LayoutTests/fast/canvas/canvas-blend-image-expected.txt

    r138334 r170433  
    7474PASS pixelDataAtPoint(3)[3] is within 5 of 191
    7575
     76Testing blend mode "normal"
     77solid on solid
     78PASS pixelDataAtPoint(0)[0] is within 5 of 255
     79PASS pixelDataAtPoint(0)[1] is within 5 of 0
     80PASS pixelDataAtPoint(0)[2] is within 5 of 0
     81PASS pixelDataAtPoint(0)[3] is within 5 of 255
     82PASS pixelDataAtPoint(1)[0] is within 5 of 255
     83PASS pixelDataAtPoint(1)[1] is within 5 of 255
     84PASS pixelDataAtPoint(1)[2] is within 5 of 0
     85PASS pixelDataAtPoint(1)[3] is within 5 of 255
     86PASS pixelDataAtPoint(2)[0] is within 5 of 0
     87PASS pixelDataAtPoint(2)[1] is within 5 of 128
     88PASS pixelDataAtPoint(2)[2] is within 5 of 0
     89PASS pixelDataAtPoint(2)[3] is within 5 of 255
     90PASS pixelDataAtPoint(3)[0] is within 5 of 0
     91PASS pixelDataAtPoint(3)[1] is within 5 of 0
     92PASS pixelDataAtPoint(3)[2] is within 5 of 255
     93PASS pixelDataAtPoint(3)[3] is within 5 of 255
     94solid on alpha
     95PASS pixelDataAtPoint(0)[0] is within 5 of 128
     96PASS pixelDataAtPoint(0)[1] is within 5 of 0
     97PASS pixelDataAtPoint(0)[2] is within 5 of 127
     98PASS pixelDataAtPoint(0)[3] is within 5 of 255
     99PASS pixelDataAtPoint(1)[0] is within 5 of 128
     100PASS pixelDataAtPoint(1)[1] is within 5 of 128
     101PASS pixelDataAtPoint(1)[2] is within 5 of 127
     102PASS pixelDataAtPoint(1)[3] is within 5 of 255
     103PASS pixelDataAtPoint(2)[0] is within 5 of 0
     104PASS pixelDataAtPoint(2)[1] is within 5 of 64
     105PASS pixelDataAtPoint(2)[2] is within 5 of 127
     106PASS pixelDataAtPoint(2)[3] is within 5 of 255
     107PASS pixelDataAtPoint(3)[0] is within 5 of 0
     108PASS pixelDataAtPoint(3)[1] is within 5 of 0
     109PASS pixelDataAtPoint(3)[2] is within 5 of 255
     110PASS pixelDataAtPoint(3)[3] is within 5 of 255
     111alpha on solid
     112PASS pixelDataAtPoint(0)[0] is within 5 of 255
     113PASS pixelDataAtPoint(0)[1] is within 5 of 0
     114PASS pixelDataAtPoint(0)[2] is within 5 of 0
     115PASS pixelDataAtPoint(0)[3] is within 5 of 255
     116PASS pixelDataAtPoint(1)[0] is within 5 of 255
     117PASS pixelDataAtPoint(1)[1] is within 5 of 255
     118PASS pixelDataAtPoint(1)[2] is within 5 of 0
     119PASS pixelDataAtPoint(1)[3] is within 5 of 255
     120PASS pixelDataAtPoint(2)[0] is within 5 of 0
     121PASS pixelDataAtPoint(2)[1] is within 5 of 128
     122PASS pixelDataAtPoint(2)[2] is within 5 of 0
     123PASS pixelDataAtPoint(2)[3] is within 5 of 255
     124PASS pixelDataAtPoint(3)[0] is within 5 of 0
     125PASS pixelDataAtPoint(3)[1] is within 5 of 0
     126PASS pixelDataAtPoint(3)[2] is within 5 of 255
     127PASS pixelDataAtPoint(3)[3] is within 5 of 255
     128alpha on alpha
     129PASS pixelDataAtPoint(0)[0] is within 5 of 171
     130PASS pixelDataAtPoint(0)[1] is within 5 of 0
     131PASS pixelDataAtPoint(0)[2] is within 5 of 84
     132PASS pixelDataAtPoint(0)[3] is within 5 of 191
     133PASS pixelDataAtPoint(1)[0] is within 5 of 171
     134PASS pixelDataAtPoint(1)[1] is within 5 of 171
     135PASS pixelDataAtPoint(1)[2] is within 5 of 84
     136PASS pixelDataAtPoint(1)[3] is within 5 of 191
     137PASS pixelDataAtPoint(2)[0] is within 5 of 0
     138PASS pixelDataAtPoint(2)[1] is within 5 of 85
     139PASS pixelDataAtPoint(2)[2] is within 5 of 84
     140PASS pixelDataAtPoint(2)[3] is within 5 of 191
     141PASS pixelDataAtPoint(3)[0] is within 5 of 0
     142PASS pixelDataAtPoint(3)[1] is within 5 of 0
     143PASS pixelDataAtPoint(3)[2] is within 5 of 255
     144PASS pixelDataAtPoint(3)[3] is within 5 of 191
     145
    76146Testing blend mode "multiply"
    77147solid on solid
  • trunk/LayoutTests/fast/canvas/canvas-blend-solid-expected.txt

    r138334 r170433  
    7474PASS pixelDataAtPoint(3)[3] is within 5 of 191
    7575
     76Testing blend mode "normal"
     77solid on solid
     78PASS pixelDataAtPoint(0)[0] is within 5 of 255
     79PASS pixelDataAtPoint(0)[1] is within 5 of 0
     80PASS pixelDataAtPoint(0)[2] is within 5 of 0
     81PASS pixelDataAtPoint(0)[3] is within 5 of 255
     82PASS pixelDataAtPoint(1)[0] is within 5 of 255
     83PASS pixelDataAtPoint(1)[1] is within 5 of 255
     84PASS pixelDataAtPoint(1)[2] is within 5 of 0
     85PASS pixelDataAtPoint(1)[3] is within 5 of 255
     86PASS pixelDataAtPoint(2)[0] is within 5 of 0
     87PASS pixelDataAtPoint(2)[1] is within 5 of 128
     88PASS pixelDataAtPoint(2)[2] is within 5 of 0
     89PASS pixelDataAtPoint(2)[3] is within 5 of 255
     90PASS pixelDataAtPoint(3)[0] is within 5 of 0
     91PASS pixelDataAtPoint(3)[1] is within 5 of 0
     92PASS pixelDataAtPoint(3)[2] is within 5 of 255
     93PASS pixelDataAtPoint(3)[3] is within 5 of 255
     94solid on alpha
     95PASS pixelDataAtPoint(0)[0] is within 5 of 128
     96PASS pixelDataAtPoint(0)[1] is within 5 of 0
     97PASS pixelDataAtPoint(0)[2] is within 5 of 127
     98PASS pixelDataAtPoint(0)[3] is within 5 of 255
     99PASS pixelDataAtPoint(1)[0] is within 5 of 128
     100PASS pixelDataAtPoint(1)[1] is within 5 of 128
     101PASS pixelDataAtPoint(1)[2] is within 5 of 127
     102PASS pixelDataAtPoint(1)[3] is within 5 of 255
     103PASS pixelDataAtPoint(2)[0] is within 5 of 0
     104PASS pixelDataAtPoint(2)[1] is within 5 of 64
     105PASS pixelDataAtPoint(2)[2] is within 5 of 127
     106PASS pixelDataAtPoint(2)[3] is within 5 of 255
     107PASS pixelDataAtPoint(3)[0] is within 5 of 0
     108PASS pixelDataAtPoint(3)[1] is within 5 of 0
     109PASS pixelDataAtPoint(3)[2] is within 5 of 255
     110PASS pixelDataAtPoint(3)[3] is within 5 of 255
     111alpha on solid
     112PASS pixelDataAtPoint(0)[0] is within 5 of 255
     113PASS pixelDataAtPoint(0)[1] is within 5 of 0
     114PASS pixelDataAtPoint(0)[2] is within 5 of 0
     115PASS pixelDataAtPoint(0)[3] is within 5 of 255
     116PASS pixelDataAtPoint(1)[0] is within 5 of 255
     117PASS pixelDataAtPoint(1)[1] is within 5 of 255
     118PASS pixelDataAtPoint(1)[2] is within 5 of 0
     119PASS pixelDataAtPoint(1)[3] is within 5 of 255
     120PASS pixelDataAtPoint(2)[0] is within 5 of 0
     121PASS pixelDataAtPoint(2)[1] is within 5 of 128
     122PASS pixelDataAtPoint(2)[2] is within 5 of 0
     123PASS pixelDataAtPoint(2)[3] is within 5 of 255
     124PASS pixelDataAtPoint(3)[0] is within 5 of 0
     125PASS pixelDataAtPoint(3)[1] is within 5 of 0
     126PASS pixelDataAtPoint(3)[2] is within 5 of 255
     127PASS pixelDataAtPoint(3)[3] is within 5 of 255
     128alpha on alpha
     129PASS pixelDataAtPoint(0)[0] is within 5 of 171
     130PASS pixelDataAtPoint(0)[1] is within 5 of 0
     131PASS pixelDataAtPoint(0)[2] is within 5 of 84
     132PASS pixelDataAtPoint(0)[3] is within 5 of 191
     133PASS pixelDataAtPoint(1)[0] is within 5 of 171
     134PASS pixelDataAtPoint(1)[1] is within 5 of 171
     135PASS pixelDataAtPoint(1)[2] is within 5 of 84
     136PASS pixelDataAtPoint(1)[3] is within 5 of 191
     137PASS pixelDataAtPoint(2)[0] is within 5 of 0
     138PASS pixelDataAtPoint(2)[1] is within 5 of 85
     139PASS pixelDataAtPoint(2)[2] is within 5 of 84
     140PASS pixelDataAtPoint(2)[3] is within 5 of 191
     141PASS pixelDataAtPoint(3)[0] is within 5 of 0
     142PASS pixelDataAtPoint(3)[1] is within 5 of 0
     143PASS pixelDataAtPoint(3)[2] is within 5 of 255
     144PASS pixelDataAtPoint(3)[3] is within 5 of 191
     145
    76146Testing blend mode "multiply"
    77147solid on solid
  • trunk/LayoutTests/fast/canvas/script-tests/canvas-blend-image.js

    r138334 r170433  
    2727[
    2828  ['source-over',
    29          [[255, 0, 0, 255],[255, 255, 0, 255],[0, 128, 0, 255],[0, 0, 255, 255]],
    30          [[128, 0, 127, 255],[128, 128, 127, 255],[0, 64, 127, 255],[0, 0, 255, 255]],
    31          [[255, 0, 0, 255],[255, 255, 0, 255],[0, 128, 0, 255],[0, 0, 255, 255]],
    32          [[171, 0, 84, 191],[171, 171, 84, 191],[0, 85, 84, 191],[0, 0, 255, 191]]
     29     [[255, 0, 0, 255],[255, 255, 0, 255],[0, 128, 0, 255],[0, 0, 255, 255]],
     30     [[128, 0, 127, 255],[128, 128, 127, 255],[0, 64, 127, 255],[0, 0, 255, 255]],
     31     [[255, 0, 0, 255],[255, 255, 0, 255],[0, 128, 0, 255],[0, 0, 255, 255]],
     32     [[171, 0, 84, 191],[171, 171, 84, 191],[0, 85, 84, 191],[0, 0, 255, 191]]
     33  ],
     34  ['normal',
     35     [[255, 0, 0, 255],[255, 255, 0, 255],[0, 128, 0, 255],[0, 0, 255, 255]],
     36     [[128, 0, 127, 255],[128, 128, 127, 255],[0, 64, 127, 255],[0, 0, 255, 255]],
     37     [[255, 0, 0, 255],[255, 255, 0, 255],[0, 128, 0, 255],[0, 0, 255, 255]],
     38     [[171, 0, 84, 191],[171, 171, 84, 191],[0, 85, 84, 191],[0, 0, 255, 191]]
    3339  ],
    3440  ['multiply',
    35         [[0, 0, 0, 255],[0, 0, 0, 255],[0, 0, 0, 255],[0, 0, 255, 255]],
    36         [[0, 0, 127, 255],[0, 0, 127, 255],[0, 0, 127, 255],[0, 0, 255, 255]],
    37         [[128, 0, 0, 255],[128, 128, 0, 255],[0, 64, 0, 255],[0, 0, 255, 255]],
    38         [[85, 0, 84, 191],[85, 85, 84, 191],[0, 43, 84, 191],[0, 0, 255, 191]]
     41    [[0, 0, 0, 255],[0, 0, 0, 255],[0, 0, 0, 255],[0, 0, 255, 255]],
     42    [[0, 0, 127, 255],[0, 0, 127, 255],[0, 0, 127, 255],[0, 0, 255, 255]],
     43    [[128, 0, 0, 255],[128, 128, 0, 255],[0, 64, 0, 255],[0, 0, 255, 255]],
     44    [[85, 0, 84, 191],[85, 85, 84, 191],[0, 43, 84, 191],[0, 0, 255, 191]]
    3945  ],
    4046  ['screen',
    41         [[255, 0, 255, 255],[255, 255, 255, 255],[0, 128, 255, 255],[0, 0, 255, 255]],
    42         [[128, 0, 255, 255],[128, 128, 255, 255],[0, 64, 255, 255],[0, 0, 255, 255]],
    43         [[255, 0, 127, 255],[255, 255, 127, 255],[0, 128, 127, 255],[0, 0, 255, 255]],
    44         [[171, 0, 170, 191],[171, 171, 170, 191],[0, 85, 170, 191],[0, 0, 255, 191]]
     47    [[255, 0, 255, 255],[255, 255, 255, 255],[0, 128, 255, 255],[0, 0, 255, 255]],
     48    [[128, 0, 255, 255],[128, 128, 255, 255],[0, 64, 255, 255],[0, 0, 255, 255]],
     49    [[255, 0, 127, 255],[255, 255, 127, 255],[0, 128, 127, 255],[0, 0, 255, 255]],
     50    [[171, 0, 170, 191],[171, 171, 170, 191],[0, 85, 170, 191],[0, 0, 255, 191]]
    4551  ],
    4652  ['overlay',
    47         [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
    48         [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
    49         [[128, 0, 127, 255],[128, 128, 127, 255],[0, 64, 127, 255],[0, 0, 255, 255]],
    50         [[85, 0, 170, 191],[85, 85, 170, 191],[0, 43, 170, 191],[0, 0, 255, 191]]
     53    [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
     54    [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
     55    [[128, 0, 127, 255],[128, 128, 127, 255],[0, 64, 127, 255],[0, 0, 255, 255]],
     56    [[85, 0, 170, 191],[85, 85, 170, 191],[0, 43, 170, 191],[0, 0, 255, 191]]
    5157  ],
    5258  ['darken',
    53         [[0, 0, 0, 255],[0, 0, 0, 255],[0, 0, 0, 255],[0, 0, 255, 255]],
    54         [[0, 0, 127, 255],[0, 0, 127, 255],[0, 0, 127, 255],[0, 0, 255, 255]],
    55         [[128, 0, 0, 255],[128, 128, 0, 255],[0, 64, 0, 255],[0, 0, 255, 255]],
    56         [[85, 0, 84, 191],[85, 85, 84, 191],[0, 43, 84, 191],[0, 0, 255, 191]]
     59    [[0, 0, 0, 255],[0, 0, 0, 255],[0, 0, 0, 255],[0, 0, 255, 255]],
     60    [[0, 0, 127, 255],[0, 0, 127, 255],[0, 0, 127, 255],[0, 0, 255, 255]],
     61    [[128, 0, 0, 255],[128, 128, 0, 255],[0, 64, 0, 255],[0, 0, 255, 255]],
     62    [[85, 0, 84, 191],[85, 85, 84, 191],[0, 43, 84, 191],[0, 0, 255, 191]]
    5763  ],
    5864  ['lighten',
    59         [[255, 0, 255, 255],[255, 255, 255, 255],[0, 128, 255, 255],[0, 0, 255, 255]],
    60         [[128, 0, 255, 255],[128, 128, 255, 255],[0, 64, 255, 255],[0, 0, 255, 255]],
    61         [[255, 0, 127, 255],[255, 255, 127, 255],[0, 128, 127, 255],[0, 0, 255, 255]],
    62         [[171, 0, 170, 191],[171, 171, 170, 191],[0, 85, 170, 191],[0, 0, 255, 191]]
     65    [[255, 0, 255, 255],[255, 255, 255, 255],[0, 128, 255, 255],[0, 0, 255, 255]],
     66    [[128, 0, 255, 255],[128, 128, 255, 255],[0, 64, 255, 255],[0, 0, 255, 255]],
     67    [[255, 0, 127, 255],[255, 255, 127, 255],[0, 128, 127, 255],[0, 0, 255, 255]],
     68    [[171, 0, 170, 191],[171, 171, 170, 191],[0, 85, 170, 191],[0, 0, 255, 191]]
    6369  ],
    6470  ['color-dodge',
    65         [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
    66         [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
    67         [[128, 0, 127, 255],[128, 128, 127, 255],[0, 64, 127, 255],[0, 0, 255, 255]],
    68         [[85, 0, 170, 191],[85, 85, 170, 191],[0, 43, 170, 191],[0, 0, 255, 191]]
     71    [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
     72    [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
     73    [[128, 0, 127, 255],[128, 128, 127, 255],[0, 64, 127, 255],[0, 0, 255, 255]],
     74    [[85, 0, 170, 191],[85, 85, 170, 191],[0, 43, 170, 191],[0, 0, 255, 191]]
    6975  ],
    7076  ['color-burn',
    71         [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
    72         [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
    73         [[128, 0, 127, 255],[128, 128, 127, 255],[0, 0, 127, 255],[0, 0, 255, 255]],
    74         [[85, 0, 170, 191],[85, 85, 170, 191],[0, 0, 170, 191],[0, 0, 255, 191]]
     77    [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
     78    [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
     79    [[128, 0, 127, 255],[128, 128, 127, 255],[0, 0, 127, 255],[0, 0, 255, 255]],
     80    [[85, 0, 170, 191],[85, 85, 170, 191],[0, 0, 170, 191],[0, 0, 255, 191]]
    7581
    7682  ],
    7783  ['hard-light',
    78         [[255, 0, 0, 255],[255, 255, 0, 255],[0, 1, 0, 255],[0, 0, 255, 255]],
    79         [[128, 0, 127, 255],[128, 128, 127, 255],[0, 0, 127, 255],[0, 0, 255, 255]],
    80         [[255, 0, 0, 255],[255, 255, 0, 255],[0, 65, 0, 255],[0, 0, 255, 255]],
    81         [[171, 0, 84, 191],[171, 171, 84, 191],[0, 43, 84, 191],[0, 0, 255, 191]]
     84    [[255, 0, 0, 255],[255, 255, 0, 255],[0, 1, 0, 255],[0, 0, 255, 255]],
     85    [[128, 0, 127, 255],[128, 128, 127, 255],[0, 0, 127, 255],[0, 0, 255, 255]],
     86    [[255, 0, 0, 255],[255, 255, 0, 255],[0, 65, 0, 255],[0, 0, 255, 255]],
     87    [[171, 0, 84, 191],[171, 171, 84, 191],[0, 43, 84, 191],[0, 0, 255, 191]]
    8288  ],
    8389  ['soft-light',
    84         [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
    85         [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
    86         [[128, 0, 127, 255],[128, 128, 127, 255],[0, 64, 127, 255],[0, 0, 255, 255]],
    87         [[85, 0, 170, 191],[85, 85, 170, 191],[0, 43, 170, 191],[0, 0, 255, 191]]
     90    [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
     91    [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
     92    [[128, 0, 127, 255],[128, 128, 127, 255],[0, 64, 127, 255],[0, 0, 255, 255]],
     93    [[85, 0, 170, 191],[85, 85, 170, 191],[0, 43, 170, 191],[0, 0, 255, 191]]
    8894  ],
    8995  ['difference',
    90         [[255, 0, 255, 255],[255, 255, 255, 255],[0, 128, 255, 255],[0, 0, 0, 255]],
    91         [[128, 0, 255, 255],[128, 128, 255, 255],[0, 64, 255, 255],[0, 0, 127, 255]],
    92         [[255, 0, 127, 255],[255, 255, 127, 255],[0, 128, 127, 255],[0, 0, 128, 255]],
    93         [[171, 0, 170, 191],[171, 171, 170, 191],[0, 85, 170, 191],[0, 0, 171, 191]]
     96    [[255, 0, 255, 255],[255, 255, 255, 255],[0, 128, 255, 255],[0, 0, 0, 255]],
     97    [[128, 0, 255, 255],[128, 128, 255, 255],[0, 64, 255, 255],[0, 0, 127, 255]],
     98    [[255, 0, 127, 255],[255, 255, 127, 255],[0, 128, 127, 255],[0, 0, 128, 255]],
     99    [[171, 0, 170, 191],[171, 171, 170, 191],[0, 85, 170, 191],[0, 0, 171, 191]]
    94100  ],
    95101  ['exclusion',
    96         [[255, 0, 255, 255],[255, 255, 255, 255],[0, 128, 255, 255],[0, 0, 0, 255]],
    97         [[128, 0, 255, 255],[128, 128, 255, 255],[0, 64, 255, 255],[0, 0, 127, 255]],
    98         [[255, 0, 127, 255],[255, 255, 127, 255],[0, 128, 127, 255],[0, 0, 128, 255]],
    99         [[171, 0, 170, 191],[171, 171, 170, 191],[0, 85, 170, 191],[0, 0, 171, 191]]
     102    [[255, 0, 255, 255],[255, 255, 255, 255],[0, 128, 255, 255],[0, 0, 0, 255]],
     103    [[128, 0, 255, 255],[128, 128, 255, 255],[0, 64, 255, 255],[0, 0, 127, 255]],
     104    [[255, 0, 127, 255],[255, 255, 127, 255],[0, 128, 127, 255],[0, 0, 128, 255]],
     105    [[171, 0, 170, 191],[171, 171, 170, 191],[0, 85, 170, 191],[0, 0, 171, 191]]
    100106  ],
    101107  ['hue',
    102         [[93, 0, 0, 255],[31, 31, 0, 255],[0, 46, 0, 255],[0, 0, 255, 255]],
    103         [[49, 0, 127, 255],[16, 16, 127, 255],[0, 25, 127, 255],[0, 0, 255, 255]],
    104         [[175, 0, 0, 255],[144, 144, 0, 255],[0, 88, 0, 255],[0, 0, 255, 255]],
    105         [[116, 0, 84, 191],[96, 96, 84, 191],[0, 58, 84, 191],[0, 0, 255, 191]]
     108    [[93, 0, 0, 255],[31, 31, 0, 255],[0, 46, 0, 255],[0, 0, 255, 255]],
     109    [[49, 0, 127, 255],[16, 16, 127, 255],[0, 25, 127, 255],[0, 0, 255, 255]],
     110    [[175, 0, 0, 255],[144, 144, 0, 255],[0, 88, 0, 255],[0, 0, 255, 255]],
     111    [[116, 0, 84, 191],[96, 96, 84, 191],[0, 58, 84, 191],[0, 0, 255, 191]]
    106112  ],
    107113  ['saturation',
    108         [[0, 0, 255, 255],[0, 0, 255, 255],[14, 14, 142, 255],[0, 0, 255, 255]],
    109         [[0, 0, 255, 255],[0, 0, 255, 255],[7, 7, 198, 255],[0, 0, 255, 255]],
    110         [[128, 0, 127, 255],[128, 128, 127, 255],[7, 71, 70, 255],[0, 0, 255, 255]],
    111         [[85, 0, 167, 191],[85, 85, 167, 191],[0, 48, 130, 191],[0, 0, 255, 191]]
     114    [[0, 0, 255, 255],[0, 0, 255, 255],[14, 14, 142, 255],[0, 0, 255, 255]],
     115    [[0, 0, 255, 255],[0, 0, 255, 255],[7, 7, 198, 255],[0, 0, 255, 255]],
     116    [[128, 0, 127, 255],[128, 128, 127, 255],[7, 71, 70, 255],[0, 0, 255, 255]],
     117    [[85, 0, 167, 191],[85, 85, 167, 191],[0, 48, 130, 191],[0, 0, 255, 191]]
    112118  ],
    113119  ['color',
    114         [[93, 0, 0, 255],[31, 31, 0, 255],[0, 47, 0, 255],[0, 0, 255, 255]],
    115         [[49, 0, 127, 255],[16, 16, 127, 255],[0, 24, 127, 255],[0, 0, 255, 255]],
    116         [[175, 0, 0, 255],[144, 144, 0, 255],[0, 88, 0, 255],[0, 0, 255, 255]],
    117         [[116, 0, 84, 191],[96, 96, 84, 191],[0, 58, 84, 191],[0, 0, 255, 191]]
     120    [[93, 0, 0, 255],[31, 31, 0, 255],[0, 47, 0, 255],[0, 0, 255, 255]],
     121    [[49, 0, 127, 255],[16, 16, 127, 255],[0, 24, 127, 255],[0, 0, 255, 255]],
     122    [[175, 0, 0, 255],[144, 144, 0, 255],[0, 88, 0, 255],[0, 0, 255, 255]],
     123    [[116, 0, 84, 191],[96, 96, 84, 191],[0, 58, 84, 191],[0, 0, 255, 191]]
    118124  ],
    119125  ['luminosity',
    120         [[55, 55, 255, 255],[224, 224, 255, 255],[54, 54, 255, 255],[0, 0, 255, 255]],
    121         [[28, 28, 255, 255],[112, 112, 255, 255],[27, 27, 255, 255],[0, 0, 255, 255]],
    122         [[155, 27, 127, 255],[239, 239, 127, 255],[26, 90, 127, 255],[0, 0, 255, 255]],
    123         [[104, 19, 167, 191],[158, 158, 167, 191],[16, 58, 167, 191],[0, 0, 255, 191]]
     126    [[55, 55, 255, 255],[224, 224, 255, 255],[54, 54, 255, 255],[0, 0, 255, 255]],
     127    [[28, 28, 255, 255],[112, 112, 255, 255],[27, 27, 255, 255],[0, 0, 255, 255]],
     128    [[155, 27, 127, 255],[239, 239, 127, 255],[26, 90, 127, 255],[0, 0, 255, 255]],
     129    [[104, 19, 167, 191],[158, 158, 167, 191],[16, 58, 167, 191],[0, 0, 255, 191]]
    124130  ]];
    125131
     
    154160  // Check each blend mode individually.
    155161  for (var i = 0; i < blendModes.length; i++) {
    156         debug('Testing blend mode "' + blendModes[i][0] + '"');
    157         for (var j = 0; j < testScenario.length; j++) {
    158           ctx.clearRect(0,0,200,200);
    159           ctx.save();
    160          
    161           // Draw backdrop.
    162           ctx.fillStyle = 'rgba(0, 0, 255, ' + testScenario[j][1] + ')';
    163           ctx.fillRect(0,0,200,200);
    164          
    165           // Apply blend mode.
    166           ctx.globalCompositeOperation = blendModes[i][0];
    167           ctx.globalAlpha = testScenario[j][2];
    168           ctx.drawImage(img, 0, 0);
    169          
    170           checkBlendModeResult(blendModes[i][0], testScenario[j][0], blendModes[i][j+1], sigma);
    171           ctx.restore();                                 
    172           }
    173         debug('');
    174         }
     162    debug('Testing blend mode "' + blendModes[i][0] + '"');
     163    for (var j = 0; j < testScenario.length; j++) {
     164      ctx.clearRect(0,0,200,200);
     165      ctx.save();
     166     
     167      // Draw backdrop.
     168      ctx.fillStyle = 'rgba(0, 0, 255, ' + testScenario[j][1] + ')';
     169      ctx.fillRect(0,0,200,200);
     170     
     171      // Apply blend mode.
     172      ctx.globalCompositeOperation = blendModes[i][0];
     173      ctx.globalAlpha = testScenario[j][2];
     174      ctx.drawImage(img, 0, 0);
     175     
     176      checkBlendModeResult(blendModes[i][0], testScenario[j][0], blendModes[i][j+1], sigma);
     177      ctx.restore();                                 
     178      }
     179    debug('');
     180    }
    175181  }
    176182
  • trunk/LayoutTests/fast/canvas/script-tests/canvas-blend-solid.js

    r138334 r170433  
    2828[
    2929  ['source-over',
    30          [[255, 0, 0, 255],[255, 255, 0, 255],[0, 128, 0, 255],[0, 0, 255, 255]],
    31          [[128, 0, 127, 255],[128, 128, 127, 255],[0, 64, 127, 255],[0, 0, 255, 255]],
    32          [[255, 0, 0, 255],[255, 255, 0, 255],[0, 128, 0, 255],[0, 0, 255, 255]],
    33          [[171, 0, 84, 191],[171, 171, 84, 191],[0, 85, 84, 191],[0, 0, 255, 191]]
     30     [[255, 0, 0, 255],[255, 255, 0, 255],[0, 128, 0, 255],[0, 0, 255, 255]],
     31     [[128, 0, 127, 255],[128, 128, 127, 255],[0, 64, 127, 255],[0, 0, 255, 255]],
     32     [[255, 0, 0, 255],[255, 255, 0, 255],[0, 128, 0, 255],[0, 0, 255, 255]],
     33     [[171, 0, 84, 191],[171, 171, 84, 191],[0, 85, 84, 191],[0, 0, 255, 191]]
     34  ],
     35  ['normal',
     36     [[255, 0, 0, 255],[255, 255, 0, 255],[0, 128, 0, 255],[0, 0, 255, 255]],
     37     [[128, 0, 127, 255],[128, 128, 127, 255],[0, 64, 127, 255],[0, 0, 255, 255]],
     38     [[255, 0, 0, 255],[255, 255, 0, 255],[0, 128, 0, 255],[0, 0, 255, 255]],
     39     [[171, 0, 84, 191],[171, 171, 84, 191],[0, 85, 84, 191],[0, 0, 255, 191]]
    3440  ],
    3541  ['multiply',
    36         [[0, 0, 0, 255],[0, 0, 0, 255],[0, 0, 0, 255],[0, 0, 255, 255]],
    37         [[0, 0, 127, 255],[0, 0, 127, 255],[0, 0, 127, 255],[0, 0, 255, 255]],
    38         [[128, 0, 0, 255],[128, 128, 0, 255],[0, 64, 0, 255],[0, 0, 255, 255]],
    39         [[85, 0, 84, 191],[85, 85, 84, 191],[0, 43, 84, 191],[0, 0, 255, 191]]
     42    [[0, 0, 0, 255],[0, 0, 0, 255],[0, 0, 0, 255],[0, 0, 255, 255]],
     43    [[0, 0, 127, 255],[0, 0, 127, 255],[0, 0, 127, 255],[0, 0, 255, 255]],
     44    [[128, 0, 0, 255],[128, 128, 0, 255],[0, 64, 0, 255],[0, 0, 255, 255]],
     45    [[85, 0, 84, 191],[85, 85, 84, 191],[0, 43, 84, 191],[0, 0, 255, 191]]
    4046  ],
    4147  ['screen',
    42         [[255, 0, 255, 255],[255, 255, 255, 255],[0, 128, 255, 255],[0, 0, 255, 255]],
    43         [[128, 0, 255, 255],[128, 128, 255, 255],[0, 64, 255, 255],[0, 0, 255, 255]],
    44         [[255, 0, 127, 255],[255, 255, 127, 255],[0, 128, 127, 255],[0, 0, 255, 255]],
    45         [[171, 0, 170, 191],[171, 171, 170, 191],[0, 85, 170, 191],[0, 0, 255, 191]]
     48    [[255, 0, 255, 255],[255, 255, 255, 255],[0, 128, 255, 255],[0, 0, 255, 255]],
     49    [[128, 0, 255, 255],[128, 128, 255, 255],[0, 64, 255, 255],[0, 0, 255, 255]],
     50    [[255, 0, 127, 255],[255, 255, 127, 255],[0, 128, 127, 255],[0, 0, 255, 255]],
     51    [[171, 0, 170, 191],[171, 171, 170, 191],[0, 85, 170, 191],[0, 0, 255, 191]]
    4652  ],
    4753  ['overlay',
    48         [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
    49         [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
    50         [[128, 0, 127, 255],[128, 128, 127, 255],[0, 64, 127, 255],[0, 0, 255, 255]],
    51         [[85, 0, 170, 191],[85, 85, 170, 191],[0, 43, 170, 191],[0, 0, 255, 191]]
     54    [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
     55    [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
     56    [[128, 0, 127, 255],[128, 128, 127, 255],[0, 64, 127, 255],[0, 0, 255, 255]],
     57    [[85, 0, 170, 191],[85, 85, 170, 191],[0, 43, 170, 191],[0, 0, 255, 191]]
    5258  ],
    5359  ['darken',
    54         [[0, 0, 0, 255],[0, 0, 0, 255],[0, 0, 0, 255],[0, 0, 255, 255]],
    55         [[0, 0, 127, 255],[0, 0, 127, 255],[0, 0, 127, 255],[0, 0, 255, 255]],
    56         [[128, 0, 0, 255],[128, 128, 0, 255],[0, 64, 0, 255],[0, 0, 255, 255]],
    57         [[85, 0, 84, 191],[85, 85, 84, 191],[0, 43, 84, 191],[0, 0, 255, 191]]
     60    [[0, 0, 0, 255],[0, 0, 0, 255],[0, 0, 0, 255],[0, 0, 255, 255]],
     61    [[0, 0, 127, 255],[0, 0, 127, 255],[0, 0, 127, 255],[0, 0, 255, 255]],
     62    [[128, 0, 0, 255],[128, 128, 0, 255],[0, 64, 0, 255],[0, 0, 255, 255]],
     63    [[85, 0, 84, 191],[85, 85, 84, 191],[0, 43, 84, 191],[0, 0, 255, 191]]
    5864  ],
    5965  ['lighten',
    60         [[255, 0, 255, 255],[255, 255, 255, 255],[0, 128, 255, 255],[0, 0, 255, 255]],
    61         [[128, 0, 255, 255],[128, 128, 255, 255],[0, 64, 255, 255],[0, 0, 255, 255]],
    62         [[255, 0, 127, 255],[255, 255, 127, 255],[0, 128, 127, 255],[0, 0, 255, 255]],
    63         [[171, 0, 170, 191],[171, 171, 170, 191],[0, 85, 170, 191],[0, 0, 255, 191]]
     66    [[255, 0, 255, 255],[255, 255, 255, 255],[0, 128, 255, 255],[0, 0, 255, 255]],
     67    [[128, 0, 255, 255],[128, 128, 255, 255],[0, 64, 255, 255],[0, 0, 255, 255]],
     68    [[255, 0, 127, 255],[255, 255, 127, 255],[0, 128, 127, 255],[0, 0, 255, 255]],
     69    [[171, 0, 170, 191],[171, 171, 170, 191],[0, 85, 170, 191],[0, 0, 255, 191]]
    6470  ],
    6571  ['color-dodge',
    66         [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
    67         [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
    68         [[128, 0, 127, 255],[128, 128, 127, 255],[0, 64, 127, 255],[0, 0, 255, 255]],
    69         [[85, 0, 170, 191],[85, 85, 170, 191],[0, 43, 170, 191],[0, 0, 255, 191]]
     72    [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
     73    [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
     74    [[128, 0, 127, 255],[128, 128, 127, 255],[0, 64, 127, 255],[0, 0, 255, 255]],
     75    [[85, 0, 170, 191],[85, 85, 170, 191],[0, 43, 170, 191],[0, 0, 255, 191]]
    7076  ],
    7177  ['color-burn',
    72         [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
    73         [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
    74         [[128, 0, 127, 255],[128, 128, 127, 255],[0, 0, 127, 255],[0, 0, 255, 255]],
    75         [[85, 0, 170, 191],[85, 85, 170, 191],[0, 0, 170, 191],[0, 0, 255, 191]]
     78    [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
     79    [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
     80    [[128, 0, 127, 255],[128, 128, 127, 255],[0, 0, 127, 255],[0, 0, 255, 255]],
     81    [[85, 0, 170, 191],[85, 85, 170, 191],[0, 0, 170, 191],[0, 0, 255, 191]]
    7682
    7783  ],
    7884  ['hard-light',
    79         [[255, 0, 0, 255],[255, 255, 0, 255],[0, 1, 0, 255],[0, 0, 255, 255]],
    80         [[128, 0, 127, 255],[128, 128, 127, 255],[0, 0, 127, 255],[0, 0, 255, 255]],
    81         [[255, 0, 0, 255],[255, 255, 0, 255],[0, 65, 0, 255],[0, 0, 255, 255]],
    82         [[171, 0, 84, 191],[171, 171, 84, 191],[0, 43, 84, 191],[0, 0, 255, 191]]
     85    [[255, 0, 0, 255],[255, 255, 0, 255],[0, 1, 0, 255],[0, 0, 255, 255]],
     86    [[128, 0, 127, 255],[128, 128, 127, 255],[0, 0, 127, 255],[0, 0, 255, 255]],
     87    [[255, 0, 0, 255],[255, 255, 0, 255],[0, 65, 0, 255],[0, 0, 255, 255]],
     88    [[171, 0, 84, 191],[171, 171, 84, 191],[0, 43, 84, 191],[0, 0, 255, 191]]
    8389  ],
    8490  ['soft-light',
    85         [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
    86         [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
    87         [[128, 0, 127, 255],[128, 128, 127, 255],[0, 64, 127, 255],[0, 0, 255, 255]],
    88         [[85, 0, 170, 191],[85, 85, 170, 191],[0, 43, 170, 191],[0, 0, 255, 191]]
     91    [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
     92    [[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255],[0, 0, 255, 255]],
     93    [[128, 0, 127, 255],[128, 128, 127, 255],[0, 64, 127, 255],[0, 0, 255, 255]],
     94    [[85, 0, 170, 191],[85, 85, 170, 191],[0, 43, 170, 191],[0, 0, 255, 191]]
    8995  ],
    9096  ['difference',
    91         [[255, 0, 255, 255],[255, 255, 255, 255],[0, 128, 255, 255],[0, 0, 0, 255]],
    92         [[128, 0, 255, 255],[128, 128, 255, 255],[0, 64, 255, 255],[0, 0, 127, 255]],
    93         [[255, 0, 127, 255],[255, 255, 127, 255],[0, 128, 127, 255],[0, 0, 128, 255]],
    94         [[171, 0, 170, 191],[171, 171, 170, 191],[0, 85, 170, 191],[0, 0, 171, 191]]
     97    [[255, 0, 255, 255],[255, 255, 255, 255],[0, 128, 255, 255],[0, 0, 0, 255]],
     98    [[128, 0, 255, 255],[128, 128, 255, 255],[0, 64, 255, 255],[0, 0, 127, 255]],
     99    [[255, 0, 127, 255],[255, 255, 127, 255],[0, 128, 127, 255],[0, 0, 128, 255]],
     100    [[171, 0, 170, 191],[171, 171, 170, 191],[0, 85, 170, 191],[0, 0, 171, 191]]
    95101  ],
    96102  ['exclusion',
    97         [[255, 0, 255, 255],[255, 255, 255, 255],[0, 128, 255, 255],[0, 0, 0, 255]],
    98         [[128, 0, 255, 255],[128, 128, 255, 255],[0, 64, 255, 255],[0, 0, 127, 255]],
    99         [[255, 0, 127, 255],[255, 255, 127, 255],[0, 128, 127, 255],[0, 0, 128, 255]],
    100         [[171, 0, 170, 191],[171, 171, 170, 191],[0, 85, 170, 191],[0, 0, 171, 191]]
     103    [[255, 0, 255, 255],[255, 255, 255, 255],[0, 128, 255, 255],[0, 0, 0, 255]],
     104    [[128, 0, 255, 255],[128, 128, 255, 255],[0, 64, 255, 255],[0, 0, 127, 255]],
     105    [[255, 0, 127, 255],[255, 255, 127, 255],[0, 128, 127, 255],[0, 0, 128, 255]],
     106    [[171, 0, 170, 191],[171, 171, 170, 191],[0, 85, 170, 191],[0, 0, 171, 191]]
    101107  ],
    102108  ['hue',
    103         [[93, 0, 0, 255],[31, 31, 0, 255],[0, 46, 0, 255],[0, 0, 255, 255]],
    104         [[49, 0, 127, 255],[16, 16, 127, 255],[0, 25, 127, 255],[0, 0, 255, 255]],
    105         [[175, 0, 0, 255],[144, 144, 0, 255],[0, 88, 0, 255],[0, 0, 255, 255]],
    106         [[116, 0, 84, 191],[96, 96, 84, 191],[0, 58, 84, 191],[0, 0, 255, 191]]
     109    [[93, 0, 0, 255],[31, 31, 0, 255],[0, 46, 0, 255],[0, 0, 255, 255]],
     110    [[49, 0, 127, 255],[16, 16, 127, 255],[0, 25, 127, 255],[0, 0, 255, 255]],
     111    [[175, 0, 0, 255],[144, 144, 0, 255],[0, 88, 0, 255],[0, 0, 255, 255]],
     112    [[116, 0, 84, 191],[96, 96, 84, 191],[0, 58, 84, 191],[0, 0, 255, 191]]
    107113  ],
    108114  ['saturation',
    109         [[0, 0, 255, 255],[0, 0, 255, 255],[14, 14, 142, 255],[0, 0, 255, 255]],
    110         [[0, 0, 255, 255],[0, 0, 255, 255],[7, 7, 198, 255],[0, 0, 255, 255]],
    111         [[128, 0, 127, 255],[128, 128, 127, 255],[7, 71, 70, 255],[0, 0, 255, 255]],
    112         [[85, 0, 167, 191],[85, 85, 167, 191],[0, 48, 130, 191],[0, 0, 255, 191]]
     115    [[0, 0, 255, 255],[0, 0, 255, 255],[14, 14, 142, 255],[0, 0, 255, 255]],
     116    [[0, 0, 255, 255],[0, 0, 255, 255],[7, 7, 198, 255],[0, 0, 255, 255]],
     117    [[128, 0, 127, 255],[128, 128, 127, 255],[7, 71, 70, 255],[0, 0, 255, 255]],
     118    [[85, 0, 167, 191],[85, 85, 167, 191],[0, 48, 130, 191],[0, 0, 255, 191]]
    113119  ],
    114120  ['color',
    115         [[93, 0, 0, 255],[31, 31, 0, 255],[0, 47, 0, 255],[0, 0, 255, 255]],
    116         [[49, 0, 127, 255],[16, 16, 127, 255],[0, 24, 127, 255],[0, 0, 255, 255]],
    117         [[175, 0, 0, 255],[144, 144, 0, 255],[0, 88, 0, 255],[0, 0, 255, 255]],
    118         [[116, 0, 84, 191],[96, 96, 84, 191],[0, 58, 84, 191],[0, 0, 255, 191]]
     121    [[93, 0, 0, 255],[31, 31, 0, 255],[0, 47, 0, 255],[0, 0, 255, 255]],
     122    [[49, 0, 127, 255],[16, 16, 127, 255],[0, 24, 127, 255],[0, 0, 255, 255]],
     123    [[175, 0, 0, 255],[144, 144, 0, 255],[0, 88, 0, 255],[0, 0, 255, 255]],
     124    [[116, 0, 84, 191],[96, 96, 84, 191],[0, 58, 84, 191],[0, 0, 255, 191]]
    119125  ],
    120126  ['luminosity',
    121         [[55, 55, 255, 255],[224, 224, 255, 255],[54, 54, 255, 255],[0, 0, 255, 255]],
    122         [[28, 28, 255, 255],[112, 112, 255, 255],[27, 27, 255, 255],[0, 0, 255, 255]],
    123         [[155, 27, 127, 255],[239, 239, 127, 255],[26, 90, 127, 255],[0, 0, 255, 255]],
    124         [[104, 19, 167, 191],[158, 158, 167, 191],[16, 58, 167, 191],[0, 0, 255, 191]]
     127    [[55, 55, 255, 255],[224, 224, 255, 255],[54, 54, 255, 255],[0, 0, 255, 255]],
     128    [[28, 28, 255, 255],[112, 112, 255, 255],[27, 27, 255, 255],[0, 0, 255, 255]],
     129    [[155, 27, 127, 255],[239, 239, 127, 255],[26, 90, 127, 255],[0, 0, 255, 255]],
     130    [[104, 19, 167, 191],[158, 158, 167, 191],[16, 58, 167, 191],[0, 0, 255, 191]]
    125131  ]];
    126132
     
    155161  // Check each blend mode individually.
    156162  for (var i = 0; i < blendModes.length; i++) {
    157         debug('Testing blend mode "' + blendModes[i][0] + '"');
    158         for (var j = 0; j < testScenario.length; j++) {
    159           ctx.globalCompositeOperation = 'clear';
    160           ctx.fillRect(0,0,200,200);
    161           ctx.globalCompositeOperation = 'source-over';
    162           ctx.save();
    163          
    164           // Draw backdrop.
    165           ctx.fillStyle = 'rgba(0, 0, 255, ' + testScenario[j][1] + ')';
    166           ctx.fillRect(0,0,200,200);
    167          
    168           // Apply blend mode.
    169           ctx.globalCompositeOperation = blendModes[i][0];
    170           ctx.globalAlpha = testScenario[j][2];
    171           ctx.fillStyle = "red";
    172           ctx.fillRect(0,0,100,100);
    173           ctx.fillStyle = "yellow";
    174           ctx.fillRect(100,0,100,100);
    175           ctx.fillStyle = "green";
    176           ctx.fillRect(100,100,100,100);
    177           ctx.fillStyle = "blue";
    178           ctx.fillRect(0,100,100,100);
    179           ctx.restore();
    180          
    181           checkBlendModeResult(blendModes[i][0], testScenario[j][0], blendModes[i][j+1], sigma);
    182           ctx.restore();                                 
    183           }
    184         debug('');
     163    debug('Testing blend mode "' + blendModes[i][0] + '"');
     164    for (var j = 0; j < testScenario.length; j++) {
     165      ctx.globalCompositeOperation = 'clear';
     166      ctx.fillRect(0,0,200,200);
     167      ctx.globalCompositeOperation = 'source-over';
     168      ctx.save();
     169     
     170      // Draw backdrop.
     171      ctx.fillStyle = 'rgba(0, 0, 255, ' + testScenario[j][1] + ')';
     172      ctx.fillRect(0,0,200,200);
     173     
     174      // Apply blend mode.
     175      ctx.globalCompositeOperation = blendModes[i][0];
     176      ctx.globalAlpha = testScenario[j][2];
     177      ctx.fillStyle = "red";
     178      ctx.fillRect(0,0,100,100);
     179      ctx.fillStyle = "yellow";
     180      ctx.fillRect(100,0,100,100);
     181      ctx.fillStyle = "green";
     182      ctx.fillRect(100,100,100,100);
     183      ctx.fillStyle = "blue";
     184      ctx.fillRect(0,100,100,100);
     185      ctx.restore();
     186     
     187      checkBlendModeResult(blendModes[i][0], testScenario[j][0], blendModes[i][j+1], sigma);
     188      ctx.restore();                                 
     189      }
     190    debug('');
    185191  }
    186192}
  • trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/filters-blend-01-b-expected.txt

    r161884 r170433  
    77      RenderSVGHiddenContainer {defs} at (0,0) size 0x0
    88        RenderSVGResourceFilter {filter} [id="BlendNormal"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
    9           [feBlend mode="NORMAL"]
     9          [feBlend mode="normal"]
    1010            [SourceGraphic]
    1111            [feFlood flood-color="#00FF00" flood-opacity="0.50"]
    1212        RenderSVGResourceFilter {filter} [id="BlendMultiply"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
    13           [feBlend mode="MULTIPLY"]
     13          [feBlend mode="multiply"]
    1414            [SourceGraphic]
    1515            [feFlood flood-color="#00FF00" flood-opacity="0.50"]
    1616        RenderSVGResourceFilter {filter} [id="BlendScreen"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
    17           [feBlend mode="SCREEN"]
     17          [feBlend mode="screen"]
    1818            [SourceGraphic]
    1919            [feFlood flood-color="#00FF00" flood-opacity="0.50"]
    2020        RenderSVGResourceFilter {filter} [id="BlendDarken"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
    21           [feBlend mode="DARKEN"]
     21          [feBlend mode="darken"]
    2222            [SourceGraphic]
    2323            [feFlood flood-color="#00FF00" flood-opacity="0.50"]
    2424        RenderSVGResourceFilter {filter} [id="BlendLighten"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
    25           [feBlend mode="LIGHTEN"]
     25          [feBlend mode="lighten"]
    2626            [SourceGraphic]
    2727            [feFlood flood-color="#00FF00" flood-opacity="0.50"]
  • trunk/LayoutTests/svg/css/path-gradient-stroke-shadow-expected.txt

    r119860 r170433  
    88        RenderSVGGradientStop {stop} [offset=1.00] [color=#0000FF]
    99      RenderSVGResourceFilter {filter} [id="shadow"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
    10         [feBlend mode="NORMAL"]
     10        [feBlend mode="normal"]
    1111          [SourceGraphic]
    1212          [feGaussianBlur stdDeviation="10.00, 10.00"]
  • trunk/LayoutTests/svg/css/rect-gradient-stroke-shadow-expected.txt

    r103407 r170433  
    88        RenderSVGGradientStop {stop} [offset=1.00] [color=#0000FF]
    99      RenderSVGResourceFilter {filter} [id="shadow"] [filterUnits=objectBoundingBox] [primitiveUnits=userSpaceOnUse]
    10         [feBlend mode="NORMAL"]
     10        [feBlend mode="normal"]
    1111          [SourceGraphic]
    1212          [feGaussianBlur stdDeviation="10.00, 10.00"]
  • trunk/Source/WebCore/ChangeLog

    r170430 r170433  
     12014-06-25  Dirk Schulze  <krit@webkit.org>
     2
     3        Add all blend modes to feBlend
     4
     5        feBlend should support all blend modes from CSS and Canvas
     6        https://bugs.webkit.org/show_bug.cgi?id=134296
     7
     8        Reviewed by Dean Jackson.
     9
     10        Add all blend modes to <feBlend> (the SVG filter primitive) that are also
     11        supported by HTML Canvas and CSS.
     12
     13        In addition, add "normal" blend mode to HTML Canvas as requested by the
     14        CSS Compositing and Blending specification. (Referenced from HTML Canvas.)
     15        With this change, SVG, CSS and Canvas truly share the same blend modes and
     16        even the same keywords. This is much easier to for web authors.
     17
     18        http://www.w3.org/TR/2014/CR-compositing-1-20140220/#ltblendmodegt
     19
     20        Test: svg/filters/feBlend-all-blendmodes.svg
     21
     22        * platform/graphics/GraphicsTypes.cpp: Reorder blend mode text streams to match
     23            enumeration order. Add a new function to parse blend modes independent of
     24            compositing modes. Add a string "normal" that is supported by CSS, feBlend and
     25            HTML Canvas now.
     26        (WebCore::parseBlendMode):
     27        (WebCore::parseCompositeAndBlendOperator):
     28        * platform/graphics/GraphicsTypes.h: Reorder BlendMode enumeration values to match
     29         the SVG JS enumeration for blend modes.
     30        * platform/graphics/cpu/arm/filters/FEBlendNEON.h: Move all software code that is no
     31            longer required by the software path but still used by NEON here.
     32        (WebCore::FEBlend::platformApplySoftware):
     33        (WebCore::FEBlend::platformApplyNEON):
     34        * platform/graphics/filters/FEBlend.cpp:
     35            Use drawImageBuffer() to blend the results of previous filter primitives. This
     36            allows removing more than 60% of the code.
     37        (WebCore::FEBlend::FEBlend):
     38        (WebCore::FEBlend::create):
     39        (WebCore::FEBlend::blendMode):
     40        (WebCore::FEBlend::setBlendMode):
     41        (WebCore::FEBlend::platformApplySoftware):
     42        (WebCore::FEBlend::dump):
     43        (WebCore::FEBlend::externalRepresentation):
     44        (WebCore::feBlendNormal): Deleted.
     45        (WebCore::feBlendMultiply): Deleted.
     46        (WebCore::feBlendScreen): Deleted.
     47        (WebCore::feBlendDarken): Deleted.
     48        (WebCore::feBlendLighten): Deleted.
     49        (WebCore::feBlendUnknown): Deleted.
     50        (WebCore::platformApply): Deleted.
     51        (WebCore::FEBlend::platformApplyGeneric): Deleted.
     52        (WebCore::operator<<): Deleted.
     53        * platform/graphics/filters/FEBlend.h:
     54        * svg/SVGAnimatedEnumeration.cpp: Use the global BlendMode enumeration.
     55        (WebCore::enumerationValueForTargetAttribute):
     56        * svg/SVGFEBlendElement.cpp:
     57        (WebCore::SVGFEBlendElement::SVGFEBlendElement): Use the global BlendMode enumeration.
     58            No new enumeration values added or exposed to SVG DOM as requested by SVG WG.
     59        (WebCore::SVGFEBlendElement::parseAttribute):
     60        * svg/SVGFEBlendElement.h: Replace BlendModeType with global BlendMode enumeration. Remove
     61            blend mode parsing code and use the code in GraphicsTypes instead.
     62        (WebCore::SVGPropertyTraits<BlendMode>::highestEnumValue):
     63        (WebCore::SVGPropertyTraits<BlendMode>::toString):
     64        (WebCore::SVGPropertyTraits<BlendModeType>::highestEnumValue): Deleted.
     65        (WebCore::SVGPropertyTraits<BlendModeType>::toString): Deleted.
     66        (WebCore::SVGPropertyTraits<BlendModeType>::fromString): Deleted.
     67
    1682014-06-25  Zalan Bujtas  <zalan@apple.com>
    269
  • trunk/Source/WebCore/platform/graphics/GraphicsTypes.cpp

    r165676 r170433  
    22 * Copyright (C) 2006 Apple Inc.  All rights reserved.
    33 * Copyright (C) 2012 Rik Cabanier (cabanier@adobe.com)
     4 * Copyright (C) 2014 Adobe Systems Incorporated. All rights reserved.
    45 *
    56 * Redistribution and use in source and binary forms, with or without
     
    5051
    5152static const char* const blendOperatorNames[] = {
     53    "normal",
    5254    "multiply",
    5355    "screen",
    54     "overlay",
    5556    "darken",
    5657    "lighten",
     58    "overlay",
    5759    "color-dodge",
    5860    "color-burn",
     
    6971const int numBlendOperatorNames = WTF_ARRAY_LENGTH(blendOperatorNames);
    7072
     73bool parseBlendMode(const String& s, BlendMode& blendMode)
     74{
     75    for (int i = 0; i < numBlendOperatorNames; i++) {
     76        if (s == blendOperatorNames[i]) {
     77            blendMode = static_cast<BlendMode>(i+1);
     78            return true;
     79        }
     80    }
     81   
     82    return false;
     83}
     84
    7185bool parseCompositeAndBlendOperator(const String& s, CompositeOperator& op, BlendMode& blendOp)
    7286{
     
    7993    }
    8094   
    81     for (int i = 0; i < numBlendOperatorNames; i++) {
    82         if (s == blendOperatorNames[i]) {
    83             blendOp = static_cast<BlendMode>(i+1);
    84             // For now, blending will always assume source-over. This will be fixed in the future
    85             op = CompositeSourceOver;
    86             return true;
    87         }
     95    if (parseBlendMode(s, blendOp)) {
     96        // For now, blending will always assume source-over. This will be fixed in the future
     97        op = CompositeSourceOver;
     98        return true;
    8899    }
    89100   
  • trunk/Source/WebCore/platform/graphics/GraphicsTypes.h

    r165676 r170433  
    4949
    5050    enum BlendMode {
    51         BlendModeNormal,
     51        BlendModeNormal = 1, // Start with 1 to match SVG's blendmode enumeration.
    5252        BlendModeMultiply,
    5353        BlendModeScreen,
    54         BlendModeOverlay,
    5554        BlendModeDarken,
    5655        BlendModeLighten,
     56        BlendModeOverlay,
    5757        BlendModeColorDodge,
    5858        BlendModeColorBurn,
     
    8484
    8585    String compositeOperatorName(CompositeOperator, BlendMode);
     86    bool parseBlendMode(const String&, BlendMode&);
    8687    bool parseCompositeAndBlendOperator(const String&, CompositeOperator&, BlendMode&);
    8788
  • trunk/Source/WebCore/platform/graphics/cpu/arm/filters/FEBlendNEON.h

    r143499 r170433  
    22 * Copyright (C) 2012 University of Szeged
    33 * Copyright (C) 2012 Gabor Rapcsanyi
     4 * Copyright (C) 2014 Adobe Systems Incorporated. All rights reserved.
    45 *
    56 * Redistribution and use in source and binary forms, with or without
     
    106107};
    107108
     109void FEBlend::platformApplySoftware()
     110{
     111    FilterEffect* in = inputEffect(0);
     112    FilterEffect* in2 = inputEffect(1);
     113
     114    Uint8ClampedArray* dstPixelArray = createPremultipliedImageResult();
     115    if (!dstPixelArray)
     116        return;
     117
     118    IntRect effectADrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect());
     119    RefPtr<Uint8ClampedArray> srcPixelArrayA = in->asPremultipliedImage(effectADrawingRect);
     120
     121    IntRect effectBDrawingRect = requestedRegionOfInputImageData(in2->absolutePaintRect());
     122    RefPtr<Uint8ClampedArray> srcPixelArrayB = in2->asPremultipliedImage(effectBDrawingRect);
     123
     124    unsigned pixelArrayLength = srcPixelArrayA->length();
     125    ASSERT(pixelArrayLength == srcPixelArrayB->length());
     126
     127    if (pixelArrayLength >= 8) {
     128        platformApplyNEON(srcPixelArrayA->data(), srcPixelArrayB->data(), dstPixelArray->data(), pixelArrayLength);
     129        return
     130    }
     131    // If there is just one pixel we expand it to two.
     132    ASSERT(pixelArrayLength > 0);
     133    uint32_t sourceA[2] = {0, 0};
     134    uint32_t sourceBAndDest[2] = {0, 0};
     135
     136    sourceA[0] = reinterpret_cast<uint32_t*>(srcPixelArrayA->data())[0];
     137    sourceBAndDest[0] = reinterpret_cast<uint32_t*>(srcPixelArrayB->data())[0];
     138    platformApplyNEON(reinterpret_cast<uint8_t*>(sourceA), reinterpret_cast<uint8_t*>(sourceBAndDest), reinterpret_cast<uint8_t*>(sourceBAndDest), 8);
     139    reinterpret_cast<uint32_t*>(dstPixelArray->data())[0] = sourceBAndDest[0];
     140}
     141
    108142void FEBlend::platformApplyNEON(unsigned char* srcPixelArrayA, unsigned char* srcPixelArrayB, unsigned char* dstPixelArray,
    109143                                unsigned colorArrayLength)
     
    130164        uint16x8_t result;
    131165        switch (m_mode) {
    132         case FEBLEND_MODE_NORMAL:
     166        case BlendModeNormal:
    133167            result = FEBlendUtilitiesNEON::normal(doubblePixelA, doubblePixelB, alphaA, alphaB, sixteenConst255, sixteenConstOne);
    134168            break;
    135         case FEBLEND_MODE_MULTIPLY:
     169        case BlendModeMultiply:
    136170            result = FEBlendUtilitiesNEON::multiply(doubblePixelA, doubblePixelB, alphaA, alphaB, sixteenConst255, sixteenConstOne);
    137171            break;
    138         case FEBLEND_MODE_SCREEN:
     172        case BlendModeScreen:
    139173            result = FEBlendUtilitiesNEON::screen(doubblePixelA, doubblePixelB, alphaA, alphaB, sixteenConst255, sixteenConstOne);
    140174            break;
    141         case FEBLEND_MODE_DARKEN:
     175        case BlendModeDarken:
    142176            result = FEBlendUtilitiesNEON::darken(doubblePixelA, doubblePixelB, alphaA, alphaB, sixteenConst255, sixteenConstOne);
    143177            break;
    144         case FEBLEND_MODE_LIGHTEN:
     178        case BlendModeLighten:
    145179            result = FEBlendUtilitiesNEON::lighten(doubblePixelA, doubblePixelB, alphaA, alphaB, sixteenConst255, sixteenConstOne);
    146180            break;
    147         case FEBLEND_MODE_UNKNOWN:
    148181        default:
    149182            result = vdupq_n_u16(0);
  • trunk/Source/WebCore/platform/graphics/filters/FEBlend.cpp

    r158183 r170433  
    55 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
    66 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
     7 * Copyright (C) 2014 Adobe Systems Incorporated. All rights reserved.
    78 *
    89 * This library is free software; you can redistribute it and/or
     
    3536#include <runtime/Uint8ClampedArray.h>
    3637
    37 typedef unsigned char (*BlendType)(unsigned char colorA, unsigned char colorB, unsigned char alphaA, unsigned char alphaB);
    38 
    3938namespace WebCore {
    4039
    41 FEBlend::FEBlend(Filter* filter, BlendModeType mode)
     40FEBlend::FEBlend(Filter* filter, BlendMode mode)
    4241    : FilterEffect(filter)
    4342    , m_mode(mode)
     
    4544}
    4645
    47 PassRefPtr<FEBlend> FEBlend::create(Filter* filter, BlendModeType mode)
     46PassRefPtr<FEBlend> FEBlend::create(Filter* filter, BlendMode mode)
    4847{
    4948    return adoptRef(new FEBlend(filter, mode));
    5049}
    5150
    52 BlendModeType FEBlend::blendMode() const
     51BlendMode FEBlend::blendMode() const
    5352{
    5453    return m_mode;
    5554}
    5655
    57 bool FEBlend::setBlendMode(BlendModeType mode)
     56bool FEBlend::setBlendMode(BlendMode mode)
    5857{
    5958    if (m_mode == mode)
     
    6362}
    6463
    65 inline unsigned char feBlendNormal(unsigned char colorA, unsigned char colorB, unsigned char alphaA, unsigned char)
    66 {
    67     return fastDivideBy255((255 - alphaA) * colorB + colorA * 255);
    68 }
    69 
    70 inline unsigned char feBlendMultiply(unsigned char colorA, unsigned char colorB, unsigned char alphaA, unsigned char alphaB)
    71 {
    72     return fastDivideBy255((255 - alphaA) * colorB + (255 - alphaB + colorB) * colorA);
    73 }
    74 
    75 inline unsigned char feBlendScreen(unsigned char colorA, unsigned char colorB, unsigned char, unsigned char)
    76 {
    77     return fastDivideBy255((colorB + colorA) * 255 - colorA * colorB);
    78 }
    79 
    80 inline unsigned char feBlendDarken(unsigned char colorA, unsigned char colorB, unsigned char alphaA, unsigned char alphaB)
    81 {
    82     return fastDivideBy255(std::min((255 - alphaA) * colorB + colorA * 255, (255 - alphaB) * colorA + colorB * 255));
    83 }
    84 
    85 inline unsigned char feBlendLighten(unsigned char colorA, unsigned char colorB, unsigned char alphaA, unsigned char alphaB)
    86 {
    87     return fastDivideBy255(std::max((255 - alphaA) * colorB + colorA * 255, (255 - alphaB) * colorA + colorB * 255));
    88 }
    89 
    90 inline unsigned char feBlendUnknown(unsigned char, unsigned char, unsigned char, unsigned char)
    91 {
    92     return 0;
    93 }
    94 
    95 template<BlendType BlendFunction>
    96 static void platformApply(unsigned char* sourcePixelA, unsigned char* sourcePixelB,
    97                           unsigned char* destinationPixel, unsigned pixelArrayLength)
    98 {
    99     unsigned len = pixelArrayLength / 4;
    100     for (unsigned pixelOffset = 0; pixelOffset < len; pixelOffset++) {
    101         unsigned char alphaA = sourcePixelA[3];
    102         unsigned char alphaB = sourcePixelB[3];
    103         destinationPixel[0] = BlendFunction(sourcePixelA[0], sourcePixelB[0], alphaA, alphaB);
    104         destinationPixel[1] = BlendFunction(sourcePixelA[1], sourcePixelB[1], alphaA, alphaB);
    105         destinationPixel[2] = BlendFunction(sourcePixelA[2], sourcePixelB[2], alphaA, alphaB);
    106         destinationPixel[3] = 255 - fastDivideBy255((255 - alphaA) * (255 - alphaB));
    107         sourcePixelA += 4;
    108         sourcePixelB += 4;
    109         destinationPixel += 4;
    110     }
    111 }
    112 
    113 void FEBlend::platformApplyGeneric(unsigned char* sourcePixelA, unsigned char* sourcePixelB,
    114                                    unsigned char* destinationPixel, unsigned pixelArrayLength)
    115 {
    116     switch (m_mode) {
    117     case FEBLEND_MODE_NORMAL:
    118         platformApply<feBlendNormal>(sourcePixelA, sourcePixelB, destinationPixel, pixelArrayLength);
    119         break;
    120     case FEBLEND_MODE_MULTIPLY:
    121         platformApply<feBlendMultiply>(sourcePixelA, sourcePixelB, destinationPixel, pixelArrayLength);
    122         break;
    123     case FEBLEND_MODE_SCREEN:
    124         platformApply<feBlendScreen>(sourcePixelA, sourcePixelB, destinationPixel, pixelArrayLength);
    125         break;
    126     case FEBLEND_MODE_DARKEN:
    127         platformApply<feBlendDarken>(sourcePixelA, sourcePixelB, destinationPixel, pixelArrayLength);
    128         break;
    129     case FEBLEND_MODE_LIGHTEN:
    130         platformApply<feBlendLighten>(sourcePixelA, sourcePixelB, destinationPixel, pixelArrayLength);
    131         break;
    132     case FEBLEND_MODE_UNKNOWN:
    133         platformApply<feBlendUnknown>(sourcePixelA, sourcePixelB, destinationPixel, pixelArrayLength);
    134         break;
    135     }
    136 }
    137 
     64#if !HAVE(ARM_NEON_INTRINSICS)
    13865void FEBlend::platformApplySoftware()
    13966{
     
    14168    FilterEffect* in2 = inputEffect(1);
    14269
    143     ASSERT(m_mode > FEBLEND_MODE_UNKNOWN);
    144     ASSERT(m_mode <= FEBLEND_MODE_LIGHTEN);
     70    ImageBuffer* resultImage = createImageBufferResult();
     71    if (!resultImage)
     72        return;
     73    GraphicsContext* filterContext = resultImage->context();
    14574
    146     Uint8ClampedArray* dstPixelArray = createPremultipliedImageResult();
    147     if (!dstPixelArray)
    148         return;
     75    ImageBuffer* imageBuffer = in->asImageBuffer();
     76    ImageBuffer* imageBuffer2 = in2->asImageBuffer();
     77    ASSERT(imageBuffer);
     78    ASSERT(imageBuffer2);
    14979
    150     IntRect effectADrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect());
    151     RefPtr<Uint8ClampedArray> srcPixelArrayA = in->asPremultipliedImage(effectADrawingRect);
    152 
    153     IntRect effectBDrawingRect = requestedRegionOfInputImageData(in2->absolutePaintRect());
    154     RefPtr<Uint8ClampedArray> srcPixelArrayB = in2->asPremultipliedImage(effectBDrawingRect);
    155 
    156     unsigned pixelArrayLength = srcPixelArrayA->length();
    157     ASSERT(pixelArrayLength == srcPixelArrayB->length());
    158 
    159 #if HAVE(ARM_NEON_INTRINSICS)
    160     if (pixelArrayLength >= 8)
    161         platformApplyNEON(srcPixelArrayA->data(), srcPixelArrayB->data(), dstPixelArray->data(), pixelArrayLength);
    162     else { // If there is just one pixel we expand it to two.
    163         ASSERT(pixelArrayLength > 0);
    164         uint32_t sourceA[2] = {0, 0};
    165         uint32_t sourceBAndDest[2] = {0, 0};
    166 
    167         sourceA[0] = reinterpret_cast<uint32_t*>(srcPixelArrayA->data())[0];
    168         sourceBAndDest[0] = reinterpret_cast<uint32_t*>(srcPixelArrayB->data())[0];
    169         platformApplyNEON(reinterpret_cast<uint8_t*>(sourceA), reinterpret_cast<uint8_t*>(sourceBAndDest), reinterpret_cast<uint8_t*>(sourceBAndDest), 8);
    170         reinterpret_cast<uint32_t*>(dstPixelArray->data())[0] = sourceBAndDest[0];
    171     }
    172 #else
    173     platformApplyGeneric(srcPixelArrayA->data(), srcPixelArrayB->data(), dstPixelArray->data(), pixelArrayLength);
     80    filterContext->drawImageBuffer(imageBuffer2, ColorSpaceDeviceRGB, drawingRegionOfInputImage(in2->absolutePaintRect()));
     81    filterContext->drawImageBuffer(imageBuffer, ColorSpaceDeviceRGB, drawingRegionOfInputImage(in->absolutePaintRect()), IntRect(IntPoint(), imageBuffer->logicalSize()), ImagePaintingOptions(CompositeSourceOver, m_mode));
     82}
    17483#endif
    175 }
    17684
    17785void FEBlend::dump()
    17886{
    179 }
    180 
    181 static TextStream& operator<<(TextStream& ts, const BlendModeType& type)
    182 {
    183     switch (type) {
    184     case FEBLEND_MODE_UNKNOWN:
    185         ts << "UNKNOWN";
    186         break;
    187     case FEBLEND_MODE_NORMAL:
    188         ts << "NORMAL";
    189         break;
    190     case FEBLEND_MODE_MULTIPLY:
    191         ts << "MULTIPLY";
    192         break;
    193     case FEBLEND_MODE_SCREEN:
    194         ts << "SCREEN";
    195         break;
    196     case FEBLEND_MODE_DARKEN:
    197         ts << "DARKEN";
    198         break;
    199     case FEBLEND_MODE_LIGHTEN:
    200         ts << "LIGHTEN";
    201         break;
    202     }
    203     return ts;
    20487}
    20588
     
    20992    ts << "[feBlend";
    21093    FilterEffect::externalRepresentation(ts);
    211     ts << " mode=\"" << m_mode << "\"]\n";
     94    ts << " mode=\"" << (m_mode == BlendModeNormal ? "normal" : compositeOperatorName(CompositeSourceOver, m_mode)) << "\"]\n";
    21295    inputEffect(0)->externalRepresentation(ts, indent + 1);
    21396    inputEffect(1)->externalRepresentation(ts, indent + 1);
  • trunk/Source/WebCore/platform/graphics/filters/FEBlend.h

    r149193 r170433  
    33 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
    44 * Copyright (C) 2005 Eric Seidel <eric@webkit.org>
     5 * Copyright (C) 2014 Adobe Systems Incorporated. All rights reserved.
    56 *
    67 * This library is free software; you can redistribute it and/or
     
    3031namespace WebCore {
    3132
    32 enum BlendModeType {
    33     FEBLEND_MODE_UNKNOWN = 0,
    34     FEBLEND_MODE_NORMAL = 1,
    35     FEBLEND_MODE_MULTIPLY = 2,
    36     FEBLEND_MODE_SCREEN = 3,
    37     FEBLEND_MODE_DARKEN = 4,
    38     FEBLEND_MODE_LIGHTEN = 5
    39 };
    40 
    4133class FEBlend : public FilterEffect {
    4234public:
    43     static PassRefPtr<FEBlend> create(Filter*, BlendModeType);
     35    static PassRefPtr<FEBlend> create(Filter*, BlendMode);
    4436
    45     BlendModeType blendMode() const;
    46     bool setBlendMode(BlendModeType);
     37    BlendMode blendMode() const;
     38    bool setBlendMode(BlendMode);
    4739
    4840    void platformApplyGeneric(unsigned char* srcPixelArrayA, unsigned char* srcPixelArrayB, unsigned char* dstPixelArray,
     
    5648
    5749private:
    58     FEBlend(Filter*, BlendModeType);
     50    FEBlend(Filter*, BlendMode);
    5951
    60     BlendModeType m_mode;
     52    BlendMode m_mode;
    6153};
    6254
  • trunk/Source/WebCore/svg/SVGAnimatedEnumeration.cpp

    r163440 r170433  
    8787    }
    8888
    89     if (attrName == SVGNames::modeAttr)
    90         return SVGPropertyTraits<BlendModeType>::fromString(value);
     89    if (attrName == SVGNames::modeAttr) {
     90        BlendMode mode = BlendModeNormal;
     91        parseBlendMode(value, mode);
     92        return mode;
     93    }
    9194    if (attrName == SVGNames::stitchTilesAttr)
    9295        return SVGPropertyTraits<SVGStitchOptions>::fromString(value);
  • trunk/Source/WebCore/svg/SVGFEBlendElement.cpp

    r168469 r170433  
    22 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
    33 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
     4 * Copyright (C) 2014 Adobe Systems Incorporated. All rights reserved.
    45 *
    56 * This library is free software; you can redistribute it and/or
     
    3637DEFINE_ANIMATED_STRING(SVGFEBlendElement, SVGNames::inAttr, In1, in1)
    3738DEFINE_ANIMATED_STRING(SVGFEBlendElement, SVGNames::in2Attr, In2, in2)
    38 DEFINE_ANIMATED_ENUMERATION(SVGFEBlendElement, SVGNames::modeAttr, Mode, mode, BlendModeType)
     39DEFINE_ANIMATED_ENUMERATION(SVGFEBlendElement, SVGNames::modeAttr, Mode, mode, BlendMode)
    3940
    4041BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGFEBlendElement)
     
    4748inline SVGFEBlendElement::SVGFEBlendElement(const QualifiedName& tagName, Document& document)
    4849    : SVGFilterPrimitiveStandardAttributes(tagName, document)
    49     , m_mode(FEBLEND_MODE_NORMAL)
     50    , m_mode(BlendModeNormal)
    5051{
    5152    ASSERT(hasTagName(SVGNames::feBlendTag));
     
    7778
    7879    if (name == SVGNames::modeAttr) {
    79         BlendModeType propertyValue = SVGPropertyTraits<BlendModeType>::fromString(value);
    80         if (propertyValue > 0)
    81             setModeBaseValue(propertyValue);
     80        BlendMode mode = BlendModeNormal;
     81        if (parseBlendMode(value, mode))
     82            setModeBaseValue(mode);
    8283        return;
    8384    }
  • trunk/Source/WebCore/svg/SVGFEBlendElement.h

    r163440 r170433  
    22 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
    33 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
     4 * Copyright (C) 2014 Adobe Systems Incorporated. All rights reserved.
    45 *
    56 * This library is free software; you can redistribute it and/or
     
    3031
    3132template<>
    32 struct SVGPropertyTraits<BlendModeType> {
    33     static unsigned highestEnumValue() { return FEBLEND_MODE_LIGHTEN; }
     33struct SVGPropertyTraits<BlendMode> {
     34    static unsigned highestEnumValue() { return BlendModeLighten; }
    3435
    35     static String toString(BlendModeType type)
     36    static String toString(BlendMode type)
    3637    {
    3738        switch (type) {
    38         case FEBLEND_MODE_UNKNOWN:
     39        case BlendModeNormal:
     40            return "normal";
     41        case BlendModeMultiply:
     42            return "multiply";
     43        case BlendModeScreen:
     44            return "screen";
     45        case BlendModeDarken:
     46            return "darken";
     47        case BlendModeLighten:
     48            return "lighten";
     49        default:
    3950            return emptyString();
    40         case FEBLEND_MODE_NORMAL:
    41             return "normal";
    42         case FEBLEND_MODE_MULTIPLY:
    43             return "multiply";
    44         case FEBLEND_MODE_SCREEN:
    45             return "screen";
    46         case FEBLEND_MODE_DARKEN:
    47             return "darken";
    48         case FEBLEND_MODE_LIGHTEN:
    49             return "lighten";
    5051        }
    51 
    52         ASSERT_NOT_REACHED();
    53         return emptyString();
    54     }
    55 
    56     static BlendModeType fromString(const String& value)
    57     {
    58         if (value == "normal")
    59             return FEBLEND_MODE_NORMAL;
    60         if (value == "multiply")
    61             return FEBLEND_MODE_MULTIPLY;
    62         if (value == "screen")
    63             return FEBLEND_MODE_SCREEN;
    64         if (value == "darken")
    65             return FEBLEND_MODE_DARKEN;
    66         if (value == "lighten")
    67             return FEBLEND_MODE_LIGHTEN;
    68         return FEBLEND_MODE_UNKNOWN;
    6952    }
    7053};
     
    8669        DECLARE_ANIMATED_STRING(In1, in1)
    8770        DECLARE_ANIMATED_STRING(In2, in2)
    88         DECLARE_ANIMATED_ENUMERATION(Mode, mode, BlendModeType)
     71        DECLARE_ANIMATED_ENUMERATION(Mode, mode, BlendMode)
    8972    END_DECLARE_ANIMATED_PROPERTIES
    9073};
Note: See TracChangeset for help on using the changeset viewer.