| 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 "SkAutoPixmapStorage.h" | 8 #include "SkAutoPixmapStorage.h" |
| 9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
| 10 #include "SkGpuBlurUtils.h" | 10 #include "SkGpuBlurUtils.h" |
| 11 #include "SkOpts.h" | 11 #include "SkOpts.h" |
| 12 #include "SkReadBuffer.h" | 12 #include "SkReadBuffer.h" |
| 13 #include "SkSpecialImage.h" | 13 #include "SkSpecialImage.h" |
| 14 #include "SkWriteBuffer.h" | 14 #include "SkWriteBuffer.h" |
| 15 | 15 |
| 16 #if SK_SUPPORT_GPU | 16 #if SK_SUPPORT_GPU |
| 17 #include "GrContext.h" | 17 #include "GrContext.h" |
| 18 #include "GrTextureProxy.h" |
| 18 #include "SkGr.h" | 19 #include "SkGr.h" |
| 19 #endif | 20 #endif |
| 20 | 21 |
| 21 class SkBlurImageFilterImpl : public SkImageFilter { | 22 class SkBlurImageFilterImpl : public SkImageFilter { |
| 22 public: | 23 public: |
| 23 SkBlurImageFilterImpl(SkScalar sigmaX, | 24 SkBlurImageFilterImpl(SkScalar sigmaX, |
| 24 SkScalar sigmaY, | 25 SkScalar sigmaY, |
| 25 sk_sp<SkImageFilter> input, | 26 sk_sp<SkImageFilter> input, |
| 26 const CropRect* cropRect); | 27 const CropRect* cropRect); |
| 27 | 28 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 *lowOffset = *highOffset = (d - 1) / 2; | 104 *lowOffset = *highOffset = (d - 1) / 2; |
| 104 *kernelSize3 = d; | 105 *kernelSize3 = d; |
| 105 } else { | 106 } else { |
| 106 *highOffset = d / 2; | 107 *highOffset = d / 2; |
| 107 *lowOffset = *highOffset - 1; | 108 *lowOffset = *highOffset - 1; |
| 108 *kernelSize3 = d + 1; | 109 *kernelSize3 = d + 1; |
| 109 } | 110 } |
| 110 } | 111 } |
| 111 | 112 |
| 112 sk_sp<SkSpecialImage> SkBlurImageFilterImpl::onFilterImage(SkSpecialImage* sourc
e, | 113 sk_sp<SkSpecialImage> SkBlurImageFilterImpl::onFilterImage(SkSpecialImage* sourc
e, |
| 113 const Context& ctx, | 114 const Context& ctx, |
| 114 SkIPoint* offset) const { | 115 SkIPoint* offset) con
st { |
| 115 SkIPoint inputOffset = SkIPoint::Make(0, 0); | 116 SkIPoint inputOffset = SkIPoint::Make(0, 0); |
| 116 | 117 |
| 117 sk_sp<SkSpecialImage> input(this->filterInput(0, source, ctx, &inputOffset))
; | 118 sk_sp<SkSpecialImage> input(this->filterInput(0, source, ctx, &inputOffset))
; |
| 118 if (!input) { | 119 if (!input) { |
| 119 return nullptr; | 120 return nullptr; |
| 120 } | 121 } |
| 121 | 122 |
| 122 SkIRect inputBounds = SkIRect::MakeXYWH(inputOffset.fX, inputOffset.fY, | 123 SkIRect inputBounds = SkIRect::MakeXYWH(inputOffset.fX, inputOffset.fY, |
| 123 input->width(), input->height()); | 124 input->width(), input->height()); |
| 124 | 125 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 sk_ref_sp(source
->getColorSpace()), | 161 sk_ref_sp(source
->getColorSpace()), |
| 161 dstBounds, | 162 dstBounds, |
| 162 &inputBounds, | 163 &inputBounds, |
| 163 sigma.x(), | 164 sigma.x(), |
| 164 sigma.y())); | 165 sigma.y())); |
| 165 if (!renderTargetContext) { | 166 if (!renderTargetContext) { |
| 166 return nullptr; | 167 return nullptr; |
| 167 } | 168 } |
| 168 | 169 |
| 169 // TODO: Get the colorSpace from the renderTargetContext (once it has on
e) | 170 // TODO: Get the colorSpace from the renderTargetContext (once it has on
e) |
| 170 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(dstBounds.width(), ds
tBounds.height()), | 171 return SkSpecialImage::MakeDeferredFromGpu( |
| 172 context, |
| 173 SkIRect::MakeWH(dstBounds.width(), ds
tBounds.height()), |
| 171 kNeedNewImageUniqueID_SpecialImage, | 174 kNeedNewImageUniqueID_SpecialImage, |
| 172 renderTargetContext->asTexture(), | 175 sk_ref_sp(renderTargetContext->asDefe
rredTexture()), |
| 173 sk_ref_sp(input->getColorSpace()), &s
ource->props()); | 176 sk_ref_sp(input->getColorSpace()), &s
ource->props()); |
| 174 } | 177 } |
| 175 #endif | 178 #endif |
| 176 | 179 |
| 177 int kernelSizeX, kernelSizeX3, lowOffsetX, highOffsetX; | 180 int kernelSizeX, kernelSizeX3, lowOffsetX, highOffsetX; |
| 178 int kernelSizeY, kernelSizeY3, lowOffsetY, highOffsetY; | 181 int kernelSizeY, kernelSizeY3, lowOffsetY, highOffsetY; |
| 179 get_box3_params(sigma.x(), &kernelSizeX, &kernelSizeX3, &lowOffsetX, &highOf
fsetX); | 182 get_box3_params(sigma.x(), &kernelSizeX, &kernelSizeX3, &lowOffsetX, &highOf
fsetX); |
| 180 get_box3_params(sigma.y(), &kernelSizeY, &kernelSizeY3, &lowOffsetY, &highOf
fsetY); | 183 get_box3_params(sigma.y(), &kernelSizeY, &kernelSizeY3, &lowOffsetY, &highOf
fsetY); |
| 181 | 184 |
| 182 if (kernelSizeX < 0 || kernelSizeY < 0) { | 185 if (kernelSizeX < 0 || kernelSizeY < 0) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 str->appendf("SkBlurImageFilterImpl: ("); | 287 str->appendf("SkBlurImageFilterImpl: ("); |
| 285 str->appendf("sigma: (%f, %f) input (", fSigma.fWidth, fSigma.fHeight); | 288 str->appendf("sigma: (%f, %f) input (", fSigma.fWidth, fSigma.fHeight); |
| 286 | 289 |
| 287 if (this->getInput(0)) { | 290 if (this->getInput(0)) { |
| 288 this->getInput(0)->toString(str); | 291 this->getInput(0)->toString(str); |
| 289 } | 292 } |
| 290 | 293 |
| 291 str->append("))"); | 294 str->append("))"); |
| 292 } | 295 } |
| 293 #endif | 296 #endif |
| OLD | NEW |