Commit 89d03f85 authored by zimmermann@webkit.org's avatar zimmermann@webkit.org

2011-11-08 Nikolas Zimmermann <nzimmermann@rim.com>

        Switch SVGImage cache to store ImageBuffers instead of whole SVGImages, including a DOM/Render tree
        https://bugs.webkit.org/show_bug.cgi?id=71368

        Reviewed by Antti Koivisto.

        Add some layout tests covering repainting of embedded SVG documents triggered by SMIL animations.

        * platform/chromium/test_expectations.txt: Fix test expectations, as described in bug 71226.
        * platform/mac/svg/as-image/animated-svg-as-image-no-fixed-intrinsic-size-expected.png: Added.
        * platform/mac/svg/as-image/animated-svg-as-image-no-fixed-intrinsic-size-expected.txt: Added.
        * platform/mac/svg/as-image/animated-svg-as-image-same-image-expected.png: Added.
        * platform/mac/svg/as-image/animated-svg-as-image-same-image-expected.txt: Added.
        * svg/as-image/animated-svg-as-image-no-fixed-intrinsic-size.html: Added.
        * svg/as-image/animated-svg-as-image-same-image.html: Added.
        * svg/as-image/resources/animated-rect-same-image.svg: Copied from LayoutTests/svg/as-image/resources/animated-rect-fixed-size.svg.
        * svg/zoom/page/zoom-coords-viewattr-01-b.svg: Add comment, why scrollbars shouldn't appear anymore here.

2011-11-08  Nikolas Zimmermann  <nzimmermann@rim.com>

        Switch SVGImage cache to store ImageBuffers instead of whole SVGImages, including a DOM/Render tree
        https://bugs.webkit.org/show_bug.cgi?id=71368

        Reviewed by Antti Koivisto.

        Fix regressions/races introduced by r98852. SVGImage repainting didn't work under certain circumstances.
        The problem was hard to reproduce on Mac ports, but easily visible on Chromium, when opening two files
        that shared the same animated SVG image. The problem of sharing a single ImageObserver across multiple
        instances of the same SVGImage, leads to nasty problems, that are timing dependant. changedInRect() calls
        that should only by received in one document, are received in the other as well, due the shared nature
        of CachedImage. To avoid these problems alltogether, a new approach is needed, that was initially suggested
        by Antti.

        Avoid creating multiple SVGImages and caching them for different sizes/zoom levels. Introduce SVGImageCache
        which holds rendered versions of the SVGImage at certain sizes/zoom levels. It holds (ImageBuffer, Image) pairs
        for each renderer, associated with a size and zoom level.

        This is a major change to the cache as introduced some weeks ago. Instead of holding multiple SVGImages, each containing
        a whole DOM/render tree, we now create bitmap images rendered at the requested sizes/zoom levels and cache them.

        Revert ImageBySizeCache changes that were needed to make it usable wih SVGImage. Its now used only in CSSImageGeneratorValue and
        thus the extra information that CSSImageGeneratorValue doesn't need can be removed again (desired/actual size differentations, and the zoom level).

        Tests: svg/as-image/animated-svg-as-image-no-fixed-intrinsic-size.html
               svg/as-image/animated-svg-as-image-same-image.html

        * CMakeLists.txt: Add svg/graphics/SVGImageCache.* to build.
        * GNUmakefile.list.am: Ditto.
        * Target.pri: Ditto.
        * WebCore.gypi: Ditto.
        * WebCore.vcproj/WebCore.vcproj: Ditto.
        * WebCore.vcproj/copyForwardingHeaders.cmd: Copy headers from svg/graphics, as SVGImageCache is needed by CachedImage in SVG enabled builds.
        * WebCore.xcodeproj/project.pbxproj: Add svg/graphics/SVGImageCache.* to build.
        * css/CSSImageGeneratorValue.cpp: Remove zoom parameter from addClient/getImage, no need to pass 1 default values anymore.
        (WebCore::CSSImageGeneratorValue::addClient):
        (WebCore::CSSImageGeneratorValue::getImage):
        * loader/cache/CachedImage.cpp: Stop using ImageBySizeCache, and switch to the new SVGImageCache.
        (WebCore::CachedImage::removeClientForRenderer):
        (WebCore::CachedImage::lookupOrCreateImageForRenderer):
        (WebCore::CachedImage::setContainerSizeForRenderer):
        (WebCore::CachedImage::imageSizeForRenderer):
        (WebCore::CachedImage::clear):
        (WebCore::CachedImage::createImage):
        (WebCore::CachedImage::destroyDecodedData):
        (WebCore::CachedImage::decodedSizeChanged):
        (WebCore::CachedImage::didDraw):
        (WebCore::CachedImage::shouldPauseAnimation):
        (WebCore::CachedImage::animationAdvanced):
        (WebCore::CachedImage::changedInRect):
        * loader/cache/CachedImage.h:
        * page/DragController.cpp: Stop using imageForRenderer(), as it may return cached BitmapImages, that don't carry a filename extension anymore, which is required here.
        (WebCore::getImage):
        * rendering/ImageBySizeCache.cpp: Revert changes to ImageBySizeCache, which were needed to make it usable for SVGImages. CSSImageGenerator doesn't need it.
        (WebCore::ImageBySizeCache::addClient):
        (WebCore::ImageBySizeCache::removeClient):
        (WebCore::ImageBySizeCache::getImage):
        * rendering/ImageBySizeCache.h: Ditto.
        (WebCore::SizeAndCount::SizeAndCount):
        * rendering/RenderImage.cpp: Stop using imageForRenderer(), use cachedImage()->image(), which is guaranteed to be a SVGImage for svg images, and not a cached bitmap copy.
        (WebCore::RenderImage::embeddedContentBox):
        * rendering/RenderReplaced.cpp: Simplify logic to figure out the intrinsic size - the special logic for the old SVGImage cache can go away now.
        (WebCore::RenderReplaced::computeIntrinsicLogicalWidth):
        (WebCore::RenderReplaced::computeIntrinsicLogicalHeight):
        * rendering/style/StyleCachedImage.cpp: Call removeClientForRenderer(), which takes care of clearing SVGImageCache entries as well.
        (WebCore::StyleCachedImage::removeClient): This change is needed, as we don't want to make removeClient() virtual in CachedResource.
        * rendering/svg/RenderSVGRoot.cpp: Rename isEmbeddedThroughImageElement to isEmbeddedThroughSVGImage, as this is what it actually checks.
        (WebCore::RenderSVGRoot::isEmbeddedThroughSVGImage):
        * rendering/svg/RenderSVGRoot.h:
        * svg/SVGSVGElement.cpp: Fix bug that's visible now with the SVGImageCache, which was already there before, but hard to trigger.
        (WebCore::SVGSVGElement::currentViewBoxRect): The viewBox depends on who's asking for it: the host document or the embedded document? Take that into account.
        * svg/SVGSVGElement.h:
        * svg/graphics/SVGImage.cpp: Cleanup some code. Add new logic that draws a SVGImage into an ImageBuffer at a desired size & zoom.
        (WebCore::SVGImage::setContainerSize):
        (WebCore::SVGImage::size):
        (WebCore::SVGImage::drawSVGToImageBuffer):
        * svg/graphics/SVGImage.h:
        * svg/graphics/SVGImageCache.cpp: Added. SVGImageCache caches Image/ImageBuffer pairs for each _renderer_ and size/zoom level. The ImageBySizeCache only cared about size.
        (WebCore::SVGImageCache::SVGImageCache):
        (WebCore::SVGImageCache::~SVGImageCache):
        (WebCore::SVGImageCache::removeRendererFromCache):
        (WebCore::SVGImageCache::setRequestedSizeAndZoom):
        (WebCore::SVGImageCache::getRequestedSizeAndZoom):
        (WebCore::SVGImageCache::imageContentChanged):
        (WebCore::SVGImageCache::redrawTimerFired):
        (WebCore::SVGImageCache::lookupOrCreateBitmapImageForRenderer):
        * svg/graphics/SVGImageCache.h: Added.
        (WebCore::SVGImageCache::create):
        (WebCore::SVGImageCache::CachedSizeAndZoom::CachedSizeAndZoom):
        (WebCore::SVGImageCache::CachedImageData::CachedImageData):

