Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: src/effects/SkBlurImageFilter.cpp

Issue 1845283003: Gamma-correctness pushed into Skia, top-down. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 GrTexture* inputTexture = input->peekTexture(); 106 GrTexture* inputTexture = input->peekTexture();
107 107
108 offset->fX = dstBounds.fLeft; 108 offset->fX = dstBounds.fLeft;
109 offset->fY = dstBounds.fTop; 109 offset->fY = dstBounds.fTop;
110 inputBounds.offset(-inputOffset); 110 inputBounds.offset(-inputOffset);
111 dstBounds.offset(-inputOffset); 111 dstBounds.offset(-inputOffset);
112 SkRect inputBoundsF(SkRect::Make(inputBounds)); 112 SkRect inputBoundsF(SkRect::Make(inputBounds));
113 SkAutoTUnref<GrTexture> tex(SkGpuBlurUtils::GaussianBlur(inputTexture->g etContext(), 113 SkAutoTUnref<GrTexture> tex(SkGpuBlurUtils::GaussianBlur(inputTexture->g etContext(),
114 inputTexture, 114 inputTexture,
115 false, 115 false,
116 source->props() .allowSRGBInputs(),
116 SkRect::Make(ds tBounds), 117 SkRect::Make(ds tBounds),
117 &inputBoundsF, 118 &inputBoundsF,
118 sigma.x(), 119 sigma.x(),
119 sigma.y())); 120 sigma.y()));
120 if (!tex) { 121 if (!tex) {
121 return nullptr; 122 return nullptr;
122 } 123 }
123 124
124 return SkSpecialImage::MakeFromGpu(source->internal_getProxy(), 125 return SkSpecialImage::MakeFromGpu(source->internal_getProxy(),
125 SkIRect::MakeWH(dstBounds.width(), ds tBounds.height()), 126 SkIRect::MakeWH(dstBounds.width(), ds tBounds.height()),
126 kNeedNewImageUniqueID_SpecialImage, 127 kNeedNewImageUniqueID_SpecialImage,
127 tex); 128 tex, &source->props());
128 } 129 }
129 #endif 130 #endif
130 131
131 int kernelSizeX, kernelSizeX3, lowOffsetX, highOffsetX; 132 int kernelSizeX, kernelSizeX3, lowOffsetX, highOffsetX;
132 int kernelSizeY, kernelSizeY3, lowOffsetY, highOffsetY; 133 int kernelSizeY, kernelSizeY3, lowOffsetY, highOffsetY;
133 get_box3_params(sigma.x(), &kernelSizeX, &kernelSizeX3, &lowOffsetX, &highOf fsetX); 134 get_box3_params(sigma.x(), &kernelSizeX, &kernelSizeX3, &lowOffsetX, &highOf fsetX);
134 get_box3_params(sigma.y(), &kernelSizeY, &kernelSizeY3, &lowOffsetY, &highOf fsetY); 135 get_box3_params(sigma.y(), &kernelSizeY, &kernelSizeY3, &lowOffsetY, &highOf fsetY);
135 136
136 if (kernelSizeX < 0 || kernelSizeY < 0) { 137 if (kernelSizeX < 0 || kernelSizeY < 0) {
137 return nullptr; 138 return nullptr;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 SkOpts::box_blur_xx(t, w, dstBounds, d, kernelSizeX3, highOffsetX, highOffsetX, w, h); 210 SkOpts::box_blur_xx(t, w, dstBounds, d, kernelSizeX3, highOffsetX, highOffsetX, w, h);
210 } else if (kernelSizeY > 0) { 211 } else if (kernelSizeY > 0) {
211 SkOpts::box_blur_yx(s, sw, inputBoundsT, d, kernelSizeY, lowOffsetY, highOffsetY, h, w); 212 SkOpts::box_blur_yx(s, sw, inputBoundsT, d, kernelSizeY, lowOffsetY, highOffsetY, h, w);
212 SkOpts::box_blur_xx(d, h, dstBoundsT, t, kernelSizeY, highOffsetY, lowOffsetY, h, w); 213 SkOpts::box_blur_xx(d, h, dstBoundsT, t, kernelSizeY, highOffsetY, lowOffsetY, h, w);
213 SkOpts::box_blur_xy(t, h, dstBoundsT, d, kernelSizeY3, highOffsetY, highOffsetY, h, w); 214 SkOpts::box_blur_xy(t, h, dstBoundsT, d, kernelSizeY3, highOffsetY, highOffsetY, h, w);
214 } 215 }
215 216
216 return SkSpecialImage::MakeFromRaster(source->internal_getProxy(), 217 return SkSpecialImage::MakeFromRaster(source->internal_getProxy(),
217 SkIRect::MakeWH(dstBounds.width(), 218 SkIRect::MakeWH(dstBounds.width(),
218 dstBounds.height()), 219 dstBounds.height()),
219 dst); 220 dst, &source->props());
220 } 221 }
221 222
222 223
223 SkRect SkBlurImageFilter::computeFastBounds(const SkRect& src) const { 224 SkRect SkBlurImageFilter::computeFastBounds(const SkRect& src) const {
224 SkRect bounds = this->getInput(0) ? this->getInput(0)->computeFastBounds(src ) : src; 225 SkRect bounds = this->getInput(0) ? this->getInput(0)->computeFastBounds(src ) : src;
225 bounds.outset(SkScalarMul(fSigma.width(), SkIntToScalar(3)), 226 bounds.outset(SkScalarMul(fSigma.width(), SkIntToScalar(3)),
226 SkScalarMul(fSigma.height(), SkIntToScalar(3))); 227 SkScalarMul(fSigma.height(), SkIntToScalar(3)));
227 return bounds; 228 return bounds;
228 } 229 }
229 230
230 SkIRect SkBlurImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix & ctm, 231 SkIRect SkBlurImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix & ctm,
231 MapDirection) const { 232 MapDirection) const {
232 SkVector sigma = map_sigma(fSigma, ctm); 233 SkVector sigma = map_sigma(fSigma, ctm);
233 return src.makeOutset(SkScalarCeilToInt(SkScalarMul(sigma.x(), SkIntToScalar (3))), 234 return src.makeOutset(SkScalarCeilToInt(SkScalarMul(sigma.x(), SkIntToScalar (3))),
234 SkScalarCeilToInt(SkScalarMul(sigma.y(), SkIntToScalar (3)))); 235 SkScalarCeilToInt(SkScalarMul(sigma.y(), SkIntToScalar (3))));
235 } 236 }
236 237
237 #ifndef SK_IGNORE_TO_STRING 238 #ifndef SK_IGNORE_TO_STRING
238 void SkBlurImageFilter::toString(SkString* str) const { 239 void SkBlurImageFilter::toString(SkString* str) const {
239 str->appendf("SkBlurImageFilter: ("); 240 str->appendf("SkBlurImageFilter: (");
240 str->appendf("sigma: (%f, %f) input (", fSigma.fWidth, fSigma.fHeight); 241 str->appendf("sigma: (%f, %f) input (", fSigma.fWidth, fSigma.fHeight);
241 242
242 if (this->getInput(0)) { 243 if (this->getInput(0)) {
243 this->getInput(0)->toString(str); 244 this->getInput(0)->toString(str);
244 } 245 }
245 246
246 str->append("))"); 247 str->append("))");
247 } 248 }
248 #endif 249 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698