1 /* 2 * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann (at) kde.org> 3 * Copyright (C) 2004, 2005 Rob Buis <buis (at) kde.org> 4 * Copyright (C) 2005 Eric Seidel <eric (at) webkit.org> 5 * Copyright (C) 2013 Google Inc. All rights reserved. 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Library General Public 9 * License as published by the Free Software Foundation; either 10 * version 2 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Library General Public License for more details. 16 * 17 * You should have received a copy of the GNU Library General Public License 18 * along with this library; see the file COPYING.LIB. If not, write to 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 * Boston, MA 02110-1301, USA. 21 */ 22 23 #ifndef FEMorphology_h 24 #define FEMorphology_h 25 26 #include "core/platform/graphics/filters/Filter.h" 27 #include "core/platform/graphics/filters/FilterEffect.h" 28 29 namespace WebCore { 30 31 enum MorphologyOperatorType { 32 FEMORPHOLOGY_OPERATOR_UNKNOWN = 0, 33 FEMORPHOLOGY_OPERATOR_ERODE = 1, 34 FEMORPHOLOGY_OPERATOR_DILATE = 2 35 }; 36 37 class FEMorphology : public FilterEffect { 38 public: 39 static PassRefPtr<FEMorphology> create(Filter*, MorphologyOperatorType, float radiusX, float radiusY); 40 MorphologyOperatorType morphologyOperator() const; 41 bool setMorphologyOperator(MorphologyOperatorType); 42 43 float radiusX() const; 44 bool setRadiusX(float); 45 46 float radiusY() const; 47 bool setRadiusY(float); 48 49 virtual PassRefPtr<SkImageFilter> createImageFilter(SkiaImageFilterBuilder*) OVERRIDE; 50 51 virtual void determineAbsolutePaintRect(); 52 virtual FloatRect mapRect(const FloatRect&, bool forward = true) OVERRIDE FINAL; 53 54 virtual TextStream& externalRepresentation(TextStream&, int indention) const; 55 56 struct PaintingData { 57 Uint8ClampedArray* srcPixelArray; 58 Uint8ClampedArray* dstPixelArray; 59 int width; 60 int height; 61 int radiusX; 62 int radiusY; 63 }; 64 65 static const int s_minimalArea = (300 * 300); // Empirical data limit for parallel jobs 66 67 struct PlatformApplyParameters { 68 FEMorphology* filter; 69 int startY; 70 int endY; 71 PaintingData* paintingData; 72 }; 73 74 static void platformApplyWorker(PlatformApplyParameters*); 75 76 inline void platformApply(PaintingData*); 77 inline void platformApplyGeneric(PaintingData*, const int yStart, const int yEnd); 78 private: 79 FEMorphology(Filter*, MorphologyOperatorType, float radiusX, float radiusY); 80 81 virtual void applySoftware() OVERRIDE; 82 virtual bool applySkia() OVERRIDE; 83 84 MorphologyOperatorType m_type; 85 float m_radiusX; 86 float m_radiusY; 87 }; 88 89 } // namespace WebCore 90 91 #endif // FEMorphology_h 92