| 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 #include "SkMorphologyImageFilter.h" | 8 #include "SkMorphologyImageFilter.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 static void dilateY(const SkBitmap& src, SkBitmap* dst, int radiusY) | 129 static void dilateY(const SkBitmap& src, SkBitmap* dst, int radiusY) |
| 130 { | 130 { |
| 131 dilate(src.getAddr32(0, 0), dst->getAddr32(0, 0), | 131 dilate(src.getAddr32(0, 0), dst->getAddr32(0, 0), |
| 132 radiusY, src.height(), src.width(), | 132 radiusY, src.height(), src.width(), |
| 133 src.rowBytesAsPixels(), 1, dst->rowBytesAsPixels(), 1); | 133 src.rowBytesAsPixels(), 1, dst->rowBytesAsPixels(), 1); |
| 134 } | 134 } |
| 135 | 135 |
| 136 bool SkErodeImageFilter::onFilterImage(Proxy* proxy, | 136 bool SkErodeImageFilter::onFilterImage(Proxy* proxy, |
| 137 const SkBitmap& source, const SkMatrix& c
tm, | 137 const SkBitmap& source, const SkMatrix& c
tm, |
| 138 SkBitmap* dst, SkIPoint* offset) { | 138 SkBitmap* dst, SkIPoint* offset) { |
| 139 SkBitmap src = this->getInputResult(0, proxy, source, ctm, offset); | 139 SkBitmap src = source; |
| 140 if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctm, &src, offse
t)) { |
| 141 return false; |
| 142 } |
| 143 |
| 140 if (src.config() != SkBitmap::kARGB_8888_Config) { | 144 if (src.config() != SkBitmap::kARGB_8888_Config) { |
| 141 return false; | 145 return false; |
| 142 } | 146 } |
| 143 | 147 |
| 144 SkAutoLockPixels alp(src); | 148 SkAutoLockPixels alp(src); |
| 145 if (!src.getPixels()) { | 149 if (!src.getPixels()) { |
| 146 return false; | 150 return false; |
| 147 } | 151 } |
| 148 | 152 |
| 149 dst->setConfig(src.config(), src.width(), src.height()); | 153 dst->setConfig(src.config(), src.width(), src.height()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 174 erodeX(src, dst, width); | 178 erodeX(src, dst, width); |
| 175 } else if (height > 0) { | 179 } else if (height > 0) { |
| 176 erodeY(src, dst, height); | 180 erodeY(src, dst, height); |
| 177 } | 181 } |
| 178 return true; | 182 return true; |
| 179 } | 183 } |
| 180 | 184 |
| 181 bool SkDilateImageFilter::onFilterImage(Proxy* proxy, | 185 bool SkDilateImageFilter::onFilterImage(Proxy* proxy, |
| 182 const SkBitmap& source, const SkMatrix&
ctm, | 186 const SkBitmap& source, const SkMatrix&
ctm, |
| 183 SkBitmap* dst, SkIPoint* offset) { | 187 SkBitmap* dst, SkIPoint* offset) { |
| 184 SkBitmap src = this->getInputResult(0, proxy, source, ctm, offset); | 188 SkBitmap src = source; |
| 189 if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctm, &src, offse
t)) { |
| 190 return false; |
| 191 } |
| 185 if (src.config() != SkBitmap::kARGB_8888_Config) { | 192 if (src.config() != SkBitmap::kARGB_8888_Config) { |
| 186 return false; | 193 return false; |
| 187 } | 194 } |
| 188 | 195 |
| 189 SkAutoLockPixels alp(src); | 196 SkAutoLockPixels alp(src); |
| 190 if (!src.getPixels()) { | 197 if (!src.getPixels()) { |
| 191 return false; | 198 return false; |
| 192 } | 199 } |
| 193 | 200 |
| 194 dst->setConfig(src.config(), src.width(), src.height()); | 201 dst->setConfig(src.config(), src.width(), src.height()); |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 } | 522 } |
| 516 GrTexture* input = (GrTexture*) inputBM.getTexture(); | 523 GrTexture* input = (GrTexture*) inputBM.getTexture(); |
| 517 SkIRect bounds; | 524 SkIRect bounds; |
| 518 src.getBounds(&bounds); | 525 src.getBounds(&bounds); |
| 519 SkAutoTUnref<GrTexture> resultTex(apply_morphology(input, bounds, | 526 SkAutoTUnref<GrTexture> resultTex(apply_morphology(input, bounds, |
| 520 GrMorphologyEffect::kErode_MorphologyType, radius())); | 527 GrMorphologyEffect::kErode_MorphologyType, radius())); |
| 521 return SkImageFilterUtils::WrapTexture(resultTex, src.width(), src.height(),
result); | 528 return SkImageFilterUtils::WrapTexture(resultTex, src.width(), src.height(),
result); |
| 522 } | 529 } |
| 523 | 530 |
| 524 #endif | 531 #endif |
| OLD | NEW |