Allow ImageBuffer to use an IOSurface that is larger than necessary
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Dec 2013 21:35:38 +0000 (21:35 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Dec 2013 21:35:38 +0000 (21:35 +0000)
commita8ce612738ec706f740896b84386a95887afa525
tree93fd1debb77655efd33757637ec00908124f277d
parent4e5e8be63299dce185ca5036d85876427d43b7cb
Allow ImageBuffer to use an IOSurface that is larger than necessary
https://bugs.webkit.org/show_bug.cgi?id=124626

Patch by Myles C. Maxfield <mmaxfield@apple.com> on 2013-12-04
Reviewed by Simon Fraser.

Source/WebCore:

Because creating ImageBuffer's backing store can be so expensive, it
would be beneficial to have a pool of pre-created backing stores
available. However, this means that ImageBuffer might have to use a
backing store that is larger than the exact dimensions that it needs.
This patch adds a field, m_backingStoreSize, to CG's ImageBufferData
class, and uses this new field when performing ImageBuffer operations
to allow for larger-than-necessary backing stores. Content is always
drawn in the top left corner of the backing store.

No new tests are necessary because there is no behavior change.

* platform/graphics/ImageBuffer.h:
(WebCore::ImageBuffer::baseTransform): The base transform has to put
content at the top left corner instead of bottom left
* platform/graphics/cg/ImageBufferCG.cpp:
(WebCore::createCroppedImageIfNecessary): Convenience function to figure out
the dimensions of the backing texture in user space
(WebCore::ImageBuffer::ImageBuffer): Set up new m_backingStoreSize member
(WebCore::maybeCropToBounds): Some ImageBuffer API functions require
outputting an image with logical size. This function performs the cropping
(WebCore::ImageBuffer::copyImage): Updated for larger-than-necessary
backing stores
(WebCore::ImageBuffer::copyNativeImage): Ditto
(WebCore::ImageBuffer::draw): Ditto
(WebCore::ImageBuffer::clip): Ditto
(WebCore::ImageBuffer::putByteArray): Ditto
(WebCore::ImageBuffer::toDataURL): Ditto
* platform/graphics/cg/ImageBufferDataCG.cpp:
(WebCore::ImageBufferData::getData): Ditto
(WebCore::ImageBufferData::putData): Ditto
* platform/graphics/cg/ImageBufferDataCG.h: New m_backingStoreSize field

LayoutTests:

Update tests to be more robust with respect to accelerated vs
non-accelerated ImageBuffers.

* fast/canvas/script-tests/canvas-fillPath-shadow.js: Don't sample a canvas at exactly
the corner of a drawn shape (because the corner might be antialiased). Instead, sample
a single pixel inside the shape
* fast/canvas/script-tests/canvas-scale-shadowBlur.js: Don't sample a canvas at exactly
the edge of the blur radius. Instead, sample a single pixel past the blur radius.
* fast/canvas/script-tests/canvas-scale-strokePath-shadow.js:
(shouldBeAround): Allow this test to be less strict when sampling inside a blurred region
* platform/mac/fast/canvas/canvas-scale-shadowBlur-expected.txt: Matching update w/r/t
canvas-scale-shadowBlur.js

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@160121 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/canvas/script-tests/canvas-fillPath-shadow.js
LayoutTests/fast/canvas/script-tests/canvas-scale-shadowBlur.js
LayoutTests/fast/canvas/script-tests/canvas-scale-strokePath-shadow.js
LayoutTests/platform/mac/fast/canvas/canvas-scale-shadowBlur-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/ImageBuffer.h
Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp
Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp
Source/WebCore/platform/graphics/cg/ImageBufferDataCG.h