Changeset 114992 in webkit
- Timestamp:
- Apr 23, 2012 8:43:31 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 61 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r114990 r114992 1 2012-04-23 Kenneth Russell <kbr@google.com> 2 3 Change ImageData to reference Uint8ClampedArray rather than CanvasPixelArray 4 https://bugs.webkit.org/show_bug.cgi?id=73011 5 6 Reviewed by Oliver Hunt. 7 8 * fast/canvas/imagedata-contains-uint8clampedarray-expected.txt: Added. 9 * fast/canvas/imagedata-contains-uint8clampedarray.html: Added. 10 * fast/dom/Window/script-tests/postmessage-clone.js: 11 * fast/dom/Window/window-postmessage-clone-expected.txt: 12 * platform/chromium/fast/dom/Window/window-postmessage-clone-expected.txt: 13 * platform/gtk/fast/dom/Window/window-postmessage-clone-expected.txt: 14 1 15 2012-04-23 Kent Tamura <tkent@chromium.org> 2 16 -
trunk/LayoutTests/fast/dom/Window/script-tests/postmessage-clone.js
r100239 r114992 60 60 mutatedImageData.data[i] = i % 256; 61 61 tryPostMessage('imageData', false, imageData); 62 tryPostMessage('imageData.data', true, null, DOMException.DATA_CLONE_ERR)62 tryPostMessage('imageData.data', false, imageData.data) 63 63 tryPostMessage('mutatedImageData', false, imageData); 64 tryPostMessage('mutatedImageData.data', true, null, DOMException.DATA_CLONE_ERR)64 tryPostMessage('mutatedImageData.data', false, imageData.data) 65 65 for (var i = 0; i < imageData.data.length * 4; i++) 66 66 mutatedImageData.data[i] = 0; -
trunk/LayoutTests/fast/dom/Window/window-postmessage-clone-expected.txt
r91959 r114992 7 7 PASS: 'postMessage(window)' threw TypeError: Type error 8 8 PASS: 'postMessage(({get a() { throw "x" }}))' threw x 9 FAIL: 'postMessage(imageData.data)' should throw but didn't10 FAIL: 'postMessage(mutatedImageData.data)' should throw but didn't11 9 PASS: 'postMessage((function() {return {get a() { throw "accessor-exn"; }};})())' threw accessor-exn 12 10 PASS: 'postMessage((function() {var obja = {get p() { throw "accessor-exn"; }}; return {get a() { return obja; }};})())' threw accessor-exn … … 45 43 PASS: eventData[0] is === to eventData[1] 46 44 PASS: eventData is [object ImageData] of type object 45 PASS: eventData is [object Uint8ClampedArray] of type object 47 46 PASS: eventData is [object ImageData] of type object 47 PASS: eventData is [object Uint8ClampedArray] of type object 48 48 PASS: eventData is 42 of type number 49 49 PASS: eventData is 42 of type number -
trunk/LayoutTests/platform/chromium/fast/dom/Window/window-postmessage-clone-expected.txt
r91959 r114992 5 5 PASS: 'postMessage(window)' threw Error: DATA_CLONE_ERR: DOM Exception 25 6 6 PASS: 'postMessage(({get a() { throw "x" }}))' threw x 7 PASS: 'postMessage(imageData.data)' threw Error: DATA_CLONE_ERR: DOM Exception 258 PASS: 'postMessage(mutatedImageData.data)' threw Error: DATA_CLONE_ERR: DOM Exception 259 7 PASS: 'postMessage((function() {return {get a() { throw "accessor-exn"; }};})())' threw accessor-exn 10 8 PASS: 'postMessage((function() {var obja = {get p() { throw "accessor-exn"; }}; return {get a() { return obja; }};})())' threw accessor-exn … … 41 39 PASS: eventData[0] is === to eventData[1] 42 40 PASS: eventData is [object ImageData] of type object 41 PASS: eventData is [object Uint8ClampedArray] of type object 43 42 PASS: eventData is [object ImageData] of type object 43 PASS: eventData is [object Uint8ClampedArray] of type object 44 44 PASS: eventData is 42 of type number 45 45 PASS: eventData is 42 of type number -
trunk/LayoutTests/platform/gtk/fast/dom/Window/window-postmessage-clone-expected.txt
r92368 r114992 38 38 PASS: eventData.graph1 is === to eventData.graph2 39 39 PASS: eventData[0] is === to eventData[1] 40 FAIL: 'postMessage(imageData.data)' should throw but didn't41 FAIL: 'postMessage(mutatedImageData.data)' should throw but didn't42 40 PASS: 'postMessage((function() {return {get a() { throw "accessor-exn"; }};})())' threw accessor-exn 43 41 PASS: 'postMessage((function() {var obja = {get p() { throw "accessor-exn"; }}; return {get a() { return obja; }};})())' threw accessor-exn … … 45 43 PASS: sanity on file reference equality 46 44 PASS: eventData is [object ImageData] of type object 45 PASS: eventData is [object Uint8ClampedArray] of type object 47 46 PASS: eventData is [object ImageData] of type object 47 PASS: eventData is [object Uint8ClampedArray] of type object 48 48 PASS: eventData is 42 of type number 49 49 PASS: eventData is 42 of type number -
trunk/Source/WTF/ChangeLog
r114985 r114992 1 2012-04-23 Kenneth Russell <kbr@google.com> 2 3 Change ImageData to reference Uint8ClampedArray rather than CanvasPixelArray 4 https://bugs.webkit.org/show_bug.cgi?id=73011 5 6 Reviewed by Oliver Hunt. 7 8 * wtf/ArrayBuffer.h: 9 (ArrayBuffer): 10 (WTF::ArrayBuffer::create): 11 (WTF::ArrayBuffer::createUninitialized): 12 (WTF): 13 (WTF::ArrayBufferContents::tryAllocate): 14 * wtf/TypedArrayBase.h: 15 (WTF::TypedArrayBase::createUninitialized): 16 (TypedArrayBase): 17 * wtf/Uint8ClampedArray.h: 18 (Uint8ClampedArray): 19 (WTF::Uint8ClampedArray::createUninitialized): 20 (WTF): 21 (WTF::Uint8ClampedArray::zeroFill): 22 1 23 2012-04-23 George Staikos <staikos@webkit.org> 2 24 -
trunk/Source/WTF/wtf/ArrayBuffer.h
r111778 r114992 58 58 friend class ArrayBuffer; 59 59 60 static inline void tryAllocate(unsigned numElements, unsigned elementByteSize, ArrayBufferContents&); 60 enum InitializationPolicy { 61 ZeroInitialize, 62 DontInitialize 63 }; 64 65 static inline void tryAllocate(unsigned numElements, unsigned elementByteSize, InitializationPolicy, ArrayBufferContents&); 61 66 void transfer(ArrayBufferContents& other) 62 67 { … … 79 84 static inline PassRefPtr<ArrayBuffer> create(ArrayBufferContents&); 80 85 86 // Only for use by Uint8ClampedArray::createUninitialized. 87 static inline PassRefPtr<ArrayBuffer> createUninitialized(unsigned numElements, unsigned elementByteSize); 88 81 89 inline void* data(); 82 90 inline const void* data() const; … … 95 103 96 104 private: 105 static inline PassRefPtr<ArrayBuffer> create(unsigned numElements, unsigned elementByteSize, ArrayBufferContents::InitializationPolicy); 106 97 107 inline ArrayBuffer(ArrayBufferContents&); 98 108 inline PassRefPtr<ArrayBuffer> sliceImpl(unsigned begin, unsigned end) const; … … 116 126 PassRefPtr<ArrayBuffer> ArrayBuffer::create(unsigned numElements, unsigned elementByteSize) 117 127 { 128 return create(numElements, elementByteSize, ArrayBufferContents::ZeroInitialize); 129 } 130 131 PassRefPtr<ArrayBuffer> ArrayBuffer::create(ArrayBuffer* other) 132 { 133 return ArrayBuffer::create(other->data(), other->byteLength()); 134 } 135 136 PassRefPtr<ArrayBuffer> ArrayBuffer::create(const void* source, unsigned byteLength) 137 { 118 138 ArrayBufferContents contents; 119 ArrayBufferContents::tryAllocate(numElements, elementByteSize, contents); 120 if (!contents.m_data) 121 return 0; 122 return adoptRef(new ArrayBuffer(contents)); 123 } 124 125 PassRefPtr<ArrayBuffer> ArrayBuffer::create(ArrayBuffer* other) 126 { 127 return ArrayBuffer::create(other->data(), other->byteLength()); 128 } 129 130 PassRefPtr<ArrayBuffer> ArrayBuffer::create(const void* source, unsigned byteLength) 131 { 132 ArrayBufferContents contents; 133 ArrayBufferContents::tryAllocate(byteLength, 1, contents); 139 ArrayBufferContents::tryAllocate(byteLength, 1, ArrayBufferContents::ZeroInitialize, contents); 134 140 if (!contents.m_data) 135 141 return 0; … … 144 150 } 145 151 152 PassRefPtr<ArrayBuffer> ArrayBuffer::createUninitialized(unsigned numElements, unsigned elementByteSize) 153 { 154 return create(numElements, elementByteSize, ArrayBufferContents::DontInitialize); 155 } 156 157 PassRefPtr<ArrayBuffer> ArrayBuffer::create(unsigned numElements, unsigned elementByteSize, ArrayBufferContents::InitializationPolicy policy) 158 { 159 ArrayBufferContents contents; 160 ArrayBufferContents::tryAllocate(numElements, elementByteSize, policy, contents); 161 if (!contents.m_data) 162 return 0; 163 return adoptRef(new ArrayBuffer(contents)); 164 } 165 146 166 ArrayBuffer::ArrayBuffer(ArrayBufferContents& contents) 147 167 : m_firstView(0) … … 189 209 } 190 210 191 void ArrayBufferContents::tryAllocate(unsigned numElements, unsigned elementByteSize, ArrayBufferContents & result)211 void ArrayBufferContents::tryAllocate(unsigned numElements, unsigned elementByteSize, ArrayBufferContents::InitializationPolicy policy, ArrayBufferContents& result) 192 212 { 193 213 // Do not allow 32-bit overflow of the total size. … … 202 222 } 203 223 } 204 if (WTF::tryFastCalloc(numElements, elementByteSize).getValue(result.m_data)) { 224 bool allocationSucceeded = false; 225 if (policy == ZeroInitialize) 226 allocationSucceeded = WTF::tryFastCalloc(numElements, elementByteSize).getValue(result.m_data); 227 else { 228 ASSERT(policy == DontInitialize); 229 allocationSucceeded = WTF::tryFastMalloc(numElements * elementByteSize).getValue(result.m_data); 230 } 231 232 if (allocationSucceeded) { 205 233 result.m_sizeInBytes = numElements * elementByteSize; 206 234 return; -
trunk/Source/WTF/wtf/TypedArrayBase.h
r111778 r114992 105 105 106 106 template <class Subclass> 107 static PassRefPtr<Subclass> createUninitialized(unsigned length) 108 { 109 RefPtr<ArrayBuffer> buffer = ArrayBuffer::createUninitialized(length, sizeof(T)); 110 if (!buffer.get()) 111 return 0; 112 return create<Subclass>(buffer, 0, length); 113 } 114 115 template <class Subclass> 107 116 PassRefPtr<Subclass> subarrayImpl(int start, int end) const 108 117 { -
trunk/Source/WTF/wtf/Uint8ClampedArray.h
r111778 r114992 39 39 static inline PassRefPtr<Uint8ClampedArray> create(PassRefPtr<ArrayBuffer>, unsigned byteOffset, unsigned length); 40 40 41 // Should only be used for WebCore-internal use (like filters and 42 // getImageData) when it is known the entire array will be filled. 43 // Do not return these results directly to JavaScript. 44 static inline PassRefPtr<Uint8ClampedArray> createUninitialized(unsigned length); 45 46 // It's only needed to potentially call this method if the array 47 // was created uninitialized -- the default initialization paths 48 // zero the allocated memory. 49 inline void zeroFill(); 50 41 51 // Can’t use "using" here due to a bug in the RVCT compiler. 42 52 bool set(TypedArrayBase<unsigned char>* array, unsigned offset) { return TypedArrayBase<unsigned char>::set(array, offset); } … … 72 82 } 73 83 84 PassRefPtr<Uint8ClampedArray> Uint8ClampedArray::createUninitialized(unsigned length) 85 { 86 return TypedArrayBase<unsigned char>::createUninitialized<Uint8ClampedArray>(length); 87 } 88 89 void Uint8ClampedArray::zeroFill() 90 { 91 zeroRange(0, length()); 92 } 93 74 94 void Uint8ClampedArray::set(unsigned index, double value) 75 95 { -
trunk/Source/WebCore/ChangeLog
r114991 r114992 1 2012-04-23 Kenneth Russell <kbr@google.com> 2 3 Change ImageData to reference Uint8ClampedArray rather than CanvasPixelArray 4 https://bugs.webkit.org/show_bug.cgi?id=73011 5 6 Reviewed by Oliver Hunt. 7 8 Changed ImageData to contain Uint8ClampedArray instead of ByteArray 9 per current HTML5 spec. 10 11 In order to avoid introducing large data copies, it was necessary to 12 switch a few other places in WebKit to use Uint8ClampedArray at the 13 same time, most notably the FilterEffect implementation, portions of 14 ImageBuffer, and a couple of places in the image encoders. 15 16 Note that the change in method name from "get" to "item" occurred 17 because JSC's autogenerated indexed getters reference a method 18 called "item". If desired, a convenience method could be 19 introduced to avoid the renamings in the FilterEffect classes. 20 21 With these changes, ByteArray and some custom code in JavaScriptCore 22 actually become unreferenced, and can be deleted. This deletion will 23 be done separately in Bug 83655, to keep the size of this patch 24 manageable. 25 26 Test: fast/canvas/imagedata-contains-uint8clampedarray.html 27 28 * bindings/js/JSImageDataCustom.cpp: 29 (WebCore::toJS): 30 * bindings/js/SerializedScriptValue.cpp: 31 (WebCore::CloneSerializer::dumpIfTerminal): 32 (WebCore::CloneDeserializer::readTerminal): 33 * bindings/v8/SerializedScriptValue.cpp: 34 * bindings/v8/custom/V8ImageDataCustom.cpp: 35 (WebCore::toV8): 36 * bridge/qt/qt_pixmapruntime.cpp: 37 (JSC::Bindings::QtPixmapToImageDataMethod::invoke): 38 * html/ImageData.cpp: 39 (WebCore::ImageData::create): 40 (WebCore::ImageData::ImageData): 41 * html/ImageData.h: 42 (ImageData): 43 (WebCore::ImageData::data): 44 * html/ImageData.idl: 45 * html/canvas/CanvasRenderingContext2D.cpp: 46 (WebCore::createEmptyImageData): 47 (WebCore::CanvasRenderingContext2D::getImageData): 48 (WebCore::CanvasRenderingContext2D::putImageData): 49 * platform/graphics/GraphicsContext3D.cpp: 50 (WebCore::GraphicsContext3D::extractImageData): 51 * platform/graphics/ImageBuffer.cpp: 52 (WebCore::ImageBuffer::genericConvertToLuminanceMask): 53 * platform/graphics/ImageBuffer.h: 54 * platform/graphics/ShadowBlur.cpp: 55 (WebCore::ShadowBlur::blurShadowBuffer): 56 * platform/graphics/cairo/ImageBufferCairo.cpp: 57 (WebCore::getImageData): 58 (WebCore::ImageBuffer::getUnmultipliedImageData): 59 (WebCore::ImageBuffer::getPremultipliedImageData): 60 (WebCore::ImageBuffer::putByteArray): 61 * platform/graphics/cg/ImageBufferCG.cpp: 62 (WebCore::ImageBuffer::getUnmultipliedImageData): 63 (WebCore::ImageBuffer::getPremultipliedImageData): 64 (WebCore::ImageBuffer::putByteArray): 65 (WebCore::ImageBuffer::toDataURL): 66 (WebCore::ImageDataToDataURL): 67 * platform/graphics/cg/ImageBufferDataCG.cpp: 68 (WebCore::ImageBufferData::getData): 69 (WebCore::ImageBufferData::putData): 70 * platform/graphics/cg/ImageBufferDataCG.h: 71 (ImageBufferData): 72 * platform/graphics/filters/FEBlend.cpp: 73 (WebCore::FEBlend::platformApplySoftware): 74 * platform/graphics/filters/FEColorMatrix.cpp: 75 (WebCore::effectType): 76 (WebCore::FEColorMatrix::platformApplySoftware): 77 * platform/graphics/filters/FEComponentTransfer.cpp: 78 (WebCore::FEComponentTransfer::platformApplySoftware): 79 * platform/graphics/filters/FEComposite.cpp: 80 (WebCore::FEComposite::platformArithmeticSoftware): 81 (WebCore::FEComposite::platformApplySoftware): 82 * platform/graphics/filters/FEComposite.h: 83 * platform/graphics/filters/FEConvolveMatrix.cpp: 84 (WebCore::setDestinationPixels): 85 (WebCore::FEConvolveMatrix::fastSetInteriorPixels): 86 (WebCore::FEConvolveMatrix::fastSetOuterPixels): 87 (WebCore::FEConvolveMatrix::platformApplySoftware): 88 * platform/graphics/filters/FEConvolveMatrix.h: 89 (PaintingData): 90 * platform/graphics/filters/FECustomFilter.cpp: 91 (WebCore::FECustomFilter::platformApplySoftware): 92 (WebCore::FECustomFilter::bindProgramAndBuffers): 93 * platform/graphics/filters/FECustomFilter.h: 94 (JSC): 95 (FECustomFilter): 96 * platform/graphics/filters/FEDisplacementMap.cpp: 97 (WebCore::FEDisplacementMap::platformApplySoftware): 98 * platform/graphics/filters/FEDropShadow.cpp: 99 (WebCore::FEDropShadow::platformApplySoftware): 100 * platform/graphics/filters/FEGaussianBlur.cpp: 101 (WebCore::boxBlur): 102 (WebCore::FEGaussianBlur::platformApplyGeneric): 103 (WebCore::FEGaussianBlur::platformApply): 104 (WebCore::FEGaussianBlur::platformApplySoftware): 105 * platform/graphics/filters/FEGaussianBlur.h: 106 (PlatformApplyParameters): 107 (FEGaussianBlur): 108 * platform/graphics/filters/FELighting.cpp: 109 (WebCore::FELighting::LightingData::topLeft): 110 (WebCore::FELighting::LightingData::topRow): 111 (WebCore::FELighting::LightingData::topRight): 112 (WebCore::FELighting::LightingData::leftColumn): 113 (WebCore::FELighting::LightingData::interior): 114 (WebCore::FELighting::LightingData::rightColumn): 115 (WebCore::FELighting::LightingData::bottomLeft): 116 (WebCore::FELighting::LightingData::bottomRow): 117 (WebCore::FELighting::LightingData::bottomRight): 118 (WebCore::FELighting::inlineSetPixel): 119 (WebCore::FELighting::drawLighting): 120 (WebCore::FELighting::platformApplySoftware): 121 * platform/graphics/filters/FELighting.h: 122 (LightingData): 123 (FELighting): 124 * platform/graphics/filters/FEMorphology.cpp: 125 (WebCore::FEMorphology::platformApplyGeneric): 126 (WebCore::FEMorphology::platformApplySoftware): 127 * platform/graphics/filters/FEMorphology.h: 128 (PaintingData): 129 * platform/graphics/filters/FETurbulence.cpp: 130 (WebCore::FETurbulence::fillRegion): 131 (WebCore::FETurbulence::platformApplySoftware): 132 * platform/graphics/filters/FETurbulence.h: 133 (FillRegionParameters): 134 (FETurbulence): 135 * platform/graphics/filters/FilterEffect.cpp: 136 (WebCore::FilterEffect::forceValidPreMultipliedPixels): 137 (WebCore::FilterEffect::asUnmultipliedImage): 138 (WebCore::FilterEffect::asPremultipliedImage): 139 (WebCore::FilterEffect::copyImageBytes): 140 (WebCore::FilterEffect::copyUnmultipliedImage): 141 (WebCore::FilterEffect::copyPremultipliedImage): 142 (WebCore::FilterEffect::createUnmultipliedImageResult): 143 (WebCore::FilterEffect::createPremultipliedImageResult): 144 * platform/graphics/filters/FilterEffect.h: 145 (FilterEffect): 146 * platform/graphics/filters/arm/FEGaussianBlurNEON.h: 147 (WebCore::FEGaussianBlur::platformApplyNeon): 148 * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp: 149 (WebCore::GraphicsContext3D::paintRenderingResultsToImageData): 150 * platform/graphics/qt/ImageBufferQt.cpp: 151 (WebCore::getImageData): 152 (WebCore::ImageBuffer::getUnmultipliedImageData): 153 (WebCore::ImageBuffer::getPremultipliedImageData): 154 (WebCore::ImageBuffer::putByteArray): 155 * platform/graphics/skia/ImageBufferSkia.cpp: 156 (WebCore::getImageData): 157 (WebCore::ImageBuffer::getUnmultipliedImageData): 158 (WebCore::ImageBuffer::getPremultipliedImageData): 159 (WebCore::ImageBuffer::putByteArray): 160 * platform/graphics/texmap/TextureMapperGL.cpp: 161 * platform/graphics/wince/ImageBufferWinCE.cpp: 162 (WebCore::getImageData): 163 (WebCore::ImageBuffer::getUnmultipliedImageData): 164 (WebCore::ImageBuffer::getPremultipliedImageData): 165 (WebCore::ImageBuffer::putByteArray): 166 * platform/graphics/wx/ImageBufferWx.cpp: 167 (WebCore::ImageBuffer::getUnmultipliedImageData): 168 (WebCore::ImageBuffer::getPremultipliedImageData): 169 (WebCore::ImageBuffer::putByteArray): 170 * platform/image-encoders/skia/JPEGImageEncoder.cpp: 171 (WebCore::JPEGImageEncoder::encode): 172 * platform/image-encoders/skia/PNGImageEncoder.cpp: 173 (WebCore::PNGImageEncoder::encode): 174 * platform/image-encoders/skia/WEBPImageEncoder.cpp: 175 (WebCore::WEBPImageEncoder::encode): 176 1 177 2012-04-23 Ryan Sleevi <rsleevi@chromium.org> 2 178 -
trunk/Source/WebCore/bindings/js/JSImageDataCustom.cpp
r104324 r114992 26 26 #include "config.h" 27 27 #include "JSImageData.h" 28 #include "JSUint8ClampedArray.h" 28 29 29 30 #include "ImageData.h" 30 31 #include "PlatformString.h" 31 32 32 #include <runtime/JSByteArray.h>33 33 #include <wtf/StdLibExtras.h> 34 34 … … 48 48 wrapper = CREATE_DOM_WRAPPER(exec, globalObject, ImageData, imageData); 49 49 Identifier dataName(exec, "data"); 50 Structure* cpaStructure = getCachedDOMStructure(globalObject, &JSByteArray::s_info); 51 if (!cpaStructure) 52 cpaStructure = cacheDOMStructure(globalObject, JSByteArray::createStructure(exec->globalData(), globalObject, jsNull(), &JSByteArray::s_info), &JSByteArray::s_info); 53 wrapper->putDirect(exec->globalData(), dataName, JSByteArray::create(exec, cpaStructure, imageData->data()->data()), DontDelete | ReadOnly); 50 wrapper->putDirect(exec->globalData(), dataName, toJS(exec, globalObject, imageData->data()), DontDelete | ReadOnly); 54 51 exec->heap()->reportExtraMemoryCost(imageData->data()->length()); 55 52 -
trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp
r114013 r114992 64 64 #include <runtime/RegExpObject.h> 65 65 #include <wtf/ArrayBuffer.h> 66 #include <wtf/ByteArray.h>67 66 #include <wtf/HashTraits.h> 67 #include <wtf/Uint8ClampedArray.h> 68 68 #include <wtf/Vector.h> 69 69 … … 610 610 write(data->height()); 611 611 write(data->data()->length()); 612 write(data->data()->data() ->data(), data->data()->length());612 write(data->data()->data(), data->data()->length()); 613 613 return true; 614 614 } … … 1431 1431 } 1432 1432 RefPtr<ImageData> result = ImageData::create(IntSize(width, height)); 1433 memcpy(result->data()->data() ->data(), m_ptr, length);1433 memcpy(result->data()->data(), m_ptr, length); 1434 1434 m_ptr += length; 1435 1435 return getJSValue(result.get()); -
trunk/Source/WebCore/bindings/v8/SerializedScriptValue.cpp
r111258 r114992 35 35 #include <wtf/ArrayBufferView.h> 36 36 #include "Blob.h" 37 #include <wtf/ByteArray.h>38 37 #include "CanvasPixelArray.h" 39 38 #include "DataView.h" … … 1007 1006 if (!imageData) 1008 1007 return; 1009 WTF::ByteArray* pixelArray = imageData->data()->data();1008 Uint8ClampedArray* pixelArray = imageData->data(); 1010 1009 m_writer.writeImageData(imageData->width(), imageData->height(), pixelArray->data(), pixelArray->length()); 1011 1010 } … … 1583 1582 return false; 1584 1583 RefPtr<ImageData> imageData = ImageData::create(IntSize(width, height)); 1585 WTF::ByteArray* pixelArray = imageData->data()->data();1584 Uint8ClampedArray* pixelArray = imageData->data(); 1586 1585 ASSERT(pixelArray); 1587 1586 ASSERT(pixelArray->length() >= pixelDataLength); -
trunk/Source/WebCore/bindings/v8/custom/V8ImageDataCustom.cpp
r114927 r114992 32 32 #include "V8ImageData.h" 33 33 34 #include "V8 CanvasPixelArray.h"34 #include "V8Uint8ClampedArray.h" 35 35 36 36 namespace WebCore { … … 42 42 v8::Handle<v8::Object> wrapper = V8ImageData::wrap(impl); 43 43 if (!wrapper.IsEmpty()) { 44 // Create a V8 CanvasPixelArray object.44 // Create a V8 Uint8ClampedArray object. 45 45 v8::Handle<v8::Value> pixelArray = toV8(impl->data(), isolate); 46 46 // Set the "data" property of the ImageData object to -
trunk/Source/WebCore/bridge/qt/qt_pixmapruntime.cpp
r97448 r114992 93 93 int width = instance->width(); 94 94 int height = instance->height(); 95 RefPtr<ByteArray> byteArray = ByteArray::create(width * height * 4); 96 copyPixels(instance->toImage(), width, height, byteArray->data()); 97 RefPtr<ImageData> imageData = ImageData::create(IntSize(width, height), byteArray); 95 RefPtr<ImageData> imageData = ImageData::create(IntSize(width, height)); 96 copyPixels(instance->toImage(), width, height, imageData->data()->data()); 98 97 return toJS(exec, static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), imageData.get()); 99 98 } -
trunk/Source/WebCore/html/ImageData.cpp
r95901 r114992 34 34 PassRefPtr<ImageData> ImageData::create(const IntSize& size) 35 35 { 36 Checked<int, RecordOverflow> dataSize = 4; 37 dataSize *= size.width(); 38 dataSize *= size.height(); 39 if (dataSize.hasOverflowed()) 40 return 0; 41 36 42 return adoptRef(new ImageData(size)); 37 43 } 38 44 39 PassRefPtr<ImageData> ImageData::create(const IntSize& size, PassRefPtr< ByteArray> byteArray)45 PassRefPtr<ImageData> ImageData::create(const IntSize& size, PassRefPtr<Uint8ClampedArray> byteArray) 40 46 { 47 Checked<int, RecordOverflow> dataSize = 4; 48 dataSize *= size.width(); 49 dataSize *= size.height(); 50 if (dataSize.hasOverflowed()) 51 return 0; 52 53 if (dataSize.unsafeGet() < 0 54 || static_cast<unsigned>(dataSize.unsafeGet()) > byteArray->length()) 55 return 0; 56 41 57 return adoptRef(new ImageData(size, byteArray)); 42 58 } … … 44 60 ImageData::ImageData(const IntSize& size) 45 61 : m_size(size) 46 , m_data( CanvasPixelArray::create(size.width() * size.height() * 4))62 , m_data(Uint8ClampedArray::createUninitialized(size.width() * size.height() * 4)) 47 63 { 48 64 } 49 65 50 ImageData::ImageData(const IntSize& size, PassRefPtr< ByteArray> byteArray)66 ImageData::ImageData(const IntSize& size, PassRefPtr<Uint8ClampedArray> byteArray) 51 67 : m_size(size) 52 , m_data( CanvasPixelArray::create(byteArray))68 , m_data(byteArray) 53 69 { 70 ASSERT(static_cast<unsigned>(size.width() * size.height() * 4) <= m_data->length()); 54 71 } 55 72 -
trunk/Source/WebCore/html/ImageData.h
r95901 r114992 30 30 #define ImageData_h 31 31 32 #include "CanvasPixelArray.h"33 32 #include "IntSize.h" 34 #include <wtf/ByteArray.h>35 33 #include <wtf/RefCounted.h> 36 34 #include <wtf/RefPtr.h> 35 #include <wtf/Uint8ClampedArray.h> 37 36 38 37 namespace WebCore { … … 41 40 public: 42 41 static PassRefPtr<ImageData> create(const IntSize&); 43 static PassRefPtr<ImageData> create(const IntSize&, PassRefPtr< ByteArray>);42 static PassRefPtr<ImageData> create(const IntSize&, PassRefPtr<Uint8ClampedArray>); 44 43 45 44 IntSize size() const { return m_size; } 46 45 int width() const { return m_size.width(); } 47 46 int height() const { return m_size.height(); } 48 CanvasPixelArray* data() const { return m_data.get(); }47 Uint8ClampedArray* data() const { return m_data.get(); } 49 48 50 49 private: 51 50 ImageData(const IntSize&); 52 ImageData(const IntSize&, PassRefPtr< ByteArray>);51 ImageData(const IntSize&, PassRefPtr<Uint8ClampedArray>); 53 52 54 53 IntSize m_size; 55 RefPtr< CanvasPixelArray> m_data;54 RefPtr<Uint8ClampedArray> m_data; 56 55 }; 57 56 -
trunk/Source/WebCore/html/ImageData.idl
r107636 r114992 35 35 readonly attribute long height; 36 36 #if !defined(LANGUAGE_JAVASCRIPT) || !LANGUAGE_JAVASCRIPT 37 readonly attribute CanvasPixelArray data;37 readonly attribute Uint8ClampedArray data; 38 38 #endif 39 39 }; -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
r114691 r114992 63 63 #include "TextRun.h" 64 64 65 #include <wtf/ByteArray.h> 65 #if USE(ACCELERATED_COMPOSITING) 66 #include "RenderLayer.h" 67 #endif 68 66 69 #include <wtf/CheckedArithmetic.h> 67 70 #include <wtf/MathExtras.h> 68 71 #include <wtf/OwnPtr.h> 72 #include <wtf/Uint8ClampedArray.h> 69 73 #include <wtf/UnusedParam.h> 70 74 … … 1741 1745 1742 1746 RefPtr<ImageData> data = ImageData::create(size); 1743 memset(data->data()->data()->data(), 0, data->data()->data()->length());1747 data->data()->zeroFill(); 1744 1748 return data.release(); 1745 1749 } … … 1830 1834 return createEmptyImageData(imageDataRect.size()); 1831 1835 1832 RefPtr< ByteArray> byteArray = buffer->getUnmultipliedImageData(imageDataRect, coordinateSystem);1836 RefPtr<Uint8ClampedArray> byteArray = buffer->getUnmultipliedImageData(imageDataRect, coordinateSystem); 1833 1837 if (!byteArray) 1834 1838 return 0; … … 1903 1907 sourceRect.move(-destOffset); 1904 1908 1905 buffer->putByteArray(Unmultiplied, data->data() ->data(), IntSize(data->width(), data->height()), sourceRect, IntPoint(destOffset), coordinateSystem);1909 buffer->putByteArray(Unmultiplied, data->data(), IntSize(data->width(), data->height()), sourceRect, IntPoint(destOffset), coordinateSystem); 1906 1910 1907 1911 if (coordinateSystem == ImageBuffer::BackingStoreCoordinateSystem) { -
trunk/Source/WebCore/platform/graphics/GraphicsContext3D.cpp
r110602 r114992 203 203 int dataBytes = width * height * 4; 204 204 data.resize(dataBytes); 205 if (!packPixels(imageData->data()->data() ->data(),205 if (!packPixels(imageData->data()->data(), 206 206 SourceFormatRGBA8, 207 207 width, -
trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp
r109016 r114992 73 73 { 74 74 IntRect luminanceRect(IntPoint(), internalSize()); 75 RefPtr< ByteArray> srcPixelArray = getUnmultipliedImageData(luminanceRect);75 RefPtr<Uint8ClampedArray> srcPixelArray = getUnmultipliedImageData(luminanceRect); 76 76 77 77 unsigned pixelArrayLength = srcPixelArray->length(); 78 78 for (unsigned pixelOffset = 0; pixelOffset < pixelArrayLength; pixelOffset += 4) { 79 unsigned char a = srcPixelArray-> get(pixelOffset + 3);79 unsigned char a = srcPixelArray->item(pixelOffset + 3); 80 80 if (!a) 81 81 continue; 82 unsigned char r = srcPixelArray-> get(pixelOffset);83 unsigned char g = srcPixelArray-> get(pixelOffset + 1);84 unsigned char b = srcPixelArray-> get(pixelOffset + 2);82 unsigned char r = srcPixelArray->item(pixelOffset); 83 unsigned char g = srcPixelArray->item(pixelOffset + 1); 84 unsigned char b = srcPixelArray->item(pixelOffset + 2); 85 85 86 86 double luma = (r * 0.2125 + g * 0.7154 + b * 0.0721) * ((double)a / 255.0); -
trunk/Source/WebCore/platform/graphics/ImageBuffer.h
r114150 r114992 39 39 #include "IntSize.h" 40 40 #include "ImageBufferData.h" 41 #include <wtf/ByteArray.h>42 41 #include <wtf/Forward.h> 43 42 #include <wtf/OwnPtr.h> 44 43 #include <wtf/PassOwnPtr.h> 45 44 #include <wtf/PassRefPtr.h> 45 #include <wtf/Uint8ClampedArray.h> 46 46 #include <wtf/Vector.h> 47 47 … … 99 99 enum CoordinateSystem { LogicalCoordinateSystem, BackingStoreCoordinateSystem }; 100 100 101 PassRefPtr< ByteArray> getUnmultipliedImageData(const IntRect&, CoordinateSystem = LogicalCoordinateSystem) const;102 PassRefPtr< ByteArray> getPremultipliedImageData(const IntRect&, CoordinateSystem = LogicalCoordinateSystem) const;101 PassRefPtr<Uint8ClampedArray> getUnmultipliedImageData(const IntRect&, CoordinateSystem = LogicalCoordinateSystem) const; 102 PassRefPtr<Uint8ClampedArray> getPremultipliedImageData(const IntRect&, CoordinateSystem = LogicalCoordinateSystem) const; 103 103 104 void putByteArray(Multiply multiplied, ByteArray*, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, CoordinateSystem = LogicalCoordinateSystem);104 void putByteArray(Multiply multiplied, Uint8ClampedArray*, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, CoordinateSystem = LogicalCoordinateSystem); 105 105 106 106 void convertToLuminanceMask(); -
trunk/Source/WebCore/platform/graphics/ShadowBlur.cpp
r109016 r114992 827 827 828 828 IntRect blurRect(IntPoint(), templateSize); 829 RefPtr< ByteArray> layerData = m_layerImage->getUnmultipliedImageData(blurRect);829 RefPtr<Uint8ClampedArray> layerData = m_layerImage->getUnmultipliedImageData(blurRect); 830 830 blurLayerImage(layerData->data(), blurRect.size(), blurRect.width() * 4); 831 831 m_layerImage->putByteArray(Unmultiplied, layerData.get(), blurRect.size(), blurRect, IntPoint()); -
trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
r114216 r114992 133 133 134 134 template <Multiply multiplied> 135 PassRefPtr< ByteArray> getImageData(const IntRect& rect, const ImageBufferData& data, const IntSize& size)135 PassRefPtr<Uint8ClampedArray> getImageData(const IntRect& rect, const ImageBufferData& data, const IntSize& size) 136 136 { 137 137 ASSERT(cairo_surface_get_type(data.m_surface) == CAIRO_SURFACE_TYPE_IMAGE); 138 138 139 RefPtr< ByteArray> result = ByteArray::create(rect.width() * rect.height() * 4);139 RefPtr<Uint8ClampedArray> result = Uint8ClampedArray::createUninitialized(rect.width() * rect.height() * 4); 140 140 unsigned char* dataSrc = cairo_image_surface_get_data(data.m_surface); 141 141 unsigned char* dataDst = result->data(); 142 142 143 143 if (rect.x() < 0 || rect.y() < 0 || (rect.x() + rect.width()) > size.width() || (rect.y() + rect.height()) > size.height()) 144 memset(dataDst, 0, result->length());144 result->zeroFill(); 145 145 146 146 int originx = rect.x(); … … 191 191 } 192 192 193 PassRefPtr< ByteArray> ImageBuffer::getUnmultipliedImageData(const IntRect& rect, CoordinateSystem) const193 PassRefPtr<Uint8ClampedArray> ImageBuffer::getUnmultipliedImageData(const IntRect& rect, CoordinateSystem) const 194 194 { 195 195 return getImageData<Unmultiplied>(rect, m_data, m_size); 196 196 } 197 197 198 PassRefPtr< ByteArray> ImageBuffer::getPremultipliedImageData(const IntRect& rect, CoordinateSystem) const198 PassRefPtr<Uint8ClampedArray> ImageBuffer::getPremultipliedImageData(const IntRect& rect, CoordinateSystem) const 199 199 { 200 200 return getImageData<Premultiplied>(rect, m_data, m_size); 201 201 } 202 202 203 void ImageBuffer::putByteArray(Multiply multiplied, ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, CoordinateSystem)203 void ImageBuffer::putByteArray(Multiply multiplied, Uint8ClampedArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, CoordinateSystem) 204 204 { 205 205 ASSERT(cairo_surface_get_type(m_data.m_surface) == CAIRO_SURFACE_TYPE_IMAGE); -
trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp
r114616 r114992 307 307 } 308 308 309 PassRefPtr< ByteArray> ImageBuffer::getUnmultipliedImageData(const IntRect& rect, CoordinateSystem coordinateSystem) const309 PassRefPtr<Uint8ClampedArray> ImageBuffer::getUnmultipliedImageData(const IntRect& rect, CoordinateSystem coordinateSystem) const 310 310 { 311 311 if (m_context->isAcceleratedContext()) { … … 318 318 } 319 319 320 PassRefPtr< ByteArray> ImageBuffer::getPremultipliedImageData(const IntRect& rect, CoordinateSystem coordinateSystem) const320 PassRefPtr<Uint8ClampedArray> ImageBuffer::getPremultipliedImageData(const IntRect& rect, CoordinateSystem coordinateSystem) const 321 321 { 322 322 if (m_context->isAcceleratedContext()) { … … 329 329 } 330 330 331 void ImageBuffer::putByteArray(Multiply multiplied, ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, CoordinateSystem coordinateSystem)331 void ImageBuffer::putByteArray(Multiply multiplied, Uint8ClampedArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, CoordinateSystem coordinateSystem) 332 332 { 333 333 if (!m_context->isAcceleratedContext()) { … … 441 441 ASSERT(uti); 442 442 443 RefPtr< ByteArray> premultipliedData;443 RefPtr<Uint8ClampedArray> premultipliedData; 444 444 RetainPtr<CGImageRef> image; 445 445 … … 481 481 RetainPtr<CGDataProviderRef> dataProvider; 482 482 483 unsigned char* data = source.data()->data() ->data();483 unsigned char* data = source.data()->data(); 484 484 RetainPtr<CFStringRef> uti = utiFromMIMEType(mimeType); 485 485 ASSERT(uti); -
trunk/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp
r113457 r114992 117 117 #endif // USE(ACCELERATE) 118 118 119 PassRefPtr< ByteArray> ImageBufferData::getData(const IntRect& rect, const IntSize& size, bool accelerateRendering, bool unmultiplied, float resolutionScale) const119 PassRefPtr<Uint8ClampedArray> ImageBufferData::getData(const IntRect& rect, const IntSize& size, bool accelerateRendering, bool unmultiplied, float resolutionScale) const 120 120 { 121 121 float area = 4.0f * rect.width() * rect.height(); … … 123 123 return 0; 124 124 125 RefPtr< ByteArray> result = ByteArray::create(rect.width() * rect.height() * 4);125 RefPtr<Uint8ClampedArray> result = Uint8ClampedArray::createUninitialized(rect.width() * rect.height() * 4); 126 126 unsigned char* data = result->data(); 127 127 … … 129 129 int endy = ceilf(rect.maxY() * resolutionScale); 130 130 if (rect.x() < 0 || rect.y() < 0 || endx > size.width() || endy > size.height()) 131 memset(data, 0, result->length());131 result->zeroFill(); 132 132 133 133 int originx = rect.x(); … … 343 343 } 344 344 345 void ImageBufferData::putData( ByteArray*& source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, const IntSize& size, bool accelerateRendering, bool unmultiplied, float resolutionScale)345 void ImageBufferData::putData(Uint8ClampedArray*& source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, const IntSize& size, bool accelerateRendering, bool unmultiplied, float resolutionScale) 346 346 { 347 347 ASSERT(sourceRect.width() > 0); -
trunk/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.h
r113457 r114992 26 26 27 27 #include "Image.h" 28 #include <wtf/ByteArray.h>29 28 #include <wtf/CheckedArithmetic.h> 30 29 #include <wtf/RefPtr.h> 31 30 #include <wtf/RetainPtr.h> 31 #include <wtf/Uint8ClampedArray.h> 32 32 33 33 #if (PLATFORM(MAC) && USE(CA) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)) … … 59 59 #endif 60 60 61 PassRefPtr< ByteArray> getData(const IntRect& rect, const IntSize& size, bool accelerateRendering, bool unmultiplied, float resolutionScale) const;62 void putData( ByteArray*& source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, const IntSize& size, bool accelerateRendering, bool unmultiplied, float resolutionScale);61 PassRefPtr<Uint8ClampedArray> getData(const IntRect&, const IntSize&, bool accelerateRendering, bool unmultiplied, float resolutionScale) const; 62 void putData(Uint8ClampedArray*& source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, const IntSize&, bool accelerateRendering, bool unmultiplied, float resolutionScale); 63 63 }; 64 64 -
trunk/Source/WebCore/platform/graphics/filters/FEBlend.cpp
r97853 r114992 32 32 #include "TextStream.h" 33 33 34 #include <wtf/ ByteArray.h>34 #include <wtf/Uint8ClampedArray.h> 35 35 36 36 typedef unsigned char (*BlendType)(unsigned char colorA, unsigned char colorB, unsigned char alphaA, unsigned char alphaB); … … 95 95 ASSERT(m_mode <= FEBLEND_MODE_LIGHTEN); 96 96 97 ByteArray* dstPixelArray = createPremultipliedImageResult();97 Uint8ClampedArray* dstPixelArray = createPremultipliedImageResult(); 98 98 if (!dstPixelArray) 99 99 return; 100 100 101 101 IntRect effectADrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect()); 102 RefPtr< ByteArray> srcPixelArrayA = in->asPremultipliedImage(effectADrawingRect);102 RefPtr<Uint8ClampedArray> srcPixelArrayA = in->asPremultipliedImage(effectADrawingRect); 103 103 104 104 IntRect effectBDrawingRect = requestedRegionOfInputImageData(in2->absolutePaintRect()); 105 RefPtr< ByteArray> srcPixelArrayB = in2->asPremultipliedImage(effectBDrawingRect);105 RefPtr<Uint8ClampedArray> srcPixelArrayB = in2->asPremultipliedImage(effectBDrawingRect); 106 106 107 107 unsigned pixelArrayLength = srcPixelArrayA->length(); 108 108 ASSERT(pixelArrayLength == srcPixelArrayB->length()); 109 109 for (unsigned pixelOffset = 0; pixelOffset < pixelArrayLength; pixelOffset += 4) { 110 unsigned char alphaA = srcPixelArrayA-> get(pixelOffset + 3);111 unsigned char alphaB = srcPixelArrayB-> get(pixelOffset + 3);110 unsigned char alphaA = srcPixelArrayA->item(pixelOffset + 3); 111 unsigned char alphaB = srcPixelArrayB->item(pixelOffset + 3); 112 112 for (unsigned channel = 0; channel < 3; ++channel) { 113 unsigned char colorA = srcPixelArrayA-> get(pixelOffset + channel);114 unsigned char colorB = srcPixelArrayB-> get(pixelOffset + channel);113 unsigned char colorA = srcPixelArrayA->item(pixelOffset + channel); 114 unsigned char colorB = srcPixelArrayB->item(pixelOffset + channel); 115 115 unsigned char result; 116 116 -
trunk/Source/WebCore/platform/graphics/filters/FEColorMatrix.cpp
r106836 r114992 31 31 #include "TextStream.h" 32 32 33 #include <wtf/ByteArray.h>34 33 #include <wtf/MathExtras.h> 34 #include <wtf/Uint8ClampedArray.h> 35 35 36 36 namespace WebCore { … … 126 126 127 127 template<ColorMatrixType filterType> 128 void effectType( ByteArray* pixelArray, const Vector<float>& values)128 void effectType(Uint8ClampedArray* pixelArray, const Vector<float>& values) 129 129 { 130 130 unsigned pixelArrayLength = pixelArray->length(); 131 131 for (unsigned pixelByteOffset = 0; pixelByteOffset < pixelArrayLength; pixelByteOffset += 4) { 132 double red = pixelArray-> get(pixelByteOffset);133 double green = pixelArray-> get(pixelByteOffset + 1);134 double blue = pixelArray-> get(pixelByteOffset + 2);135 double alpha = pixelArray-> get(pixelByteOffset + 3);132 double red = pixelArray->item(pixelByteOffset); 133 double green = pixelArray->item(pixelByteOffset + 1); 134 double blue = pixelArray->item(pixelByteOffset + 2); 135 double alpha = pixelArray->item(pixelByteOffset + 3); 136 136 137 137 switch (filterType) { … … 168 168 169 169 IntRect imageRect(IntPoint(), absolutePaintRect().size()); 170 RefPtr< ByteArray> pixelArray = resultImage->getUnmultipliedImageData(imageRect);170 RefPtr<Uint8ClampedArray> pixelArray = resultImage->getUnmultipliedImageData(imageRect); 171 171 172 172 switch (m_type) { -
trunk/Source/WebCore/platform/graphics/filters/FEComponentTransfer.cpp
r97853 r114992 32 32 #include "TextStream.h" 33 33 34 #include <wtf/ByteArray.h>35 34 #include <wtf/MathExtras.h> 36 35 #include <wtf/StdLibExtras.h> 36 #include <wtf/Uint8ClampedArray.h> 37 37 38 38 namespace WebCore { … … 155 155 FilterEffect* in = inputEffect(0); 156 156 157 ByteArray* pixelArray = createUnmultipliedImageResult();157 Uint8ClampedArray* pixelArray = createUnmultipliedImageResult(); 158 158 if (!pixelArray) 159 159 return; … … 177 177 for (unsigned pixelOffset = 0; pixelOffset < pixelArrayLength; pixelOffset += 4) { 178 178 for (unsigned channel = 0; channel < 4; ++channel) { 179 unsigned char c = pixelArray-> get(pixelOffset + channel);179 unsigned char c = pixelArray->item(pixelOffset + channel); 180 180 pixelArray->set(pixelOffset + channel, tables[channel][c]); 181 181 } -
trunk/Source/WebCore/platform/graphics/filters/FEComposite.cpp
r109820 r114992 33 33 #include "TextStream.h" 34 34 35 #include <wtf/ ByteArray.h>35 #include <wtf/Uint8ClampedArray.h> 36 36 37 37 namespace WebCore { … … 180 180 } 181 181 182 inline void FEComposite::platformArithmeticSoftware( ByteArray* source, ByteArray* destination,182 inline void FEComposite::platformArithmeticSoftware(Uint8ClampedArray* source, Uint8ClampedArray* destination, 183 183 float k1, float k2, float k3, float k4) 184 184 { … … 222 222 223 223 if (m_type == FECOMPOSITE_OPERATOR_ARITHMETIC) { 224 ByteArray* dstPixelArray = createPremultipliedImageResult();224 Uint8ClampedArray* dstPixelArray = createPremultipliedImageResult(); 225 225 if (!dstPixelArray) 226 226 return; 227 227 228 228 IntRect effectADrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect()); 229 RefPtr< ByteArray> srcPixelArray = in->asPremultipliedImage(effectADrawingRect);229 RefPtr<Uint8ClampedArray> srcPixelArray = in->asPremultipliedImage(effectADrawingRect); 230 230 231 231 IntRect effectBDrawingRect = requestedRegionOfInputImageData(in2->absolutePaintRect()); -
trunk/Source/WebCore/platform/graphics/filters/FEComposite.h
r109820 r114992 75 75 FEComposite(Filter*, const CompositeOperationType&, float, float, float, float); 76 76 77 inline void platformArithmeticSoftware( ByteArray* source, ByteArray* destination, float k1, float k2, float k3, float k4);77 inline void platformArithmeticSoftware(Uint8ClampedArray* source, Uint8ClampedArray* destination, float k1, float k2, float k3, float k4); 78 78 inline void platformArithmeticNeon(unsigned char* source, unsigned char* destination, unsigned pixelArrayLength, float* kArray); 79 79 -
trunk/Source/WebCore/platform/graphics/filters/FEConvolveMatrix.cpp
r102132 r114992 31 31 #include "TextStream.h" 32 32 33 #include <wtf/ByteArray.h>34 33 #include <wtf/ParallelJobs.h> 34 #include <wtf/Uint8ClampedArray.h> 35 35 36 36 namespace WebCore { … … 224 224 225 225 template<bool preserveAlphaValues> 226 ALWAYS_INLINE void setDestinationPixels( ByteArray* image, int& pixel, float* totals, float divisor, float bias, ByteArray* src)226 ALWAYS_INLINE void setDestinationPixels(Uint8ClampedArray* image, int& pixel, float* totals, float divisor, float bias, Uint8ClampedArray* src) 227 227 { 228 228 unsigned char maxAlpha = preserveAlphaValues ? 255 : clampRGBAValue(totals[3] / divisor + bias); … … 231 231 232 232 if (preserveAlphaValues) { 233 image->set(pixel, src-> get(pixel));233 image->set(pixel, src->item(pixel)); 234 234 ++pixel; 235 235 } else … … 268 268 269 269 while (kernelValue >= 0) { 270 totals[0] += m_kernelMatrix[kernelValue] * static_cast<float>(paintingData.srcPixelArray-> get(kernelPixel++));271 totals[1] += m_kernelMatrix[kernelValue] * static_cast<float>(paintingData.srcPixelArray-> get(kernelPixel++));272 totals[2] += m_kernelMatrix[kernelValue] * static_cast<float>(paintingData.srcPixelArray-> get(kernelPixel++));270 totals[0] += m_kernelMatrix[kernelValue] * static_cast<float>(paintingData.srcPixelArray->item(kernelPixel++)); 271 totals[1] += m_kernelMatrix[kernelValue] * static_cast<float>(paintingData.srcPixelArray->item(kernelPixel++)); 272 totals[2] += m_kernelMatrix[kernelValue] * static_cast<float>(paintingData.srcPixelArray->item(kernelPixel++)); 273 273 if (!preserveAlphaValues) 274 totals[3] += m_kernelMatrix[kernelValue] * static_cast<float>(paintingData.srcPixelArray-> get(kernelPixel));274 totals[3] += m_kernelMatrix[kernelValue] * static_cast<float>(paintingData.srcPixelArray->item(kernelPixel)); 275 275 ++kernelPixel; 276 276 --kernelValue; … … 351 351 int pixelIndex = getPixelValue(paintingData, kernelPixelX, kernelPixelY); 352 352 if (pixelIndex >= 0) { 353 totals[0] += m_kernelMatrix[kernelValue] * static_cast<float>(paintingData.srcPixelArray-> get(pixelIndex));354 totals[1] += m_kernelMatrix[kernelValue] * static_cast<float>(paintingData.srcPixelArray-> get(pixelIndex + 1));355 totals[2] += m_kernelMatrix[kernelValue] * static_cast<float>(paintingData.srcPixelArray-> get(pixelIndex + 2));353 totals[0] += m_kernelMatrix[kernelValue] * static_cast<float>(paintingData.srcPixelArray->item(pixelIndex)); 354 totals[1] += m_kernelMatrix[kernelValue] * static_cast<float>(paintingData.srcPixelArray->item(pixelIndex + 1)); 355 totals[2] += m_kernelMatrix[kernelValue] * static_cast<float>(paintingData.srcPixelArray->item(pixelIndex + 2)); 356 356 } 357 357 if (!preserveAlphaValues && pixelIndex >= 0) 358 totals[3] += m_kernelMatrix[kernelValue] * static_cast<float>(paintingData.srcPixelArray-> get(pixelIndex + 3));358 totals[3] += m_kernelMatrix[kernelValue] * static_cast<float>(paintingData.srcPixelArray->item(pixelIndex + 3)); 359 359 ++kernelPixelX; 360 360 --kernelValue; … … 404 404 FilterEffect* in = inputEffect(0); 405 405 406 ByteArray* resultImage;406 Uint8ClampedArray* resultImage; 407 407 if (m_preserveAlpha) 408 408 resultImage = createUnmultipliedImageResult(); … … 414 414 IntRect effectDrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect()); 415 415 416 RefPtr< ByteArray> srcPixelArray;416 RefPtr<Uint8ClampedArray> srcPixelArray; 417 417 if (m_preserveAlpha) 418 418 srcPixelArray = in->asUnmultipliedImage(effectDrawingRect); -
trunk/Source/WebCore/platform/graphics/filters/FEConvolveMatrix.h
r102132 r114992 83 83 84 84 struct PaintingData { 85 ByteArray* srcPixelArray;86 ByteArray* dstPixelArray;85 Uint8ClampedArray* srcPixelArray; 86 Uint8ClampedArray* dstPixelArray; 87 87 int width; 88 88 int height; -
trunk/Source/WebCore/platform/graphics/filters/FECustomFilter.cpp
r113493 r114992 47 47 #include "TransformationMatrix.h" 48 48 49 #include <wtf/ ByteArray.h>49 #include <wtf/Uint8ClampedArray.h> 50 50 51 51 namespace WebCore { … … 96 96 void FECustomFilter::platformApplySoftware() 97 97 { 98 ByteArray* dstPixelArray = createPremultipliedImageResult();98 Uint8ClampedArray* dstPixelArray = createPremultipliedImageResult(); 99 99 if (!dstPixelArray) 100 100 return; … … 102 102 FilterEffect* in = inputEffect(0); 103 103 IntRect effectDrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect()); 104 RefPtr< ByteArray> srcPixelArray = in->asPremultipliedImage(effectDrawingRect);104 RefPtr<Uint8ClampedArray> srcPixelArray = in->asPremultipliedImage(effectDrawingRect); 105 105 106 106 IntSize newContextSize(effectDrawingRect.size()); … … 130 130 131 131 RefPtr<ImageData> imageData = m_context->paintRenderingResultsToImageData(m_drawingBuffer.get()); 132 ByteArray* gpuResult = imageData->data()->data();132 Uint8ClampedArray* gpuResult = imageData->data(); 133 133 ASSERT(gpuResult->length() == dstPixelArray->length()); 134 134 memcpy(dstPixelArray->data(), gpuResult->data(), gpuResult->length()); … … 210 210 } 211 211 212 void FECustomFilter::bindProgramAndBuffers( ByteArray* srcPixelArray)212 void FECustomFilter::bindProgramAndBuffers(Uint8ClampedArray* srcPixelArray) 213 213 { 214 214 m_context->useProgram(m_shader->program()); -
trunk/Source/WebCore/platform/graphics/filters/FECustomFilter.h
r111610 r114992 39 39 40 40 namespace JSC { 41 class ByteArray;41 class Uint8ClampedArray; 42 42 } 43 43 … … 76 76 void bindProgramNumberParameters(int uniformLocation, CustomFilterNumberParameter*); 77 77 void bindProgramParameters(); 78 void bindProgramAndBuffers( ByteArray* srcPixelArray);78 void bindProgramAndBuffers(Uint8ClampedArray* srcPixelArray); 79 79 80 80 HostWindow* m_hostWindow; -
trunk/Source/WebCore/platform/graphics/filters/FEDisplacementMap.cpp
r97853 r114992 32 32 #include "TextStream.h" 33 33 34 #include <wtf/ ByteArray.h>34 #include <wtf/Uint8ClampedArray.h> 35 35 36 36 namespace WebCore { … … 97 97 ASSERT(m_yChannelSelector != CHANNEL_UNKNOWN); 98 98 99 ByteArray* dstPixelArray = createPremultipliedImageResult();99 Uint8ClampedArray* dstPixelArray = createPremultipliedImageResult(); 100 100 if (!dstPixelArray) 101 101 return; 102 102 103 103 IntRect effectADrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect()); 104 RefPtr< ByteArray> srcPixelArrayA = in->asPremultipliedImage(effectADrawingRect);104 RefPtr<Uint8ClampedArray> srcPixelArrayA = in->asPremultipliedImage(effectADrawingRect); 105 105 106 106 IntRect effectBDrawingRect = requestedRegionOfInputImageData(in2->absolutePaintRect()); 107 RefPtr< ByteArray> srcPixelArrayB = in2->asUnmultipliedImage(effectBDrawingRect);107 RefPtr<Uint8ClampedArray> srcPixelArrayB = in2->asUnmultipliedImage(effectBDrawingRect); 108 108 109 109 ASSERT(srcPixelArrayA->length() == srcPixelArrayB->length()); … … 120 120 for (int x = 0; x < paintSize.width(); ++x) { 121 121 int dstIndex = line + x * 4; 122 int srcX = x + static_cast<int>(scaleX * srcPixelArrayB-> get(dstIndex + m_xChannelSelector - 1) + scaleAdjustmentX);123 int srcY = y + static_cast<int>(scaleY * srcPixelArrayB-> get(dstIndex + m_yChannelSelector - 1) + scaleAdjustmentY);122 int srcX = x + static_cast<int>(scaleX * srcPixelArrayB->item(dstIndex + m_xChannelSelector - 1) + scaleAdjustmentX); 123 int srcY = y + static_cast<int>(scaleY * srcPixelArrayB->item(dstIndex + m_yChannelSelector - 1) + scaleAdjustmentY); 124 124 for (unsigned channel = 0; channel < 4; ++channel) { 125 125 if (srcX < 0 || srcX >= paintSize.width() || srcY < 0 || srcY >= paintSize.height()) 126 126 dstPixelArray->set(dstIndex + channel, static_cast<unsigned char>(0)); 127 127 else { 128 unsigned char pixelValue = srcPixelArrayA-> get(srcY * stride + srcX * 4 + channel);128 unsigned char pixelValue = srcPixelArrayA->item(srcY * stride + srcX * 4 + channel); 129 129 dstPixelArray->set(dstIndex + channel, pixelValue); 130 130 } -
trunk/Source/WebCore/platform/graphics/filters/FEDropShadow.cpp
r109016 r114992 30 30 #include "ShadowBlur.h" 31 31 #include "TextStream.h" 32 #include <wtf/ByteArray.h>33 32 #include <wtf/MathExtras.h> 33 #include <wtf/Uint8ClampedArray.h> 34 34 35 35 using namespace std; … … 105 105 // TODO: Direct pixel access to ImageBuffer would avoid copying the ImageData. 106 106 IntRect shadowArea(IntPoint(), resultImage->internalSize()); 107 RefPtr< ByteArray> srcPixelArray = resultImage->getPremultipliedImageData(shadowArea);107 RefPtr<Uint8ClampedArray> srcPixelArray = resultImage->getPremultipliedImageData(shadowArea); 108 108 109 109 contextShadow.blurLayerImage(srcPixelArray->data(), shadowArea.size(), 4 * shadowArea.size().width()); -
trunk/Source/WebCore/platform/graphics/filters/FEGaussianBlur.cpp
r104566 r114992 34 34 #include "TextStream.h" 35 35 36 #include <wtf/ByteArray.h>37 36 #include <wtf/MathExtras.h> 38 37 #include <wtf/ParallelJobs.h> 38 #include <wtf/Uint8ClampedArray.h> 39 39 40 40 using namespace std; … … 81 81 } 82 82 83 inline void boxBlur( ByteArray* srcPixelArray, ByteArray* dstPixelArray,83 inline void boxBlur(Uint8ClampedArray* srcPixelArray, Uint8ClampedArray* dstPixelArray, 84 84 unsigned dx, int dxLeft, int dxRight, int stride, int strideLine, int effectWidth, int effectHeight, bool alphaImage) 85 85 { … … 91 91 int maxKernelSize = min(dxRight, effectWidth); 92 92 for (int i = 0; i < maxKernelSize; ++i) 93 sum += srcPixelArray-> get(line + i * stride + channel);93 sum += srcPixelArray->item(line + i * stride + channel); 94 94 95 95 // Blurring … … 98 98 dstPixelArray->set(pixelByteOffset, static_cast<unsigned char>(sum / dx)); 99 99 if (x >= dxLeft) 100 sum -= srcPixelArray-> get(pixelByteOffset - dxLeft * stride);100 sum -= srcPixelArray->item(pixelByteOffset - dxLeft * stride); 101 101 if (x + dxRight < effectWidth) 102 sum += srcPixelArray-> get(pixelByteOffset + dxRight * stride);102 sum += srcPixelArray->item(pixelByteOffset + dxRight * stride); 103 103 } 104 104 if (alphaImage) // Source image is black, it just has different alpha values … … 108 108 } 109 109 110 inline void FEGaussianBlur::platformApplyGeneric( ByteArray* srcPixelArray, ByteArray* tmpPixelArray, unsigned kernelSizeX, unsigned kernelSizeY, IntSize& paintSize)110 inline void FEGaussianBlur::platformApplyGeneric(Uint8ClampedArray* srcPixelArray, Uint8ClampedArray* tmpPixelArray, unsigned kernelSizeX, unsigned kernelSizeY, IntSize& paintSize) 111 111 { 112 112 int stride = 4 * paintSize.width(); … … 115 115 int dyLeft = 0; 116 116 int dyRight = 0; 117 ByteArray* src = srcPixelArray;118 ByteArray* dst = tmpPixelArray;117 Uint8ClampedArray* src = srcPixelArray; 118 Uint8ClampedArray* dst = tmpPixelArray; 119 119 120 120 for (int i = 0; i < 3; ++i) { … … 152 152 } 153 153 154 inline void FEGaussianBlur::platformApply( ByteArray* srcPixelArray, ByteArray* tmpPixelArray, unsigned kernelSizeX, unsigned kernelSizeY, IntSize& paintSize)154 inline void FEGaussianBlur::platformApply(Uint8ClampedArray* srcPixelArray, Uint8ClampedArray* tmpPixelArray, unsigned kernelSizeX, unsigned kernelSizeY, IntSize& paintSize) 155 155 { 156 156 int scanline = 4 * paintSize.width(); … … 186 186 187 187 int blockSize = (endY - startY) * scanline; 188 params.srcPixelArray = ByteArray::create(blockSize);189 params.dstPixelArray = ByteArray::create(blockSize);188 params.srcPixelArray = Uint8ClampedArray::createUninitialized(blockSize); 189 params.dstPixelArray = Uint8ClampedArray::createUninitialized(blockSize); 190 190 memcpy(params.srcPixelArray->data(), srcPixelArray->data() + startY * scanline, blockSize); 191 191 } … … 276 276 FilterEffect* in = inputEffect(0); 277 277 278 ByteArray* srcPixelArray = createPremultipliedImageResult();278 Uint8ClampedArray* srcPixelArray = createPremultipliedImageResult(); 279 279 if (!srcPixelArray) 280 280 return; … … 293 293 294 294 IntSize paintSize = absolutePaintRect().size(); 295 RefPtr< ByteArray> tmpImageData = ByteArray::create(paintSize.width() * paintSize.height() * 4);296 ByteArray* tmpPixelArray = tmpImageData.get();295 RefPtr<Uint8ClampedArray> tmpImageData = Uint8ClampedArray::createUninitialized(paintSize.width() * paintSize.height() * 4); 296 Uint8ClampedArray* tmpPixelArray = tmpImageData.get(); 297 297 298 298 platformApply(srcPixelArray, tmpPixelArray, kernelSizeX, kernelSizeY, paintSize); -
trunk/Source/WebCore/platform/graphics/filters/FEGaussianBlur.h
r104566 r114992 58 58 struct PlatformApplyParameters { 59 59 FEGaussianBlur* filter; 60 RefPtr< ByteArray> srcPixelArray;61 RefPtr< ByteArray> dstPixelArray;60 RefPtr<Uint8ClampedArray> srcPixelArray; 61 RefPtr<Uint8ClampedArray> dstPixelArray; 62 62 int width; 63 63 int height; … … 71 71 72 72 static inline void kernelPosition(int boxBlur, unsigned& std, int& dLeft, int& dRight); 73 inline void platformApply( ByteArray* srcPixelArray, ByteArray* tmpPixelArray, unsigned kernelSizeX, unsigned kernelSizeY, IntSize& paintSize);73 inline void platformApply(Uint8ClampedArray* srcPixelArray, Uint8ClampedArray* tmpPixelArray, unsigned kernelSizeX, unsigned kernelSizeY, IntSize& paintSize); 74 74 75 inline void platformApplyGeneric( ByteArray* srcPixelArray, ByteArray* tmpPixelArray, unsigned kernelSizeX, unsigned kernelSizeY, IntSize& paintSize);76 inline void platformApplyNeon( ByteArray* srcPixelArray, ByteArray* tmpPixelArray, unsigned kernelSizeX, unsigned kernelSizeY, IntSize& paintSize);75 inline void platformApplyGeneric(Uint8ClampedArray* srcPixelArray, Uint8ClampedArray* tmpPixelArray, unsigned kernelSizeX, unsigned kernelSizeY, IntSize& paintSize); 76 inline void platformApplyNeon(Uint8ClampedArray* srcPixelArray, Uint8ClampedArray* tmpPixelArray, unsigned kernelSizeX, unsigned kernelSizeY, IntSize& paintSize); 77 77 #if USE(SKIA) 78 78 virtual bool platformApplySkia(); -
trunk/Source/WebCore/platform/graphics/filters/FELighting.cpp
r102132 r114992 62 62 inline void FELighting::LightingData::topLeft(int offset, IntPoint& normalVector) 63 63 { 64 int center = static_cast<int>(pixels-> get(offset + cAlphaChannelOffset));65 int right = static_cast<int>(pixels-> get(offset + cPixelSize + cAlphaChannelOffset));64 int center = static_cast<int>(pixels->item(offset + cAlphaChannelOffset)); 65 int right = static_cast<int>(pixels->item(offset + cPixelSize + cAlphaChannelOffset)); 66 66 offset += widthMultipliedByPixelSize; 67 int bottom = static_cast<int>(pixels-> get(offset + cAlphaChannelOffset));68 int bottomRight = static_cast<int>(pixels-> get(offset + cPixelSize + cAlphaChannelOffset));67 int bottom = static_cast<int>(pixels->item(offset + cAlphaChannelOffset)); 68 int bottomRight = static_cast<int>(pixels->item(offset + cPixelSize + cAlphaChannelOffset)); 69 69 normalVector.setX(-(center << 1) + (right << 1) - bottom + bottomRight); 70 70 normalVector.setY(-(center << 1) - right + (bottom << 1) + bottomRight); … … 73 73 inline void FELighting::LightingData::topRow(int offset, IntPoint& normalVector) 74 74 { 75 int left = static_cast<int>(pixels-> get(offset - cPixelSize + cAlphaChannelOffset));76 int center = static_cast<int>(pixels-> get(offset + cAlphaChannelOffset));77 int right = static_cast<int>(pixels-> get(offset + cPixelSize + cAlphaChannelOffset));75 int left = static_cast<int>(pixels->item(offset - cPixelSize + cAlphaChannelOffset)); 76 int center = static_cast<int>(pixels->item(offset + cAlphaChannelOffset)); 77 int right = static_cast<int>(pixels->item(offset + cPixelSize + cAlphaChannelOffset)); 78 78 offset += widthMultipliedByPixelSize; 79 int bottomLeft = static_cast<int>(pixels-> get(offset - cPixelSize + cAlphaChannelOffset));80 int bottom = static_cast<int>(pixels-> get(offset + cAlphaChannelOffset));81 int bottomRight = static_cast<int>(pixels-> get(offset + cPixelSize + cAlphaChannelOffset));79 int bottomLeft = static_cast<int>(pixels->item(offset - cPixelSize + cAlphaChannelOffset)); 80 int bottom = static_cast<int>(pixels->item(offset + cAlphaChannelOffset)); 81 int bottomRight = static_cast<int>(pixels->item(offset + cPixelSize + cAlphaChannelOffset)); 82 82 normalVector.setX(-(left << 1) + (right << 1) - bottomLeft + bottomRight); 83 83 normalVector.setY(-left - (center << 1) - right + bottomLeft + (bottom << 1) + bottomRight); … … 86 86 inline void FELighting::LightingData::topRight(int offset, IntPoint& normalVector) 87 87 { 88 int left = static_cast<int>(pixels-> get(offset - cPixelSize + cAlphaChannelOffset));89 int center = static_cast<int>(pixels-> get(offset + cAlphaChannelOffset));88 int left = static_cast<int>(pixels->item(offset - cPixelSize + cAlphaChannelOffset)); 89 int center = static_cast<int>(pixels->item(offset + cAlphaChannelOffset)); 90 90 offset += widthMultipliedByPixelSize; 91 int bottomLeft = static_cast<int>(pixels-> get(offset - cPixelSize + cAlphaChannelOffset));92 int bottom = static_cast<int>(pixels-> get(offset + cAlphaChannelOffset));91 int bottomLeft = static_cast<int>(pixels->item(offset - cPixelSize + cAlphaChannelOffset)); 92 int bottom = static_cast<int>(pixels->item(offset + cAlphaChannelOffset)); 93 93 normalVector.setX(-(left << 1) + (center << 1) - bottomLeft + bottom); 94 94 normalVector.setY(-left - (center << 1) + bottomLeft + (bottom << 1)); … … 97 97 inline void FELighting::LightingData::leftColumn(int offset, IntPoint& normalVector) 98 98 { 99 int center = static_cast<int>(pixels-> get(offset + cAlphaChannelOffset));100 int right = static_cast<int>(pixels-> get(offset + cPixelSize + cAlphaChannelOffset));101 offset -= widthMultipliedByPixelSize; 102 int top = static_cast<int>(pixels-> get(offset + cAlphaChannelOffset));103 int topRight = static_cast<int>(pixels-> get(offset + cPixelSize + cAlphaChannelOffset));99 int center = static_cast<int>(pixels->item(offset + cAlphaChannelOffset)); 100 int right = static_cast<int>(pixels->item(offset + cPixelSize + cAlphaChannelOffset)); 101 offset -= widthMultipliedByPixelSize; 102 int top = static_cast<int>(pixels->item(offset + cAlphaChannelOffset)); 103 int topRight = static_cast<int>(pixels->item(offset + cPixelSize + cAlphaChannelOffset)); 104 104 offset += widthMultipliedByPixelSize << 1; 105 int bottom = static_cast<int>(pixels-> get(offset + cAlphaChannelOffset));106 int bottomRight = static_cast<int>(pixels-> get(offset + cPixelSize + cAlphaChannelOffset));105 int bottom = static_cast<int>(pixels->item(offset + cAlphaChannelOffset)); 106 int bottomRight = static_cast<int>(pixels->item(offset + cPixelSize + cAlphaChannelOffset)); 107 107 normalVector.setX(-top + topRight - (center << 1) + (right << 1) - bottom + bottomRight); 108 108 normalVector.setY(-(top << 1) - topRight + (bottom << 1) + bottomRight); … … 111 111 inline void FELighting::LightingData::interior(int offset, IntPoint& normalVector) 112 112 { 113 int left = static_cast<int>(pixels-> get(offset - cPixelSize + cAlphaChannelOffset));114 int right = static_cast<int>(pixels-> get(offset + cPixelSize + cAlphaChannelOffset));115 offset -= widthMultipliedByPixelSize; 116 int topLeft = static_cast<int>(pixels-> get(offset - cPixelSize + cAlphaChannelOffset));117 int top = static_cast<int>(pixels-> get(offset + cAlphaChannelOffset));118 int topRight = static_cast<int>(pixels-> get(offset + cPixelSize + cAlphaChannelOffset));113 int left = static_cast<int>(pixels->item(offset - cPixelSize + cAlphaChannelOffset)); 114 int right = static_cast<int>(pixels->item(offset + cPixelSize + cAlphaChannelOffset)); 115 offset -= widthMultipliedByPixelSize; 116 int topLeft = static_cast<int>(pixels->item(offset - cPixelSize + cAlphaChannelOffset)); 117 int top = static_cast<int>(pixels->item(offset + cAlphaChannelOffset)); 118 int topRight = static_cast<int>(pixels->item(offset + cPixelSize + cAlphaChannelOffset)); 119 119 offset += widthMultipliedByPixelSize << 1; 120 int bottomLeft = static_cast<int>(pixels-> get(offset - cPixelSize + cAlphaChannelOffset));121 int bottom = static_cast<int>(pixels-> get(offset + cAlphaChannelOffset));122 int bottomRight = static_cast<int>(pixels-> get(offset + cPixelSize + cAlphaChannelOffset));120 int bottomLeft = static_cast<int>(pixels->item(offset - cPixelSize + cAlphaChannelOffset)); 121 int bottom = static_cast<int>(pixels->item(offset + cAlphaChannelOffset)); 122 int bottomRight = static_cast<int>(pixels->item(offset + cPixelSize + cAlphaChannelOffset)); 123 123 normalVector.setX(-topLeft + topRight - (left << 1) + (right << 1) - bottomLeft + bottomRight); 124 124 normalVector.setY(-topLeft - (top << 1) - topRight + bottomLeft + (bottom << 1) + bottomRight); … … 127 127 inline void FELighting::LightingData::rightColumn(int offset, IntPoint& normalVector) 128 128 { 129 int left = static_cast<int>(pixels-> get(offset - cPixelSize + cAlphaChannelOffset));130 int center = static_cast<int>(pixels-> get(offset + cAlphaChannelOffset));131 offset -= widthMultipliedByPixelSize; 132 int topLeft = static_cast<int>(pixels-> get(offset - cPixelSize + cAlphaChannelOffset));133 int top = static_cast<int>(pixels-> get(offset + cAlphaChannelOffset));129 int left = static_cast<int>(pixels->item(offset - cPixelSize + cAlphaChannelOffset)); 130 int center = static_cast<int>(pixels->item(offset + cAlphaChannelOffset)); 131 offset -= widthMultipliedByPixelSize; 132 int topLeft = static_cast<int>(pixels->item(offset - cPixelSize + cAlphaChannelOffset)); 133 int top = static_cast<int>(pixels->item(offset + cAlphaChannelOffset)); 134 134 offset += widthMultipliedByPixelSize << 1; 135 int bottomLeft = static_cast<int>(pixels-> get(offset - cPixelSize + cAlphaChannelOffset));136 int bottom = static_cast<int>(pixels-> get(offset + cAlphaChannelOffset));135 int bottomLeft = static_cast<int>(pixels->item(offset - cPixelSize + cAlphaChannelOffset)); 136 int bottom = static_cast<int>(pixels->item(offset + cAlphaChannelOffset)); 137 137 normalVector.setX(-topLeft + top - (left << 1) + (center << 1) - bottomLeft + bottom); 138 138 normalVector.setY(-topLeft - (top << 1) + bottomLeft + (bottom << 1)); … … 141 141 inline void FELighting::LightingData::bottomLeft(int offset, IntPoint& normalVector) 142 142 { 143 int center = static_cast<int>(pixels-> get(offset + cAlphaChannelOffset));144 int right = static_cast<int>(pixels-> get(offset + cPixelSize + cAlphaChannelOffset));145 offset -= widthMultipliedByPixelSize; 146 int top = static_cast<int>(pixels-> get(offset + cAlphaChannelOffset));147 int topRight = static_cast<int>(pixels-> get(offset + cPixelSize + cAlphaChannelOffset));143 int center = static_cast<int>(pixels->item(offset + cAlphaChannelOffset)); 144 int right = static_cast<int>(pixels->item(offset + cPixelSize + cAlphaChannelOffset)); 145 offset -= widthMultipliedByPixelSize; 146 int top = static_cast<int>(pixels->item(offset + cAlphaChannelOffset)); 147 int topRight = static_cast<int>(pixels->item(offset + cPixelSize + cAlphaChannelOffset)); 148 148 normalVector.setX(-top + topRight - (center << 1) + (right << 1)); 149 149 normalVector.setY(-(top << 1) - topRight + (center << 1) + right); … … 152 152 inline void FELighting::LightingData::bottomRow(int offset, IntPoint& normalVector) 153 153 { 154 int left = static_cast<int>(pixels-> get(offset - cPixelSize + cAlphaChannelOffset));155 int center = static_cast<int>(pixels-> get(offset + cAlphaChannelOffset));156 int right = static_cast<int>(pixels-> get(offset + cPixelSize + cAlphaChannelOffset));157 offset -= widthMultipliedByPixelSize; 158 int topLeft = static_cast<int>(pixels-> get(offset - cPixelSize + cAlphaChannelOffset));159 int top = static_cast<int>(pixels-> get(offset + cAlphaChannelOffset));160 int topRight = static_cast<int>(pixels-> get(offset + cPixelSize + cAlphaChannelOffset));154 int left = static_cast<int>(pixels->item(offset - cPixelSize + cAlphaChannelOffset)); 155 int center = static_cast<int>(pixels->item(offset + cAlphaChannelOffset)); 156 int right = static_cast<int>(pixels->item(offset + cPixelSize + cAlphaChannelOffset)); 157 offset -= widthMultipliedByPixelSize; 158 int topLeft = static_cast<int>(pixels->item(offset - cPixelSize + cAlphaChannelOffset)); 159 int top = static_cast<int>(pixels->item(offset + cAlphaChannelOffset)); 160 int topRight = static_cast<int>(pixels->item(offset + cPixelSize + cAlphaChannelOffset)); 161 161 normalVector.setX(-topLeft + topRight - (left << 1) + (right << 1)); 162 162 normalVector.setY(-topLeft - (top << 1) - topRight + left + (center << 1) + right); … … 165 165 inline void FELighting::LightingData::bottomRight(int offset, IntPoint& normalVector) 166 166 { 167 int left = static_cast<int>(pixels-> get(offset - cPixelSize + cAlphaChannelOffset));168 int center = static_cast<int>(pixels-> get(offset + cAlphaChannelOffset));169 offset -= widthMultipliedByPixelSize; 170 int topLeft = static_cast<int>(pixels-> get(offset - cPixelSize + cAlphaChannelOffset));171 int top = static_cast<int>(pixels-> get(offset + cAlphaChannelOffset));167 int left = static_cast<int>(pixels->item(offset - cPixelSize + cAlphaChannelOffset)); 168 int center = static_cast<int>(pixels->item(offset + cAlphaChannelOffset)); 169 offset -= widthMultipliedByPixelSize; 170 int topLeft = static_cast<int>(pixels->item(offset - cPixelSize + cAlphaChannelOffset)); 171 int top = static_cast<int>(pixels->item(offset + cAlphaChannelOffset)); 172 172 normalVector.setX(-topLeft + top - (left << 1) + (center << 1)); 173 173 normalVector.setY(-topLeft - (top << 1) + left + (center << 1)); … … 177 177 int lightX, int lightY, float factorX, float factorY, IntPoint& normal2DVector) 178 178 { 179 m_lightSource->updatePaintingData(paintingData, lightX, lightY, static_cast<float>(data.pixels-> get(offset + cAlphaChannelOffset)) * data.surfaceScale);179 m_lightSource->updatePaintingData(paintingData, lightX, lightY, static_cast<float>(data.pixels->item(offset + cAlphaChannelOffset)) * data.surfaceScale); 180 180 181 181 float lightStrength; … … 291 291 } 292 292 293 bool FELighting::drawLighting( ByteArray* pixels, int width, int height)293 bool FELighting::drawLighting(Uint8ClampedArray* pixels, int width, int height) 294 294 { 295 295 LightSource::PaintingData paintingData; … … 374 374 } else { 375 375 for (int i = 0; i < lastPixel; i += cPixelSize) { 376 unsigned char a1 = data.pixels-> get(i);377 unsigned char a2 = data.pixels-> get(i + 1);378 unsigned char a3 = data.pixels-> get(i + 2);376 unsigned char a1 = data.pixels->item(i); 377 unsigned char a2 = data.pixels->item(i + 1); 378 unsigned char a3 = data.pixels->item(i + 2); 379 379 // alpha set to set to max(a1, a2, a3) 380 380 data.pixels->set(i + 3, a1 >= a2 ? (a1 >= a3 ? a1 : a3) : (a2 >= a3 ? a2 : a3)); … … 389 389 FilterEffect* in = inputEffect(0); 390 390 391 ByteArray* srcPixelArray = createUnmultipliedImageResult();391 Uint8ClampedArray* srcPixelArray = createUnmultipliedImageResult(); 392 392 if (!srcPixelArray) 393 393 return; -
trunk/Source/WebCore/platform/graphics/filters/FELighting.h
r102132 r114992 35 35 #include "PointLightSource.h" 36 36 #include "SpotLightSource.h" 37 #include <wtf/ByteArray.h>38 37 #include <wtf/Platform.h> 38 #include <wtf/Uint8ClampedArray.h> 39 39 40 40 // Common base class for FEDiffuseLighting and FESpecularLighting … … 60 60 struct LightingData { 61 61 // This structure contains only read-only (SMP safe) data 62 ByteArray* pixels;62 Uint8ClampedArray* pixels; 63 63 float surfaceScale; 64 64 int widthMultipliedByPixelSize; … … 93 93 FELighting(Filter*, LightingType, const Color&, float, float, float, float, float, float, PassRefPtr<LightSource>); 94 94 95 bool drawLighting( ByteArray*, int, int);95 bool drawLighting(Uint8ClampedArray*, int, int); 96 96 inline void inlineSetPixel(int offset, LightingData&, LightSource::PaintingData&, 97 97 int lightX, int lightY, float factorX, float factorY, IntPoint& normalVector); -
trunk/Source/WebCore/platform/graphics/filters/FEMorphology.cpp
r103076 r114992 31 31 #include "TextStream.h" 32 32 33 #include <wtf/ByteArray.h>34 33 #include <wtf/ParallelJobs.h> 34 #include <wtf/Uint8ClampedArray.h> 35 35 #include <wtf/Vector.h> 36 36 … … 107 107 void FEMorphology::platformApplyGeneric(PaintingData* paintingData, int yStart, int yEnd) 108 108 { 109 ByteArray* srcPixelArray = paintingData->srcPixelArray;110 ByteArray* dstPixelArray = paintingData->dstPixelArray;109 Uint8ClampedArray* srcPixelArray = paintingData->srcPixelArray; 110 Uint8ClampedArray* dstPixelArray = paintingData->dstPixelArray; 111 111 const int width = paintingData->width; 112 112 const int height = paintingData->height; … … 123 123 // Compute extremas for each columns 124 124 for (int x = 0; x <= radiusX; ++x) { 125 unsigned char columnExtrema = srcPixelArray-> get(extremaStartY * effectWidth + 4 * x + clrChannel);125 unsigned char columnExtrema = srcPixelArray->item(extremaStartY * effectWidth + 4 * x + clrChannel); 126 126 for (int eY = extremaStartY + 1; eY < extremaEndY; ++eY) { 127 unsigned char pixel = srcPixelArray-> get(eY * effectWidth + 4 * x + clrChannel);127 unsigned char pixel = srcPixelArray->item(eY * effectWidth + 4 * x + clrChannel); 128 128 if ((m_type == FEMORPHOLOGY_OPERATOR_ERODE && pixel <= columnExtrema) 129 129 || (m_type == FEMORPHOLOGY_OPERATOR_DILATE && pixel >= columnExtrema)) { … … 138 138 for (int x = 0; x < width; ++x) { 139 139 const int endX = min(x + radiusX, width - 1); 140 unsigned char columnExtrema = srcPixelArray-> get(extremaStartY * effectWidth + endX * 4 + clrChannel);140 unsigned char columnExtrema = srcPixelArray->item(extremaStartY * effectWidth + endX * 4 + clrChannel); 141 141 for (int i = extremaStartY + 1; i <= extremaEndY; ++i) { 142 unsigned char pixel = srcPixelArray-> get(i * effectWidth + endX * 4 + clrChannel);142 unsigned char pixel = srcPixelArray->item(i * effectWidth + endX * 4 + clrChannel); 143 143 if ((m_type == FEMORPHOLOGY_OPERATOR_ERODE && pixel <= columnExtrema) 144 144 || (m_type == FEMORPHOLOGY_OPERATOR_DILATE && pixel >= columnExtrema)) … … 198 198 FilterEffect* in = inputEffect(0); 199 199 200 ByteArray* dstPixelArray = createPremultipliedImageResult();200 Uint8ClampedArray* dstPixelArray = createPremultipliedImageResult(); 201 201 if (!dstPixelArray) 202 202 return; … … 204 204 setIsAlphaImage(in->isAlphaImage()); 205 205 if (m_radiusX <= 0 || m_radiusY <= 0) { 206 dstPixelArray-> clear();206 dstPixelArray->zeroFill(); 207 207 return; 208 208 } … … 213 213 214 214 IntRect effectDrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect()); 215 RefPtr< ByteArray> srcPixelArray = in->asPremultipliedImage(effectDrawingRect);215 RefPtr<Uint8ClampedArray> srcPixelArray = in->asPremultipliedImage(effectDrawingRect); 216 216 217 217 PaintingData paintingData; -
trunk/Source/WebCore/platform/graphics/filters/FEMorphology.h
r111922 r114992 58 58 59 59 struct PaintingData { 60 ByteArray* srcPixelArray;61 ByteArray* dstPixelArray;60 Uint8ClampedArray* srcPixelArray; 61 Uint8ClampedArray* dstPixelArray; 62 62 int width; 63 63 int height; -
trunk/Source/WebCore/platform/graphics/filters/FETurbulence.cpp
r104824 r114992 32 32 #include "TextStream.h" 33 33 34 #include <wtf/ByteArray.h>35 34 #include <wtf/MathExtras.h> 36 35 #include <wtf/ParallelJobs.h> 36 #include <wtf/Uint8ClampedArray.h> 37 37 38 38 namespace WebCore { … … 331 331 } 332 332 333 inline void FETurbulence::fillRegion( ByteArray* pixelArray, PaintingData& paintingData, int startY, int endY)333 inline void FETurbulence::fillRegion(Uint8ClampedArray* pixelArray, PaintingData& paintingData, int startY, int endY) 334 334 { 335 335 IntRect filterRegion = absolutePaintRect(); … … 357 357 void FETurbulence::platformApplySoftware() 358 358 { 359 ByteArray* pixelArray = createUnmultipliedImageResult();359 Uint8ClampedArray* pixelArray = createUnmultipliedImageResult(); 360 360 if (!pixelArray) 361 361 return; 362 362 363 363 if (absolutePaintRect().isEmpty()) { 364 pixelArray-> clear();364 pixelArray->zeroFill(); 365 365 return; 366 366 } -
trunk/Source/WebCore/platform/graphics/filters/FETurbulence.h
r104824 r114992 109 109 struct FillRegionParameters { 110 110 FETurbulence* filter; 111 ByteArray* pixelArray;111 Uint8ClampedArray* pixelArray; 112 112 PaintingData* paintingData; 113 113 int startY; … … 122 122 float noise2D(int channel, PaintingData&, StitchData&, const FloatPoint&); 123 123 unsigned char calculateTurbulenceValueForPoint(int channel, PaintingData&, StitchData&, const FloatPoint&); 124 inline void fillRegion( ByteArray*, PaintingData&, int, int);124 inline void fillRegion(Uint8ClampedArray*, PaintingData&, int, int); 125 125 126 126 TurbulenceType m_type; -
trunk/Source/WebCore/platform/graphics/filters/FilterEffect.cpp
r114172 r114992 28 28 #include "ImageBuffer.h" 29 29 #include "TextStream.h" 30 #include <wtf/ ByteArray.h>30 #include <wtf/Uint8ClampedArray.h> 31 31 32 32 namespace WebCore { … … 126 126 return; 127 127 128 ByteArray* imageArray = m_premultipliedImageResult.get();128 Uint8ClampedArray* imageArray = m_premultipliedImageResult.get(); 129 129 unsigned char* pixelData = imageArray->data(); 130 130 int pixelArrayLength = imageArray->length(); … … 174 174 } 175 175 176 PassRefPtr< ByteArray> FilterEffect::asUnmultipliedImage(const IntRect& rect)176 PassRefPtr<Uint8ClampedArray> FilterEffect::asUnmultipliedImage(const IntRect& rect) 177 177 { 178 178 ASSERT(isFilterSizeValid(rect)); 179 RefPtr< ByteArray> imageData = ByteArray::create(rect.width() * rect.height() * 4);179 RefPtr<Uint8ClampedArray> imageData = Uint8ClampedArray::createUninitialized(rect.width() * rect.height() * 4); 180 180 copyUnmultipliedImage(imageData.get(), rect); 181 181 return imageData.release(); 182 182 } 183 183 184 PassRefPtr< ByteArray> FilterEffect::asPremultipliedImage(const IntRect& rect)184 PassRefPtr<Uint8ClampedArray> FilterEffect::asPremultipliedImage(const IntRect& rect) 185 185 { 186 186 ASSERT(isFilterSizeValid(rect)); 187 RefPtr< ByteArray> imageData = ByteArray::create(rect.width() * rect.height() * 4);187 RefPtr<Uint8ClampedArray> imageData = Uint8ClampedArray::createUninitialized(rect.width() * rect.height() * 4); 188 188 copyPremultipliedImage(imageData.get(), rect); 189 189 return imageData.release(); 190 190 } 191 191 192 inline void FilterEffect::copyImageBytes( ByteArray* source, ByteArray* destination, const IntRect& rect)192 inline void FilterEffect::copyImageBytes(Uint8ClampedArray* source, Uint8ClampedArray* destination, const IntRect& rect) 193 193 { 194 194 // Initialize the destination to transparent black, if not entirely covered by the source. … … 234 234 } 235 235 236 void FilterEffect::copyUnmultipliedImage( ByteArray* destination, const IntRect& rect)236 void FilterEffect::copyUnmultipliedImage(Uint8ClampedArray* destination, const IntRect& rect) 237 237 { 238 238 ASSERT(hasResult()); … … 244 244 else { 245 245 ASSERT(isFilterSizeValid(m_absolutePaintRect)); 246 m_unmultipliedImageResult = ByteArray::create(m_absolutePaintRect.width() * m_absolutePaintRect.height() * 4);246 m_unmultipliedImageResult = Uint8ClampedArray::createUninitialized(m_absolutePaintRect.width() * m_absolutePaintRect.height() * 4); 247 247 unsigned char* sourceComponent = m_premultipliedImageResult->data(); 248 248 unsigned char* destinationComponent = m_unmultipliedImageResult->data(); … … 268 268 } 269 269 270 void FilterEffect::copyPremultipliedImage( ByteArray* destination, const IntRect& rect)270 void FilterEffect::copyPremultipliedImage(Uint8ClampedArray* destination, const IntRect& rect) 271 271 { 272 272 ASSERT(hasResult()); … … 278 278 else { 279 279 ASSERT(isFilterSizeValid(m_absolutePaintRect)); 280 m_premultipliedImageResult = ByteArray::create(m_absolutePaintRect.width() * m_absolutePaintRect.height() * 4);280 m_premultipliedImageResult = Uint8ClampedArray::createUninitialized(m_absolutePaintRect.width() * m_absolutePaintRect.height() * 4); 281 281 unsigned char* sourceComponent = m_unmultipliedImageResult->data(); 282 282 unsigned char* destinationComponent = m_premultipliedImageResult->data(); … … 309 309 } 310 310 311 ByteArray* FilterEffect::createUnmultipliedImageResult()311 Uint8ClampedArray* FilterEffect::createUnmultipliedImageResult() 312 312 { 313 313 // Only one result type is allowed. … … 317 317 if (m_absolutePaintRect.isEmpty()) 318 318 return 0; 319 m_unmultipliedImageResult = ByteArray::create(m_absolutePaintRect.width() * m_absolutePaintRect.height() * 4);319 m_unmultipliedImageResult = Uint8ClampedArray::createUninitialized(m_absolutePaintRect.width() * m_absolutePaintRect.height() * 4); 320 320 return m_unmultipliedImageResult.get(); 321 321 } 322 322 323 ByteArray* FilterEffect::createPremultipliedImageResult()323 Uint8ClampedArray* FilterEffect::createPremultipliedImageResult() 324 324 { 325 325 // Only one result type is allowed. … … 329 329 if (m_absolutePaintRect.isEmpty()) 330 330 return 0; 331 m_premultipliedImageResult = ByteArray::create(m_absolutePaintRect.width() * m_absolutePaintRect.height() * 4);331 m_premultipliedImageResult = Uint8ClampedArray::createUninitialized(m_absolutePaintRect.width() * m_absolutePaintRect.height() * 4); 332 332 return m_premultipliedImageResult.get(); 333 333 } -
trunk/Source/WebCore/platform/graphics/filters/FilterEffect.h
r109820 r114992 27 27 #include "IntRect.h" 28 28 29 #include <wtf/ByteArray.h>30 29 #include <wtf/PassOwnPtr.h> 31 30 #include <wtf/RefCounted.h> 32 31 #include <wtf/RefPtr.h> 32 #include <wtf/Uint8ClampedArray.h> 33 33 #include <wtf/Vector.h> 34 34 … … 57 57 void clearResult(); 58 58 ImageBuffer* asImageBuffer(); 59 PassRefPtr< ByteArray> asUnmultipliedImage(const IntRect&);60 PassRefPtr< ByteArray> asPremultipliedImage(const IntRect&);61 void copyUnmultipliedImage( ByteArray* destination, const IntRect&);62 void copyPremultipliedImage( ByteArray* destination, const IntRect&);59 PassRefPtr<Uint8ClampedArray> asUnmultipliedImage(const IntRect&); 60 PassRefPtr<Uint8ClampedArray> asPremultipliedImage(const IntRect&); 61 void copyUnmultipliedImage(Uint8ClampedArray* destination, const IntRect&); 62 void copyPremultipliedImage(Uint8ClampedArray* destination, const IntRect&); 63 63 64 64 FilterEffectVector& inputEffects() { return m_inputEffects; } … … 134 134 135 135 ImageBuffer* createImageBufferResult(); 136 ByteArray* createUnmultipliedImageResult();137 ByteArray* createPremultipliedImageResult();136 Uint8ClampedArray* createUnmultipliedImageResult(); 137 Uint8ClampedArray* createPremultipliedImageResult(); 138 138 139 139 // Return true if the filter will only operate correctly on valid RGBA values, with … … 146 146 private: 147 147 OwnPtr<ImageBuffer> m_imageBufferResult; 148 RefPtr< ByteArray> m_unmultipliedImageResult;149 RefPtr< ByteArray> m_premultipliedImageResult;148 RefPtr<Uint8ClampedArray> m_unmultipliedImageResult; 149 RefPtr<Uint8ClampedArray> m_premultipliedImageResult; 150 150 FilterEffectVector m_inputEffects; 151 151 … … 160 160 161 161 private: 162 inline void copyImageBytes( ByteArray* source, ByteArray* destination, const IntRect&);162 inline void copyImageBytes(Uint8ClampedArray* source, Uint8ClampedArray* destination, const IntRect&); 163 163 164 164 // The following member variables are SVG specific and will move to RenderSVGResourceFilterPrimitive. -
trunk/Source/WebCore/platform/graphics/filters/arm/FEGaussianBlurNEON.h
r95901 r114992 55 55 } 56 56 57 inline void FEGaussianBlur::platformApplyNeon( ByteArray* srcPixelArray, ByteArray* tmpPixelArray, unsigned kernelSizeX, unsigned kernelSizeY, IntSize& paintSize)57 inline void FEGaussianBlur::platformApplyNeon(Uint8ClampedArray* srcPixelArray, Uint8ClampedArray* tmpPixelArray, unsigned kernelSizeX, unsigned kernelSizeY, IntSize& paintSize) 58 58 { 59 59 const int widthMultipliedByFour = 4 * paintSize.width(); … … 90 90 neonDrawAllChannelGaussianBlur(srcPixelArray->data(), tmpPixelArray->data(), &argumentsX); 91 91 } else { 92 ByteArray* auxPixelArray = tmpPixelArray;92 Uint8ClampedArray* auxPixelArray = tmpPixelArray; 93 93 tmpPixelArray = srcPixelArray; 94 94 srcPixelArray = auxPixelArray; … … 103 103 neonDrawAllChannelGaussianBlur(tmpPixelArray->data(), srcPixelArray->data(), &argumentsY); 104 104 } else { 105 ByteArray* auxPixelArray = tmpPixelArray;105 Uint8ClampedArray* auxPixelArray = tmpPixelArray; 106 106 tmpPixelArray = srcPixelArray; 107 107 srcPixelArray = auxPixelArray; -
trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp
r114268 r114992 151 151 152 152 RefPtr<ImageData> imageData = ImageData::create(IntSize(m_currentWidth, m_currentHeight)); 153 unsigned char* pixels = imageData->data()->data() ->data();153 unsigned char* pixels = imageData->data()->data(); 154 154 int totalBytes = 4 * m_currentWidth * m_currentHeight; 155 155 -
trunk/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp
r114150 r114992 190 190 191 191 template <Multiply multiplied> 192 PassRefPtr< ByteArray> getImageData(const IntRect& rect, const ImageBufferData& imageData, const IntSize& size)192 PassRefPtr<Uint8ClampedArray> getImageData(const IntRect& rect, const ImageBufferData& imageData, const IntSize& size) 193 193 { 194 194 float area = 4.0f * rect.width() * rect.height(); … … 196 196 return 0; 197 197 198 RefPtr< ByteArray> result = ByteArray::create(rect.width() * rect.height() * 4);198 RefPtr<Uint8ClampedArray> result = Uint8ClampedArray::createUninitialized(rect.width() * rect.height() * 4); 199 199 unsigned char* data = result->data(); 200 200 201 201 if (rect.x() < 0 || rect.y() < 0 || rect.maxX() > size.width() || rect.maxY() > size.height()) 202 memset(data, 0, result->length());202 result->zeroFill(); 203 203 204 204 int originx = rect.x(); … … 272 272 } 273 273 274 PassRefPtr< ByteArray> ImageBuffer::getUnmultipliedImageData(const IntRect& rect, CoordinateSystem) const274 PassRefPtr<Uint8ClampedArray> ImageBuffer::getUnmultipliedImageData(const IntRect& rect, CoordinateSystem) const 275 275 { 276 276 return getImageData<Unmultiplied>(rect, m_data, m_size); 277 277 } 278 278 279 PassRefPtr< ByteArray> ImageBuffer::getPremultipliedImageData(const IntRect& rect, CoordinateSystem) const279 PassRefPtr<Uint8ClampedArray> ImageBuffer::getPremultipliedImageData(const IntRect& rect, CoordinateSystem) const 280 280 { 281 281 return getImageData<Premultiplied>(rect, m_data, m_size); … … 298 298 } 299 299 300 void ImageBuffer::putByteArray(Multiply multiplied, ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, CoordinateSystem)300 void ImageBuffer::putByteArray(Multiply multiplied, Uint8ClampedArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, CoordinateSystem) 301 301 { 302 302 ASSERT(sourceRect.width() > 0); -
trunk/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
r114150 r114992 231 231 232 232 template <Multiply multiplied> 233 PassRefPtr< ByteArray> getImageData(const IntRect& rect, SkCanvas* canvas,233 PassRefPtr<Uint8ClampedArray> getImageData(const IntRect& rect, SkCanvas* canvas, 234 234 const IntSize& size) 235 235 { … … 238 238 return 0; 239 239 240 RefPtr< ByteArray> result = ByteArray::create(rect.width() * rect.height() * 4);240 RefPtr<Uint8ClampedArray> result = Uint8ClampedArray::createUninitialized(rect.width() * rect.height() * 4); 241 241 242 242 unsigned char* data = result->data(); … … 246 246 || rect.maxX() > size.width() 247 247 || rect.maxY() > size.height()) 248 memset(data, 0, result->length());248 result->zeroFill(); 249 249 250 250 unsigned destBytesPerRow = 4 * rect.width(); … … 263 263 } 264 264 265 PassRefPtr< ByteArray> ImageBuffer::getUnmultipliedImageData(const IntRect& rect, CoordinateSystem) const265 PassRefPtr<Uint8ClampedArray> ImageBuffer::getUnmultipliedImageData(const IntRect& rect, CoordinateSystem) const 266 266 { 267 267 return getImageData<Unmultiplied>(rect, context()->platformContext()->canvas(), m_size); 268 268 } 269 269 270 PassRefPtr< ByteArray> ImageBuffer::getPremultipliedImageData(const IntRect& rect, CoordinateSystem) const270 PassRefPtr<Uint8ClampedArray> ImageBuffer::getPremultipliedImageData(const IntRect& rect, CoordinateSystem) const 271 271 { 272 272 return getImageData<Premultiplied>(rect, context()->platformContext()->canvas(), m_size); 273 273 } 274 274 275 void ImageBuffer::putByteArray(Multiply multiplied, ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, CoordinateSystem)275 void ImageBuffer::putByteArray(Multiply multiplied, Uint8ClampedArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, CoordinateSystem) 276 276 { 277 277 SkCanvas* canvas = context()->platformContext()->canvas(); -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp
r114118 r114992 48 48 #include "RefPtrCairo.h" 49 49 #include <cairo.h> 50 #include <wtf/ByteArray.h>51 50 #endif 52 51 -
trunk/Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp
r114150 r114992 122 122 123 123 template <bool premultiplied> 124 static PassRefPtr< ByteArray> getImageData(const IntRect& rect, const SharedBitmap* bitmap)125 { 126 RefPtr< ByteArray> imageData = ByteArray::create(rect.width() * rect.height() * 4);124 static PassRefPtr<Uint8ClampedArray> getImageData(const IntRect& rect, const SharedBitmap* bitmap) 125 { 126 RefPtr<Uint8ClampedArray> imageData = Uint8ClampedArray::createUninitialized(rect.width() * rect.height() * 4); 127 127 128 128 const unsigned char* src = static_cast<const unsigned char*>(bitmap->bytes()); … … 136 136 137 137 unsigned char* dst = imageData->data(); 138 memset(dst, 0, imageData->length());138 imageData->zeroFill(); 139 139 src += (sourceRect.y() * bitmap->width() + sourceRect.x()) * 4; 140 140 dst += ((sourceRect.y() - rect.y()) * rect.width() + sourceRect.x() - rect.x()) * 4; … … 171 171 } 172 172 173 PassRefPtr< ByteArray> ImageBuffer::getUnmultipliedImageData(const IntRect& rect, CoordinateSystem) const173 PassRefPtr<Uint8ClampedArray> ImageBuffer::getUnmultipliedImageData(const IntRect& rect, CoordinateSystem) const 174 174 { 175 175 return getImageData<false>(rect, m_data.m_bitmap.get()); 176 176 } 177 177 178 PassRefPtr< ByteArray> ImageBuffer::getPremultipliedImageData(const IntRect& rect, CoordinateSystem) const178 PassRefPtr<Uint8ClampedArray> ImageBuffer::getPremultipliedImageData(const IntRect& rect, CoordinateSystem) const 179 179 { 180 180 return getImageData<true>(rect, m_data.m_bitmap.get()); 181 181 } 182 182 183 void ImageBuffer::putByteArray(Multiply multiplied, ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, CoordinateSystem)183 void ImageBuffer::putByteArray(Multiply multiplied, Uint8ClampedArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, CoordinateSystem) 184 184 { 185 185 SharedBitmap* bitmap = m_data.m_bitmap.get(); -
trunk/Source/WebCore/platform/graphics/wx/ImageBufferWx.cpp
r114150 r114992 123 123 } 124 124 125 PassRefPtr< ByteArray> ImageBuffer::getUnmultipliedImageData(const IntRect& rect, CoordinateSystem) const125 PassRefPtr<Uint8ClampedArray> ImageBuffer::getUnmultipliedImageData(const IntRect& rect, CoordinateSystem) const 126 126 { 127 127 notImplemented(); … … 129 129 } 130 130 131 PassRefPtr< ByteArray> ImageBuffer::getPremultipliedImageData(const IntRect& rect, CoordinateSystem) const131 PassRefPtr<Uint8ClampedArray> ImageBuffer::getPremultipliedImageData(const IntRect& rect, CoordinateSystem) const 132 132 { 133 133 notImplemented(); … … 135 135 } 136 136 137 void ImageBuffer::putByteArray(Multiply multiplied, ByteArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, CoordinateSystem)137 void ImageBuffer::putByteArray(Multiply multiplied, Uint8ClampedArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, CoordinateSystem) 138 138 { 139 139 notImplemented(); -
trunk/Source/WebCore/platform/image-encoders/skia/JPEGImageEncoder.cpp
r113455 r114992 196 196 bool JPEGImageEncoder::encode(const ImageData& imageData, int quality, Vector<unsigned char>* output) 197 197 { 198 return encodePixels(imageData.size(), imageData.data()->data() ->data(), false, quality, output);198 return encodePixels(imageData.size(), imageData.data()->data(), false, quality, output); 199 199 } 200 200 -
trunk/Source/WebCore/platform/image-encoders/skia/PNGImageEncoder.cpp
r96338 r114992 127 127 bool PNGImageEncoder::encode(const ImageData& imageData, Vector<unsigned char>* output) 128 128 { 129 return encodePixels(imageData.size(), imageData.data()->data() ->data(), false, output);129 return encodePixels(imageData.size(), imageData.data()->data(), false, output); 130 130 } 131 131 -
trunk/Source/WebCore/platform/image-encoders/skia/WEBPImageEncoder.cpp
r105860 r114992 131 131 bool WEBPImageEncoder::encode(const ImageData& imageData, int quality, Vector<unsigned char>* output) 132 132 { 133 return encodePixels(imageData.size(), imageData.data()->data() ->data(), false, quality, output);133 return encodePixels(imageData.size(), imageData.data()->data(), false, quality, output); 134 134 } 135 135 -
trunk/Source/WebKit/chromium/ChangeLog
r114987 r114992 1 2012-04-23 Kenneth Russell <kbr@google.com> 2 3 Change ImageData to reference Uint8ClampedArray rather than CanvasPixelArray 4 https://bugs.webkit.org/show_bug.cgi?id=73011 5 6 Reviewed by Oliver Hunt. 7 8 * src/GraphicsContext3DChromium.cpp: 9 (WebCore::GraphicsContext3DPrivate::paintRenderingResultsToImageData): 10 * src/WebViewImpl.cpp: 11 (WebKit::WebViewImpl::doPixelReadbackToCanvas): 12 1 13 2012-04-23 Kent Tamura <tkent@chromium.org> 2 14 -
trunk/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp
r113092 r114992 319 319 320 320 RefPtr<ImageData> imageData = ImageData::create(IntSize(width, height)); 321 unsigned char* pixels = imageData->data()->data() ->data();321 unsigned char* pixels = imageData->data()->data(); 322 322 size_t bufferSize = 4 * width * height; 323 323 -
trunk/Source/WebKit/chromium/src/WebViewImpl.cpp
r114987 r114992 157 157 #include <public/WebPoint.h> 158 158 #include <public/WebRect.h> 159 #include <wtf/ByteArray.h>160 159 #include <wtf/CurrentTime.h> 161 160 #include <wtf/MainThread.h> 162 161 #include <wtf/RefPtr.h> 162 #include <wtf/Uint8ClampedArray.h> 163 163 164 164 #if ENABLE(GESTURE_EVENTS) … … 1478 1478 1479 1479 OwnPtr<ImageBuffer> imageBuffer(ImageBuffer::create(rect.size())); 1480 RefPtr< ByteArray> pixelArray(ByteArray::create(rect.width() * rect.height() * 4));1480 RefPtr<Uint8ClampedArray> pixelArray(Uint8ClampedArray::createUninitialized(rect.width() * rect.height() * 4)); 1481 1481 if (imageBuffer && pixelArray) { 1482 1482 m_layerTreeView.compositeAndReadback(pixelArray->data(), invertRect);
Note: See TracChangeset
for help on using the changeset viewer.