inline void FELighting::platformApply(LightingData& data, LightSource::PaintingData& paintingData) { // The selection here eventually should happen dynamically on some platforms. #if CPU(ARM_NEON) && CPU(ARM_TRADITIONAL) && COMPILER(GCC) platformApplyNeon(data, paintingData); #else platformApplyGeneric(data, paintingData); #endif }
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) { WTF::ParallelJobs<PlatformApplyParameters> parallelJobs(&platformApplyWorker, optimalThreadNumber); int jobs = parallelJobs.numberOfJobs(); if (jobs > 1) { int blockHeight = paintSize.height() / jobs; --jobs; for (int job = jobs; job >= 0; --job) { PlatformApplyParameters& params = parallelJobs.parameter(job); params.filter = this; int startY; int endY; if (!job) { startY = 0; endY = blockHeight + extraHeight; params.srcPixelArray = srcPixelArray; params.dstPixelArray = tmpPixelArray; } else { if (job == jobs) { startY = job * blockHeight - extraHeight; endY = paintSize.height(); } else { startY = job * blockHeight - extraHeight; endY = (job + 1) * blockHeight + extraHeight; } int blockSize = (endY - startY) * scanline; 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. for (int job = jobs; job >= 1; --job) { PlatformApplyParameters& params = parallelJobs.parameter(job); int sourceOffset; int destinationOffset; int size; if (job == jobs) { sourceOffset = extraHeight * scanline; destinationOffset = job * blockHeight * scanline; size = (paintSize.height() - job * blockHeight) * scanline; } else { sourceOffset = extraHeight * scanline; destinationOffset = job * blockHeight * scanline; size = blockHeight * 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. #if CPU(ARM_NEON) && COMPILER(GCC) platformApplyNeon(srcPixelArray, tmpPixelArray, kernelSizeX, kernelSizeY, paintSize); #else platformApplyGeneric(srcPixelArray, tmpPixelArray, kernelSizeX, kernelSizeY, paintSize); #endif }