2011-04-10 Simon Fraser <simon.fraser@apple.com>
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Apr 2011 04:51:42 +0000 (04:51 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Apr 2011 04:51:42 +0000 (04:51 +0000)
commit2ebc3e188398a49e687a7ed2a250e463b3d264be
tree6fde9ccaa9bd0bfa81e9e4222a8900e39bc170ce
parentbc0e1c9ba20778b24d969380553a6da4c7cc8570
2011-04-10  Simon Fraser  <simon.fraser@apple.com>

        Reviewed by Ariya Hidayat.

        Allow ShadowBlur to re-use the last buffer if it already contains the correct shadow
        https://bugs.webkit.org/show_bug.cgi?id=58161

        ShadowBlur already has a singleton scratch buffer that is re-used
        between shadows. Enhance use of this scratch buffer to avoid drawing
        and blurring the shadow if the results will match what is already
        in the buffer.

        Cleaned up ShadowBlur code to remove beginShadowLayer() and endShadowLayer(),
        which ended up with little reusable code after adding the re-use logic.

        * platform/graphics/FloatRect.cpp:
        (WebCore::enclosingIntRect): Replace safeFloatToInt() with the existing
        clampToInteger() from MathExtras.h

        * platform/graphics/FloatSize.h:
        (WebCore::expandedIntSize): New method to safely ceil() the size.

        * platform/graphics/RoundedIntRect.h:
        Add operator== for Radii and RoundedIntRect.

        * platform/graphics/ShadowBlur.cpp:
        (WebCore::ScratchBuffer::ScratchBuffer):
        (WebCore::ScratchBuffer::setLastShadowValues):
        (WebCore::ScratchBuffer::setLastInsetShadowValues):
        (WebCore::ScratchBuffer::matchesLastShadow):
        (WebCore::ScratchBuffer::matchesLastInsetShadow):
        (WebCore::ScratchBuffer::clearScratchBuffer):
        Have the scratch buffer remember what shadow parameters were used
        to render the buffer contents.

        (WebCore::ShadowBlur::drawShadowBuffer):
        Renamed from endShadowLayer(), and only contains the drawing
        logic now.

        (WebCore::ShadowBlur::drawRectShadow):
        Promote some code from beginShadowLayer().

        (WebCore::ShadowBlur::drawInsetShadow):
        Promote some code from beginShadowLayer().

        (WebCore::ShadowBlur::drawRectShadowWithoutTiling):
        (WebCore::ShadowBlur::drawInsetShadowWithoutTiling):
        (WebCore::ShadowBlur::drawInsetShadowWithTiling):
        (WebCore::ShadowBlur::drawRectShadowWithTiling):
        These methods now check to see if the buffer already matches
        their required parameters, and avoid work if it does.

        (WebCore::ShadowBlur::blurShadowBuffer):
        Factored some code into this new method.

        (WebCore::ShadowBlur::blurAndColorShadowBuffer):
        Minor refactoring.

        * platform/graphics/ShadowBlur.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@83422 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/FloatRect.cpp
Source/WebCore/platform/graphics/FloatSize.h
Source/WebCore/platform/graphics/RoundedIntRect.h
Source/WebCore/platform/graphics/ShadowBlur.cpp
Source/WebCore/platform/graphics/ShadowBlur.h