Changeset 108008 in webkit


Ignore:
Timestamp:
Feb 16, 2012 5:40:33 PM (12 years ago)
Author:
mdelaney@apple.com
Message:

ShadowBlur.cpp's cached content matching needs to consider m_layerSize changes
https://bugs.webkit.org/show_bug.cgi?id=78765

Reviewed by Simon Fraser.

No new tests due to the flaky nature of reproducing the issue.

  • platform/graphics/ShadowBlur.cpp:

(WebCore::ScratchBuffer::getScratchBuffer): Make sure to call clearScratchBuffer()
when we create a new ImageBuffer in order to invalidate cached values.
(WebCore::ScratchBuffer::setCachedShadowValues): Roll together matching and setting
of cached values into one method to enforce them being the same.
(WebCore::ScratchBuffer::setCachedInsetShadowValues): Ditto.

Restructure to use new method described above.
(WebCore::ShadowBlur::drawRectShadowWithoutTiling):
(WebCore::ShadowBlur::drawInsetShadowWithoutTiling):
(WebCore::ShadowBlur::drawInsetShadowWithTiling):
(WebCore::ShadowBlur::drawRectShadowWithTiling):
(WebCore::ShadowBlur::beginShadowLayer):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r108007 r108008  
     12012-02-16  Matthew Delaney  <mdelaney@apple.com>
     2
     3        ShadowBlur.cpp's cached content matching needs to consider m_layerSize changes
     4        https://bugs.webkit.org/show_bug.cgi?id=78765
     5
     6        Reviewed by Simon Fraser.
     7
     8        No new tests due to the flaky nature of reproducing the issue.
     9
     10        * platform/graphics/ShadowBlur.cpp:
     11        (WebCore::ScratchBuffer::getScratchBuffer): Make sure to call clearScratchBuffer()
     12        when we create a new ImageBuffer in order to invalidate cached values.
     13        (WebCore::ScratchBuffer::setCachedShadowValues): Roll together matching and setting
     14        of cached values into one method to enforce them being the same.
     15        (WebCore::ScratchBuffer::setCachedInsetShadowValues): Ditto.
     16
     17        Restructure to use new method described above.
     18        (WebCore::ShadowBlur::drawRectShadowWithoutTiling):
     19        (WebCore::ShadowBlur::drawInsetShadowWithoutTiling):
     20        (WebCore::ShadowBlur::drawInsetShadowWithTiling):
     21        (WebCore::ShadowBlur::drawRectShadowWithTiling):
     22        (WebCore::ShadowBlur::beginShadowLayer):
     23
    1242012-02-16  Dana Jansens  <danakj@chromium.org>
    225
  • trunk/Source/WebCore/platform/graphics/ShadowBlur.cpp

    r106836 r108008  
    8080        IntSize roundedSize(roundUpToMultipleOf32(size.width()), roundUpToMultipleOf32(size.height()));
    8181
     82        clearScratchBuffer();
    8283        m_imageBuffer = ImageBuffer::create(roundedSize);
    8384        return m_imageBuffer.get();
    8485    }
    8586
    86     void setLastShadowValues(const FloatSize& radius, const Color& color, ColorSpace colorSpace, const FloatRect& shadowRect, const RoundedRect::Radii& radii)
     87    bool setCachedShadowValues(const FloatSize& radius, const Color& color, ColorSpace colorSpace, const FloatRect& shadowRect, const RoundedRect::Radii& radii, const FloatSize& layerSize)
    8788    {
     89        if (!m_lastWasInset && m_lastRadius == radius && m_lastColor == color && m_lastColorSpace == colorSpace && m_lastShadowRect == shadowRect &&  m_lastRadii == radii && m_lastLayerSize == layerSize)
     90            return false;
     91
    8892        m_lastWasInset = false;
    8993        m_lastRadius = radius;
     
    9296        m_lastShadowRect = shadowRect;
    9397        m_lastRadii = radii;
    94     }
    95 
    96     void setLastInsetShadowValues(const FloatSize& radius, const Color& color, ColorSpace colorSpace, const FloatRect& bounds, const FloatRect& shadowRect, const RoundedRect::Radii& radii)
     98        m_lastLayerSize = layerSize;
     99
     100        return true;
     101    }
     102
     103    bool setCachedInsetShadowValues(const FloatSize& radius, const Color& color, ColorSpace colorSpace, const FloatRect& bounds, const FloatRect& shadowRect, const RoundedRect::Radii& radii)
    97104    {
     105        if (m_lastWasInset && m_lastRadius == radius && m_lastColor == color && m_lastColorSpace == colorSpace && m_lastInsetBounds == bounds && shadowRect == m_lastShadowRect && radii == m_lastRadii)
     106            return false;
     107
    98108        m_lastWasInset = true;
    99109        m_lastInsetBounds = bounds;
     
    103113        m_lastShadowRect = shadowRect;
    104114        m_lastRadii = radii;
    105     }
    106    
    107     bool matchesLastShadow(const FloatSize& radius, const Color& color, ColorSpace colorSpace, const FloatRect& shadowRect, const RoundedRect::Radii& radii) const
    108     {
    109         if (m_lastWasInset)
    110             return false;
    111         return m_lastRadius == radius && m_lastColor == color && m_lastColorSpace == colorSpace && shadowRect == m_lastShadowRect && radii == m_lastRadii;
    112     }
    113 
    114     bool matchesLastInsetShadow(const FloatSize& radius, const Color& color, ColorSpace colorSpace, const FloatRect& bounds, const FloatRect& shadowRect, const RoundedRect::Radii& radii) const
    115     {
    116         if (!m_lastWasInset)
    117             return false;
    118         return m_lastRadius == radius && m_lastColor == color && m_lastColorSpace == colorSpace && m_lastInsetBounds == bounds && shadowRect == m_lastShadowRect && radii == m_lastRadii;
     115
     116        return true;
    119117    }
    120118
     
    155153    FloatSize m_lastRadius;
    156154    bool m_lastWasInset;
     155    FloatSize m_lastLayerSize;
    157156   
    158157#if !ASSERT_DISABLED
     
    544543    FloatRect bufferRelativeShadowedRect = shadowedRect;
    545544    bufferRelativeShadowedRect.move(m_layerContextTranslation);
    546     if (!ScratchBuffer::shared().matchesLastShadow(m_blurRadius, Color::black, ColorSpaceDeviceRGB, bufferRelativeShadowedRect, radii)) {
     545
     546    // Only redraw in the scratch buffer if its cached contents don't match our needs
     547    bool redrawNeeded = ScratchBuffer::shared().setCachedShadowValues(m_blurRadius, Color::black, ColorSpaceDeviceRGB, bufferRelativeShadowedRect, radii, m_layerSize);
     548    if (redrawNeeded) {
    547549        GraphicsContext* shadowContext = m_layerImage->context();
    548550        GraphicsContextStateSaver stateSaver(*shadowContext);
     
    561563
    562564        blurShadowBuffer(expandedIntSize(m_layerSize));
    563        
    564         ScratchBuffer::shared().setLastShadowValues(m_blurRadius, Color::black, ColorSpaceDeviceRGB, bufferRelativeShadowedRect, radii);
    565565    }
    566566   
     
    582582    bufferRelativeHoleRect.move(m_layerContextTranslation);
    583583
    584     if (!ScratchBuffer::shared().matchesLastInsetShadow(m_blurRadius, Color::black, ColorSpaceDeviceRGB, bufferRelativeRect, bufferRelativeHoleRect, holeRadii)) {
     584    // Only redraw in the scratch buffer if its cached contents don't match our needs
     585    bool redrawNeeded = ScratchBuffer::shared().setCachedInsetShadowValues(m_blurRadius, Color::black, ColorSpaceDeviceRGB, bufferRelativeRect, bufferRelativeHoleRect, holeRadii);
     586    if (redrawNeeded) {
    585587        GraphicsContext* shadowContext = m_layerImage->context();
    586588        GraphicsContextStateSaver stateSaver(*shadowContext);
     
    602604
    603605        blurShadowBuffer(expandedIntSize(m_layerSize));
    604 
    605         ScratchBuffer::shared().setLastInsetShadowValues(m_blurRadius, Color::black, ColorSpaceDeviceRGB, bufferRelativeRect, bufferRelativeHoleRect, holeRadii);
    606606    }
    607607   
     
    653653    FloatRect templateHole = FloatRect(edgeSize.width(), edgeSize.height(), templateSize.width() - 2 * edgeSize.width(), templateSize.height() - 2 * edgeSize.height());
    654654
    655     if (!ScratchBuffer::shared().matchesLastInsetShadow(m_blurRadius, m_color, m_colorSpace, templateBounds, templateHole, radii)) {
     655    // Only redraw in the scratch buffer if its cached contents don't match our needs
     656    bool redrawNeeded = ScratchBuffer::shared().setCachedInsetShadowValues(m_blurRadius, m_color, m_colorSpace, templateBounds, templateHole, radii);
     657    if (redrawNeeded) {
    656658        // Draw shadow into a new ImageBuffer.
    657659        GraphicsContext* shadowContext = m_layerImage->context();
     
    671673
    672674        blurAndColorShadowBuffer(templateSize);
    673    
    674         ScratchBuffer::shared().setLastInsetShadowValues(m_blurRadius, m_color, m_colorSpace, templateBounds, templateHole, radii);
    675675    }
    676676
     
    711711    FloatRect templateShadow = FloatRect(edgeSize.width(), edgeSize.height(), templateSize.width() - 2 * edgeSize.width(), templateSize.height() - 2 * edgeSize.height());
    712712
    713     if (!ScratchBuffer::shared().matchesLastShadow(m_blurRadius, m_color, m_colorSpace, templateShadow, radii)) {
     713    // Only redraw in the scratch buffer if its cached contents don't match our needs
     714    bool redrawNeeded = ScratchBuffer::shared().setCachedShadowValues(m_blurRadius, m_color, m_colorSpace, templateShadow, radii, m_layerSize);
     715    if (redrawNeeded) {
    714716        // Draw shadow into the ImageBuffer.
    715717        GraphicsContext* shadowContext = m_layerImage->context();
     
    728730
    729731        blurAndColorShadowBuffer(templateSize);
    730 
    731         ScratchBuffer::shared().setLastShadowValues(m_blurRadius, m_color, m_colorSpace, templateShadow, radii);
    732732    }
    733733
     
    855855    // We reset the scratch buffer values here, because the buffer will no longer contain
    856856    // data from any previous rectangle or inset shadows drawn via the tiling path.
    857     ScratchBuffer::shared().setLastShadowValues(FloatSize(), Color::black, ColorSpaceDeviceRGB, IntRect(), RoundedRect::Radii());
     857    ScratchBuffer::shared().setCachedShadowValues(FloatSize(), Color::black, ColorSpaceDeviceRGB, IntRect(), RoundedRect::Radii(), m_layerSize);
    858858    m_layerImage = ScratchBuffer::shared().getScratchBuffer(layerRect.size());
    859859
Note: See TracChangeset for help on using the changeset viewer.