Index: Source/platform/graphics/filters/FEGaussianBlur.cpp |
diff --git a/Source/platform/graphics/filters/FEGaussianBlur.cpp b/Source/platform/graphics/filters/FEGaussianBlur.cpp |
index 6b8e45f2e86e62ba0fb4fa12515e77a2c0858485..0db31daadce9bf502fa471e8037b4533008200cf 100644 |
--- a/Source/platform/graphics/filters/FEGaussianBlur.cpp |
+++ b/Source/platform/graphics/filters/FEGaussianBlur.cpp |
@@ -80,154 +80,6 @@ void FEGaussianBlur::setStdDeviationY(float y) |
m_stdY = y; |
} |
-inline void boxBlur(Uint8ClampedArray* srcPixelArray, Uint8ClampedArray* dstPixelArray, |
- unsigned dx, int dxLeft, int dxRight, int stride, int strideLine, int effectWidth, int effectHeight, bool alphaImage) |
-{ |
- for (int y = 0; y < effectHeight; ++y) { |
- int line = y * strideLine; |
- for (int channel = 3; channel >= 0; --channel) { |
- int sum = 0; |
- // Fill the kernel |
- int maxKernelSize = min(dxRight, effectWidth); |
- for (int i = 0; i < maxKernelSize; ++i) |
- sum += srcPixelArray->item(line + i * stride + channel); |
- |
- // Blurring |
- for (int x = 0; x < effectWidth; ++x) { |
- int pixelByteOffset = line + x * stride + channel; |
- dstPixelArray->set(pixelByteOffset, static_cast<unsigned char>(sum / dx)); |
- if (x >= dxLeft) |
- sum -= srcPixelArray->item(pixelByteOffset - dxLeft * stride); |
- if (x + dxRight < effectWidth) |
- sum += srcPixelArray->item(pixelByteOffset + dxRight * stride); |
- } |
- if (alphaImage) // Source image is black, it just has different alpha values |
- break; |
- } |
- } |
-} |
- |
-inline void FEGaussianBlur::platformApplyGeneric(Uint8ClampedArray* srcPixelArray, Uint8ClampedArray* tmpPixelArray, unsigned kernelSizeX, unsigned kernelSizeY, IntSize& paintSize) |
-{ |
- int stride = 4 * paintSize.width(); |
- int dxLeft = 0; |
- int dxRight = 0; |
- int dyLeft = 0; |
- int dyRight = 0; |
- Uint8ClampedArray* src = srcPixelArray; |
- Uint8ClampedArray* dst = tmpPixelArray; |
- |
- for (int i = 0; i < 3; ++i) { |
- if (kernelSizeX) { |
- kernelPosition(i, kernelSizeX, dxLeft, dxRight); |
-#if HAVE(ARM_NEON_INTRINSICS) |
- if (!isAlphaImage()) |
- boxBlurNEON(src, dst, kernelSizeX, dxLeft, dxRight, 4, stride, paintSize.width(), paintSize.height()); |
- else |
- boxBlur(src, dst, kernelSizeX, dxLeft, dxRight, 4, stride, paintSize.width(), paintSize.height(), true); |
-#else |
- boxBlur(src, dst, kernelSizeX, dxLeft, dxRight, 4, stride, paintSize.width(), paintSize.height(), isAlphaImage()); |
-#endif |
- swap(src, dst); |
- } |
- |
- if (kernelSizeY) { |
- kernelPosition(i, kernelSizeY, dyLeft, dyRight); |
-#if HAVE(ARM_NEON_INTRINSICS) |
- if (!isAlphaImage()) |
- boxBlurNEON(src, dst, kernelSizeY, dyLeft, dyRight, stride, 4, paintSize.height(), paintSize.width()); |
- else |
- boxBlur(src, dst, kernelSizeY, dyLeft, dyRight, stride, 4, paintSize.height(), paintSize.width(), true); |
-#else |
- boxBlur(src, dst, kernelSizeY, dyLeft, dyRight, stride, 4, paintSize.height(), paintSize.width(), isAlphaImage()); |
-#endif |
- swap(src, dst); |
- } |
- } |
- |
- // The final result should be stored in srcPixelArray. |
- if (dst == srcPixelArray) { |
- ASSERT(src->length() == dst->length()); |
- memcpy(dst->data(), src->data(), src->length()); |
- } |
- |
-} |
- |
-void FEGaussianBlur::platformApplyWorker(PlatformApplyParameters* parameters) |
-{ |
- IntSize paintSize(parameters->width, parameters->height); |
- parameters->filter->platformApplyGeneric(parameters->srcPixelArray.get(), parameters->dstPixelArray.get(), |
- parameters->kernelSizeX, parameters->kernelSizeY, paintSize); |
-} |
- |
-inline void FEGaussianBlur::platformApply(Uint8ClampedArray* srcPixelArray, Uint8ClampedArray* tmpPixelArray, unsigned kernelSizeX, unsigned kernelSizeY, IntSize& paintSize) |
-{ |
- int scanline = 4 * paintSize.width(); |
- int extraHeight = 3 * kernelSizeY * 0.5f; |
- int optimalThreadNumber = (paintSize.width() * paintSize.height()) / (s_minimalRectDimension + extraHeight * paintSize.width()); |
- |
- if (optimalThreadNumber > 1) { |
- ParallelJobs<PlatformApplyParameters> parallelJobs(&platformApplyWorker, optimalThreadNumber); |
- |
- int jobs = parallelJobs.numberOfJobs(); |
- if (jobs > 1) { |
- // Split the job into "blockHeight"-sized jobs but there a few jobs that need to be slightly larger since |
- // blockHeight * jobs < total size. These extras are handled by the remainder "jobsWithExtra". |
- const int blockHeight = paintSize.height() / jobs; |
- const int jobsWithExtra = paintSize.height() % jobs; |
- |
- int currentY = 0; |
- for (int job = 0; job < jobs; job++) { |
- PlatformApplyParameters& params = parallelJobs.parameter(job); |
- params.filter = this; |
- |
- int startY = !job ? 0 : currentY - extraHeight; |
- currentY += job < jobsWithExtra ? blockHeight + 1 : blockHeight; |
- int endY = job == jobs - 1 ? currentY : currentY + extraHeight; |
- |
- int blockSize = (endY - startY) * scanline; |
- if (!job) { |
- params.srcPixelArray = srcPixelArray; |
- params.dstPixelArray = tmpPixelArray; |
- } else { |
- params.srcPixelArray = Uint8ClampedArray::createUninitialized(blockSize); |
- params.dstPixelArray = Uint8ClampedArray::createUninitialized(blockSize); |
- memcpy(params.srcPixelArray->data(), srcPixelArray->data() + startY * scanline, blockSize); |
- } |
- |
- params.width = paintSize.width(); |
- params.height = endY - startY; |
- params.kernelSizeX = kernelSizeX; |
- params.kernelSizeY = kernelSizeY; |
- } |
- |
- parallelJobs.execute(); |
- |
- // Copy together the parts of the image. |
- currentY = 0; |
- for (int job = 1; job < jobs; job++) { |
- PlatformApplyParameters& params = parallelJobs.parameter(job); |
- int sourceOffset; |
- int destinationOffset; |
- int size; |
- int adjustedBlockHeight = job < jobsWithExtra ? blockHeight + 1 : blockHeight; |
- |
- currentY += adjustedBlockHeight; |
- sourceOffset = extraHeight * scanline; |
- destinationOffset = currentY * scanline; |
- size = adjustedBlockHeight * scanline; |
- |
- memcpy(srcPixelArray->data() + destinationOffset, params.srcPixelArray->data() + sourceOffset, size); |
- } |
- return; |
- } |
- // Fallback to single threaded mode. |
- } |
- |
- // The selection here eventually should happen dynamically on some platforms. |
- platformApplyGeneric(srcPixelArray, tmpPixelArray, kernelSizeX, kernelSizeY, paintSize); |
-} |
- |
IntSize FEGaussianBlur::calculateUnscaledKernelSize(const FloatPoint& std) |
{ |
ASSERT(std.x() >= 0 && std.y() >= 0); |
@@ -288,34 +140,9 @@ FloatRect FEGaussianBlur::determineAbsolutePaintRect(const FloatRect& originalRe |
void FEGaussianBlur::applySoftware() |
{ |
- FilterEffect* in = inputEffect(0); |
- |
- Uint8ClampedArray* srcPixelArray = createPremultipliedImageResult(); |
- if (!srcPixelArray) |
- return; |
- |
- setIsAlphaImage(in->isAlphaImage()); |
- |
- IntRect effectDrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect()); |
- in->copyPremultipliedImage(srcPixelArray, effectDrawingRect); |
- |
- if (!m_stdX && !m_stdY) |
- return; |
- |
- IntSize kernelSize = calculateKernelSize(filter(), FloatPoint(m_stdX, m_stdY)); |
- |
- IntSize paintSize = absolutePaintRect().size(); |
- RefPtr<Uint8ClampedArray> tmpImageData = Uint8ClampedArray::createUninitialized(paintSize.width() * paintSize.height() * 4); |
- Uint8ClampedArray* tmpPixelArray = tmpImageData.get(); |
- |
- platformApply(srcPixelArray, tmpPixelArray, kernelSize.width(), kernelSize.height(), paintSize); |
-} |
- |
-bool FEGaussianBlur::applySkia() |
-{ |
ImageBuffer* resultImage = createImageBufferResult(); |
if (!resultImage) |
- return false; |
+ return; |
FilterEffect* in = inputEffect(0); |
@@ -336,7 +163,6 @@ bool FEGaussianBlur::applySkia() |
paint.setColor(0xFFFFFFFF); |
dstContext->drawImage(image.get(), drawingRegion.location(), CompositeCopy); |
dstContext->restoreLayer(); |
- return true; |
} |
PassRefPtr<SkImageFilter> FEGaussianBlur::createImageFilter(SkiaImageFilterBuilder* builder) |