| Differences between
and this patch
- a/Source/WebCore/ChangeLog +22 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2013-10-16  YongGeol Jung  <yg48.jung@samsung.com>
2
3
        [cairo] ShadowBlur is extremely slow when canvas's scale is very small.
4
        https://bugs.webkit.org/show_bug.cgi?id=120346
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Drawing of shadow-blur is too slow when the canvas scale value is small.
9
        If the canvas blur value is 100 and the scale is 0.01, the blur radius becomes 10,000
10
        and most of the processing time is used to blur the layer.
11
12
        To improve the performance,
13
        first create the layer(for blurring) with applying the canvas scale and set the scale of the target context to 1,
14
        then copy it to the target.
15
16
        * platform/graphics/ShadowBlur.cpp:
17
        (WebCore::ShadowBlur::useScaledBlurLayer):
18
        (WebCore::ShadowBlur::calculateLayerBoundingRect):
19
        (WebCore::ShadowBlur::beginShadowLayer):
20
        (WebCore::ShadowBlur::endShadowLayer):
21
        * platform/graphics/ShadowBlur.h:
22
1
2013-10-16  Tim Horton  <timothy_horton@apple.com>
23
2013-10-16  Tim Horton  <timothy_horton@apple.com>
2
24
3
        Attempt to fix the Windows build after http://trac.webkit.org/changeset/157547.
25
        Attempt to fix the Windows build after http://trac.webkit.org/changeset/157547.
- a/Source/WebCore/platform/graphics/ShadowBlur.cpp -4 / +36 lines
Lines 397-403 IntSize ShadowBlur::blurredEdgeSize() const a/Source/WebCore/platform/graphics/ShadowBlur.cpp_sec1
397
    return edgeSize;
397
    return edgeSize;
