| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 The Android Open Source Project | 2 * Copyright 2012 The Android Open Source Project |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 | 8 |
| 9 #ifndef SkMorphologyImageFilter_DEFINED | 9 #ifndef SkMorphologyImageFilter_DEFINED |
| 10 #define SkMorphologyImageFilter_DEFINED | 10 #define SkMorphologyImageFilter_DEFINED |
| 11 | 11 |
| 12 #include "SkColor.h" | 12 #include "SkColor.h" |
| 13 #include "SkImageFilter.h" | 13 #include "SkImageFilter.h" |
| 14 #include "SkSize.h" | 14 #include "SkSize.h" |
| 15 | 15 |
| 16 class SK_API SkMorphologyImageFilter : public SkImageFilter { | 16 class SK_API SkMorphologyImageFilter : public SkImageFilter { |
| 17 public: | 17 public: |
| 18 SkMorphologyImageFilter(int radiusX, int radiusY, SkImageFilter* input, cons
t CropRect* cropRect); | |
| 19 virtual void computeFastBounds(const SkRect& src, SkRect* dst) const SK_OVER
RIDE; | 18 virtual void computeFastBounds(const SkRect& src, SkRect* dst) const SK_OVER
RIDE; |
| 20 virtual bool onFilterBounds(const SkIRect& src, const SkMatrix& ctm, SkIRect
* dst) const SK_OVERRIDE; | 19 virtual bool onFilterBounds(const SkIRect& src, const SkMatrix& ctm, SkIRect
* dst) const SK_OVERRIDE; |
| 21 | 20 |
| 22 /** | 21 /** |
| 23 * All morphology procs have the same signature: src is the source buffer, d
st the | 22 * All morphology procs have the same signature: src is the source buffer, d
st the |
| 24 * destination buffer, radius is the morphology radius, width and height are
the bounds | 23 * destination buffer, radius is the morphology radius, width and height are
the bounds |
| 25 * of the destination buffer (in pixels), and srcStride and dstStride are th
e | 24 * of the destination buffer (in pixels), and srcStride and dstStride are th
e |
| 26 * number of pixels per row in each buffer. All buffers are 8888. | 25 * number of pixels per row in each buffer. All buffers are 8888. |
| 27 */ | 26 */ |
| 28 | 27 |
| 29 typedef void (*Proc)(const SkPMColor* src, SkPMColor* dst, int radius, | 28 typedef void (*Proc)(const SkPMColor* src, SkPMColor* dst, int radius, |
| 30 int width, int height, int srcStride, int dstStride); | 29 int width, int height, int srcStride, int dstStride); |
| 31 | 30 |
| 32 protected: | 31 protected: |
| 32 SkMorphologyImageFilter(int radiusX, int radiusY, SkImageFilter* input, |
| 33 const CropRect* cropRect); |
| 33 bool filterImageGeneric(Proc procX, Proc procY, | 34 bool filterImageGeneric(Proc procX, Proc procY, |
| 34 Proxy*, const SkBitmap& src, const SkMatrix&, | 35 Proxy*, const SkBitmap& src, const SkMatrix&, |
| 35 SkBitmap* result, SkIPoint* offset) const; | 36 SkBitmap* result, SkIPoint* offset) const; |
| 36 SkMorphologyImageFilter(SkReadBuffer& buffer); | 37 SkMorphologyImageFilter(SkReadBuffer& buffer); |
| 37 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 38 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
| 38 #if SK_SUPPORT_GPU | 39 #if SK_SUPPORT_GPU |
| 39 virtual bool canFilterImageGPU() const SK_OVERRIDE { return true; } | 40 virtual bool canFilterImageGPU() const SK_OVERRIDE { return true; } |
| 40 bool filterImageGPUGeneric(bool dilate, Proxy* proxy, const SkBitmap& src, | 41 bool filterImageGPUGeneric(bool dilate, Proxy* proxy, const SkBitmap& src, |
| 41 const SkMatrix& ctm, SkBitmap* result, | 42 const SkMatrix& ctm, SkBitmap* result, |
| 42 SkIPoint* offset) const; | 43 SkIPoint* offset) const; |
| 43 #endif | 44 #endif |
| 44 | 45 |
| 45 SkISize radius() const { return fRadius; } | 46 SkISize radius() const { return fRadius; } |
| 46 | 47 |
| 47 private: | 48 private: |
| 48 SkISize fRadius; | 49 SkISize fRadius; |
| 49 typedef SkImageFilter INHERITED; | 50 typedef SkImageFilter INHERITED; |
| 50 }; | 51 }; |
| 51 | 52 |
| 52 class SK_API SkDilateImageFilter : public SkMorphologyImageFilter { | 53 class SK_API SkDilateImageFilter : public SkMorphologyImageFilter { |
| 53 public: | 54 public: |
| 54 SkDilateImageFilter(int radiusX, int radiusY, | 55 static SkDilateImageFilter* Create(int radiusX, int radiusY, |
| 55 SkImageFilter* input = NULL, | 56 SkImageFilter* input = NULL, |
| 56 const CropRect* cropRect = NULL) | 57 const CropRect* cropRect = NULL) { |
| 57 : INHERITED(radiusX, radiusY, input, cropRect) {} | 58 return SkNEW_ARGS(SkDilateImageFilter, (radiusX, radiusY, input, cropRec
t)); |
| 59 } |
| 58 | 60 |
| 59 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, | 61 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, |
| 60 SkBitmap* result, SkIPoint* offset) const SK_OVER
RIDE; | 62 SkBitmap* result, SkIPoint* offset) const SK_OVER
RIDE; |
| 61 #if SK_SUPPORT_GPU | 63 #if SK_SUPPORT_GPU |
| 62 virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatri
x& ctm, | 64 virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatri
x& ctm, |
| 63 SkBitmap* result, SkIPoint* offset) const SK_OVE
RRIDE; | 65 SkBitmap* result, SkIPoint* offset) const SK_OVE
RRIDE; |
| 64 #endif | 66 #endif |
| 65 | 67 |
| 66 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDilateImageFilter) | 68 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDilateImageFilter) |
| 67 | 69 |
| 68 protected: | 70 protected: |
| 69 SkDilateImageFilter(SkReadBuffer& buffer) : INHERITED(buffer) {} | 71 SkDilateImageFilter(SkReadBuffer& buffer) : INHERITED(buffer) {} |
| 70 | 72 |
| 73 #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS |
| 74 public: |
| 75 #endif |
| 76 SkDilateImageFilter(int radiusX, int radiusY, |
| 77 SkImageFilter* input = NULL, |
| 78 const CropRect* cropRect = NULL) |
| 79 : INHERITED(radiusX, radiusY, input, cropRect) {} |
| 80 |
| 71 private: | 81 private: |
| 72 typedef SkMorphologyImageFilter INHERITED; | 82 typedef SkMorphologyImageFilter INHERITED; |
| 73 }; | 83 }; |
| 74 | 84 |
| 75 class SK_API SkErodeImageFilter : public SkMorphologyImageFilter { | 85 class SK_API SkErodeImageFilter : public SkMorphologyImageFilter { |
| 76 public: | 86 public: |
| 77 SkErodeImageFilter(int radiusX, int radiusY, | 87 static SkErodeImageFilter* Create(int radiusX, int radiusY, |
| 78 SkImageFilter* input = NULL, | 88 SkImageFilter* input = NULL, |
| 79 const CropRect* cropRect = NULL) | 89 const CropRect* cropRect = NULL) { |
| 80 : INHERITED(radiusX, radiusY, input, cropRect) {} | 90 return SkNEW_ARGS(SkErodeImageFilter, (radiusX, radiusY, input, cropRect
)); |
| 91 } |
| 81 | 92 |
| 82 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, | 93 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, |
| 83 SkBitmap* result, SkIPoint* offset) const SK_OVER
RIDE; | 94 SkBitmap* result, SkIPoint* offset) const SK_OVER
RIDE; |
| 84 #if SK_SUPPORT_GPU | 95 #if SK_SUPPORT_GPU |
| 85 virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatri
x& ctm, | 96 virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatri
x& ctm, |
| 86 SkBitmap* result, SkIPoint* offset) const SK_OVE
RRIDE; | 97 SkBitmap* result, SkIPoint* offset) const SK_OVE
RRIDE; |
| 87 #endif | 98 #endif |
| 88 | 99 |
| 89 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkErodeImageFilter) | 100 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkErodeImageFilter) |
| 90 | 101 |
| 91 protected: | 102 protected: |
| 92 SkErodeImageFilter(SkReadBuffer& buffer) : INHERITED(buffer) {} | 103 SkErodeImageFilter(SkReadBuffer& buffer) : INHERITED(buffer) {} |
| 93 | 104 |
| 105 #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS |
| 106 public: |
| 107 #endif |
| 108 SkErodeImageFilter(int radiusX, int radiusY, |
| 109 SkImageFilter* input = NULL, |
| 110 const CropRect* cropRect = NULL) |
| 111 : INHERITED(radiusX, radiusY, input, cropRect) {} |
| 112 |
| 94 private: | 113 private: |
| 95 typedef SkMorphologyImageFilter INHERITED; | 114 typedef SkMorphologyImageFilter INHERITED; |
| 96 }; | 115 }; |
| 97 | 116 |
| 98 #endif | 117 #endif |
| OLD | NEW |