Changeset 139804 in webkit


Ignore:
Timestamp:
Jan 15, 2013 3:58:42 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Add Canvas blend modes to Cairo
https://bugs.webkit.org/show_bug.cgi?id=105074

Patch by Arnaud Renevier <a.renevier@sisa.samsung.com> on 2013-01-15
Reviewed by Martin Robinson.

Source/WebCore:

Blend mode implementation for cairo. If BlendMode is normal, use
CompositeOperator; otherwise, consider CompositeOperator is
source-over.

Add toCairoOperator(BlendMode) to translate BlendMode to matching
cairo_operator_t.

  • platform/graphics/cairo/BitmapImageCairo.cpp:

(WebCore::BitmapImage::draw):

  • platform/graphics/cairo/CairoUtilities.cpp:

(WebCore::toCairoOperator):

  • platform/graphics/cairo/CairoUtilities.h:

(WebCore):

  • platform/graphics/cairo/GraphicsContextCairo.cpp:

(WebCore::GraphicsContext::setPlatformCompositeOperation):

LayoutTests:

Unskip fast/canvas/canvas-blend-image.html and
fast/canvas/canvas-blend-solid.html

Add platform specific expected files because currently, expected
results are not correct.

  • platform/gtk/TestExpectations:
  • platform/gtk/fast/canvas/canvas-blend-image-expected.txt: Added.
  • platform/gtk/fast/canvas/canvas-blend-solid-expected.txt: Added.
Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r139803 r139804  
     12013-01-15  Arnaud Renevier  <a.renevier@sisa.samsung.com>
     2
     3        Add Canvas blend modes to Cairo
     4        https://bugs.webkit.org/show_bug.cgi?id=105074
     5
     6        Reviewed by Martin Robinson.
     7
     8        Unskip fast/canvas/canvas-blend-image.html and
     9        fast/canvas/canvas-blend-solid.html
     10
     11        Add platform specific expected files because currently, expected
     12        results are not correct.
     13
     14        * platform/gtk/TestExpectations:
     15        * platform/gtk/fast/canvas/canvas-blend-image-expected.txt: Added.
     16        * platform/gtk/fast/canvas/canvas-blend-solid-expected.txt: Added.
     17
    1182013-01-15  Dima Gorbik  <dgorbik@apple.com>
    219
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r139768 r139804  
    322322webkit.org/b/71849 inspector-protocol/layer-tree.html [ Failure ]
    323323webkit.org/b/71849 transforms/3d [ Skip ]
    324 
    325 # The following test fail because blending is not yet implemented
    326 webkit.org/b/105543 fast/canvas/canvas-blend-image.html [ Skip ]
    327 webkit.org/b/105543 fast/canvas/canvas-blend-solid.html [ Skip ]
    328324
    329325# LAYER_TREE_INCLUDES_VISIBLE_RECTS option to layerTreeAsText is only applicable to Mac.
  • trunk/Source/WebCore/ChangeLog

    r139803 r139804  
     12013-01-15  Arnaud Renevier  <a.renevier@sisa.samsung.com>
     2
     3        Add Canvas blend modes to Cairo
     4        https://bugs.webkit.org/show_bug.cgi?id=105074
     5
     6        Reviewed by Martin Robinson.
     7
     8        Blend mode implementation for cairo. If BlendMode is normal, use
     9        CompositeOperator; otherwise, consider CompositeOperator is
     10        source-over.
     11
     12        Add toCairoOperator(BlendMode) to translate BlendMode to matching
     13        cairo_operator_t.
     14
     15        * platform/graphics/cairo/BitmapImageCairo.cpp:
     16        (WebCore::BitmapImage::draw):
     17        * platform/graphics/cairo/CairoUtilities.cpp:
     18        (WebCore::toCairoOperator):
     19        * platform/graphics/cairo/CairoUtilities.h:
     20        (WebCore):
     21        * platform/graphics/cairo/GraphicsContextCairo.cpp:
     22        (WebCore::GraphicsContext::setPlatformCompositeOperation):
     23
    1242013-01-15  Dima Gorbik  <dgorbik@apple.com>
    225        Implement matching by the voice attribute for WebVTT ::cue pseudo element
  • trunk/Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp

    r137011 r139804  
    7878
    7979void BitmapImage::draw(GraphicsContext* context, const FloatRect& dst, const FloatRect& src, ColorSpace styleColorSpace, CompositeOperator op,
    80     BlendMode, RespectImageOrientationEnum shouldRespectImageOrientation)
     80    BlendMode blendMode, RespectImageOrientationEnum shouldRespectImageOrientation)
    8181{
    8282    if (!dst.width() || !dst.height() || !src.width() || !src.height())
     
    9797
    9898    // Set the compositing operation.
    99     if (op == CompositeSourceOver && !frameHasAlphaAtIndex(m_currentFrame))
     99    if (op == CompositeSourceOver && blendMode == BlendModeNormal && !frameHasAlphaAtIndex(m_currentFrame))
    100100        context->setCompositeOperation(CompositeCopy);
    101101    else
    102         context->setCompositeOperation(op);
     102        context->setCompositeOperation(op, blendMode);
    103103
    104104#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
  • trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp

    r124135 r139804  
    132132    }
    133133}
     134cairo_operator_t toCairoOperator(BlendMode blendOp)
     135{
     136    switch (blendOp) {
     137    case BlendModeNormal:
     138        return CAIRO_OPERATOR_OVER;
     139    case BlendModeMultiply:
     140        return CAIRO_OPERATOR_MULTIPLY;
     141    case BlendModeScreen:
     142        return CAIRO_OPERATOR_SCREEN;
     143    case BlendModeOverlay:
     144        return CAIRO_OPERATOR_OVERLAY;
     145    case BlendModeDarken:
     146        return CAIRO_OPERATOR_DARKEN;
     147    case BlendModeLighten:
     148        return CAIRO_OPERATOR_LIGHTEN;
     149    case BlendModeColorDodge:
     150        return CAIRO_OPERATOR_COLOR_DODGE;
     151    case BlendModeColorBurn:
     152        return CAIRO_OPERATOR_COLOR_BURN;
     153    case BlendModeHardLight:
     154        return CAIRO_OPERATOR_HARD_LIGHT;
     155    case BlendModeSoftLight:
     156        return CAIRO_OPERATOR_SOFT_LIGHT;
     157    case BlendModeDifference:
     158        return CAIRO_OPERATOR_DIFFERENCE;
     159    case BlendModeExclusion:
     160        return CAIRO_OPERATOR_EXCLUSION;
     161    case BlendModeHue:
     162        return CAIRO_OPERATOR_HSL_HUE;
     163    case BlendModeSaturation:
     164        return CAIRO_OPERATOR_HSL_SATURATION;
     165    case BlendModeColor:
     166        return CAIRO_OPERATOR_HSL_COLOR;
     167    case BlendModeLuminosity:
     168        return CAIRO_OPERATOR_HSL_LUMINOSITY;
     169    default:
     170        return CAIRO_OPERATOR_OVER;
     171    }
     172}
    134173
    135174void drawPatternToCairoContext(cairo_t* cr, cairo_surface_t* image, const IntSize& imageSize, const FloatRect& tileRect,
  • trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.h

    r98827 r139804  
    4747void appendRegionToCairoContext(cairo_t*, const cairo_region_t*);
    4848cairo_operator_t toCairoOperator(CompositeOperator op);
     49cairo_operator_t toCairoOperator(BlendMode blendOp);
    4950void drawPatternToCairoContext(cairo_t* cr, cairo_surface_t* image, const IntSize& imageSize, const FloatRect& tileRect,
    5051                               const AffineTransform& patternTransform, const FloatPoint& phase, cairo_operator_t op, const FloatRect& destRect);
  • trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp

    r139138 r139804  
    984984}
    985985
    986 void GraphicsContext::setPlatformCompositeOperation(CompositeOperator op, BlendMode)
    987 {
    988     if (paintingDisabled())
    989         return;
    990 
    991     cairo_set_operator(platformContext()->cr(), toCairoOperator(op));
     986void GraphicsContext::setPlatformCompositeOperation(CompositeOperator op, BlendMode blendOp)
     987{
     988    if (paintingDisabled())
     989        return;
     990
     991    cairo_operator_t cairo_op;
     992    if (blendOp == BlendModeNormal)
     993        cairo_op = toCairoOperator(op);
     994    else
     995        cairo_op = toCairoOperator(blendOp);
     996
     997    cairo_set_operator(platformContext()->cr(), cairo_op);
    992998}
    993999
Note: See TracChangeset for help on using the changeset viewer.