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

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

Issue 1855733002: change flattenable factory to return sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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
« no previous file with comments | « src/effects/SkDisplacementMapEffect.cpp ('k') | src/effects/SkEmbossMaskFilter.cpp » ('j') | 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 "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
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
OLDNEW
« no previous file with comments | « src/effects/SkDisplacementMapEffect.cpp ('k') | src/effects/SkEmbossMaskFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698