| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 The Android Open Source Project | 2 * Copyright 2011 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
| 9 #include "SkBlurImageFilter.h" | 9 #include "SkBlurImageFilter.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 SkIPoint srcOffset = SkIPoint::Make(0, 0); | 75 SkIPoint srcOffset = SkIPoint::Make(0, 0); |
| 76 if (!this->filterInput(0, proxy, source, ctx, &src, &srcOffset)) { | 76 if (!this->filterInput(0, proxy, source, ctx, &src, &srcOffset)) { |
| 77 return false; | 77 return false; |
| 78 } | 78 } |
| 79 | 79 |
| 80 if (src.colorType() != kN32_SkColorType) { | 80 if (src.colorType() != kN32_SkColorType) { |
| 81 return false; | 81 return false; |
| 82 } | 82 } |
| 83 | 83 |
| 84 SkIRect srcBounds, dstBounds; | 84 SkIRect srcBounds, dstBounds; |
| 85 if (!this->applyCropRect(ctx, src, srcOffset, &dstBounds, &srcBounds)) { | 85 if (!this->applyCropRect(this->mapContext(ctx), src, srcOffset, &dstBounds,
&srcBounds)) { |
| 86 return false; |
| 87 } |
| 88 if (!srcBounds.intersect(dstBounds)) { |
| 86 return false; | 89 return false; |
| 87 } | 90 } |
| 88 | 91 |
| 89 SkAutoLockPixels alp(src); | 92 SkAutoLockPixels alp(src); |
| 90 if (!src.getPixels()) { | 93 if (!src.getPixels()) { |
| 91 return false; | 94 return false; |
| 92 } | 95 } |
| 93 | 96 |
| 94 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(dstBounds.width(), dst
Bounds.height())); | 97 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(dstBounds.width(), dst
Bounds.height())); |
| 95 if (!device) { | 98 if (!device) { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 if (this->getInput(0)) { | 180 if (this->getInput(0)) { |
| 178 this->getInput(0)->computeFastBounds(src, dst); | 181 this->getInput(0)->computeFastBounds(src, dst); |
| 179 } else { | 182 } else { |
| 180 *dst = src; | 183 *dst = src; |
| 181 } | 184 } |
| 182 | 185 |
| 183 dst->outset(SkScalarMul(fSigma.width(), SkIntToScalar(3)), | 186 dst->outset(SkScalarMul(fSigma.width(), SkIntToScalar(3)), |
| 184 SkScalarMul(fSigma.height(), SkIntToScalar(3))); | 187 SkScalarMul(fSigma.height(), SkIntToScalar(3))); |
| 185 } | 188 } |
| 186 | 189 |
| 187 bool SkBlurImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm, | 190 void SkBlurImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& c
tm, |
| 188 SkIRect* dst) const { | 191 SkIRect* dst, MapDirection) const { |
| 189 SkIRect bounds = src; | 192 *dst = src; |
| 190 SkVector sigma = mapSigma(fSigma, ctm); | 193 SkVector sigma = mapSigma(fSigma, ctm); |
| 191 bounds.outset(SkScalarCeilToInt(SkScalarMul(sigma.x(), SkIntToScalar(3))), | 194 dst->outset(SkScalarCeilToInt(SkScalarMul(sigma.x(), SkIntToScalar(3))), |
| 192 SkScalarCeilToInt(SkScalarMul(sigma.y(), SkIntToScalar(3)))); | 195 SkScalarCeilToInt(SkScalarMul(sigma.y(), SkIntToScalar(3)))); |
| 193 if (this->getInput(0) && !this->getInput(0)->filterBounds(bounds, ctm, &boun
ds)) { | |
| 194 return false; | |
| 195 } | |
| 196 *dst = bounds; | |
| 197 return true; | |
| 198 } | 196 } |
| 199 | 197 |
| 200 bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, | 198 bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, |
| 201 SkBitmap* result, SkIPoint* offset) const
{ | 199 SkBitmap* result, SkIPoint* offset) const
{ |
| 202 #if SK_SUPPORT_GPU | 200 #if SK_SUPPORT_GPU |
| 203 SkBitmap input = src; | 201 SkBitmap input = src; |
| 204 SkIPoint srcOffset = SkIPoint::Make(0, 0); | 202 SkIPoint srcOffset = SkIPoint::Make(0, 0); |
| 205 if (!this->filterInputGPU(0, proxy, src, ctx, &input, &srcOffset)) { | 203 if (!this->filterInputGPU(0, proxy, src, ctx, &input, &srcOffset)) { |
| 206 return false; | 204 return false; |
| 207 } | 205 } |
| 208 SkIRect srcBounds, dstBounds; | 206 SkIRect srcBounds, dstBounds; |
| 209 if (!this->applyCropRect(ctx, input, srcOffset, &dstBounds, &srcBounds)) { | 207 if (!this->applyCropRect(this->mapContext(ctx), input, srcOffset, &dstBounds
, &srcBounds)) { |
| 208 return false; |
| 209 } |
| 210 if (!srcBounds.intersect(dstBounds)) { |
| 210 return false; | 211 return false; |
| 211 } | 212 } |
| 212 GrTexture* source = input.getTexture(); | 213 GrTexture* source = input.getTexture(); |
| 213 SkVector sigma = mapSigma(fSigma, ctx.ctm()); | 214 SkVector sigma = mapSigma(fSigma, ctx.ctm()); |
| 214 offset->fX = dstBounds.fLeft; | 215 offset->fX = dstBounds.fLeft; |
| 215 offset->fY = dstBounds.fTop; | 216 offset->fY = dstBounds.fTop; |
| 216 srcBounds.offset(-srcOffset); | 217 srcBounds.offset(-srcOffset); |
| 217 dstBounds.offset(-srcOffset); | 218 dstBounds.offset(-srcOffset); |
| 218 SkRect srcBoundsF(SkRect::Make(srcBounds)); | 219 SkRect srcBoundsF(SkRect::Make(srcBounds)); |
| 219 auto constraint = GrTextureProvider::FromImageFilter(ctx.sizeConstraint()); | 220 auto constraint = GrTextureProvider::FromImageFilter(ctx.sizeConstraint()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 241 str->appendf("SkBlurImageFilter: ("); | 242 str->appendf("SkBlurImageFilter: ("); |
| 242 str->appendf("sigma: (%f, %f) input (", fSigma.fWidth, fSigma.fHeight); | 243 str->appendf("sigma: (%f, %f) input (", fSigma.fWidth, fSigma.fHeight); |
| 243 | 244 |
| 244 if (this->getInput(0)) { | 245 if (this->getInput(0)) { |
| 245 this->getInput(0)->toString(str); | 246 this->getInput(0)->toString(str); |
| 246 } | 247 } |
| 247 | 248 |
| 248 str->append("))"); | 249 str->append("))"); |
| 249 } | 250 } |
| 250 #endif | 251 #endif |
| OLD | NEW |