Change ImageData to reference Uint8ClampedArray rather than CanvasPixelArray
authorkbr@google.com <kbr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Apr 2012 03:43:31 +0000 (03:43 +0000)
committerkbr@google.com <kbr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Apr 2012 03:43:31 +0000 (03:43 +0000)
commitf648b5108805beb64e88deb1b3cee4eef5b989c4
tree59ab0c3b1d62b425a7e25147f169ef3be32ca6df
parent616871c3c0f242187b8ba303791dac1eefd376b7
Change ImageData to reference Uint8ClampedArray rather than CanvasPixelArray
https://bugs.webkit.org/show_bug.cgi?id=73011

Reviewed by Oliver Hunt.

Source/WebCore:

Changed ImageData to contain Uint8ClampedArray instead of ByteArray
per current HTML5 spec.

In order to avoid introducing large data copies, it was necessary to
switch a few other places in WebKit to use Uint8ClampedArray at the
same time, most notably the FilterEffect implementation, portions of
ImageBuffer, and a couple of places in the image encoders.

Note that the change in method name from "get" to "item" occurred
because JSC's autogenerated indexed getters reference a method
called "item". If desired, a convenience method could be
introduced to avoid the renamings in the FilterEffect classes.

With these changes, ByteArray and some custom code in JavaScriptCore
actually become unreferenced, and can be deleted. This deletion will
be done separately in Bug 83655, to keep the size of this patch
manageable.

Test: fast/canvas/imagedata-contains-uint8clampedarray.html

