| 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 / +27 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 406-412 IntRect ShadowBlur::calculateLayerBoundingRect(GraphicsContext* context, const F a/Source/WebCore/platform/graphics/ShadowBlur.cpp_sec2
406
    IntSize inflation;
415
    IntSize inflation;
407
416
408
    const AffineTransform transform = context->getCTM();
417
    const AffineTransform transform = context->getCTM();
409
    if (m_shadowsIgnoreTransforms && !transform.isIdentity()) {
418
    if (m_shadowsIgnoreTransforms && !transform.isIdentity() && !scaledBlurLayer) {
410
        FloatQuad transformedPolygon = transform.mapQuad(FloatQuad(shadowedRect));
419
        FloatQuad transformedPolygon = transform.mapQuad(FloatQuad(shadowedRect));
411
        transformedPolygon.move(m_offset);
420
        transformedPolygon.move(m_offset);
412
        layerRect = transform.inverse().mapQuad(transformedPolygon).boundingBox();
421
        layerRect = transform.inverse().mapQuad(transformedPolygon).boundingBox();
Lines 885-893 void ShadowBlur::blurAndColorShadowBuffer(const IntSize& templateSize) a/Source/WebCore/platform/graphics/ShadowBlur.cpp_sec3
885
894
886
GraphicsContext* ShadowBlur::beginShadowLayer(GraphicsContext *context, const FloatRect& layerArea)
895
GraphicsContext* ShadowBlur::beginShadowLayer(GraphicsContext *context, const FloatRect& layerArea)
887
{
896
{
888
    adjustBlurRadius(context);
897
    FloatRect scaledLayerArea = layerArea;
898
    bool scaledBlurLayer = useScaledBlurLayer(context);
899
    const AffineTransform transform = context->getCTM();
900
    if (scaledBlurLayer)
901
        scaledLayerArea.scale(static_cast<float>(transform.xScale()), static_cast<float>(transform.yScale()));
902
    else
903
        adjustBlurRadius(context);
889
904
890
    IntRect layerRect = calculateLayerBoundingRect(context, layerArea, context->clipBounds());
905
    IntRect layerRect = calculateLayerBoundingRect(context, scaledLayerArea, context->clipBounds(), scaledBlurLayer);
891
906
892
    if (layerRect.isEmpty())
907
    if (layerRect.isEmpty())
893
        return 0;
908
        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));
919
    shadowContext->clearRect(FloatRect(0, 0, m_layerSize.width() + 1, m_layerSize.height() + 1));
905
920
906
    shadowContext->translate(m_layerContextTranslation);
921
    shadowContext->translate(m_layerContextTranslation);
922
923
    if (scaledBlurLayer)
924
        shadowContext->scale(FloatSize(static_cast<float>(transform.xScale()), static_cast<float>(transform.yScale())));
925
907
    return shadowContext;
926
    return shadowContext;
908
}
927
}
909
928
Lines 914-919 void ShadowBlur::endShadowLayer(GraphicsContext* context) a/Source/WebCore/platform/graphics/ShadowBlur.cpp_sec5
914
    blurAndColorShadowBuffer(expandedIntSize(m_layerSize));
933
    blurAndColorShadowBuffer(expandedIntSize(m_layerSize));
915
    GraphicsContextStateSaver stateSave(*context);
934
    GraphicsContextStateSaver stateSave(*context);
916
935
936
    if (useScaledBlurLayer(context)) {
937
        AffineTransform transform = context->getCTM();
938
        context->scale(FloatSize(1 / static_cast<float>(transform.xScale()), 1 / static_cast<float>(transform.yScale())));
939
    }
917
    context->clearShadow();
940
    context->clearShadow();
918
    context->drawImageBuffer(m_layerImage, ColorSpaceDeviceRGB, roundedIntPoint(m_layerOrigin), IntRect(0, 0, m_layerSize.width(), m_layerSize.height()), context->compositeOperation());
941
    context->drawImageBuffer(m_layerImage, ColorSpaceDeviceRGB, roundedIntPoint(m_layerOrigin), IntRect(0, 0, m_layerSize.width(), m_layerSize.height()), context->compositeOperation());
919
942
- 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