| Differences between
and this patch
- a/Source/WebCore/ChangeLog +19 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2013-08-27  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
        ShadowBlur drawing is too slow if scale of canvas is set to very small value such as 0.01.
9
        The main reason is blurRadius gets huge value if scale is small.
10
        If shadow value is 100 with 0.01 scale value, blurRadius will be 10000.
11
        Almost time is consumed to make blurred-layer.
12
13
        * platform/graphics/ShadowBlur.cpp:
14
        (WebCore::ShadowBlur::useScaledBlurLayer):
15
        (WebCore::ShadowBlur::calculateLayerBoundingRect):
16
        (WebCore::ShadowBlur::beginShadowLayer):
17
        (WebCore::ShadowBlur::endShadowLayer):
18
        * platform/graphics/ShadowBlur.h:
19
1
2013-08-26  Sam Weinig  <sam@webkit.org>
20
2013-08-26  Sam Weinig  <sam@webkit.org>
2
21
3
        EditorInternalCommand should use Frame& where possible
22
        EditorInternalCommand should use Frame& where possible
- a/Source/WebCore/platform/graphics/ShadowBlur.cpp -4 / +29 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
    const AffineTransform transform = context->getCTM();
403
    if (m_shadowsIgnoreTransforms && !transform.isIdentity() && transform.xScale() < 1 && transform.yScale() < 1)
404
        return true;
405
406
    return false;
407
}
408
409
IntRect ShadowBlur::calculateLayerBoundingRect(GraphicsContext* context, const FloatRect& shadowedRect, const IntRect& clipRect, const bool scaledBlurLayer)
401
{
410
{
402
    IntSize edgeSize = blurredEdgeSize();
411
    IntSize edgeSize = blurredEdgeSize();
403
412
Lines 405-412 IntRect ShadowBlur::calculateLayerBoundingRect(GraphicsContext* context, const F a/Source/WebCore/platform/graphics/ShadowBlur.cpp_sec2
405
    FloatRect layerRect;
414
    FloatRect layerRect;
406
    IntSize inflation;
415
    IntSize inflation;
407
416
408
    const AffineTransform transform = context->getCTM();
417
    AffineTransform transform = context->getCTM();
409
    if (m_shadowsIgnoreTransforms && !transform.isIdentity()) {
418
    if (m_shadowsIgnoreTransforms && !transform.isIdentity()) {
419
        if (scaledBlurLayer)
420
            transform.scale(1 / transform.xScale(), 1 / transform.yScale());
410
        FloatQuad transformedPolygon = transform.mapQuad(FloatQuad(shadowedRect));
421
        FloatQuad transformedPolygon = transform.mapQuad(FloatQuad(shadowedRect));
411
        transformedPolygon.move(m_offset);
422
        transformedPolygon.move(m_offset);
412
        layerRect = transform.inverse().mapQuad(transformedPolygon).boundingBox();
423
        layerRect = transform.inverse().mapQuad(transformedPolygon).boundingBox();
Lines 885-893 void ShadowBlur::blurAndColorShadowBuffer(const IntSize& templateSize) a/Source/WebCore/platform/graphics/ShadowBlur.cpp_sec3
885
896
886
GraphicsContext* ShadowBlur::beginShadowLayer(GraphicsContext *context, const FloatRect& layerArea)
897
GraphicsContext* ShadowBlur::beginShadowLayer(GraphicsContext *context, const FloatRect& layerArea)
887
{
898
{
888
    adjustBlurRadius(context);
899
    FloatRect scaledLayerArea = layerArea;
900
    bool scaledBlurLayer = useScaledBlurLayer(context);
901
    const AffineTransform transform = context->getCTM();
902
    if (scaledBlurLayer)
903
        scaledLayerArea.scale(static_cast<float>(transform.xScale()), static_cast<float>(transform.yScale()));
904
    else
905
        adjustBlurRadius(context);
889
906
890
    IntRect layerRect = calculateLayerBoundingRect(context, layerArea, context->clipBounds());
907
    IntRect layerRect = calculateLayerBoundingRect(context, scaledLayerArea, context->clipBounds(), scaledBlurLayer);
891
908
892
    if (layerRect.isEmpty())
909
    if (layerRect.isEmpty())
893
        return 0;
910
        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));
921
    shadowContext->clearRect(FloatRect(0, 0, m_layerSize.width() + 1, m_layerSize.height() + 1));
905
922
906
    shadowContext->translate(m_layerContextTranslation);
923
    shadowContext->translate(m_layerContextTranslation);
924
925
    if (scaledBlurLayer)
926
        shadowContext->scale(FloatSize(static_cast<float>(transform.xScale()), static_cast<float>(transform.yScale())));
927
907
    return shadowContext;
928
    return shadowContext;
908
}
929
}
909
930
Lines 914-919 void ShadowBlur::endShadowLayer(GraphicsContext* context) a/Source/WebCore/platform/graphics/ShadowBlur.cpp_sec5
914
    blurAndColorShadowBuffer(expandedIntSize(m_layerSize));
935
    blurAndColorShadowBuffer(expandedIntSize(m_layerSize));
915
    GraphicsContextStateSaver stateSave(*context);
936
    GraphicsContextStateSaver stateSave(*context);
916
937
938
    if (useScaledBlurLayer(context)) {
939
        AffineTransform transform = context->getCTM();
940
        context->scale(FloatSize(1 / static_cast<float>(transform.xScale()), 1 / static_cast<float>(transform.yScale())));
941
    }
917
    context->clearShadow();
942
    context->clearShadow();
918
    context->drawImageBuffer(m_layerImage, ColorSpaceDeviceRGB, roundedIntPoint(m_layerOrigin), IntRect(0, 0, m_layerSize.width(), m_layerSize.height()), context->compositeOperation());
943
    context->drawImageBuffer(m_layerImage, ColorSpaceDeviceRGB, roundedIntPoint(m_layerOrigin), IntRect(0, 0, m_layerSize.width(), m_layerSize.height()), context->compositeOperation());
919
944
- 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