Changeset 70421 in webkit
- Timestamp:
- Oct 24, 2010 12:24:38 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r70419 r70421 1 2010-10-24 Dirk Schulze <krit@webkit.org> 2 3 Reviewed by Nikolas Zimmermann. 4 5 Filter example Chiseled from SVG Wow! is slow 6 https://bugs.webkit.org/show_bug.cgi?id=48174 7 8 Added 'using WTF::ByteArray;' at the end of ByteArray.h 9 10 * wtf/ByteArray.h: 11 1 12 2010-10-24 Patrick Gansterer <paroga@webkit.org> 2 13 -
trunk/JavaScriptCore/wtf/ByteArray.h
r66729 r70421 98 98 #endif 99 99 }; 100 } 100 } // namespace WTF 101 102 using WTF::ByteArray; 101 103 102 104 #endif -
trunk/WebCore/ChangeLog
r70420 r70421 1 2010-10-24 Dirk Schulze <krit@webkit.org> 2 3 Reviewed by Nikolas Zimmermann. 4 5 Filter example Chiseled from SVG Wow! is slow 6 https://bugs.webkit.org/show_bug.cgi?id=48174 7 8 Use a pointer to the ByteArray instead of the ref counted CanvasPixelArray or ImageData directly 9 to access the data for pixel manipulation on SVG Filters or SVG Masker. This is a 10 performance increase since the recurring use of the -> operator can be avoided. 11 FEConvolveMatrix and FELighting still need to change in a followup patch. 12 13 No functionality was changed. So, no new tests. 14 15 * platform/graphics/filters/FEBlend.cpp: 16 (WebCore::FEBlend::apply): 17 * platform/graphics/filters/FEColorMatrix.cpp: 18 (WebCore::luminance): 19 (WebCore::effectType): 20 (WebCore::FEColorMatrix::apply): 21 * platform/graphics/filters/FEComponentTransfer.cpp: 22 (WebCore::FEComponentTransfer::apply): 23 * platform/graphics/filters/FEComposite.cpp: 24 (WebCore::arithmetic): 25 (WebCore::FEComposite::apply): 26 * platform/graphics/filters/FEDisplacementMap.cpp: 27 (WebCore::FEDisplacementMap::apply): 28 * platform/graphics/filters/FEGaussianBlur.cpp: 29 (WebCore::boxBlur): 30 (WebCore::FEGaussianBlur::apply): 31 * platform/graphics/filters/FEMorphology.cpp: 32 (WebCore::FEMorphology::apply): 33 * platform/graphics/filters/FETurbulence.cpp: 34 (WebCore::FETurbulence::apply): 35 * rendering/RenderSVGResourceMasker.cpp: 36 (WebCore::RenderSVGResourceMasker::drawContentIntoMaskImage): 37 1 38 2010-10-24 Pavel Feldman <pfeldman@chromium.org> 2 39 -
trunk/WebCore/platform/graphics/filters/FEBlend.cpp
r69181 r70421 103 103 104 104 IntRect effectADrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect()); 105 RefPtr<CanvasPixelArray> srcPixelArrayA(in->resultImage()->getPremultipliedImageData(effectADrawingRect)->data()); 105 RefPtr<ImageData> srcImageDataA = in->resultImage()->getPremultipliedImageData(effectADrawingRect); 106 ByteArray* srcPixelArrayA = srcImageDataA->data()->data(); 106 107 107 108 IntRect effectBDrawingRect = requestedRegionOfInputImageData(in2->absolutePaintRect()); 108 RefPtr<CanvasPixelArray> srcPixelArrayB(in2->resultImage()->getPremultipliedImageData(effectBDrawingRect)->data()); 109 RefPtr<ImageData> srcImageDataB = in2->resultImage()->getPremultipliedImageData(effectBDrawingRect); 110 ByteArray* srcPixelArrayB = srcImageDataB->data()->data(); 109 111 110 112 IntRect imageRect(IntPoint(), resultImage()->size()); 111 113 RefPtr<ImageData> imageData = ImageData::create(imageRect.width(), imageRect.height()); 114 ByteArray* dstPixelArray = imageData->data()->data(); 112 115 113 116 // Keep synchronized with BlendModeType 114 117 static const BlendType callEffect[] = {unknown, normal, multiply, screen, darken, lighten}; 115 118 116 ASSERT(srcPixelArrayA->length() == srcPixelArrayB->length()); 117 for (unsigned pixelOffset = 0; pixelOffset < srcPixelArrayA->length(); pixelOffset += 4) { 119 unsigned pixelArrayLength = srcPixelArrayA->length(); 120 ASSERT(pixelArrayLength == srcPixelArrayB->length()); 121 for (unsigned pixelOffset = 0; pixelOffset < pixelArrayLength; pixelOffset += 4) { 118 122 unsigned char alphaA = srcPixelArrayA->get(pixelOffset + 3); 119 123 unsigned char alphaB = srcPixelArrayB->get(pixelOffset + 3); … … 123 127 124 128 unsigned char result = (*callEffect[m_mode])(colorA, colorB, alphaA, alphaB); 125 imageData->data()->set(pixelOffset + channel, result);129 dstPixelArray->set(pixelOffset + channel, result); 126 130 } 127 131 unsigned char alphaR = 255 - ((255 - alphaA) * (255 - alphaB)) / 255; 128 imageData->data()->set(pixelOffset + 3, alphaR);132 dstPixelArray->set(pixelOffset + 3, alphaR); 129 133 } 130 134 -
trunk/WebCore/platform/graphics/filters/FEColorMatrix.cpp
r70143 r70421 26 26 #include "FEColorMatrix.h" 27 27 28 #include "CanvasPixelArray.h"29 28 #include "Filter.h" 30 29 #include "GraphicsContext.h" 31 30 #include "ImageData.h" 32 #include <math.h> 31 33 32 #include <wtf/MathExtras.h> 34 33 … … 113 112 { 114 113 alpha = 0.2125 * red + 0.7154 * green + 0.0721 * blue; 115 red = 0 .;116 green = 0 .;117 blue = 0 .;114 red = 0; 115 green = 0; 116 blue = 0; 118 117 } 119 118 120 119 template<ColorMatrixType filterType> 121 void effectType(const PassRefPtr<CanvasPixelArray>& srcPixelArray, PassRefPtr<ImageData>& imageData, const Vector<float>& values) 122 { 123 for (unsigned pixelOffset = 0; pixelOffset < srcPixelArray->length(); pixelOffset++) { 124 unsigned pixelByteOffset = pixelOffset * 4; 125 126 unsigned char r = 0, g = 0, b = 0, a = 0; 127 srcPixelArray->get(pixelByteOffset, r); 128 srcPixelArray->get(pixelByteOffset + 1, g); 129 srcPixelArray->get(pixelByteOffset + 2, b); 130 srcPixelArray->get(pixelByteOffset + 3, a); 131 132 double red = r, green = g, blue = b, alpha = a; 133 120 void effectType(ByteArray* pixelArray, const Vector<float>& values) 121 { 122 unsigned pixelArrayLength = pixelArray->length(); 123 for (unsigned pixelByteOffset = 0; pixelByteOffset < pixelArrayLength; pixelByteOffset += 4) { 124 double red = pixelArray->get(pixelByteOffset); 125 double green = pixelArray->get(pixelByteOffset + 1); 126 double blue = pixelArray->get(pixelByteOffset + 2); 127 double alpha = pixelArray->get(pixelByteOffset + 3); 128 134 129 switch (filterType) { 135 130 case FECOLORMATRIX_TYPE_MATRIX: … … 147 142 } 148 143 149 imageData->data()->set(pixelByteOffset, red);150 imageData->data()->set(pixelByteOffset + 1, green);151 imageData->data()->set(pixelByteOffset + 2, blue);152 imageData->data()->set(pixelByteOffset + 3, alpha);144 pixelArray->set(pixelByteOffset, red); 145 pixelArray->set(pixelByteOffset + 1, green); 146 pixelArray->set(pixelByteOffset + 2, blue); 147 pixelArray->set(pixelByteOffset + 3, alpha); 153 148 } 154 149 } … … 168 163 169 164 IntRect imageRect(IntPoint(), resultImage()->size()); 170 PassRefPtr<ImageData> imageData(resultImage()->getUnmultipliedImageData(imageRect));171 PassRefPtr<CanvasPixelArray> srcPixelArray(imageData->data());165 RefPtr<ImageData> imageData = resultImage()->getUnmultipliedImageData(imageRect); 166 ByteArray* pixelArray = imageData->data()->data(); 172 167 173 168 switch (m_type) { … … 175 170 break; 176 171 case FECOLORMATRIX_TYPE_MATRIX: 177 effectType<FECOLORMATRIX_TYPE_MATRIX>( srcPixelArray, imageData, m_values);172 effectType<FECOLORMATRIX_TYPE_MATRIX>(pixelArray, m_values); 178 173 break; 179 174 case FECOLORMATRIX_TYPE_SATURATE: 180 effectType<FECOLORMATRIX_TYPE_SATURATE>( srcPixelArray, imageData, m_values);175 effectType<FECOLORMATRIX_TYPE_SATURATE>(pixelArray, m_values); 181 176 break; 182 177 case FECOLORMATRIX_TYPE_HUEROTATE: 183 effectType<FECOLORMATRIX_TYPE_HUEROTATE>( srcPixelArray, imageData, m_values);178 effectType<FECOLORMATRIX_TYPE_HUEROTATE>(pixelArray, m_values); 184 179 break; 185 180 case FECOLORMATRIX_TYPE_LUMINANCETOALPHA: 186 effectType<FECOLORMATRIX_TYPE_LUMINANCETOALPHA>( srcPixelArray, imageData, m_values);181 effectType<FECOLORMATRIX_TYPE_LUMINANCETOALPHA>(pixelArray, m_values); 187 182 setIsAlphaImage(true); 188 183 break; -
trunk/WebCore/platform/graphics/filters/FEComponentTransfer.cpp
r69181 r70421 27 27 #include "FEComponentTransfer.h" 28 28 29 #include "CanvasPixelArray.h"30 29 #include "Filter.h" 31 30 #include "GraphicsContext.h" 32 31 #include "ImageData.h" 33 #include <math.h> 32 33 #include <wtf/MathExtras.h> 34 34 35 35 namespace WebCore { … … 169 169 170 170 IntRect drawingRect = requestedRegionOfInputImageData(in->absolutePaintRect()); 171 RefPtr<ImageData> imageData(in->resultImage()->getUnmultipliedImageData(drawingRect)); 172 CanvasPixelArray* srcPixelArray(imageData->data()); 173 174 for (unsigned pixelOffset = 0; pixelOffset < srcPixelArray->length(); pixelOffset += 4) { 171 RefPtr<ImageData> imageData = in->resultImage()->getUnmultipliedImageData(drawingRect); 172 ByteArray* pixelArray = imageData->data()->data(); 173 174 unsigned pixelArrayLength = pixelArray->length(); 175 for (unsigned pixelOffset = 0; pixelOffset < pixelArrayLength; pixelOffset += 4) { 175 176 for (unsigned channel = 0; channel < 4; ++channel) { 176 unsigned char c = srcPixelArray->get(pixelOffset + channel);177 imageData->data()->set(pixelOffset + channel, tables[channel][c]);177 unsigned char c = pixelArray->get(pixelOffset + channel); 178 pixelArray->set(pixelOffset + channel, tables[channel][c]); 178 179 } 179 180 } -
trunk/WebCore/platform/graphics/filters/FEComposite.cpp
r70143 r70421 27 27 #include "FEComposite.h" 28 28 29 #include "CanvasPixelArray.h"30 29 #include "Filter.h" 31 30 #include "GraphicsContext.h" … … 99 98 } 100 99 101 inline void arithmetic(const RefPtr<CanvasPixelArray>& srcPixelArrayA, CanvasPixelArray*&srcPixelArrayB,100 inline void arithmetic(const ByteArray* srcPixelArrayA, ByteArray* srcPixelArrayB, 102 101 float k1, float k2, float k3, float k4) 103 102 { 104 103 float scaledK1 = k1 / 255.f; 105 104 float scaledK4 = k4 * 255.f; 106 for (unsigned pixelOffset = 0; pixelOffset < srcPixelArrayA->length(); pixelOffset += 4) { 105 unsigned pixelArrayLength = srcPixelArrayA->length(); 106 for (unsigned pixelOffset = 0; pixelOffset < pixelArrayLength; pixelOffset += 4) { 107 107 for (unsigned channel = 0; channel < 4; ++channel) { 108 108 unsigned char i1 = srcPixelArrayA->get(pixelOffset + channel); … … 175 175 case FECOMPOSITE_OPERATOR_ARITHMETIC: { 176 176 IntRect effectADrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect()); 177 RefPtr<CanvasPixelArray> srcPixelArrayA(in->resultImage()->getPremultipliedImageData(effectADrawingRect)->data()); 177 RefPtr<ImageData> srcImageData = in->resultImage()->getPremultipliedImageData(effectADrawingRect); 178 ByteArray* srcPixelArrayA = srcImageData->data()->data(); 178 179 179 180 IntRect effectBDrawingRect = requestedRegionOfInputImageData(in2->absolutePaintRect()); 180 RefPtr<ImageData> imageData (in2->resultImage()->getPremultipliedImageData(effectBDrawingRect));181 CanvasPixelArray* srcPixelArrayB(imageData->data());181 RefPtr<ImageData> imageData = in2->resultImage()->getPremultipliedImageData(effectBDrawingRect); 182 ByteArray* srcPixelArrayB = imageData->data()->data(); 182 183 183 184 arithmetic(srcPixelArrayA, srcPixelArrayB, m_k1, m_k2, m_k3, m_k4); -
trunk/WebCore/platform/graphics/filters/FEDisplacementMap.cpp
r69181 r70421 27 27 #include "FEDisplacementMap.h" 28 28 29 #include "CanvasPixelArray.h"30 29 #include "Filter.h" 31 30 #include "GraphicsContext.h" … … 94 93 95 94 IntRect effectADrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect()); 96 RefPtr<CanvasPixelArray> srcPixelArrayA(in->resultImage()->getPremultipliedImageData(effectADrawingRect)->data()); 95 RefPtr<ImageData> srcImageDataA = in->resultImage()->getPremultipliedImageData(effectADrawingRect); 96 ByteArray* srcPixelArrayA = srcImageDataA->data()->data() ; 97 97 98 98 IntRect effectBDrawingRect = requestedRegionOfInputImageData(in2->absolutePaintRect()); 99 RefPtr<CanvasPixelArray> srcPixelArrayB(in2->resultImage()->getUnmultipliedImageData(effectBDrawingRect)->data()); 99 RefPtr<ImageData> srcImageDataB = in2->resultImage()->getUnmultipliedImageData(effectBDrawingRect); 100 ByteArray* srcPixelArrayB = srcImageDataB->data()->data(); 100 101 101 102 IntRect imageRect(IntPoint(), resultImage()->size()); 102 103 RefPtr<ImageData> imageData = ImageData::create(imageRect.width(), imageRect.height()); 104 ByteArray* dstPixelArray = imageData->data()->data(); 103 105 104 106 ASSERT(srcPixelArrayA->length() == srcPixelArrayB->length()); … … 117 119 for (unsigned channel = 0; channel < 4; ++channel) { 118 120 if (srcX < 0 || srcX >= imageRect.width() || srcY < 0 || srcY >= imageRect.height()) 119 imageData->data()->set(dstIndex + channel, static_cast<unsigned char>(0));121 dstPixelArray->set(dstIndex + channel, static_cast<unsigned char>(0)); 120 122 else { 121 123 unsigned char pixelValue = srcPixelArrayA->get(srcY * stride + srcX * 4 + channel); 122 imageData->data()->set(dstIndex + channel, pixelValue);124 dstPixelArray->set(dstIndex + channel, pixelValue); 123 125 } 124 126 } -
trunk/WebCore/platform/graphics/filters/FEGaussianBlur.cpp
r70140 r70421 28 28 #include "FEGaussianBlur.h" 29 29 30 #include "CanvasPixelArray.h"31 30 #include "Filter.h" 32 31 #include "GraphicsContext.h" 33 32 #include "ImageData.h" 33 34 34 #include <wtf/MathExtras.h> 35 35 … … 73 73 } 74 74 75 static void boxBlur(CanvasPixelArray*& srcPixelArray, CanvasPixelArray*&dstPixelArray,75 inline void boxBlur(ByteArray* srcPixelArray, ByteArray* dstPixelArray, 76 76 unsigned dx, int dxLeft, int dxRight, int stride, int strideLine, int effectWidth, int effectHeight, bool alphaImage) 77 77 { … … 176 176 177 177 IntRect effectDrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect()); 178 RefPtr<ImageData> srcImageData (in->resultImage()->getPremultipliedImageData(effectDrawingRect));178 RefPtr<ImageData> srcImageData = in->resultImage()->getPremultipliedImageData(effectDrawingRect); 179 179 IntRect imageRect(IntPoint(), resultImage()->size()); 180 180 … … 188 188 calculateKernelSize(filter, kernelSizeX, kernelSizeY, m_stdX, m_stdY); 189 189 190 CanvasPixelArray* srcPixelArray(srcImageData->data());190 ByteArray* srcPixelArray = srcImageData->data()->data(); 191 191 RefPtr<ImageData> tmpImageData = ImageData::create(imageRect.width(), imageRect.height()); 192 CanvasPixelArray* tmpPixelArray(tmpImageData->data());192 ByteArray* tmpPixelArray = tmpImageData->data()->data(); 193 193 194 194 int stride = 4 * imageRect.width(); … … 202 202 boxBlur(srcPixelArray, tmpPixelArray, kernelSizeX, dxLeft, dxRight, 4, stride, imageRect.width(), imageRect.height(), isAlphaImage()); 203 203 } else { 204 CanvasPixelArray* auxPixelArray = tmpPixelArray;204 ByteArray* auxPixelArray = tmpPixelArray; 205 205 tmpPixelArray = srcPixelArray; 206 206 srcPixelArray = auxPixelArray; … … 211 211 boxBlur(tmpPixelArray, srcPixelArray, kernelSizeY, dyLeft, dyRight, stride, 4, imageRect.height(), imageRect.width(), isAlphaImage()); 212 212 } else { 213 CanvasPixelArray* auxPixelArray = tmpPixelArray;213 ByteArray* auxPixelArray = tmpPixelArray; 214 214 tmpPixelArray = srcPixelArray; 215 215 srcPixelArray = auxPixelArray; -
trunk/WebCore/platform/graphics/filters/FEMorphology.cpp
r69194 r70421 27 27 #include "FEMorphology.h" 28 28 29 #include "CanvasPixelArray.h"30 29 #include "Filter.h" 31 30 #include "ImageData.h" … … 109 108 IntRect imageRect(IntPoint(), resultImage()->size()); 110 109 IntRect effectDrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect()); 111 RefPtr<CanvasPixelArray> srcPixelArray(in->resultImage()->getPremultipliedImageData(effectDrawingRect)->data()); 110 RefPtr<ImageData> srcImageData = in->resultImage()->getPremultipliedImageData(effectDrawingRect); 111 ByteArray* srcPixelArray = srcImageData->data()->data(); 112 112 RefPtr<ImageData> imageData = ImageData::create(imageRect.width(), imageRect.height()); 113 ByteArray* dstPixelArray = imageData->data()->data(); 113 114 114 115 int effectWidth = effectDrawingRect.width() * 4; … … 156 157 entireExtrema = extrema[kernelIndex]; 157 158 } 158 imageData->data()->set(y * effectWidth + 4 * x + channel, entireExtrema);159 dstPixelArray->set(y * effectWidth + 4 * x + channel, entireExtrema); 159 160 } 160 161 } -
trunk/WebCore/platform/graphics/filters/FETurbulence.cpp
r69181 r70421 27 27 #include "FETurbulence.h" 28 28 29 #include "CanvasPixelArray.h"30 29 #include "Filter.h" 31 30 #include "ImageData.h" … … 330 329 331 330 RefPtr<ImageData> imageData = ImageData::create(imageRect.width(), imageRect.height()); 331 ByteArray* pixelArray = imageData->data()->data(); 332 332 PaintingData paintingData(m_seed, roundedIntSize(filterPrimitiveSubregion().size())); 333 333 initPaint(paintingData); … … 343 343 point.setX(point.x() + 1); 344 344 for (paintingData.channel = 0; paintingData.channel < 4; ++paintingData.channel, ++indexOfPixelChannel) 345 imageData->data()->set(indexOfPixelChannel, calculateTurbulenceValueForPoint(paintingData, filter->mapAbsolutePointToLocalPoint(point)));345 pixelArray->set(indexOfPixelChannel, calculateTurbulenceValueForPoint(paintingData, filter->mapAbsolutePointToLocalPoint(point))); 346 346 } 347 347 } -
trunk/WebCore/rendering/RenderSVGResourceMasker.cpp
r70143 r70421 162 162 // Create the luminance mask. 163 163 IntRect maskImageRect(IntPoint(), maskerData->maskImage->size()); 164 RefPtr<ImageData> imageData(maskerData->maskImage->getUnmultipliedImageData(maskImageRect)); 165 CanvasPixelArray* srcPixelArray(imageData->data()); 166 167 for (unsigned pixelOffset = 0; pixelOffset < srcPixelArray->length(); pixelOffset += 4) { 164 RefPtr<ImageData> imageData = maskerData->maskImage->getUnmultipliedImageData(maskImageRect); 165 ByteArray* srcPixelArray = imageData->data()->data(); 166 167 unsigned pixelArrayLength = srcPixelArray->length(); 168 for (unsigned pixelOffset = 0; pixelOffset < pixelArrayLength; pixelOffset += 4) { 168 169 unsigned char a = srcPixelArray->get(pixelOffset + 3); 169 170 if (!a)
Note: See TracChangeset
for help on using the changeset viewer.