| 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 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 typedef void (*Proc)(const SkPMColor* src, SkPMColor* dst, int radius, | 28 typedef void (*Proc)(const SkPMColor* src, SkPMColor* dst, int radius, |
| 29 int width, int height, int srcStride, int dstStride); | 29 int width, int height, int srcStride, int dstStride); |
| 30 | 30 |
| 31 protected: | 31 protected: |
| 32 SkMorphologyImageFilter(int radiusX, int radiusY, SkImageFilter* input, | 32 SkMorphologyImageFilter(int radiusX, int radiusY, SkImageFilter* input, |
| 33 const CropRect* cropRect); | 33 const CropRect* cropRect); |
| 34 bool filterImageGeneric(Proc procX, Proc procY, | 34 bool filterImageGeneric(Proc procX, Proc procY, |
| 35 Proxy*, const SkBitmap& src, const Context&, | 35 Proxy*, const SkBitmap& src, const Context&, |
| 36 SkBitmap* result, SkIPoint* offset) const; | 36 SkBitmap* result, SkIPoint* offset) const; |
| 37 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
| 37 SkMorphologyImageFilter(SkReadBuffer& buffer); | 38 SkMorphologyImageFilter(SkReadBuffer& buffer); |
| 39 #endif |
| 38 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 40 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
| 39 #if SK_SUPPORT_GPU | 41 #if SK_SUPPORT_GPU |
| 40 virtual bool canFilterImageGPU() const SK_OVERRIDE { return true; } | 42 virtual bool canFilterImageGPU() const SK_OVERRIDE { return true; } |
| 41 bool filterImageGPUGeneric(bool dilate, Proxy* proxy, const SkBitmap& src, | 43 bool filterImageGPUGeneric(bool dilate, Proxy* proxy, const SkBitmap& src, |
| 42 const Context& ctm, SkBitmap* result, | 44 const Context& ctm, SkBitmap* result, |
| 43 SkIPoint* offset) const; | 45 SkIPoint* offset) const; |
| 44 #endif | 46 #endif |
| 45 | 47 |
| 46 SkISize radius() const { return fRadius; } | 48 SkISize radius() const { return fRadius; } |
| 47 | 49 |
| 48 private: | 50 private: |
| 49 SkISize fRadius; | 51 SkISize fRadius; |
| 50 typedef SkImageFilter INHERITED; | 52 typedef SkImageFilter INHERITED; |
| 51 }; | 53 }; |
| 52 | 54 |
| 53 class SK_API SkDilateImageFilter : public SkMorphologyImageFilter { | 55 class SK_API SkDilateImageFilter : public SkMorphologyImageFilter { |
| 54 public: | 56 public: |
| 55 static SkDilateImageFilter* Create(int radiusX, int radiusY, | 57 static SkDilateImageFilter* Create(int radiusX, int radiusY, |
| 56 SkImageFilter* input = NULL, | 58 SkImageFilter* input = NULL, |
| 57 const CropRect* cropRect = NULL) { | 59 const CropRect* cropRect = NULL) { |
| 60 if (radiusX < 0 || radiusY < 0) { |
| 61 return NULL; |
| 62 } |
| 58 return SkNEW_ARGS(SkDilateImageFilter, (radiusX, radiusY, input, cropRec
t)); | 63 return SkNEW_ARGS(SkDilateImageFilter, (radiusX, radiusY, input, cropRec
t)); |
| 59 } | 64 } |
| 60 | 65 |
| 61 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, | 66 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, |
| 62 SkBitmap* result, SkIPoint* offset) const SK_OVER
RIDE; | 67 SkBitmap* result, SkIPoint* offset) const SK_OVER
RIDE; |
| 63 #if SK_SUPPORT_GPU | 68 #if SK_SUPPORT_GPU |
| 64 virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context
&, | 69 virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context
&, |
| 65 SkBitmap* result, SkIPoint* offset) const SK_OVE
RRIDE; | 70 SkBitmap* result, SkIPoint* offset) const SK_OVE
RRIDE; |
| 66 #endif | 71 #endif |
| 67 | 72 |
| 68 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDilateImageFilter) | 73 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDilateImageFilter) |
| 69 | 74 |
| 70 protected: | 75 protected: |
| 71 SkDilateImageFilter(int radiusX, int radiusY, SkImageFilter* input, const Cr
opRect* cropRect) | 76 SkDilateImageFilter(int radiusX, int radiusY, SkImageFilter* input, const Cr
opRect* cropRect) |
| 72 : INHERITED(radiusX, radiusY, input, cropRect) {} | 77 : INHERITED(radiusX, radiusY, input, cropRect) {} |
| 78 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
| 73 explicit SkDilateImageFilter(SkReadBuffer& buffer) : INHERITED(buffer) {} | 79 explicit SkDilateImageFilter(SkReadBuffer& buffer) : INHERITED(buffer) {} |
| 80 #endif |
| 74 | 81 |
| 75 private: | 82 private: |
| 76 typedef SkMorphologyImageFilter INHERITED; | 83 typedef SkMorphologyImageFilter INHERITED; |
| 77 }; | 84 }; |
| 78 | 85 |
| 79 class SK_API SkErodeImageFilter : public SkMorphologyImageFilter { | 86 class SK_API SkErodeImageFilter : public SkMorphologyImageFilter { |
| 80 public: | 87 public: |
| 81 static SkErodeImageFilter* Create(int radiusX, int radiusY, | 88 static SkErodeImageFilter* Create(int radiusX, int radiusY, |
| 82 SkImageFilter* input = NULL, | 89 SkImageFilter* input = NULL, |
| 83 const CropRect* cropRect = NULL) { | 90 const CropRect* cropRect = NULL) { |
| 91 if (radiusX < 0 || radiusY < 0) { |
| 92 return NULL; |
| 93 } |
| 84 return SkNEW_ARGS(SkErodeImageFilter, (radiusX, radiusY, input, cropRect
)); | 94 return SkNEW_ARGS(SkErodeImageFilter, (radiusX, radiusY, input, cropRect
)); |
| 85 } | 95 } |
| 86 | 96 |
| 87 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, | 97 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, |
| 88 SkBitmap* result, SkIPoint* offset) const SK_OVER
RIDE; | 98 SkBitmap* result, SkIPoint* offset) const SK_OVER
RIDE; |
| 89 #if SK_SUPPORT_GPU | 99 #if SK_SUPPORT_GPU |
| 90 virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context
&, | 100 virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context
&, |
| 91 SkBitmap* result, SkIPoint* offset) const SK_OVE
RRIDE; | 101 SkBitmap* result, SkIPoint* offset) const SK_OVE
RRIDE; |
| 92 #endif | 102 #endif |
| 93 | 103 |
| 94 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkErodeImageFilter) | 104 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkErodeImageFilter) |
| 95 | 105 |
| 96 protected: | 106 protected: |
| 97 SkErodeImageFilter(int radiusX, int radiusY, SkImageFilter* input, const Cro
pRect* cropRect) | 107 SkErodeImageFilter(int radiusX, int radiusY, SkImageFilter* input, const Cro
pRect* cropRect) |
| 98 : INHERITED(radiusX, radiusY, input, cropRect) {} | 108 : INHERITED(radiusX, radiusY, input, cropRect) {} |
| 109 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
| 99 explicit SkErodeImageFilter(SkReadBuffer& buffer) : INHERITED(buffer) {} | 110 explicit SkErodeImageFilter(SkReadBuffer& buffer) : INHERITED(buffer) {} |
| 111 #endif |
| 100 | 112 |
| 101 private: | 113 private: |
| 102 typedef SkMorphologyImageFilter INHERITED; | 114 typedef SkMorphologyImageFilter INHERITED; |
| 103 }; | 115 }; |
| 104 | 116 |
| 105 #endif | 117 #endif |
| OLD | NEW |