398
}
398
}
399
399
400
IntRect ShadowBlur::calculateLayerBoundingRect(GraphicsContext* context, const FloatRect& shadowedRect, const IntRect& clipRect)
400
bool ShadowBlur::useScaledBlurLayer(GraphicsContext* context)
401
{
402
    if (!m_shadowsIgnoreTransforms)
403
        return false;
404
405
    AffineTransform transform = context->getCTM();
406
    if (!transform.isIdentity() && transform.xScale() < 1 && transform.yScale() < 1)
407
        return true;
408
409
    return false;
410
}
411
412
IntRect ShadowBlur::calculateLayerBoundingRect(GraphicsContext* context, const FloatRect& shadowedRect, const IntRect& clipRect, const bool scaledBlurLayer)
401
{
413
{
402
    IntSize edgeSize = blurredEdgeSize();
414
    IntSize edgeSize = blurredEdgeSize();
403
415
Lines 405-412 IntRect ShadowBlur::calculateLayerBoundingRect(GraphicsContext* context, const F a/Source/WebCore/platform/graphics/ShadowBlur.cpp_sec2
405
    FloatRect layerRect;
417
    FloatRect layerRect;
406
    IntSize inflation;
418
    IntSize inflation;
407
419
408
    const AffineTransform transform = context->getCTM();
420
    AffineTransform transform = context->getCTM();
409
    if (m_shadowsIgnoreTransforms && !transform.isIdentity()) {
421
    if (m_shadowsIgnoreTransforms && !transform.isIdentity()) {
422
        // Before drawing the shadows, the scale factor of context is 1.
423
        // So, the positions and sizes of rectangles should be calculated as considering the scale factor is 1.
424
        if (scaledBlurLayer)
425
            transform.scale(1 / transform.xScale(), 1 / transform.yScale());
426
410
        FloatQuad transformedPolygon = transform.mapQuad(FloatQuad(shadowedRect));
427
        FloatQuad transformedPolygon = transform.mapQuad(FloatQuad(shadowedRect));
411
        transformedPolygon.move(m_offset);
428
        transformedPolygon.move(m_offset);
412
        layerRect = transform.inverse().mapQuad(transformedPolygon).boundingBox();
429
        layerRect = transform.inverse().mapQuad(transformedPolygon).boundingBox();
Lines 885-893 void ShadowBlur::blurAndColorShadowBuffer(const IntSize& templateSize) a/Source/WebCore/platform/graphics/ShadowBlur.cpp_sec3
885
902
886
GraphicsContext* ShadowBlur::beginShadowLayer(GraphicsContext *context, const FloatRect& layerArea)
903
GraphicsContext* ShadowBlur::beginShadowLayer(GraphicsContext *context, const FloatRect& layerArea)
887
{
904
{
888
    adjustBlurRadius(context);
905
    FloatRect scaledLayerArea = layerArea;
906
    AffineTransform transform = context->getCTM();
907
    bool scaledBlurLayer = useScaledBlurLayer(context);
908
909
    if (scaledBlurLayer)
910
        scaledLayerArea.scale(static_cast<float>(transform.xScale()), static_cast<float>(transform.yScale()));
911
    else
912
        adjustBlurRadius(context);
889
913
890
    IntRect layerRect = calculateLayerBoundingRect(context, layerArea, context->clipBounds());
914
    IntRect layerRect = calculateLayerBoundingRect(context, scaledLayerArea, context->clipBounds(), scaledBlurLayer);
891
915
892
    if (layerRect.isEmpty())
916
    if (layerRect.isEmpty())
893
        return 0;
917
        return 0;
Lines 904-909 GraphicsContext* ShadowBlur::beginShadowLayer(GraphicsContext *context, const Fl a/Source/WebCore/platform/graphics/ShadowBlur.cpp_sec4
904
    shadowContext->clearRect(FloatRect(0, 0, m_layerSize.width() + 1, m_layerSize.height() + 1));
928
    shadowContext->clearRect(FloatRect(0, 0, m_layerSize.width() + 1, m_layerSize.height() + 1));
905
929
906
    shadowContext->translate(m_layerContextTranslation);
930
    shadowContext->translate(m_layerContextTranslation);
931
932
    if (scaledBlurLayer)
933
        shadowContext->scale(FloatSize(static_cast<float>(transform.xScale()), static_cast<float>(transform.yScale())));
934
907
    return shadowContext;
935
    return shadowContext;
908
}
936
}
909
937
Lines 914-919 void ShadowBlur::endShadowLayer(GraphicsContext* context) a/Source/WebCore/platform/graphics/ShadowBlur.cpp_sec5
914
    blurAndColorShadowBuffer(expandedIntSize(m_layerSize));
942
    blurAndColorShadowBuffer(expandedIntSize(m_layerSize));
915
    GraphicsContextStateSaver stateSave(*context);
943
    GraphicsContextStateSaver stateSave(*context);
916
944
945
    if (useScaledBlurLayer(context)) {
946
        AffineTransform transform = context->getCTM();
947
        context->scale(FloatSize(1 / static_cast<float>(transform.xScale()), 1 / static_cast<float>(transform.yScale())));
948
    }
917
    context->clearShadow();
949
    context->clearShadow();
918
    context->drawImageBuffer(m_layerImage, ColorSpaceDeviceRGB, roundedIntPoint(m_layerOrigin), IntRect(0, 0, m_layerSize.width(), m_layerSize.height()), context->compositeOperation());
950
    context->drawImageBuffer(m_layerImage, ColorSpaceDeviceRGB, roundedIntPoint(m_layerOrigin), IntRect(0, 0, m_layerSize.width(), m_layerSize.height()), context->compositeOperation());
919
951
- a/Source/WebCore/platform/graphics/ShadowBlur.h -1 / +2 lines
Lines 84-90 private: a/Source/WebCore/platform/graphics/ShadowBlur.h_sec1
84
        InnerShadow
84
        InnerShadow
85
    };
85
    };
86
    
86
    
87
    IntRect calculateLayerBoundingRect(GraphicsContext*, const FloatRect& layerArea, const IntRect& clipRect);
87
    IntRect calculateLayerBoundingRect(GraphicsContext*, const FloatRect& layerArea, const IntRect& clipRect, const bool scaledBlurLayer = false);
88
    IntSize templateSize(const IntSize& blurredEdgeSize, const RoundedRect::Radii&) const;
88
    IntSize templateSize(const IntSize& blurredEdgeSize, const RoundedRect::Radii&) const;
89
89
90
    void drawRectShadowWithoutTiling(GraphicsContext*, const FloatRect&, const RoundedRect::Radii&, const IntRect& layerRect);
90
    void drawRectShadowWithoutTiling(GraphicsContext*, const FloatRect&, const RoundedRect::Radii&, const IntRect& layerRect);
Lines 100-105 private: a/Source/WebCore/platform/graphics/ShadowBlur.h_sec2
100
    
100
    
101
    IntSize blurredEdgeSize() const;
101
    IntSize blurredEdgeSize() const;
102
    
102
    
103
    bool useScaledBlurLayer(GraphicsContext*);
103
    
104
    
104
    ShadowType m_type;
105
    ShadowType m_type;
105
106

Return to Bug 120346