* bindings/js/JSImageDataCustom.cpp:
(WebCore::toJS):
* bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneSerializer::dumpIfTerminal):
(WebCore::CloneDeserializer::readTerminal):
* bindings/v8/SerializedScriptValue.cpp:
* bindings/v8/custom/V8ImageDataCustom.cpp:
(WebCore::toV8):
* bridge/qt/qt_pixmapruntime.cpp:
(JSC::Bindings::QtPixmapToImageDataMethod::invoke):
* html/ImageData.cpp:
(WebCore::ImageData::create):
(WebCore::ImageData::ImageData):
* html/ImageData.h:
(ImageData):
(WebCore::ImageData::data):
* html/ImageData.idl:
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::createEmptyImageData):
(WebCore::CanvasRenderingContext2D::getImageData):
(WebCore::CanvasRenderingContext2D::putImageData):
* platform/graphics/GraphicsContext3D.cpp:
(WebCore::GraphicsContext3D::extractImageData):
* platform/graphics/ImageBuffer.cpp:
(WebCore::ImageBuffer::genericConvertToLuminanceMask):
* platform/graphics/ImageBuffer.h:
* platform/graphics/ShadowBlur.cpp:
(WebCore::ShadowBlur::blurShadowBuffer):
* platform/graphics/cairo/ImageBufferCairo.cpp:
(WebCore::getImageData):
(WebCore::ImageBuffer::getUnmultipliedImageData):
(WebCore::ImageBuffer::getPremultipliedImageData):
(WebCore::ImageBuffer::putByteArray):
* platform/graphics/cg/ImageBufferCG.cpp:
(WebCore::ImageBuffer::getUnmultipliedImageData):
(WebCore::ImageBuffer::getPremultipliedImageData):
(WebCore::ImageBuffer::putByteArray):
(WebCore::ImageBuffer::toDataURL):
(WebCore::ImageDataToDataURL):
* platform/graphics/cg/ImageBufferDataCG.cpp:
(WebCore::ImageBufferData::getData):
(WebCore::ImageBufferData::putData):
* platform/graphics/cg/ImageBufferDataCG.h:
(ImageBufferData):
* platform/graphics/filters/FEBlend.cpp:
(WebCore::FEBlend::platformApplySoftware):
* platform/graphics/filters/FEColorMatrix.cpp:
(WebCore::effectType):
(WebCore::FEColorMatrix::platformApplySoftware):
* platform/graphics/filters/FEComponentTransfer.cpp:
(WebCore::FEComponentTransfer::platformApplySoftware):
* platform/graphics/filters/FEComposite.cpp:
(WebCore::FEComposite::platformArithmeticSoftware):
(WebCore::FEComposite::platformApplySoftware):
* platform/graphics/filters/FEComposite.h:
* platform/graphics/filters/FEConvolveMatrix.cpp:
(WebCore::setDestinationPixels):
(WebCore::FEConvolveMatrix::fastSetInteriorPixels):
(WebCore::FEConvolveMatrix::fastSetOuterPixels):
(WebCore::FEConvolveMatrix::platformApplySoftware):
* platform/graphics/filters/FEConvolveMatrix.h:
(PaintingData):
* platform/graphics/filters/FECustomFilter.cpp:
(WebCore::FECustomFilter::platformApplySoftware):
(WebCore::FECustomFilter::bindProgramAndBuffers):
* platform/graphics/filters/FECustomFilter.h:
(JSC):
(FECustomFilter):
* platform/graphics/filters/FEDisplacementMap.cpp:
(WebCore::FEDisplacementMap::platformApplySoftware):
* platform/graphics/filters/FEDropShadow.cpp:
(WebCore::FEDropShadow::platformApplySoftware):
* platform/graphics/filters/FEGaussianBlur.cpp:
(WebCore::boxBlur):
(WebCore::FEGaussianBlur::platformApplyGeneric):
(WebCore::FEGaussianBlur::platformApply):
(WebCore::FEGaussianBlur::platformApplySoftware):
* platform/graphics/filters/FEGaussianBlur.h:
(PlatformApplyParameters):
(FEGaussianBlur):
* platform/graphics/filters/FELighting.cpp:
(WebCore::FELighting::LightingData::topLeft):
(WebCore::FELighting::LightingData::topRow):
(WebCore::FELighting::LightingData::topRight):
(WebCore::FELighting::LightingData::leftColumn):
(WebCore::FELighting::LightingData::interior):
(WebCore::FELighting::LightingData::rightColumn):
(WebCore::FELighting::LightingData::bottomLeft):
(WebCore::FELighting::LightingData::bottomRow):
(WebCore::FELighting::LightingData::bottomRight):
(WebCore::FELighting::inlineSetPixel):
(WebCore::FELighting::drawLighting):
(WebCore::FELighting::platformApplySoftware):
* platform/graphics/filters/FELighting.h:
(LightingData):
(FELighting):
* platform/graphics/filters/FEMorphology.cpp:
(WebCore::FEMorphology::platformApplyGeneric):
(WebCore::FEMorphology::platformApplySoftware):
* platform/graphics/filters/FEMorphology.h:
(PaintingData):
* platform/graphics/filters/FETurbulence.cpp:
(WebCore::FETurbulence::fillRegion):
(WebCore::FETurbulence::platformApplySoftware):
* platform/graphics/filters/FETurbulence.h:
(FillRegionParameters):
(FETurbulence):
* platform/graphics/filters/FilterEffect.cpp:
(WebCore::FilterEffect::forceValidPreMultipliedPixels):
(WebCore::FilterEffect::asUnmultipliedImage):
(WebCore::FilterEffect::asPremultipliedImage):
(WebCore::FilterEffect::copyImageBytes):
(WebCore::FilterEffect::copyUnmultipliedImage):
(WebCore::FilterEffect::copyPremultipliedImage):
(WebCore::FilterEffect::createUnmultipliedImageResult):
(WebCore::FilterEffect::createPremultipliedImageResult):
* platform/graphics/filters/FilterEffect.h:
(FilterEffect):
* platform/graphics/filters/arm/FEGaussianBlurNEON.h:
(WebCore::FEGaussianBlur::platformApplyNeon):
* platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
(WebCore::GraphicsContext3D::paintRenderingResultsToImageData):
* platform/graphics/qt/ImageBufferQt.cpp:
(WebCore::getImageData):
(WebCore::ImageBuffer::getUnmultipliedImageData):
(WebCore::ImageBuffer::getPremultipliedImageData):
(WebCore::ImageBuffer::putByteArray):
* platform/graphics/skia/ImageBufferSkia.cpp:
(WebCore::getImageData):
(WebCore::ImageBuffer::getUnmultipliedImageData):
(WebCore::ImageBuffer::getPremultipliedImageData):
(WebCore::ImageBuffer::putByteArray):
* platform/graphics/texmap/TextureMapperGL.cpp:
* platform/graphics/wince/ImageBufferWinCE.cpp:
(WebCore::getImageData):
(WebCore::ImageBuffer::getUnmultipliedImageData):
(WebCore::ImageBuffer::getPremultipliedImageData):
(WebCore::ImageBuffer::putByteArray):
* platform/graphics/wx/ImageBufferWx.cpp:
(WebCore::ImageBuffer::getUnmultipliedImageData):
(WebCore::ImageBuffer::getPremultipliedImageData):
(WebCore::ImageBuffer::putByteArray):
* platform/image-encoders/skia/JPEGImageEncoder.cpp:
(WebCore::JPEGImageEncoder::encode):
* platform/image-encoders/skia/PNGImageEncoder.cpp:
(WebCore::PNGImageEncoder::encode):
* platform/image-encoders/skia/WEBPImageEncoder.cpp:
(WebCore::WEBPImageEncoder::encode):

Source/WebKit/chromium:

* src/GraphicsContext3DChromium.cpp:
(WebCore::GraphicsContext3DPrivate::paintRenderingResultsToImageData):
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::doPixelReadbackToCanvas):

Source/WTF:

