bool FEBlend::applySoftwareNEON() { if (m_mode != WebBlendModeNormal && m_mode != WebBlendModeMultiply && m_mode != WebBlendModeScreen && m_mode != WebBlendModeDarken && m_mode != WebBlendModeLighten) return false; Uint8ClampedArray* dstPixelArray = createPremultipliedImageResult(); if (!dstPixelArray) return true; FilterEffect* in = inputEffect(0); FilterEffect* in2 = inputEffect(1); IntRect effectADrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect()); RefPtr<Uint8ClampedArray> srcPixelArrayA = in->asPremultipliedImage(effectADrawingRect); IntRect effectBDrawingRect = requestedRegionOfInputImageData(in2->absolutePaintRect()); RefPtr<Uint8ClampedArray> srcPixelArrayB = in2->asPremultipliedImage(effectBDrawingRect); unsigned pixelArrayLength = srcPixelArrayA->length(); ASSERT(pixelArrayLength == srcPixelArrayB->length()); if (pixelArrayLength >= 8) { platformApplyNEON(srcPixelArrayA->data(), srcPixelArrayB->data(), dstPixelArray->data(), pixelArrayLength); } else { // If there is just one pixel we expand it to two. ASSERT(pixelArrayLength > 0); uint32_t sourceA[2] = {0, 0}; uint32_t sourceBAndDest[2] = {0, 0}; sourceA[0] = reinterpret_cast<uint32_t*>(srcPixelArrayA->data())[0]; sourceBAndDest[0] = reinterpret_cast<uint32_t*>(srcPixelArrayB->data())[0]; platformApplyNEON(reinterpret_cast<uint8_t*>(sourceA), reinterpret_cast<uint8_t*>(sourceBAndDest), reinterpret_cast<uint8_t*>(sourceBAndDest), 8); reinterpret_cast<uint32_t*>(dstPixelArray->data())[0] = sourceBAndDest[0]; } return true; }
void FEBlend::platformApplySoftware() { FilterEffect* in = inputEffect(0); FilterEffect* in2 = inputEffect(1); ASSERT(m_mode > FEBLEND_MODE_UNKNOWN); ASSERT(m_mode <= FEBLEND_MODE_LIGHTEN); Uint8ClampedArray* dstPixelArray = createPremultipliedImageResult(); if (!dstPixelArray) return; IntRect effectADrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect()); RefPtr<Uint8ClampedArray> srcPixelArrayA = in->asPremultipliedImage(effectADrawingRect); IntRect effectBDrawingRect = requestedRegionOfInputImageData(in2->absolutePaintRect()); RefPtr<Uint8ClampedArray> srcPixelArrayB = in2->asPremultipliedImage(effectBDrawingRect); unsigned pixelArrayLength = srcPixelArrayA->length(); ASSERT(pixelArrayLength == srcPixelArrayB->length()); #if HAVE(ARM_NEON_INTRINSICS) if (pixelArrayLength >= 8) platformApplyNEON(srcPixelArrayA->data(), srcPixelArrayB->data(), dstPixelArray->data(), pixelArrayLength); else { // If there is just one pixel we expand it to two. ASSERT(pixelArrayLength > 0); uint32_t sourceA[2] = {0, 0}; uint32_t sourceBAndDest[2] = {0, 0}; sourceA[0] = reinterpret_cast<uint32_t*>(srcPixelArrayA->data())[0]; sourceBAndDest[0] = reinterpret_cast<uint32_t*>(srcPixelArrayB->data())[0]; platformApplyNEON(reinterpret_cast<uint8_t*>(sourceA), reinterpret_cast<uint8_t*>(sourceBAndDest), reinterpret_cast<uint8_t*>(sourceBAndDest), 8); reinterpret_cast<uint32_t*>(dstPixelArray->data())[0] = sourceBAndDest[0]; } #else platformApplyGeneric(srcPixelArrayA->data(), srcPixelArrayB->data(), dstPixelArray->data(), pixelArrayLength); #endif }