| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com> | 2 * Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com> |
| 3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
| 4 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 4 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 5 * Copyright (C) 2012 University of Szeged | 5 * Copyright (C) 2012 University of Szeged |
| 6 * Copyright (C) 2013 Google Inc. All rights reserved. | 6 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| 11 * version 2 of the License, or (at your option) any later version. | 11 * version 2 of the License, or (at your option) any later version. |
| 12 * | 12 * |
| 13 * This library is distributed in the hope that it will be useful, | 13 * This library is distributed in the hope that it will be useful, |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 * Library General Public License for more details. | 16 * Library General Public License for more details. |
| 17 * | 17 * |
| 18 * You should have received a copy of the GNU Library General Public License | 18 * You should have received a copy of the GNU Library General Public License |
| 19 * along with this library; see the file COPYING.LIB. If not, write to | 19 * along with this library; see the file COPYING.LIB. If not, write to |
| 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 21 * Boston, MA 02110-1301, USA. | 21 * Boston, MA 02110-1301, USA. |
| 22 */ | 22 */ |
| 23 | 23 |
| 24 #include "config.h" | 24 #include "config.h" |
| 25 | 25 |
| 26 #include "platform/graphics/filters/FilterEffect.h" | 26 #include "platform/graphics/filters/FilterEffect.h" |
| 27 | 27 |
| 28 #if HAVE(ARM_NEON_INTRINSICS) |
| 29 #include "platform/graphics/cpu/arm/filters/FilterEffectNEON.h" |
| 30 #endif |
| 28 #include "platform/graphics/ImageBuffer.h" | 31 #include "platform/graphics/ImageBuffer.h" |
| 29 #include "platform/graphics/UnacceleratedImageBufferSurface.h" | 32 #include "platform/graphics/UnacceleratedImageBufferSurface.h" |
| 30 #include "platform/graphics/filters/Filter.h" | 33 #include "platform/graphics/filters/Filter.h" |
| 31 | 34 |
| 32 #if HAVE(ARM_NEON_INTRINSICS) | |
| 33 #include <arm_neon.h> | |
| 34 #endif | |
| 35 | |
| 36 namespace blink { | 35 namespace blink { |
| 37 | 36 |
| 38 static const float kMaxFilterArea = 4096 * 4096; | 37 static const float kMaxFilterArea = 4096 * 4096; |
| 39 | 38 |
| 40 FilterEffect::FilterEffect(Filter* filter) | 39 FilterEffect::FilterEffect(Filter* filter) |
| 41 : m_alphaImage(false) | 40 : m_alphaImage(false) |
| 42 , m_filter(filter) | 41 , m_filter(filter) |
| 43 , m_hasX(false) | 42 , m_hasX(false) |
| 44 , m_hasY(false) | 43 , m_hasY(false) |
| 45 , m_hasWidth(false) | 44 , m_hasWidth(false) |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 return; | 212 return; |
| 214 | 213 |
| 215 Uint8ClampedArray* imageArray = m_premultipliedImageResult.get(); | 214 Uint8ClampedArray* imageArray = m_premultipliedImageResult.get(); |
| 216 unsigned char* pixelData = imageArray->data(); | 215 unsigned char* pixelData = imageArray->data(); |
| 217 int pixelArrayLength = imageArray->length(); | 216 int pixelArrayLength = imageArray->length(); |
| 218 | 217 |
| 219 // We must have four bytes per pixel, and complete pixels | 218 // We must have four bytes per pixel, and complete pixels |
| 220 ASSERT(!(pixelArrayLength % 4)); | 219 ASSERT(!(pixelArrayLength % 4)); |
| 221 | 220 |
| 222 #if HAVE(ARM_NEON_INTRINSICS) | 221 #if HAVE(ARM_NEON_INTRINSICS) |
| 223 if (pixelArrayLength >= 64) { | 222 if (hasCPUNEON()) |
| 224 unsigned char* lastPixel = pixelData + (pixelArrayLength & ~0x3f); | 223 pixelArrayLength = validPreMultipliedPixels64NEON(imageArray->length(),
pixelData); |
| 225 do { | |
| 226 // Increments pixelData by 64. | |
| 227 uint8x16x4_t sixteenPixels = vld4q_u8(pixelData); | |
| 228 sixteenPixels.val[0] = vminq_u8(sixteenPixels.val[0], sixteenPixels.
val[3]); | |
| 229 sixteenPixels.val[1] = vminq_u8(sixteenPixels.val[1], sixteenPixels.
val[3]); | |
| 230 sixteenPixels.val[2] = vminq_u8(sixteenPixels.val[2], sixteenPixels.
val[3]); | |
| 231 vst4q_u8(pixelData, sixteenPixels); | |
| 232 pixelData += 64; | |
| 233 } while (pixelData < lastPixel); | |
| 234 | |
| 235 pixelArrayLength &= 0x3f; | |
| 236 if (!pixelArrayLength) | |
| 237 return; | |
| 238 } | |
| 239 #endif | 224 #endif |
| 240 | 225 |
| 241 int numPixels = pixelArrayLength / 4; | 226 int numPixels = pixelArrayLength / 4; |
| 242 | 227 |
| 243 // Iterate over each pixel, checking alpha and adjusting color components if
necessary | 228 // Iterate over each pixel, checking alpha and adjusting color components if
necessary |
| 244 while (--numPixels >= 0) { | 229 while (--numPixels >= 0) { |
| 245 // Alpha is the 4th byte in a pixel | 230 // Alpha is the 4th byte in a pixel |
| 246 unsigned char a = *(pixelData + 3); | 231 unsigned char a = *(pixelData + 3); |
| 247 // Clamp each component to alpha, and increment the pixel location | 232 // Clamp each component to alpha, and increment the pixel location |
| 248 for (int i = 0; i < 3; ++i) { | 233 for (int i = 0; i < 3; ++i) { |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 return m_imageFilters[index].get(); | 577 return m_imageFilters[index].get(); |
| 593 } | 578 } |
| 594 | 579 |
| 595 void FilterEffect::setImageFilter(ColorSpace colorSpace, bool requiresPMColorVal
idation, PassRefPtr<SkImageFilter> imageFilter) | 580 void FilterEffect::setImageFilter(ColorSpace colorSpace, bool requiresPMColorVal
idation, PassRefPtr<SkImageFilter> imageFilter) |
| 596 { | 581 { |
| 597 int index = getImageFilterIndex(colorSpace, requiresPMColorValidation); | 582 int index = getImageFilterIndex(colorSpace, requiresPMColorValidation); |
| 598 m_imageFilters[index] = imageFilter; | 583 m_imageFilters[index] = imageFilter; |
| 599 } | 584 } |
| 600 | 585 |
| 601 } // namespace blink | 586 } // namespace blink |
| OLD | NEW |