* wtf/ArrayBuffer.h:
(ArrayBuffer):
(WTF::ArrayBuffer::create):
(WTF::ArrayBuffer::createUninitialized):
(WTF):
(WTF::ArrayBufferContents::tryAllocate):
* wtf/TypedArrayBase.h:
(WTF::TypedArrayBase::createUninitialized):
(TypedArrayBase):
* wtf/Uint8ClampedArray.h:
(Uint8ClampedArray):
(WTF::Uint8ClampedArray::createUninitialized):
(WTF):
(WTF::Uint8ClampedArray::zeroFill):

LayoutTests:

* fast/canvas/imagedata-contains-uint8clampedarray-expected.txt: Added.
* fast/canvas/imagedata-contains-uint8clampedarray.html: Added.
* fast/dom/Window/script-tests/postmessage-clone.js:
* fast/dom/Window/window-postmessage-clone-expected.txt:
* platform/chromium/fast/dom/Window/window-postmessage-clone-expected.txt:
* platform/gtk/fast/dom/Window/window-postmessage-clone-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@114992 268f45cc-cd09-0410-ab3c-d52691b4dbfc
63 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/canvas/imagedata-contains-uint8clampedarray-expected.txt [new file with mode: 0644]
LayoutTests/fast/canvas/imagedata-contains-uint8clampedarray.html [new file with mode: 0644]
LayoutTests/fast/dom/Window/script-tests/postmessage-clone.js
LayoutTests/fast/dom/Window/window-postmessage-clone-expected.txt
LayoutTests/platform/chromium/fast/dom/Window/window-postmessage-clone-expected.txt
LayoutTests/platform/gtk/fast/dom/Window/window-postmessage-clone-expected.txt
Source/WTF/ChangeLog
Source/WTF/wtf/ArrayBuffer.h
Source/WTF/wtf/TypedArrayBase.h
Source/WTF/wtf/Uint8ClampedArray.h
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSImageDataCustom.cpp
Source/WebCore/bindings/js/SerializedScriptValue.cpp
Source/WebCore/bindings/v8/SerializedScriptValue.cpp
Source/WebCore/bindings/v8/custom/V8ImageDataCustom.cpp
Source/WebCore/bridge/qt/qt_pixmapruntime.cpp
Source/WebCore/html/ImageData.cpp
Source/WebCore/html/ImageData.h
Source/WebCore/html/ImageData.idl
Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
Source/WebCore/platform/graphics/GraphicsContext3D.cpp
Source/WebCore/platform/graphics/ImageBuffer.cpp
Source/WebCore/platform/graphics/ImageBuffer.h
Source/WebCore/platform/graphics/ShadowBlur.cpp
Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp
Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp
Source/WebCore/platform/graphics/cg/ImageBufferDataCG.h
Source/WebCore/platform/graphics/filters/FEBlend.cpp
Source/WebCore/platform/graphics/filters/FEColorMatrix.cpp
Source/WebCore/platform/graphics/filters/FEComponentTransfer.cpp
Source/WebCore/platform/graphics/filters/FEComposite.cpp
Source/WebCore/platform/graphics/filters/FEComposite.h
Source/WebCore/platform/graphics/filters/FEConvolveMatrix.cpp
Source/WebCore/platform/graphics/filters/FEConvolveMatrix.h
Source/WebCore/platform/graphics/filters/FECustomFilter.cpp
Source/WebCore/platform/graphics/filters/FECustomFilter.h
Source/WebCore/platform/graphics/filters/FEDisplacementMap.cpp
Source/WebCore/platform/graphics/filters/FEDropShadow.cpp
Source/WebCore/platform/graphics/filters/FEGaussianBlur.cpp
Source/WebCore/platform/graphics/filters/FEGaussianBlur.h
Source/WebCore/platform/graphics/filters/FELighting.cpp
Source/WebCore/platform/graphics/filters/FELighting.h
Source/WebCore/platform/graphics/filters/FEMorphology.cpp
Source/WebCore/platform/graphics/filters/FEMorphology.h
Source/WebCore/platform/graphics/filters/FETurbulence.cpp
Source/WebCore/platform/graphics/filters/FETurbulence.h
Source/WebCore/platform/graphics/filters/FilterEffect.cpp
Source/WebCore/platform/graphics/filters/FilterEffect.h
Source/WebCore/platform/graphics/filters/arm/FEGaussianBlurNEON.h
Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp
Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp
Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp
Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp
Source/WebCore/platform/graphics/wx/ImageBufferWx.cpp
Source/WebCore/platform/image-encoders/skia/JPEGImageEncoder.cpp
Source/WebCore/platform/image-encoders/skia/PNGImageEncoder.cpp
Source/WebCore/platform/image-encoders/skia/WEBPImageEncoder.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp
Source/WebKit/chromium/src/WebViewImpl.cpp