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 "SkBlurImageFilter.h" | 8 #include "SkBlurImageFilter.h" |
9 | 9 |
10 #include "SkAutoPixmapStorage.h" | 10 #include "SkAutoPixmapStorage.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 } | 99 } |
100 if (!inputBounds.intersect(dstBounds)) { | 100 if (!inputBounds.intersect(dstBounds)) { |
101 return nullptr; | 101 return nullptr; |
102 } | 102 } |
103 | 103 |
104 const SkVector sigma = map_sigma(fSigma, ctx.ctm()); | 104 const SkVector sigma = map_sigma(fSigma, ctx.ctm()); |
105 | 105 |
106 #if SK_SUPPORT_GPU | 106 #if SK_SUPPORT_GPU |
107 if (source->isTextureBacked()) { | 107 if (source->isTextureBacked()) { |
108 GrContext* context = source->getContext(); | 108 GrContext* context = source->getContext(); |
109 SkAutoTUnref<GrTexture> inputTexture(input->asTextureRef(context)); | 109 sk_sp<GrTexture> inputTexture(input->asTextureRef(context)); |
110 SkASSERT(inputTexture); | 110 SkASSERT(inputTexture); |
111 | 111 |
112 if (0 == sigma.x() && 0 == sigma.y()) { | 112 if (0 == sigma.x() && 0 == sigma.y()) { |
113 offset->fX = inputBounds.x(); | 113 offset->fX = inputBounds.x(); |
114 offset->fY = inputBounds.y(); | 114 offset->fY = inputBounds.y(); |
115 return input->makeSubset(inputBounds.makeOffset(-inputOffset.x(), | 115 return input->makeSubset(inputBounds.makeOffset(-inputOffset.x(), |
116 -inputOffset.y())); | 116 -inputOffset.y())); |
117 } | 117 } |
118 | 118 |
119 offset->fX = dstBounds.fLeft; | 119 offset->fX = dstBounds.fLeft; |
120 offset->fY = dstBounds.fTop; | 120 offset->fY = dstBounds.fTop; |
121 inputBounds.offset(-inputOffset); | 121 inputBounds.offset(-inputOffset); |
122 dstBounds.offset(-inputOffset); | 122 dstBounds.offset(-inputOffset); |
123 SkRect inputBoundsF(SkRect::Make(inputBounds)); | 123 SkRect inputBoundsF(SkRect::Make(inputBounds)); |
124 SkAutoTUnref<GrTexture> tex(SkGpuBlurUtils::GaussianBlur(context, | 124 sk_sp<GrTexture> tex(SkGpuBlurUtils::GaussianBlur(context, |
125 inputTexture, | 125 inputTexture.get(), |
126 false, | 126 false, |
127 source->props()
.isGammaCorrect(), | 127 source->props().isGamm
aCorrect(), |
128 SkRect::Make(ds
tBounds), | 128 SkRect::Make(dstBounds
), |
129 &inputBoundsF, | 129 &inputBoundsF, |
130 sigma.x(), | 130 sigma.x(), |
131 sigma.y())); | 131 sigma.y())); |
132 if (!tex) { | 132 if (!tex) { |
133 return nullptr; | 133 return nullptr; |
134 } | 134 } |
135 | 135 |
136 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(dstBounds.width(), ds
tBounds.height()), | 136 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(dstBounds.width(), ds
tBounds.height()), |
137 kNeedNewImageUniqueID_SpecialImage, | 137 kNeedNewImageUniqueID_SpecialImage, |
138 tex, &source->props()); | 138 std::move(tex), &source->props()); |
139 } | 139 } |
140 #endif | 140 #endif |
141 | 141 |
142 int kernelSizeX, kernelSizeX3, lowOffsetX, highOffsetX; | 142 int kernelSizeX, kernelSizeX3, lowOffsetX, highOffsetX; |
143 int kernelSizeY, kernelSizeY3, lowOffsetY, highOffsetY; | 143 int kernelSizeY, kernelSizeY3, lowOffsetY, highOffsetY; |
144 get_box3_params(sigma.x(), &kernelSizeX, &kernelSizeX3, &lowOffsetX, &highOf
fsetX); | 144 get_box3_params(sigma.x(), &kernelSizeX, &kernelSizeX3, &lowOffsetX, &highOf
fsetX); |
145 get_box3_params(sigma.y(), &kernelSizeY, &kernelSizeY3, &lowOffsetY, &highOf
fsetY); | 145 get_box3_params(sigma.y(), &kernelSizeY, &kernelSizeY3, &lowOffsetY, &highOf
fsetY); |
146 | 146 |
147 if (kernelSizeX < 0 || kernelSizeY < 0) { | 147 if (kernelSizeX < 0 || kernelSizeY < 0) { |
148 return nullptr; | 148 return nullptr; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 str->appendf("SkBlurImageFilter: ("); | 249 str->appendf("SkBlurImageFilter: ("); |
250 str->appendf("sigma: (%f, %f) input (", fSigma.fWidth, fSigma.fHeight); | 250 str->appendf("sigma: (%f, %f) input (", fSigma.fWidth, fSigma.fHeight); |
251 | 251 |
252 if (this->getInput(0)) { | 252 if (this->getInput(0)) { |
253 this->getInput(0)->toString(str); | 253 this->getInput(0)->toString(str); |
254 } | 254 } |
255 | 255 |
256 str->append("))"); | 256 str->append("))"); |
257 } | 257 } |
258 #endif | 258 #endif |
OLD | NEW |