| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 SkIPoint srcOffset = SkIPoint::Make(0, 0); | 63 SkIPoint srcOffset = SkIPoint::Make(0, 0); |
| 64 if (!this->filterInput(0, proxy, source, ctx, &src, &srcOffset)) { | 64 if (!this->filterInput(0, proxy, source, ctx, &src, &srcOffset)) { |
| 65 return false; | 65 return false; |
| 66 } | 66 } |
| 67 | 67 |
| 68 if (src.colorType() != kN32_SkColorType) { | 68 if (src.colorType() != kN32_SkColorType) { |
| 69 return false; | 69 return false; |
| 70 } | 70 } |
| 71 | 71 |
| 72 SkIRect bounds; | 72 SkIRect bounds; |
| 73 if (!this->applyCropRect(ctx, proxy, src, &srcOffset, &bounds, &src)) { | 73 if (!this->applyCropRect(this->mapContext(ctx), proxy, src, &srcOffset, &bou
nds, &src)) { |
| 74 return false; | 74 return false; |
| 75 } | 75 } |
| 76 | 76 |
| 77 SkAutoLockPixels alp(src); | 77 SkAutoLockPixels alp(src); |
| 78 if (!src.getPixels()) { | 78 if (!src.getPixels()) { |
| 79 return false; | 79 return false; |
| 80 } | 80 } |
| 81 | 81 |
| 82 SkVector radius = SkVector::Make(SkIntToScalar(this->radius().width()), | 82 SkVector radius = SkVector::Make(SkIntToScalar(this->radius().width()), |
| 83 SkIntToScalar(this->radius().height())); | 83 SkIntToScalar(this->radius().height())); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 142 |
| 143 void SkMorphologyImageFilter::computeFastBounds(const SkRect& src, SkRect* dst)
const { | 143 void SkMorphologyImageFilter::computeFastBounds(const SkRect& src, SkRect* dst)
const { |
| 144 if (this->getInput(0)) { | 144 if (this->getInput(0)) { |
| 145 this->getInput(0)->computeFastBounds(src, dst); | 145 this->getInput(0)->computeFastBounds(src, dst); |
| 146 } else { | 146 } else { |
| 147 *dst = src; | 147 *dst = src; |
| 148 } | 148 } |
| 149 dst->outset(SkIntToScalar(fRadius.width()), SkIntToScalar(fRadius.height()))
; | 149 dst->outset(SkIntToScalar(fRadius.width()), SkIntToScalar(fRadius.height()))
; |
| 150 } | 150 } |
| 151 | 151 |
| 152 bool SkMorphologyImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix&
ctm, | 152 void SkMorphologyImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMat
rix& ctm, |
| 153 SkIRect* dst) const { | 153 SkIRect* dst, MapDirection) con
st { |
| 154 SkIRect bounds = src; | 154 *dst = src; |
| 155 SkVector radius = SkVector::Make(SkIntToScalar(this->radius().width()), | 155 SkVector radius = SkVector::Make(SkIntToScalar(this->radius().width()), |
| 156 SkIntToScalar(this->radius().height())); | 156 SkIntToScalar(this->radius().height())); |
| 157 ctm.mapVectors(&radius, 1); | 157 ctm.mapVectors(&radius, 1); |
| 158 bounds.outset(SkScalarCeilToInt(radius.x()), SkScalarCeilToInt(radius.y())); | 158 dst->outset(SkScalarCeilToInt(radius.x()), SkScalarCeilToInt(radius.y())); |
| 159 if (this->getInput(0) && !this->getInput(0)->filterBounds(bounds, ctm, &boun
ds)) { | |
| 160 return false; | |
| 161 } | |
| 162 *dst = bounds; | |
| 163 return true; | |
| 164 } | 159 } |
| 165 | 160 |
| 166 SkFlattenable* SkErodeImageFilter::CreateProc(SkReadBuffer& buffer) { | 161 SkFlattenable* SkErodeImageFilter::CreateProc(SkReadBuffer& buffer) { |
| 167 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); | 162 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); |
| 168 const int width = buffer.readInt(); | 163 const int width = buffer.readInt(); |
| 169 const int height = buffer.readInt(); | 164 const int height = buffer.readInt(); |
| 170 return Create(width, height, common.getInput(0), &common.cropRect()); | 165 return Create(width, height, common.getInput(0), &common.cropRect()); |
| 171 } | 166 } |
| 172 | 167 |
| 173 SkFlattenable* SkDilateImageFilter::CreateProc(SkReadBuffer& buffer) { | 168 SkFlattenable* SkDilateImageFilter::CreateProc(SkReadBuffer& buffer) { |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 const SkBitmap& src, | 625 const SkBitmap& src, |
| 631 const Context& ctx, | 626 const Context& ctx, |
| 632 SkBitmap* result, | 627 SkBitmap* result, |
| 633 SkIPoint* offset) const { | 628 SkIPoint* offset) const { |
| 634 SkBitmap input = src; | 629 SkBitmap input = src; |
| 635 SkIPoint srcOffset = SkIPoint::Make(0, 0); | 630 SkIPoint srcOffset = SkIPoint::Make(0, 0); |
| 636 if (!this->filterInputGPU(0, proxy, src, ctx, &input, &srcOffset)) { | 631 if (!this->filterInputGPU(0, proxy, src, ctx, &input, &srcOffset)) { |
| 637 return false; | 632 return false; |
| 638 } | 633 } |
| 639 SkIRect bounds; | 634 SkIRect bounds; |
| 640 if (!this->applyCropRect(ctx, proxy, input, &srcOffset, &bounds, &input)) { | 635 if (!this->applyCropRect(this->mapContext(ctx), proxy, input, &srcOffset, &b
ounds, &input)) { |
| 641 return false; | 636 return false; |
| 642 } | 637 } |
| 643 SkVector radius = SkVector::Make(SkIntToScalar(this->radius().width()), | 638 SkVector radius = SkVector::Make(SkIntToScalar(this->radius().width()), |
| 644 SkIntToScalar(this->radius().height())); | 639 SkIntToScalar(this->radius().height())); |
| 645 ctx.ctm().mapVectors(&radius, 1); | 640 ctx.ctm().mapVectors(&radius, 1); |
| 646 int width = SkScalarFloorToInt(radius.fX); | 641 int width = SkScalarFloorToInt(radius.fX); |
| 647 int height = SkScalarFloorToInt(radius.fY); | 642 int height = SkScalarFloorToInt(radius.fY); |
| 648 | 643 |
| 649 if (width < 0 || height < 0) { | 644 if (width < 0 || height < 0) { |
| 650 return false; | 645 return false; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 674 SkBitmap* result, SkIPoint* offset) con
st { | 669 SkBitmap* result, SkIPoint* offset) con
st { |
| 675 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset); | 670 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset); |
| 676 } | 671 } |
| 677 | 672 |
| 678 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, | 673 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, |
| 679 SkBitmap* result, SkIPoint* offset) cons
t { | 674 SkBitmap* result, SkIPoint* offset) cons
t { |
| 680 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset); | 675 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset); |
| 681 } | 676 } |
| 682 | 677 |
| 683 #endif | 678 #endif |
| OLD | NEW |