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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 bool SkMorphologyImageFilter::filterImageGeneric(SkMorphologyImageFilter::Proc p
rocX, | 56 bool SkMorphologyImageFilter::filterImageGeneric(SkMorphologyImageFilter::Proc p
rocX, |
57 SkMorphologyImageFilter::Proc p
rocY, | 57 SkMorphologyImageFilter::Proc p
rocY, |
58 Proxy* proxy, | 58 Proxy* proxy, |
59 const SkBitmap& source, | 59 const SkBitmap& source, |
60 const Context& ctx, | 60 const Context& ctx, |
61 SkBitmap* dst, | 61 SkBitmap* dst, |
62 SkIPoint* offset) const { | 62 SkIPoint* offset) const { |
63 SkBitmap src = source; | 63 SkBitmap src = source; |
64 SkIPoint srcOffset = SkIPoint::Make(0, 0); | 64 SkIPoint srcOffset = SkIPoint::Make(0, 0); |
65 if (!this->filterInput(0, proxy, source, ctx, &src, &srcOffset)) { | 65 if (!this->filterInputDeprecated(0, proxy, source, ctx, &src, &srcOffset)) { |
66 return false; | 66 return false; |
67 } | 67 } |
68 | 68 |
69 if (src.colorType() != kN32_SkColorType) { | 69 if (src.colorType() != kN32_SkColorType) { |
70 return false; | 70 return false; |
71 } | 71 } |
72 | 72 |
73 SkIRect bounds; | 73 SkIRect bounds; |
74 if (!this->applyCropRect(this->mapContext(ctx), proxy, src, &srcOffset, &bou
nds, &src)) { | 74 if (!this->applyCropRectDeprecated(this->mapContext(ctx), proxy, src, &srcOf
fset, |
| 75 &bounds, &src)) { |
75 return false; | 76 return false; |
76 } | 77 } |
77 | 78 |
78 SkAutoLockPixels alp(src); | 79 SkAutoLockPixels alp(src); |
79 if (!src.getPixels()) { | 80 if (!src.getPixels()) { |
80 return false; | 81 return false; |
81 } | 82 } |
82 | 83 |
83 SkVector radius = SkVector::Make(SkIntToScalar(this->radius().width()), | 84 SkVector radius = SkVector::Make(SkIntToScalar(this->radius().width()), |
84 SkIntToScalar(this->radius().height())); | 85 SkIntToScalar(this->radius().height())); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 } else if (width > 0) { | 121 } else if (width > 0) { |
121 callProcX(procX, src, dst, width, srcBounds); | 122 callProcX(procX, src, dst, width, srcBounds); |
122 } else if (height > 0) { | 123 } else if (height > 0) { |
123 callProcY(procY, src, dst, height, srcBounds); | 124 callProcY(procY, src, dst, height, srcBounds); |
124 } | 125 } |
125 offset->fX = bounds.left(); | 126 offset->fX = bounds.left(); |
126 offset->fY = bounds.top(); | 127 offset->fY = bounds.top(); |
127 return true; | 128 return true; |
128 } | 129 } |
129 | 130 |
130 bool SkErodeImageFilter::onFilterImage(Proxy* proxy, | 131 bool SkErodeImageFilter::onFilterImageDeprecated(Proxy* proxy, |
131 const SkBitmap& source, const Context& ct
x, | 132 const SkBitmap& source, const C
ontext& ctx, |
132 SkBitmap* dst, SkIPoint* offset) const { | 133 SkBitmap* dst, SkIPoint* offset
) const { |
133 return this->filterImageGeneric(SkOpts::erode_x, SkOpts::erode_y, | 134 return this->filterImageGeneric(SkOpts::erode_x, SkOpts::erode_y, |
134 proxy, source, ctx, dst, offset); | 135 proxy, source, ctx, dst, offset); |
135 } | 136 } |
136 | 137 |
137 bool SkDilateImageFilter::onFilterImage(Proxy* proxy, | 138 bool SkDilateImageFilter::onFilterImageDeprecated(Proxy* proxy, |
138 const SkBitmap& source, const Context& c
tx, | 139 const SkBitmap& source, const
Context& ctx, |
139 SkBitmap* dst, SkIPoint* offset) const { | 140 SkBitmap* dst, SkIPoint* offse
t) const { |
140 return this->filterImageGeneric(SkOpts::dilate_x, SkOpts::dilate_y, | 141 return this->filterImageGeneric(SkOpts::dilate_x, SkOpts::dilate_y, |
141 proxy, source, ctx, dst, offset); | 142 proxy, source, ctx, dst, offset); |
142 } | 143 } |
143 | 144 |
144 void SkMorphologyImageFilter::computeFastBounds(const SkRect& src, SkRect* dst)
const { | 145 void SkMorphologyImageFilter::computeFastBounds(const SkRect& src, SkRect* dst)
const { |
145 if (this->getInput(0)) { | 146 if (this->getInput(0)) { |
146 this->getInput(0)->computeFastBounds(src, dst); | 147 this->getInput(0)->computeFastBounds(src, dst); |
147 } else { | 148 } else { |
148 *dst = src; | 149 *dst = src; |
149 } | 150 } |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 }; | 601 }; |
601 | 602 |
602 bool SkMorphologyImageFilter::filterImageGPUGeneric(bool dilate, | 603 bool SkMorphologyImageFilter::filterImageGPUGeneric(bool dilate, |
603 Proxy* proxy, | 604 Proxy* proxy, |
604 const SkBitmap& src, | 605 const SkBitmap& src, |
605 const Context& ctx, | 606 const Context& ctx, |
606 SkBitmap* result, | 607 SkBitmap* result, |
607 SkIPoint* offset) const { | 608 SkIPoint* offset) const { |
608 SkBitmap input = src; | 609 SkBitmap input = src; |
609 SkIPoint srcOffset = SkIPoint::Make(0, 0); | 610 SkIPoint srcOffset = SkIPoint::Make(0, 0); |
610 if (!this->filterInputGPU(0, proxy, src, ctx, &input, &srcOffset)) { | 611 if (!this->filterInputGPUDeprecated(0, proxy, src, ctx, &input, &srcOffset))
{ |
611 return false; | 612 return false; |
612 } | 613 } |
613 SkIRect bounds; | 614 SkIRect bounds; |
614 if (!this->applyCropRect(this->mapContext(ctx), proxy, input, &srcOffset, &b
ounds, &input)) { | 615 if (!this->applyCropRectDeprecated(this->mapContext(ctx), proxy, input, &src
Offset, |
| 616 &bounds, &input)) { |
615 return false; | 617 return false; |
616 } | 618 } |
617 SkVector radius = SkVector::Make(SkIntToScalar(this->radius().width()), | 619 SkVector radius = SkVector::Make(SkIntToScalar(this->radius().width()), |
618 SkIntToScalar(this->radius().height())); | 620 SkIntToScalar(this->radius().height())); |
619 ctx.ctm().mapVectors(&radius, 1); | 621 ctx.ctm().mapVectors(&radius, 1); |
620 int width = SkScalarFloorToInt(radius.fX); | 622 int width = SkScalarFloorToInt(radius.fX); |
621 int height = SkScalarFloorToInt(radius.fY); | 623 int height = SkScalarFloorToInt(radius.fY); |
622 | 624 |
623 if (width < 0 || height < 0) { | 625 if (width < 0 || height < 0) { |
624 return false; | 626 return false; |
(...skipping 11 matching lines...) Expand all Loading... |
636 GrMorphologyEffect::MorphologyType type = dilate ? GrMorphologyEffect::kDila
te_MorphologyType | 638 GrMorphologyEffect::MorphologyType type = dilate ? GrMorphologyEffect::kDila
te_MorphologyType |
637 : GrMorphologyEffect::kErod
e_MorphologyType; | 639 : GrMorphologyEffect::kErod
e_MorphologyType; |
638 if (!apply_morphology(input, srcBounds, type, SkISize::Make(width, height),
result)) { | 640 if (!apply_morphology(input, srcBounds, type, SkISize::Make(width, height),
result)) { |
639 return false; | 641 return false; |
640 } | 642 } |
641 offset->fX = bounds.left(); | 643 offset->fX = bounds.left(); |
642 offset->fY = bounds.top(); | 644 offset->fY = bounds.top(); |
643 return true; | 645 return true; |
644 } | 646 } |
645 | 647 |
646 bool SkDilateImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, cons
t Context& ctx, | 648 bool SkDilateImageFilter::filterImageGPUDeprecated(Proxy* proxy, const SkBitmap&
src, |
647 SkBitmap* result, SkIPoint* offset) con
st { | 649 const Context& ctx, |
| 650 SkBitmap* result, SkIPoint* o
ffset) const { |
648 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset); | 651 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset); |
649 } | 652 } |
650 | 653 |
651 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, | 654 bool SkErodeImageFilter::filterImageGPUDeprecated(Proxy* proxy, const SkBitmap&
src, |
652 SkBitmap* result, SkIPoint* offset) cons
t { | 655 const Context& ctx, |
| 656 SkBitmap* result, SkIPoint* of
fset) const { |
653 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset); | 657 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset); |
654 } | 658 } |
655 | 659 |
656 #endif | 660 #endif |
OLD | NEW |