OLD | NEW |
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds
.height())); | 75 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds
.height())); |
76 if (NULL == device.get()) { | 76 if (NULL == device.get()) { |
77 return false; | 77 return false; |
78 } | 78 } |
79 SkCanvas canvas(device.get()); | 79 SkCanvas canvas(device.get()); |
80 | 80 |
81 SkVector sigma, localSigma = SkVector::Make(fSigmaX, fSigmaY); | 81 SkVector sigma, localSigma = SkVector::Make(fSigmaX, fSigmaY); |
82 matrix.mapVectors(&sigma, &localSigma, 1); | 82 matrix.mapVectors(&sigma, &localSigma, 1); |
83 sigma.fX = SkMaxScalar(0, sigma.fX); | 83 sigma.fX = SkMaxScalar(0, sigma.fX); |
84 sigma.fY = SkMaxScalar(0, sigma.fY); | 84 sigma.fY = SkMaxScalar(0, sigma.fY); |
85 SkAutoTUnref<SkImageFilter> blurFilter(new SkBlurImageFilter(sigma.fX, sigma
.fY)); | 85 SkAutoTUnref<SkImageFilter> blurFilter(SkBlurImageFilter::Create(sigma.fX, s
igma.fY)); |
86 SkAutoTUnref<SkColorFilter> colorFilter(SkColorFilter::CreateModeFilter(fCol
or, SkXfermode::kSrcIn_Mode)); | 86 SkAutoTUnref<SkColorFilter> colorFilter(SkColorFilter::CreateModeFilter(fCol
or, SkXfermode::kSrcIn_Mode)); |
87 SkPaint paint; | 87 SkPaint paint; |
88 paint.setImageFilter(blurFilter.get()); | 88 paint.setImageFilter(blurFilter.get()); |
89 paint.setColorFilter(colorFilter.get()); | 89 paint.setColorFilter(colorFilter.get()); |
90 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); | 90 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); |
91 SkVector offsetVec, localOffsetVec = SkVector::Make(fDx, fDy); | 91 SkVector offsetVec, localOffsetVec = SkVector::Make(fDx, fDy); |
92 matrix.mapVectors(&offsetVec, &localOffsetVec, 1); | 92 matrix.mapVectors(&offsetVec, &localOffsetVec, 1); |
93 canvas.translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop)); | 93 canvas.translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop)); |
94 canvas.drawBitmap(src, offsetVec.fX, offsetVec.fY, &paint); | 94 canvas.drawBitmap(src, offsetVec.fX, offsetVec.fY, &paint); |
95 canvas.drawBitmap(src, 0, 0); | 95 canvas.drawBitmap(src, 0, 0); |
(...skipping 28 matching lines...) Expand all Loading... |
124 bounds.offset(-SkScalarCeilToInt(offsetVec.x()), | 124 bounds.offset(-SkScalarCeilToInt(offsetVec.x()), |
125 -SkScalarCeilToInt(offsetVec.y())); | 125 -SkScalarCeilToInt(offsetVec.y())); |
126 SkVector sigma, localSigma = SkVector::Make(fSigmaX, fSigmaY); | 126 SkVector sigma, localSigma = SkVector::Make(fSigmaX, fSigmaY); |
127 ctm.mapVectors(&sigma, &localSigma, 1); | 127 ctm.mapVectors(&sigma, &localSigma, 1); |
128 bounds.outset(SkScalarCeilToInt(SkScalarMul(sigma.x(), SkIntToScalar(3))), | 128 bounds.outset(SkScalarCeilToInt(SkScalarMul(sigma.x(), SkIntToScalar(3))), |
129 SkScalarCeilToInt(SkScalarMul(sigma.y(), SkIntToScalar(3)))); | 129 SkScalarCeilToInt(SkScalarMul(sigma.y(), SkIntToScalar(3)))); |
130 bounds.join(src); | 130 bounds.join(src); |
131 *dst = bounds; | 131 *dst = bounds; |
132 return true; | 132 return true; |
133 } | 133 } |
OLD | NEW |