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

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

Issue 137833004: Clamp negative sigma to 0 in SkDropShadowImageFilter. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Use SkMaxScalar Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
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 "SkDropShadowImageFilter.h" 8 #include "SkDropShadowImageFilter.h"
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 } 72 }
73 73
74 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds .height())); 74 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds .height()));
75 if (NULL == device.get()) { 75 if (NULL == device.get()) {
76 return false; 76 return false;
77 } 77 }
78 SkCanvas canvas(device.get()); 78 SkCanvas canvas(device.get());
79 79
80 SkVector sigma, localSigma = SkVector::Make(fSigmaX, fSigmaY); 80 SkVector sigma, localSigma = SkVector::Make(fSigmaX, fSigmaY);
81 matrix.mapVectors(&sigma, &localSigma, 1); 81 matrix.mapVectors(&sigma, &localSigma, 1);
82 sigma.fX = SkMaxScalar(0, sigma.fX);
83 sigma.fY = SkMaxScalar(0, sigma.fY);
82 SkAutoTUnref<SkImageFilter> blurFilter(new SkBlurImageFilter(sigma.fX, sigma .fY)); 84 SkAutoTUnref<SkImageFilter> blurFilter(new SkBlurImageFilter(sigma.fX, sigma .fY));
83 SkAutoTUnref<SkColorFilter> colorFilter(SkColorFilter::CreateModeFilter(fCol or, SkXfermode::kSrcIn_Mode)); 85 SkAutoTUnref<SkColorFilter> colorFilter(SkColorFilter::CreateModeFilter(fCol or, SkXfermode::kSrcIn_Mode));
84 SkPaint paint; 86 SkPaint paint;
85 paint.setImageFilter(blurFilter.get()); 87 paint.setImageFilter(blurFilter.get());
86 paint.setColorFilter(colorFilter.get()); 88 paint.setColorFilter(colorFilter.get());
87 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); 89 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
88 SkVector offsetVec, localOffsetVec = SkVector::Make(fDx, fDy); 90 SkVector offsetVec, localOffsetVec = SkVector::Make(fDx, fDy);
89 matrix.mapVectors(&offsetVec, &localOffsetVec, 1); 91 matrix.mapVectors(&offsetVec, &localOffsetVec, 1);
90 canvas.translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop)); 92 canvas.translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop));
91 canvas.drawBitmap(src, offsetVec.fX, offsetVec.fY, &paint); 93 canvas.drawBitmap(src, offsetVec.fX, offsetVec.fY, &paint);
(...skipping 11 matching lines...) Expand all
103 *dst = src; 105 *dst = src;
104 } 106 }
105 107
106 SkRect shadowBounds = *dst; 108 SkRect shadowBounds = *dst;
107 shadowBounds.offset(fDx, fDy); 109 shadowBounds.offset(fDx, fDy);
108 shadowBounds.outset(SkScalarMul(fSigmaX, SkIntToScalar(3)), 110 shadowBounds.outset(SkScalarMul(fSigmaX, SkIntToScalar(3)),
109 SkScalarMul(fSigmaY, SkIntToScalar(3))); 111 SkScalarMul(fSigmaY, SkIntToScalar(3)));
110 dst->join(shadowBounds); 112 dst->join(shadowBounds);
111 } 113 }
112 114
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698