[GTK][EFL] ImageBufferCairo should accept resolution factor
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Jun 2016 16:05:46 +0000 (16:05 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Jun 2016 16:05:46 +0000 (16:05 +0000)
commit5666b7080f1ba61192203806711d2c3f2e4697f4
tree88950b691afd7e71dc9ff42d96af865dae470fed
parent331eada0f3ca6fe3f8115df7dc84f55ad4cf3e46
[GTK][EFL] ImageBufferCairo should accept resolution factor
https://bugs.webkit.org/show_bug.cgi?id=157848

Reviewed by Martin Robinson.

Source/WebCore:

ImageBufferCairo ignored the resolution factor passed in its constructor.
This resolution factor is originally introduced for HiDPI Canvas,
and since HiDPI canvas is not enabled in the ports using Cairo,
the lack of this implementation does not cause any problems.
And now, HiDPI Canvas is removed from the tree.

However, WebKit CSS filter uses this path.
The missing implementation is required under the HiDPI environment.

Since Cairo surface can have the device scale factor transparently,
the operations onto the surface is correctly done in the logical coordinate system.
So all we need to handle carefully is the direct surface modification done
in filter effects.

In this patch, we extend the image buffer size according to the resolution factor,
as the same to the CoreGraphics' implementation (ImageBufferCG). And by setting the
device scale factor of the surface correctly, we ensure that the rest of the Cairo
painting stack works with the existing logical coordinate system. And in ImageBufferCairo,
we carefully handle the logical and backing store coordinate system.

The attached test applies the CSS filter onto the svg image. And we resize the image size,
and perform scrolling. It incurs the paint, and filter effect recalcuation.
In that path, the filter effect side assumes that the image buffer size is scaled with the
resolution factor. So without this patch, it incurs buffer overflow and leads WebProcess crash.

* platform/graphics/IntPoint.h:
(WebCore::IntPoint::scale):
* platform/graphics/cairo/ImageBufferCairo.cpp:
(WebCore::ImageBufferData::createCompositorBuffer):
(WebCore::ImageBuffer::ImageBuffer):
(WebCore::ImageBuffer::copyImage):
(WebCore::ImageBuffer::platformTransformColorSpace):
(WebCore::getImageData):
(WebCore::logicalUnit):
(WebCore::backingStoreUnit):
(WebCore::ImageBuffer::getUnmultipliedImageData):
(WebCore::ImageBuffer::getPremultipliedImageData):
(WebCore::ImageBuffer::putByteArray):
(WebCore::ImageBuffer::copyToPlatformTexture):

LayoutTests:

* fast/hidpi/filters-and-image-buffer-resolution-expected.html: Added.
* fast/hidpi/filters-and-image-buffer-resolution.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202421 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/hidpi/filters-and-image-buffer-resolution-expected.html [new file with mode: 0644]
LayoutTests/fast/hidpi/filters-and-image-buffer-resolution.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/IntPoint.h
Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp