Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1573)

Unified Diff: Source/platform/graphics/filters/FEBlend.cpp

Issue 604373003: [WIP] Supporting arm_neon_optional flag for blink platform. Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/graphics/filters/FEBlend.h ('k') | Source/platform/graphics/filters/FEComposite.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/graphics/filters/FEBlend.cpp
diff --git a/Source/platform/graphics/filters/FEBlend.cpp b/Source/platform/graphics/filters/FEBlend.cpp
index 0761253a296ec3a5febb077b62d0cccfeb879dc6..afcc643d8e64ebe945e8aa60a5f381625d9c562b 100644
--- a/Source/platform/graphics/filters/FEBlend.cpp
+++ b/Source/platform/graphics/filters/FEBlend.cpp
@@ -28,7 +28,9 @@
#include "SkBitmapSource.h"
#include "SkXfermodeImageFilter.h"
#include "platform/graphics/GraphicsContext.h"
+#if HAVE(ARM_NEON_INTRINSICS)
#include "platform/graphics/cpu/arm/filters/FEBlendNEON.h"
+#endif
#include "platform/graphics/filters/SkiaImageFilterBuilder.h"
#include "platform/graphics/skia/NativeImageSkia.h"
#include "platform/graphics/skia/SkiaUtils.h"
@@ -63,62 +65,16 @@ bool FEBlend::setBlendMode(WebBlendMode mode)
return true;
}
-#if HAVE(ARM_NEON_INTRINSICS)
-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;
-}
-#endif
-
-void FEBlend::applySoftware()
+void FEBlend::applySoftwareInternal()
{
-#if HAVE(ARM_NEON_INTRINSICS)
- if (applySoftwareNEON())
+ ImageBuffer* resultImage = createImageBufferResult();
+ if (!resultImage)
return;
-#endif
FilterEffect* in = inputEffect(0);
FilterEffect* in2 = inputEffect(1);
- ImageBuffer* resultImage = createImageBufferResult();
- if (!resultImage)
- return;
GraphicsContext* filterContext = resultImage->context();
ImageBuffer* imageBuffer = in->asImageBuffer();
@@ -130,6 +86,11 @@ void FEBlend::applySoftware()
filterContext->drawImageBuffer(imageBuffer, drawingRegionOfInputImage(in->absolutePaintRect()), 0, CompositeSourceOver, m_mode);
}
+void FEBlend::applySoftware()
+{
+ WTF_CPU_ARM_NEON_WRAP(applySoftwareInternal)();
+}
+
PassRefPtr<SkImageFilter> FEBlend::createImageFilter(SkiaImageFilterBuilder* builder)
{
RefPtr<SkImageFilter> foreground(builder->build(inputEffect(0), operatingColorSpace()));
« no previous file with comments | « Source/platform/graphics/filters/FEBlend.h ('k') | Source/platform/graphics/filters/FEComposite.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698