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, SkImageF
ilter* input, |
20 const CropRect* cropRect) | 20 const CropRect* cropRect) |
21 : INHERITED(1, &input, cropRect) | 21 : INHERITED(1, &input, 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 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 Create(dx, dy, sigmaX, sigmaY, color, shadowMode, common.getInput(0).
get(), | 40 return sk_sp<SkFlattenable>(Create(dx, dy, sigmaX, sigmaY, color, shadowMode
, |
41 &common.cropRect()); | 41 common.getInput(0).get(), &common.cropRec
t())); |
42 } | 42 } |
43 | 43 |
44 void SkDropShadowImageFilter::flatten(SkWriteBuffer& buffer) const { | 44 void SkDropShadowImageFilter::flatten(SkWriteBuffer& buffer) const { |
45 this->INHERITED::flatten(buffer); | 45 this->INHERITED::flatten(buffer); |
46 buffer.writeScalar(fDx); | 46 buffer.writeScalar(fDx); |
47 buffer.writeScalar(fDy); | 47 buffer.writeScalar(fDy); |
48 buffer.writeScalar(fSigmaX); | 48 buffer.writeScalar(fSigmaX); |
49 buffer.writeScalar(fSigmaY); | 49 buffer.writeScalar(fSigmaY); |
50 buffer.writeColor(fColor); | 50 buffer.writeColor(fColor); |
51 buffer.writeInt(static_cast<int>(fShadowMode)); | 51 buffer.writeInt(static_cast<int>(fShadowMode)); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 "kDrawShadowAndForeground", "kDrawShadowOnly" | 154 "kDrawShadowAndForeground", "kDrawShadowOnly" |
155 }; | 155 }; |
156 | 156 |
157 static_assert(kShadowModeCount == SK_ARRAY_COUNT(gModeStrings), "enum_mismat
ch"); | 157 static_assert(kShadowModeCount == SK_ARRAY_COUNT(gModeStrings), "enum_mismat
ch"); |
158 | 158 |
159 str->appendf(" mode: %s", gModeStrings[fShadowMode]); | 159 str->appendf(" mode: %s", gModeStrings[fShadowMode]); |
160 | 160 |
161 str->append(")"); | 161 str->append(")"); |
162 } | 162 } |
163 #endif | 163 #endif |
OLD | NEW |