2011-11-08  Nikolas Zimmermann  <nzimmermann@rim.com>

        Switch SVGImage cache to store ImageBuffers instead of whole SVGImages, including a DOM/Render tree
        https://bugs.webkit.org/show_bug.cgi?id=71368

        Reviewed by Antti Koivisto.

        * CMakeLists.txt: Add svg/graphics include, for SVGImageCache.h.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@99539 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3d183005
2011-11-08 Nikolas Zimmermann <nzimmermann@rim.com>
Switch SVGImage cache to store ImageBuffers instead of whole SVGImages, including a DOM/Render tree
https://bugs.webkit.org/show_bug.cgi?id=71368
Reviewed by Antti Koivisto.
Add some layout tests covering repainting of embedded SVG documents triggered by SMIL animations.
* platform/chromium/test_expectations.txt: Fix test expectations, as described in bug 71226.
* platform/mac/svg/as-image/animated-svg-as-image-no-fixed-intrinsic-size-expected.png: Added.
* platform/mac/svg/as-image/animated-svg-as-image-no-fixed-intrinsic-size-expected.txt: Added.
* platform/mac/svg/as-image/animated-svg-as-image-same-image-expected.png: Added.
* platform/mac/svg/as-image/animated-svg-as-image-same-image-expected.txt: Added.
* svg/as-image/animated-svg-as-image-no-fixed-intrinsic-size.html: Added.
* svg/as-image/animated-svg-as-image-same-image.html: Added.
* svg/as-image/resources/animated-rect-same-image.svg: Copied from LayoutTests/svg/as-image/resources/animated-rect-fixed-size.svg.
* svg/zoom/page/zoom-coords-viewattr-01-b.svg: Add comment, why scrollbars shouldn't appear anymore here.
2011-11-08 Philippe Normand <pnormand@igalia.com>
Unreviewed, skip flaky crasher on GTK.
......@@ -1486,9 +1486,6 @@ BUGWK39966 LINUX : fast/repaint/table-cell-collapsed-border.html = IMAGE
// Thicker shadow than expected
BUGCR23471 LEOPARD : fast/text/stroking.html = IMAGE
// Failing on the bots but not locally; need investigation
BUGCR23560 MAC : svg/as-image/animated-svg-as-image.html = PASS IMAGE
// -----------------------------------------------------------------
// END MAC PORT TESTS
// -----------------------------------------------------------------
......@@ -3849,12 +3846,8 @@ BUGWK71211 GPU LINUX DEBUG : fast/canvas/shadow-offset-3.html = PASS CRASH
BUGWK71214 LEOPARD CPU-CG : css2.1/20110323/block-non-replaced-width-008.htm = FAIL
BUGWK71215 SNOWLEOPARD DEBUG : animations/change-keyframes.html = TEXT
BUGWK71226 : svg/as-background-image/animated-svg-as-background.html = IMAGE
BUGWK71226 : svg/zoom/page/zoom-coords-viewattr-01-b.svg = IMAGE+TEXT
BUGWK71226 MAC : svg/zoom/page/zoom-img-preserveAspectRatio-support-1.html = IMAGE+TEXT
BUGWK71226 WIN LINUX : svg/zoom/page/zoom-img-preserveAspectRatio-support-1.html = PASS IMAGE+TEXT
BUGWK71226 : fast/backgrounds/size/contain-and-cover-zoomed.html = IMAGE+TEXT
BUGWK71226 : fast/backgrounds/animated-svg-as-mask.html = IMAGE+TEXT IMAGE
BUGWK71673 MAC : svg/zoom/page/zoom-img-preserveAspectRatio-support-1.html = IMAGE+TEXT
BUGWK71673 WIN LINUX : svg/zoom/page/zoom-img-preserveAspectRatio-support-1.html = PASS IMAGE+TEXT
BUGWK71278 SLOW WIN RELEASE : fast/events/dispatch-message-string-data.html = PASS
......
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x584
RenderBlock {P} at (0,0) size 784x18
RenderText {#text} at (0,0) size 371x18
text run at (0,0) width 371: "Images should redraw correctly when SVG animation runs"
RenderBlock (anonymous) at (0,34) size 784x500
RenderImage {IMG} at (10,10) size 480x480
RenderText {#text} at (0,0) size 0x0
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x584
RenderBlock {P} at (0,0) size 784x18
RenderText {#text} at (0,0) size 371x18
text run at (0,0) width 371: "Images should redraw correctly when SVG animation runs"
RenderBlock (anonymous) at (0,34) size 784x548
RenderImage {IMG} at (10,10) size 354x254 [border: (2px solid #000000)]
RenderBR {BR} at (374,274) size 0x0
RenderImage {IMG} at (10,284) size 354x254 [border: (2px solid #000000)]
RenderText {#text} at (0,0) size 0x0
<html>
<head>
<style type="text/css" media="screen">
img {
margin: 10px;
}
</style>
<script type="text/javascript" charset="utf-8">
if (window.layoutTestController)
layoutTestController.waitUntilDone();
function pageLoaded()
{
window.setTimeout(function() {
if (window.layoutTestController)
layoutTestController.notifyDone();
}, 400); // empirically determined delay. SVG animation has 100ms duration.
}
window.addEventListener('load', pageLoaded, false);
</script>
</head>
<body>
<p>Images should redraw correctly when SVG animation runs</p>
<img src="resources/animated-rect-fixed-size.svg">
</body>
</html>
<html>
<head>
<style type="text/css" media="screen">
img {
margin: 10px;
}
</style>
<script type="text/javascript" charset="utf-8">
if (window.layoutTestController)
layoutTestController.waitUntilDone();
function pageLoaded()
{
window.setTimeout(function() {
if (window.layoutTestController)
layoutTestController.notifyDone();
}, 400); // empirically determined delay. SVG animation has 100ms duration.
}
window.addEventListener('load', pageLoaded, false);
</script>
</head>
<body>
<p>Images should redraw correctly when SVG animation runs</p>
<img height="250px" width="350px" border="2" src="resources/animated-rect-same-image.svg"><br>
<img height="250px" width="350px" border="2" src="resources/animated-rect-same-image.svg">
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
<!--======================================================================-->
<!--= Copyright 2000 World Wide Web Consortium, (Massachusetts =-->
<!--= Institute of Technology, Institut National de Recherche en =-->
<!--= Informatique et en Automatique, Keio University). All Rights =-->
<!--= Reserved. See http://www.w3.org/Consortium/Legal/. =-->
<!--======================================================================-->
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="svg-root" width="480px" height="480px" viewBox="0 0 480 360" version="1.1" baseProfile="tiny">
<SVGTestCase xmlns="http://www.w3.org/2000/02/svg/testsuite/description/">
</SVGTestCase>
<title id="test-title">animate-elem-14-t</title>
<desc id="test-desc">Test possible values for 'keyTimes'</desc>
<g id="test-body-content">
<g xml:space="preserve" font-family="Arial" font-size="13.5" stroke-width="3" >
<g transform="translate(150,140)">
<text font-size="36" x="-140" y="140">Time (s):</text>
<text font-size="36" x="290" y="140">0</text>
<line x1="300" y1="0" x2="300" y2="100" fill="none" stroke="#880000" />
<text font-size="36" x="20" y="140">6</text>
<line x1="30" y1="0" x2="30" y2="100" fill="none" stroke="#880000" />
<rect x="0" y="0" width="300" height="80" fill="#44AAFF" stroke="#880088" stroke-width="4" >
<animate attributeName="width" calcMode="discrete" values="300;30" keyTimes="0;.6" begin="0s" dur="100ms" fill="freeze"/>
</rect>
</g>
</g>
</g>
<rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000000"/>
</svg>
......@@ -122,6 +122,7 @@ fill='none' stroke='blue'/>">
<rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000000"/>
<defs>
<!-- Note that the zooming won't have any visible effect except for stroke size changes, as width/height is 100% -->
<script>var zoomCount = 2;</script>
<script xlink:href="../resources/testPageZoom.js"/>
</defs>
......
......@@ -1806,6 +1806,7 @@ IF (ENABLE_SVG)
svg/animation/SMILTimeContainer.cpp
svg/animation/SVGSMILElement.cpp
svg/graphics/SVGImage.cpp
svg/graphics/SVGImageCache.cpp
svg/graphics/filters/SVGFEImage.cpp
svg/graphics/filters/SVGFilter.cpp
svg/graphics/filters/SVGFilterBuilder.cpp
......
2011-11-08 Nikolas Zimmermann <nzimmermann@rim.com>
Switch SVGImage cache to store ImageBuffers instead of whole SVGImages, including a DOM/Render tree
https://bugs.webkit.org/show_bug.cgi?id=71368
Reviewed by Antti Koivisto.
Fix regressions/races introduced by r98852. SVGImage repainting didn't work under certain circumstances.
The problem was hard to reproduce on Mac ports, but easily visible on Chromium, when opening two files
that shared the same animated SVG image. The problem of sharing a single ImageObserver across multiple
instances of the same SVGImage, leads to nasty problems, that are timing dependant. changedInRect() calls
that should only by received in one document, are received in the other as well, due the shared nature
of CachedImage. To avoid these problems alltogether, a new approach is needed, that was initially suggested
by Antti.
Avoid creating multiple SVGImages and caching them for different sizes/zoom levels. Introduce SVGImageCache
which holds rendered versions of the SVGImage at certain sizes/zoom levels. It holds (ImageBuffer, Image) pairs
for each renderer, associated with a size and zoom level.
This is a major change to the cache as introduced some weeks ago. Instead of holding multiple SVGImages, each containing
a whole DOM/render tree, we now create bitmap images rendered at the requested sizes/zoom levels and cache them.
Revert ImageBySizeCache changes that were needed to make it usable wih SVGImage. Its now used only in CSSImageGeneratorValue and
thus the extra information that CSSImageGeneratorValue doesn't need can be removed again (desired/actual size differentations, and the zoom level).
Tests: svg/as-image/animated-svg-as-image-no-fixed-intrinsic-size.html
svg/as-image/animated-svg-as-image-same-image.html
* CMakeLists.txt: Add svg/graphics/SVGImageCache.* to build.
* GNUmakefile.list.am: Ditto.
* Target.pri: Ditto.
* WebCore.gypi: Ditto.
* WebCore.vcproj/WebCore.vcproj: Ditto.
* WebCore.vcproj/copyForwardingHeaders.cmd: Copy headers from svg/graphics, as SVGImageCache is needed by CachedImage in SVG enabled builds.
* WebCore.xcodeproj/project.pbxproj: Add svg/graphics/SVGImageCache.* to build.
* css/CSSImageGeneratorValue.cpp: Remove zoom parameter from addClient/getImage, no need to pass 1 default values anymore.
(WebCore::CSSImageGeneratorValue::addClient):
(WebCore::CSSImageGeneratorValue::getImage):
* loader/cache/CachedImage.cpp: Stop using ImageBySizeCache, and switch to the new SVGImageCache.
(WebCore::CachedImage::removeClientForRenderer):
(WebCore::CachedImage::lookupOrCreateImageForRenderer):
(WebCore::CachedImage::setContainerSizeForRenderer):
(WebCore::CachedImage::imageSizeForRenderer):
(WebCore::CachedImage::clear):
(WebCore::CachedImage::createImage):
(WebCore::CachedImage::destroyDecodedData):
(WebCore::CachedImage::decodedSizeChanged):
(WebCore::CachedImage::didDraw):
(WebCore::CachedImage::shouldPauseAnimation):
(WebCore::CachedImage::animationAdvanced):
(WebCore::CachedImage::changedInRect):
* loader/cache/CachedImage.h:
* page/DragController.cpp: Stop using imageForRenderer(), as it may return cached BitmapImages, that don't carry a filename extension anymore, which is required here.
(WebCore::getImage):
* rendering/ImageBySizeCache.cpp: Revert changes to ImageBySizeCache, which were needed to make it usable for SVGImages. CSSImageGenerator doesn't need it.
(WebCore::ImageBySizeCache::addClient):
(WebCore::ImageBySizeCache::removeClient):
(WebCore::ImageBySizeCache::getImage):
* rendering/ImageBySizeCache.h: Ditto.
(WebCore::SizeAndCount::SizeAndCount):
* rendering/RenderImage.cpp: Stop using imageForRenderer(), use cachedImage()->image(), which is guaranteed to be a SVGImage for svg images, and not a cached bitmap copy.
(WebCore::RenderImage::embeddedContentBox):
* rendering/RenderReplaced.cpp: Simplify logic to figure out the intrinsic size - the special logic for the old SVGImage cache can go away now.
(WebCore::RenderReplaced::computeIntrinsicLogicalWidth):
(WebCore::RenderReplaced::computeIntrinsicLogicalHeight):
* rendering/style/StyleCachedImage.cpp: Call removeClientForRenderer(), which takes care of clearing SVGImageCache entries as well.
(WebCore::StyleCachedImage::removeClient): This change is needed, as we don't want to make removeClient() virtual in CachedResource.
* rendering/svg/RenderSVGRoot.cpp: Rename isEmbeddedThroughImageElement to isEmbeddedThroughSVGImage, as this is what it actually checks.
(WebCore::RenderSVGRoot::isEmbeddedThroughSVGImage):
* rendering/svg/RenderSVGRoot.h:
* svg/SVGSVGElement.cpp: Fix bug that's visible now with the SVGImageCache, which was already there before, but hard to trigger.
(WebCore::SVGSVGElement::currentViewBoxRect): The viewBox depends on who's asking for it: the host document or the embedded document? Take that into account.
* svg/SVGSVGElement.h:
* svg/graphics/SVGImage.cpp: Cleanup some code. Add new logic that draws a SVGImage into an ImageBuffer at a desired size & zoom.
(WebCore::SVGImage::setContainerSize):
(WebCore::SVGImage::size):
(WebCore::SVGImage::drawSVGToImageBuffer):
* svg/graphics/SVGImage.h:
* svg/graphics/SVGImageCache.cpp: Added. SVGImageCache caches Image/ImageBuffer pairs for each _renderer_ and size/zoom level. The ImageBySizeCache only cared about size.
(WebCore::SVGImageCache::SVGImageCache):
(WebCore::SVGImageCache::~SVGImageCache):
(WebCore::SVGImageCache::removeRendererFromCache):
(WebCore::SVGImageCache::setRequestedSizeAndZoom):
(WebCore::SVGImageCache::getRequestedSizeAndZoom):
(WebCore::SVGImageCache::imageContentChanged):
(WebCore::SVGImageCache::redrawTimerFired):
(WebCore::SVGImageCache::lookupOrCreateBitmapImageForRenderer):
* svg/graphics/SVGImageCache.h: Added.
(WebCore::SVGImageCache::create):
(WebCore::SVGImageCache::CachedSizeAndZoom::CachedSizeAndZoom):
(WebCore::SVGImageCache::CachedImageData::CachedImageData):
2011-11-07 Yury Semikhatsky <yurys@chromium.org>
Web Inspector: refactor shortcuts and settings screens
......
......@@ -3536,6 +3536,8 @@ webcore_sources += \
Source/WebCore/svg/graphics/filters/SVGFilterBuilder.h \
Source/WebCore/svg/graphics/filters/SVGFilter.cpp \
Source/WebCore/svg/graphics/filters/SVGFilter.h \
Source/WebCore/svg/graphics/SVGImageCache.cpp \
Source/WebCore/svg/graphics/SVGImageCache.h \
Source/WebCore/svg/graphics/SVGImage.cpp \
Source/WebCore/svg/graphics/SVGImage.h \
Source/WebCore/svg/LinearGradientAttributes.h \
......
......@@ -2483,6 +2483,7 @@ HEADERS += \
svg/graphics/filters/SVGFilterBuilder.h \
svg/graphics/filters/SVGFilter.h \
svg/graphics/SVGImage.h \
svg/graphics/SVGImageCache.h \
svg/properties/SVGAttributeToPropertyMap.h \
svg/properties/SVGAnimatedEnumerationPropertyTearOff.h \
svg/properties/SVGAnimatedListPropertyTearOff.h \
......@@ -3316,6 +3317,7 @@ contains(DEFINES, ENABLE_SVG=1) {
svg/graphics/filters/SVGFilter.cpp \
svg/graphics/filters/SVGFilterBuilder.cpp \
svg/graphics/SVGImage.cpp \
svg/graphics/SVGImageCache.cpp \
svg/properties/SVGAttributeToPropertyMap.cpp \
svg/properties/SVGPathSegListPropertyTearOff.cpp
......
......@@ -6206,6 +6206,8 @@
'svg/animation/SMILTimeContainer.cpp',
'svg/animation/SMILTimeContainer.h',
'svg/animation/SVGSMILElement.cpp',
'svg/graphics/SVGImageCache.cpp',
'svg/graphics/SVGImageCache.h',
'svg/graphics/SVGImage.cpp',
'svg/graphics/SVGImage.h',
'svg/graphics/filters/SVGFEImage.cpp',
......
......@@ -67100,6 +67100,14 @@
<Filter
Name="graphics"
>
<File
RelativePath="..\svg\graphics\SVGImageCache.cpp"
>
</File>
<File
RelativePath="..\svg\graphics\SVGImageCache.h"
>
</File>
<File
RelativePath="..\svg\graphics\SVGImage.cpp"
>
......@@ -70,6 +70,7 @@ xcopy /y /d "%ProjectDir%..\dom\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
xcopy /y /d "%ProjectDir%..\xml\parser\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
xcopy /y /d "%ProjectDir%..\xml\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
xcopy /y /d "%ProjectDir%..\svg\animation\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
xcopy /y /d "%ProjectDir%..\svg\graphics\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
xcopy /y /d "%ProjectDir%..\svg\properties\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
xcopy /y /d "%ProjectDir%..\svg\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
xcopy /y /d "%ProjectDir%..\storage\*.h" "%CONFIGURATIONBUILDDIR%\include\WebCore"
......
......@@ -194,6 +194,8 @@
08F0BFC61255C53C00075185 /* SVGTextMetrics.h in Headers */ = {isa = PBXBuildFile; fileRef = 08F0BFC11255C53C00075185 /* SVGTextMetrics.h */; };
08F2F0091213E61700DCEC48 /* RenderImageResource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08F2F0071213E61700DCEC48 /* RenderImageResource.cpp */; };
08F2F00A1213E61700DCEC48 /* RenderImageResource.h in Headers */ = {isa = PBXBuildFile; fileRef = 08F2F0081213E61700DCEC48 /* RenderImageResource.h */; settings = {ATTRIBUTES = (Private, ); }; };
08F859D41463F9CD0067D933 /* SVGImageCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08F859D21463F9CD0067D933 /* SVGImageCache.cpp */; };
08F859D51463F9CD0067D933 /* SVGImageCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 08F859D31463F9CD0067D933 /* SVGImageCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
08FB17C113BC7E9100040086 /* SVGAttributeToPropertyMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08FB17C013BC7E9100040086 /* SVGAttributeToPropertyMap.cpp */; };
08FB3F8413BC754C0099FC18 /* SVGAttributeToPropertyMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 08FB3F8313BC754C0099FC18 /* SVGAttributeToPropertyMap.h */; settings = {ATTRIBUTES = (Private, ); }; };
08FE0BC5127E2AC1000C4FB5 /* SVGAnimatedPreserveAspectRatio.h in Headers */ = {isa = PBXBuildFile; fileRef = 08FE0BC4127E2AC1000C4FB5 /* SVGAnimatedPreserveAspectRatio.h */; settings = {ATTRIBUTES = (Private, ); }; };
......@@ -7224,6 +7226,8 @@
08F0BFC11255C53C00075185 /* SVGTextMetrics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGTextMetrics.h; sourceTree = "<group>"; };
08F2F0071213E61700DCEC48 /* RenderImageResource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderImageResource.cpp; sourceTree = "<group>"; };
08F2F0081213E61700DCEC48 /* RenderImageResource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderImageResource.h; sourceTree = "<group>"; };
08F859D21463F9CD0067D933 /* SVGImageCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGImageCache.cpp; sourceTree = "<group>"; };
08F859D31463F9CD0067D933 /* SVGImageCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGImageCache.h; sourceTree = "<group>"; };
08FB17C013BC7E9100040086 /* SVGAttributeToPropertyMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAttributeToPropertyMap.cpp; sourceTree = "<group>"; };
08FB3F8313BC754C0099FC18 /* SVGAttributeToPropertyMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAttributeToPropertyMap.h; sourceTree = "<group>"; };
08FE0BC4127E2AC1000C4FB5 /* SVGAnimatedPreserveAspectRatio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPreserveAspectRatio.h; sourceTree = "<group>"; };
......@@ -19004,6 +19008,8 @@
B255989C0D00D8B800BB825C /* filters */,
B255990B0D00D8B900BB825C /* SVGImage.cpp */,
B255990C0D00D8B900BB825C /* SVGImage.h */,
08F859D21463F9CD0067D933 /* SVGImageCache.cpp */,
08F859D31463F9CD0067D933 /* SVGImageCache.h */,
);
path = graphics;
sourceTree = "<group>";
......@@ -24624,6 +24630,7 @@
07846343145B151A00A58DF1 /* JSTrackEvent.h in Headers */,
07846385145B1B8E00A58DF1 /* JSTrackCustom.h in Headers */,
2D8FEBDD143E3EF70072502B /* CSSCrossfadeValue.h in Headers */,
08F859D51463F9CD0067D933 /* SVGImageCache.h in Headers */,
3169379C14609C6C00C01362 /* DragSession.h in Headers */,
CAE9F910146441F000C245B0 /* CSSAspectRatioValue.h in Headers */,
976F36EB14686225005E93B4 /* SecurityContext.h in Headers */,
......@@ -27480,6 +27487,7 @@
07846342145B151A00A58DF1 /* JSTrackEvent.cpp in Sources */,
07689D6E145B52CC001CD132 /* JSTrackEventCustom.cpp in Sources */,
2D8FEBDC143E3EF70072502B /* CSSCrossfadeValue.cpp in Sources */,
08F859D41463F9CD0067D933 /* SVGImageCache.cpp in Sources */,
CAE9F90F146441F000C245B0 /* CSSAspectRatioValue.cpp in Sources */,
CDEA763014608A53008B31F1 /* PlatformClockCA.cpp in Sources */,
CDEA76341460B56F008B31F1 /* ClockGeneric.cpp in Sources */,
......@@ -48,7 +48,7 @@ CSSImageGeneratorValue::~CSSImageGeneratorValue()
void CSSImageGeneratorValue::addClient(RenderObject* renderer, const IntSize& size)
{
ref();
m_imageCache.addClient(renderer, size, 1);
m_imageCache.addClient(renderer, size);
}
void CSSImageGeneratorValue::removeClient(RenderObject* renderer)
......@@ -61,7 +61,7 @@ Image* CSSImageGeneratorValue::getImage(RenderObject* renderer, const IntSize& s
{
// If renderer is the only client, make sure we don't delete this, if the size changes (as this will result in addClient/removeClient calls).
RefPtr<CSSImageGeneratorValue> protect(this);
return m_imageCache.getImage(renderer, size, 1);
return m_imageCache.getImage(renderer, size);
}
void CSSImageGeneratorValue::putImage(const IntSize& size, PassRefPtr<Image> image)
......
......@@ -90,6 +90,15 @@ void CachedImage::load(CachedResourceLoader* cachedResourceLoader, const Resourc
setLoading(false);
}
void CachedImage::removeClientForRenderer(RenderObject* renderer)
{
#if ENABLE(SVG)
if (m_svgImageCache)
m_svgImageCache->removeRendererFromCache(renderer);
#endif
removeClient(renderer);
}
void CachedImage::didAddClient(CachedResourceClient* c)
{
if (m_decodedDataDeletionTimer.isActive())
......@@ -132,48 +141,18 @@ bool CachedImage::willPaintBrokenImage() const
}
#if ENABLE(SVG)
inline Image* CachedImage::lookupImageForSize(const IntSize& size) const
{
if (!m_image)
return 0;
if (!m_image->isSVGImage())
return m_image.get();
if (Image* image = m_svgImageCache.imageForSize(size))
return image;
return m_image.get();
}
inline Image* CachedImage::lookupOrCreateImageForRenderer(const RenderObject* renderer)
{
if (!m_image)
return 0;
if (!m_image->isSVGImage())
return m_image.get();
// Request requested size/zoom for this renderer from the cache.
IntSize size;
float zoom = 1;
m_svgImageCache.getRequestedSizeAndZoom(renderer, size, zoom);
if (size.isEmpty())
Image* useImage = m_svgImageCache->lookupOrCreateBitmapImageForRenderer(renderer);
if (useImage == Image::nullImage())
return m_image.get();
if (Image* image = m_svgImageCache.getImage(renderer, size, zoom))
return image;
// Create and cache new image at requested size.
RefPtr<Image> newImage = SVGImage::createWithDataAndSize(this, m_data.get(), size, zoom);
Image* newImagePtr = newImage.get();
m_svgImageCache.addClient(renderer, size, zoom);
m_svgImageCache.putImage(size, newImage.release());
return newImagePtr;
return useImage;
}
#else
inline Image* CachedImage::lookupImageForSize(const IntSize&) const
{
return m_image.get();
}
inline Image* CachedImage::lookupOrCreateImageForRenderer(const RenderObject*)
{
return m_image.get();
......@@ -223,7 +202,7 @@ void CachedImage::setContainerSizeForRenderer(const RenderObject* renderer, cons
m_image->setContainerSize(containerSize);
return;
}
m_svgImageCache.addClient(renderer, containerSize, containerZoom);
m_svgImageCache->setRequestedSizeAndZoom(renderer, SVGImageCache::SizeAndZoom(containerSize, containerZoom));
#else
UNUSED_PARAM(renderer);
m_image->setContainerSize(containerSize);
......@@ -263,12 +242,18 @@ IntSize CachedImage::imageSizeForRenderer(const RenderObject* renderer, float mu
#if ENABLE(SVG)
if (m_image->isSVGImage()) {
// SVGImages already includes the zooming in its intrinsic size.
IntSize size;
float zoom = 1;
m_svgImageCache.getRequestedSizeAndZoom(renderer, size, zoom);
if (!size.isEmpty())
return size;
return m_image->size();
SVGImageCache::SizeAndZoom sizeAndZoom = m_svgImageCache->requestedSizeAndZoom(renderer);
if (sizeAndZoom.size.isEmpty())
return m_image->size();
if (sizeAndZoom.zoom == 1)
return sizeAndZoom.size;
if (multiplier == 1) {
// Consumer wants unscaled coordinates.
sizeAndZoom.size.setWidth(sizeAndZoom.size.width() / sizeAndZoom.zoom);
sizeAndZoom.size.setHeight(sizeAndZoom.size.height() / sizeAndZoom.zoom);
return sizeAndZoom.size;
}
return sizeAndZoom.size;
}
#endif
......@@ -312,7 +297,9 @@ void CachedImage::checkShouldPaintBrokenImage()
void CachedImage::clear()
{
destroyDecodedData();
#if ENABLE(SVG)
m_svgImageCache.clear();
#endif
m_image = 0;
setEncodedSize(0);
}
......@@ -330,7 +317,9 @@ inline void CachedImage::createImage()
#endif
#if ENABLE(SVG)
if (m_response.mimeType() == "image/svg+xml") {
m_image = SVGImage::create(this);
RefPtr<SVGImage> svgImage = SVGImage::create(this);
m_svgImageCache = SVGImageCache::create(svgImage.get());
m_image = svgImage.release();
return;
}
#endif
......@@ -410,16 +399,13 @@ void CachedImage::destroyDecodedData()
setDecodedSize(0);
if (!MemoryCache::shouldMakeResourcePurgeableOnEviction())
makePurgeable(true);
} else if (m_image && !errorOccurred() && !m_image->isSVGImage())
} else if (m_image && !errorOccurred())
m_image->destroyDecodedData();
}
void CachedImage::decodedSizeChanged(const Image* image, int delta)
{
if (!image)
return;
Image* useImage = lookupImageForSize(image->size());
if (image != useImage)
if (!image || image != m_image)
return;
setDecodedSize(decodedSize() + delta);
......@@ -427,10 +413,7 @@ void CachedImage::decodedSizeChanged(const Image* image, int delta)
void CachedImage::didDraw(const Image* image)
{
if (!image)
return;
Image* useImage = lookupImageForSize(image->size());
if (image != useImage)
if (!image || image != m_image)
return;
double timeStamp = FrameView::currentPaintTimeStamp();
......@@ -442,10 +425,7 @@ void CachedImage::didDraw(const Image* image)
bool CachedImage::shouldPauseAnimation(const Image* image)
{
if (!image)
return false;
Image* useImage = lookupImageForSize(image->size());
if (image != useImage)
if (!image || image != m_image)
return false;
CachedResourceClientWalker<CachedImageClient> w(m_clients);
......@@ -459,22 +439,23 @@ bool CachedImage::shouldPauseAnimation(const Image* image)
void CachedImage::animationAdvanced(const Image* image)
{
if (!image)
return;
Image* useImage = lookupImageForSize(image->size());
if (image != useImage)
if (!image || image != m_image)
return;
notifyObservers();
}
void CachedImage::changedInRect(const Image* image, const IntRect& rect)
{
if (!image)
if (!image || image != m_image)
return;
Image* useImage = lookupImageForSize(image->size());
if (image != useImage)
#if ENABLE(SVG)
// We have to update the cached ImageBuffers if the underlying content changed.
if (image->isSVGImage()) {
m_svgImageCache->imageContentChanged();
return;
}
#endif
notifyObservers(&rect);
}
} //namespace WebCore
} // namespace WebCore
......@@ -25,7 +25,7 @@
#include "CachedResource.h"
#include "CachedResourceClient.h"
#include "ImageBySizeCache.h"
#include "SVGImageCache.h"
#include "ImageObserver.h"
#include "IntRect.h"
#include "Timer.h"
......@@ -67,6 +67,7 @@ public:
IntSize imageSizeForRenderer(const RenderObject*, float multiplier); // returns the size of the complete image.
void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio);
void removeClientForRenderer(RenderObject*);
virtual void didAddClient(CachedResourceClient*);
virtual void allClientsRemoved();
......@@ -94,7 +95,6 @@ public:
virtual void changedInRect(const Image*, const IntRect&);
private:
Image* lookupImageForSize(const IntSize&) const;
Image* lookupOrCreateImageForRenderer(const RenderObject*);
void createImage();
......@@ -106,7 +106,9 @@ private:
void checkShouldPaintBrokenImage();
RefPtr<Image> m_image;
mutable ImageBySizeCache m_svgImageCache;
#if ENABLE(SVG)
OwnPtr<SVGImageCache> m_svgImageCache;
#endif
Timer<CachedImage> m_decodedDataDeletionTimer;
bool m_shouldPaintBrokenImage;
};
......
......@@ -653,8 +653,11 @@ static Image* getImage(Element* element)
{
ASSERT(element);
CachedImage* cachedImage = getCachedImage(element);
// Don't use cachedImage->imageForRenderer() here as that may return BitmapImages for cached SVG Images.
// Users of getImage() want access to the SVGImage, in order to figure out the filename extensions,
// which would be empty when asking the cached BitmapImages.
return (cachedImage && !cachedImage->errorOccurred()) ?
cachedImage->imageForRenderer(element->renderer()) : 0;
cachedImage->image() : 0;
}
static void prepareClipboardForImageDrag(Frame* source, Clipboard* clipboard, Element* node, const KURL& linkURL, const KURL& imageURL, const String& label)
......
......@@ -23,7 +23,6 @@
#include "Image.h"
#include "IntSize.h"
#include "IntSizeHash.h"
#include "RenderObject.h"
namespace WebCore {
......@@ -32,7 +31,7 @@ ImageBySizeCache::ImageBySizeCache()
{
}
void ImageBySizeCache::addClient(const RenderObject* renderer, const IntSize& size, float zoom)