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 "SkBlurImageFilter.h" | 10 #include "SkBlurImageFilter.h" |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 #include "SkReadBuffer.h" | 12 #include "SkReadBuffer.h" |
13 #include "SkSpecialImage.h" | 13 #include "SkSpecialImage.h" |
14 #include "SkSpecialSurface.h" | 14 #include "SkSpecialSurface.h" |
15 #include "SkWriteBuffer.h" | 15 #include "SkWriteBuffer.h" |
16 | 16 |
17 SkDropShadowImageFilter::SkDropShadowImageFilter(SkScalar dx, SkScalar dy, | 17 SkDropShadowImageFilter::SkDropShadowImageFilter(SkScalar dx, SkScalar dy, |
18 SkScalar sigmaX, SkScalar sigma
Y, SkColor color, | 18 SkScalar sigmaX, SkScalar sigma
Y, SkColor color, |
19 ShadowMode shadowMode, SkImageF
ilter* input, | 19 ShadowMode shadowMode, sk_sp<Sk
ImageFilter> input, |
20 const CropRect* cropRect) | 20 const CropRect* cropRect) |
21 : INHERITED(1, &input, cropRect) | 21 : INHERITED(&input, 1, cropRect) |
22 , fDx(dx) | 22 , fDx(dx) |
23 , fDy(dy) | 23 , fDy(dy) |
24 , fSigmaX(sigmaX) | 24 , fSigmaX(sigmaX) |
25 , fSigmaY(sigmaY) | 25 , fSigmaY(sigmaY) |
26 , fColor(color) | 26 , fColor(color) |
27 , fShadowMode(shadowMode) { | 27 , fShadowMode(shadowMode) { |
28 } | 28 } |
29 | 29 |
30 sk_sp<SkFlattenable> SkDropShadowImageFilter::CreateProc(SkReadBuffer& buffer) { | 30 sk_sp<SkFlattenable> SkDropShadowImageFilter::CreateProc(SkReadBuffer& buffer) { |
31 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); | 31 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); |
32 SkScalar dx = buffer.readScalar(); | 32 SkScalar dx = buffer.readScalar(); |
33 SkScalar dy = buffer.readScalar(); | 33 SkScalar dy = buffer.readScalar(); |
34 SkScalar sigmaX = buffer.readScalar(); | 34 SkScalar sigmaX = buffer.readScalar(); |
35 SkScalar sigmaY = buffer.readScalar(); | 35 SkScalar sigmaY = buffer.readScalar(); |
36 SkColor color = buffer.readColor(); | 36 SkColor color = buffer.readColor(); |
37 ShadowMode shadowMode = buffer.isVersionLT(SkReadBuffer::kDropShadowMode_Ver
sion) ? | 37 ShadowMode shadowMode = buffer.isVersionLT(SkReadBuffer::kDropShadowMode_Ver
sion) ? |
38 kDrawShadowAndForeground_ShadowMode : | 38 kDrawShadowAndForeground_ShadowMode : |
39 static_cast<ShadowMode>(buffer.readInt()); | 39 static_cast<ShadowMode>(buffer.readInt()); |
40 return sk_sp<SkFlattenable>(Create(dx, dy, sigmaX, sigmaY, color, shadowMode
, | 40 return Make(dx, dy, sigmaX, sigmaY, color, shadowMode, common.getInput(0), &
common.cropRect()); |
41 common.getInput(0).get(), &common.cropRec
t())); | |
42 } | 41 } |
43 | 42 |
44 void SkDropShadowImageFilter::flatten(SkWriteBuffer& buffer) const { | 43 void SkDropShadowImageFilter::flatten(SkWriteBuffer& buffer) const { |
45 this->INHERITED::flatten(buffer); | 44 this->INHERITED::flatten(buffer); |
46 buffer.writeScalar(fDx); | 45 buffer.writeScalar(fDx); |
47 buffer.writeScalar(fDy); | 46 buffer.writeScalar(fDy); |
48 buffer.writeScalar(fSigmaX); | 47 buffer.writeScalar(fSigmaX); |
49 buffer.writeScalar(fSigmaY); | 48 buffer.writeScalar(fSigmaY); |
50 buffer.writeColor(fColor); | 49 buffer.writeColor(fColor); |
51 buffer.writeInt(static_cast<int>(fShadowMode)); | 50 buffer.writeInt(static_cast<int>(fShadowMode)); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 "kDrawShadowAndForeground", "kDrawShadowOnly" | 152 "kDrawShadowAndForeground", "kDrawShadowOnly" |
154 }; | 153 }; |
155 | 154 |
156 static_assert(kShadowModeCount == SK_ARRAY_COUNT(gModeStrings), "enum_mismat
ch"); | 155 static_assert(kShadowModeCount == SK_ARRAY_COUNT(gModeStrings), "enum_mismat
ch"); |
157 | 156 |
158 str->appendf(" mode: %s", gModeStrings[fShadowMode]); | 157 str->appendf(" mode: %s", gModeStrings[fShadowMode]); |
159 | 158 |
160 str->append(")"); | 159 str->append(")"); |
161 } | 160 } |
162 #endif | 161 #endif |
OLD | NEW |