| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 SkBitmap src = source; | 139 SkBitmap src = source; |
| 140 SkIPoint srcOffset = SkIPoint::Make(0, 0); | 140 SkIPoint srcOffset = SkIPoint::Make(0, 0); |
| 141 if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctx, &src, &srcO
ffset)) { | 141 if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctx, &src, &srcO
ffset)) { |
| 142 return false; | 142 return false; |
| 143 } | 143 } |
| 144 | 144 |
| 145 if (src.colorType() != kPMColor_SkColorType) { | 145 if (src.colorType() != kPMColor_SkColorType) { |
| 146 return false; | 146 return false; |
| 147 } | 147 } |
| 148 | 148 |
| 149 SkIRect srcBounds, dstBounds; |
| 150 if (!this->applyCropRect(ctx, proxy, src, &srcOffset, &srcBounds, &src)) { |
| 151 return false; |
| 152 } |
| 153 |
| 149 SkAutoLockPixels alp(src); | 154 SkAutoLockPixels alp(src); |
| 150 if (!src.getPixels()) { | 155 if (!src.getPixels()) { |
| 151 return false; | 156 return false; |
| 152 } | 157 } |
| 153 | 158 |
| 154 SkIRect srcBounds, dstBounds; | |
| 155 src.getBounds(&srcBounds); | |
| 156 srcBounds.offset(srcOffset); | |
| 157 if (!this->applyCropRect(&srcBounds, ctx.ctm())) { | |
| 158 return false; | |
| 159 } | |
| 160 | |
| 161 dst->setConfig(src.config(), srcBounds.width(), srcBounds.height()); | 159 dst->setConfig(src.config(), srcBounds.width(), srcBounds.height()); |
| 162 dst->getBounds(&dstBounds); | 160 dst->getBounds(&dstBounds); |
| 163 if (!dst->allocPixels()) { | 161 if (!dst->allocPixels()) { |
| 164 return false; | 162 return false; |
| 165 } | 163 } |
| 166 | 164 |
| 167 SkVector sigma, localSigma = SkVector::Make(fSigma.width(), fSigma.height())
; | 165 SkVector sigma, localSigma = SkVector::Make(fSigma.width(), fSigma.height())
; |
| 168 ctx.ctm().mapVectors(&sigma, &localSigma, 1); | 166 ctx.ctm().mapVectors(&sigma, &localSigma, 1); |
| 169 | 167 |
| 170 int kernelSizeX, kernelSizeX3, lowOffsetX, highOffsetX; | 168 int kernelSizeX, kernelSizeX3, lowOffsetX, highOffsetX; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 } | 249 } |
| 252 | 250 |
| 253 bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, | 251 bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, |
| 254 SkBitmap* result, SkIPoint* offset) const
{ | 252 SkBitmap* result, SkIPoint* offset) const
{ |
| 255 #if SK_SUPPORT_GPU | 253 #if SK_SUPPORT_GPU |
| 256 SkBitmap input = src; | 254 SkBitmap input = src; |
| 257 SkIPoint srcOffset = SkIPoint::Make(0, 0); | 255 SkIPoint srcOffset = SkIPoint::Make(0, 0); |
| 258 if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctx, &input,
&srcOffset)) { | 256 if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctx, &input,
&srcOffset)) { |
| 259 return false; | 257 return false; |
| 260 } | 258 } |
| 261 GrTexture* source = input.getTexture(); | |
| 262 SkIRect rect; | 259 SkIRect rect; |
| 263 src.getBounds(&rect); | 260 if (!this->applyCropRect(ctx, proxy, input, &srcOffset, &rect, &input)) { |
| 264 rect.offset(srcOffset); | |
| 265 if (!this->applyCropRect(&rect, ctx.ctm())) { | |
| 266 return false; | 261 return false; |
| 267 } | 262 } |
| 263 GrTexture* source = input.getTexture(); |
| 268 SkVector sigma, localSigma = SkVector::Make(fSigma.width(), fSigma.height())
; | 264 SkVector sigma, localSigma = SkVector::Make(fSigma.width(), fSigma.height())
; |
| 269 ctx.ctm().mapVectors(&sigma, &localSigma, 1); | 265 ctx.ctm().mapVectors(&sigma, &localSigma, 1); |
| 270 offset->fX = rect.fLeft; | 266 offset->fX = rect.fLeft; |
| 271 offset->fY = rect.fTop; | 267 offset->fY = rect.fTop; |
| 272 rect.offset(-srcOffset); | 268 rect.offset(-srcOffset); |
| 273 SkAutoTUnref<GrTexture> tex(SkGpuBlurUtils::GaussianBlur(source->getContext(
), | 269 SkAutoTUnref<GrTexture> tex(SkGpuBlurUtils::GaussianBlur(source->getContext(
), |
| 274 source, | 270 source, |
| 275 false, | 271 false, |
| 276 SkRect::Make(rect), | 272 SkRect::Make(rect), |
| 277 true, | 273 true, |
| 278 sigma.x(), | 274 sigma.x(), |
| 279 sigma.y())); | 275 sigma.y())); |
| 280 WrapTexture(tex, rect.width(), rect.height(), result); | 276 WrapTexture(tex, rect.width(), rect.height(), result); |
| 281 return true; | 277 return true; |
| 282 #else | 278 #else |
| 283 SkDEBUGFAIL("Should not call in GPU-less build"); | 279 SkDEBUGFAIL("Should not call in GPU-less build"); |
| 284 return false; | 280 return false; |
| 285 #endif | 281 #endif |
| 286 } | 282 } |
| OLD | NEW |