-webkit-filter prevents rendering at retina scale
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 10 May 2014 09:30:02 +0000 (09:30 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 10 May 2014 09:30:02 +0000 (09:30 +0000)
commit02c447e108dd13abe0f3d25a1220c57c6d672712
treefffdc2224d9b766fcef6d1245e13bfd5acb2a248
parenta2e63fd05d6b232ec45e9adc8ef297a741205d30
-webkit-filter prevents rendering at retina scale
https://bugs.webkit.org/show_bug.cgi?id=93471

Reviewed by Dirk Schulze.

Source/WebCore:
Implement 2x support for filters that go through
the -webkit-filter property. This includes all
shorthand filters, and any referenced SVG-style filters
(as long as they use only the supported subset of
operations - basically the same as is exposed for
the shorthands).

Tests: fast/hidpi/filters-blur.html
       fast/hidpi/filters-hue-rotate.html
       fast/hidpi/filters-invert.html
       fast/hidpi/filters-multiple.html
       fast/hidpi/filters-reference.html
       fast/hidpi/filters-shadow.html

* platform/graphics/cg/ImageBufferCG.cpp:
(WebCore::ImageBuffer::getUnmultipliedImageData): Scale the source rectangle if the method was
called using LogicalCoordinates.
(WebCore::ImageBuffer::getPremultipliedImageData): Ditto.
(WebCore::ImageBuffer::putByteArray): Ditto.

* platform/graphics/filters/FEDropShadow.cpp:
(WebCore::FEDropShadow::platformApplySoftware): Make sure to scale the blur radius by the filter
resolution, and call the byte-array methods with the native coordinate system.
* platform/graphics/filters/FEGaussianBlur.cpp:
(WebCore::FEGaussianBlur::calculateUnscaledKernelSize): Fix typo.
(WebCore::FEGaussianBlur::platformApplySoftware): Scale the kernel and paint rectangles
by the filter scale.

* platform/graphics/filters/Filter.h:
(WebCore::Filter::Filter): Initialise the filter scale.
(WebCore::Filter::filterScale): New property which reflects the mapping between logical pixels
and device pixels.
(WebCore::Filter::setFilterScale):

* platform/graphics/filters/FilterEffect.cpp:
(WebCore::FilterEffect::asImageBuffer): Make sure buffer creation takes scale into account.
(WebCore::FilterEffect::asUnmultipliedImage): Ditto.
(WebCore::FilterEffect::asPremultipliedImage): Ditto.
(WebCore::FilterEffect::copyImageBytes): Scale any incoming regions if they are talking about
device pixels rather than logical pixels.
(WebCore::FilterEffect::copyUnmultipliedImage): Ditto.
(WebCore::FilterEffect::copyPremultipliedImage): Ditto.
(WebCore::FilterEffect::createImageBufferResult): Take scale into account when creating byte array.
(WebCore::FilterEffect::createUnmultipliedImageResult): Ditto.
(WebCore::FilterEffect::createPremultipliedImageResult): Ditto.

* rendering/FilterEffectRenderer.cpp:
(WebCore::FilterEffectRenderer::allocateBackingStoreIfNeeded): Pass filter scale into buffer creation.

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::updateOrRemoveFilterEffectRenderer): Make sure to set the filter scale to
the device scale factor, and notice if we ever change scales.

LayoutTests:
New tests for filters at high resolutions. The image used
has a crosshatch at the pixel level, so any scale changes
are visible (such as going from 2x to 1x). All the actual
filters are no-ops so they can be compared to an element
without a filter in the -expected version.

* fast/hidpi/filters-blur-expected.html: Added.
* fast/hidpi/filters-blur.html: Added.
* fast/hidpi/filters-hue-rotate-expected.html: Added.
* fast/hidpi/filters-hue-rotate.html: Added.
* fast/hidpi/filters-invert-expected.html: Added.
* fast/hidpi/filters-invert.html: Added.
* fast/hidpi/filters-multiple-expected.html: Added.
* fast/hidpi/filters-multiple.html: Added.
* fast/hidpi/filters-reference-expected.html: Added.
* fast/hidpi/filters-reference.html: Added.
* fast/hidpi/filters-shadow-expected.html: Added.
* fast/hidpi/filters-shadow.html: Added.
* fast/hidpi/resources/color-grid.png: Added.
* fast/hidpi/resources/ensure-hidpi.js: Added.
(runTest):
(scaleFactorIsSet):
* platform/mac-wk2/TestExpectations: Skip some of these on WK2 Mac.
See webkit.org/b/132766.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@168577 268f45cc-cd09-0410-ab3c-d52691b4dbfc
23 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/hidpi/filters-blur-expected.html [new file with mode: 0644]
LayoutTests/fast/hidpi/filters-blur.html [new file with mode: 0644]
LayoutTests/fast/hidpi/filters-hue-rotate-expected.html [new file with mode: 0644]
LayoutTests/fast/hidpi/filters-hue-rotate.html [new file with mode: 0644]
LayoutTests/fast/hidpi/filters-invert-expected.html [new file with mode: 0644]
LayoutTests/fast/hidpi/filters-invert.html [new file with mode: 0644]
LayoutTests/fast/hidpi/filters-multiple-expected.html [new file with mode: 0644]
LayoutTests/fast/hidpi/filters-multiple.html [new file with mode: 0644]
LayoutTests/fast/hidpi/filters-reference-expected.html [new file with mode: 0644]
LayoutTests/fast/hidpi/filters-reference.html [new file with mode: 0644]
LayoutTests/fast/hidpi/filters-shadow-expected.html [new file with mode: 0644]
LayoutTests/fast/hidpi/filters-shadow.html [new file with mode: 0644]
LayoutTests/fast/hidpi/resources/ensure-hidpi.js [new file with mode: 0644]
LayoutTests/platform/mac-wk2/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp
Source/WebCore/platform/graphics/filters/FEDropShadow.cpp
Source/WebCore/platform/graphics/filters/FEGaussianBlur.cpp
Source/WebCore/platform/graphics/filters/Filter.h
Source/WebCore/platform/graphics/filters/FilterEffect.cpp
Source/WebCore/rendering/FilterEffectRenderer.cpp
Source/WebCore/rendering/RenderLayer.cpp