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

Side by Side Diff: include/effects/SkLightingImageFilter.h

Issue 1869763002: Update LightingImageFilter to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address code review comments 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 | « gm/lighting.cpp ('k') | samplecode/SampleFilterFuzz.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 2012 The Android Open Source Project 2 * Copyright 2012 The Android Open Source Project
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 #ifndef SkLightingImageFilter_DEFINED 8 #ifndef SkLightingImageFilter_DEFINED
9 #define SkLightingImageFilter_DEFINED 9 #define SkLightingImageFilter_DEFINED
10 10
11 #include "SkImageFilter.h" 11 #include "SkImageFilter.h"
12 #include "SkColor.h" 12 #include "SkColor.h"
13 13
14 14
15 class SkImageFilterLight; 15 class SkImageFilterLight;
16 struct SkPoint3; 16 struct SkPoint3;
17 17
18 class SK_API SkLightingImageFilter : public SkImageFilter { 18 class SK_API SkLightingImageFilter : public SkImageFilter {
19 public: 19 public:
20 static SkImageFilter* CreateDistantLitDiffuse(const SkPoint3& direction, 20 static sk_sp<SkImageFilter> MakeDistantLitDiffuse(const SkPoint3& direction,
21 SkColor lightColor, SkScalar surfaceScale, SkScalar kd, 21 SkColor lightColor, SkScalar surfaceScale, SkScalar kd,
22 SkImageFilter* input = NULL, const CropRect* cropRect = NULL); 22 sk_sp<SkImageFilter> input, const CropRect* cropRect = nullptr);
23 static sk_sp<SkImageFilter> MakePointLitDiffuse(const SkPoint3& location,
24 SkColor lightColor, SkScalar surfaceScale, SkScalar kd,
25 sk_sp<SkImageFilter> input, const CropRect* cropRect = nullptr);
26 static sk_sp<SkImageFilter> MakeSpotLitDiffuse(const SkPoint3& location,
27 const SkPoint3& target, SkScalar specularExponent, SkScalar cutoffAngle,
28 SkColor lightColor, SkScalar surfaceScale, SkScalar kd,
29 sk_sp<SkImageFilter> input, const CropRect* cropRect = nullptr);
30 static sk_sp<SkImageFilter> MakeDistantLitSpecular(const SkPoint3& direction ,
31 SkColor lightColor, SkScalar surfaceScale, SkScalar ks,
32 SkScalar shininess, sk_sp<SkImageFilter> input, const CropRect* cropRect = nullptr);
33 static sk_sp<SkImageFilter> MakePointLitSpecular(const SkPoint3& location,
34 SkColor lightColor, SkScalar surfaceScale, SkScalar ks,
35 SkScalar shininess, sk_sp<SkImageFilter> input, const CropRect* cropRect = nullptr);
36 static sk_sp<SkImageFilter> MakeSpotLitSpecular(const SkPoint3& location,
37 const SkPoint3& target, SkScalar specularExponent, SkScalar cutoffAngle,
38 SkColor lightColor, SkScalar surfaceScale, SkScalar ks,
39 SkScalar shininess, sk_sp<SkImageFilter> input, const CropRect* cropRect = nullptr);
40
41 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
42
43 #ifdef SK_SUPPORT_LEGACY_IMAGEFILTER_PTR
44 static SkImageFilter* CreateDistantLitDiffuse(const SkPoint3& direction,
45 SkColor lightColor, SkScalar surfaceScale, SkScalar kd,
46 SkImageFilter* input = NULL, const CropRect* cropRect = NULL) {
47 return MakeDistantLitDiffuse(direction, lightColor, surfaceScale, kd,
48 sk_ref_sp<SkImageFilter>(input), cropRect). release();
49 }
23 static SkImageFilter* CreatePointLitDiffuse(const SkPoint3& location, 50 static SkImageFilter* CreatePointLitDiffuse(const SkPoint3& location,
24 SkColor lightColor, SkScalar surfaceScale, SkScalar kd, 51 SkColor lightColor, SkScalar surfaceScale, SkScalar kd,
25 SkImageFilter* input = NULL, const CropRect* cropRect = NULL); 52 SkImageFilter* input = NULL, const CropRect* cropRect = NULL) {
53 return MakePointLitDiffuse(location, lightColor, surfaceScale, kd,
54 sk_ref_sp<SkImageFilter>(input), cropRect).re lease();
55 }
26 static SkImageFilter* CreateSpotLitDiffuse(const SkPoint3& location, 56 static SkImageFilter* CreateSpotLitDiffuse(const SkPoint3& location,
27 const SkPoint3& target, SkScalar specularExponent, SkScalar cutoffAngle, 57 const SkPoint3& target, SkScalar specularExponent, SkScalar cutoffAngle,
28 SkColor lightColor, SkScalar surfaceScale, SkScalar kd, 58 SkColor lightColor, SkScalar surfaceScale, SkScalar kd,
29 SkImageFilter* input = NULL, const CropRect* cropRect = NULL); 59 SkImageFilter* input = NULL, const CropRect* cropRect = NULL) {
60 return MakeSpotLitDiffuse(location, target, specularExponent, cutoffAngl e,
61 lightColor, surfaceScale, kd,
62 sk_ref_sp<SkImageFilter>(input), cropRect).rel ease();
63 }
30 static SkImageFilter* CreateDistantLitSpecular(const SkPoint3& direction, 64 static SkImageFilter* CreateDistantLitSpecular(const SkPoint3& direction,
31 SkColor lightColor, SkScalar surfaceScale, SkScalar ks, 65 SkColor lightColor, SkScalar surfaceScale, SkScalar ks,
32 SkScalar shininess, SkImageFilter* input = NULL, const CropRect* cropRec t = NULL); 66 SkScalar shininess, SkImageFilter* input = NULL, const CropRect* cropRec t = NULL) {
67 return MakeDistantLitSpecular(direction, lightColor, surfaceScale, ks, s hininess,
68 sk_ref_sp<SkImageFilter>(input), cropRect) .release();
69 }
33 static SkImageFilter* CreatePointLitSpecular(const SkPoint3& location, 70 static SkImageFilter* CreatePointLitSpecular(const SkPoint3& location,
34 SkColor lightColor, SkScalar surfaceScale, SkScalar ks, 71 SkColor lightColor, SkScalar surfaceScale, SkScalar ks,
35 SkScalar shininess, SkImageFilter* input = NULL, const CropRect* cropRec t = NULL); 72 SkScalar shininess, SkImageFilter* input = NULL, const CropRect* cropRec t = NULL) {
73 return MakePointLitSpecular(location, lightColor, surfaceScale, ks, shin iness,
74 sk_ref_sp<SkImageFilter>(input), cropRect).r elease();
75 }
36 static SkImageFilter* CreateSpotLitSpecular(const SkPoint3& location, 76 static SkImageFilter* CreateSpotLitSpecular(const SkPoint3& location,
37 const SkPoint3& target, SkScalar specularExponent, SkScalar cutoffAngle, 77 const SkPoint3& target, SkScalar specularExponent, SkScalar cutoffAngle,
38 SkColor lightColor, SkScalar surfaceScale, SkScalar ks, 78 SkColor lightColor, SkScalar surfaceScale, SkScalar ks,
39 SkScalar shininess, SkImageFilter* input = NULL, const CropRect* cropRec t = NULL); 79 SkScalar shininess, SkImageFilter* input = NULL, const CropRect* cropRec t = NULL) {
40 ~SkLightingImageFilter(); 80 return MakeSpotLitSpecular(location, target, specularExponent, cutoffAng le,
41 81 lightColor, surfaceScale, ks, shininess,
42 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() 82 sk_ref_sp<SkImageFilter>(input), cropRect).re lease();
83 }
84 #endif
43 85
44 protected: 86 protected:
45 SkLightingImageFilter(SkImageFilterLight* light, 87 SkLightingImageFilter(sk_sp<SkImageFilterLight> light,
46 SkScalar surfaceScale, 88 SkScalar surfaceScale,
47 SkImageFilter* input, 89 sk_sp<SkImageFilter> input,
48 const CropRect* cropRect); 90 const CropRect* cropRect);
49 void flatten(SkWriteBuffer&) const override; 91 void flatten(SkWriteBuffer&) const override;
50 const SkImageFilterLight* light() const { return fLight.get(); } 92 const SkImageFilterLight* light() const { return fLight.get(); }
51 SkScalar surfaceScale() const { return fSurfaceScale; } 93 SkScalar surfaceScale() const { return fSurfaceScale; }
52 bool affectsTransparentBlack() const override { return true; } 94 bool affectsTransparentBlack() const override { return true; }
53 95
54 private: 96 private:
97 sk_sp<SkImageFilterLight> fLight;
98 SkScalar fSurfaceScale;
99
55 typedef SkImageFilter INHERITED; 100 typedef SkImageFilter INHERITED;
56 SkAutoTUnref<SkImageFilterLight> fLight;
57 SkScalar fSurfaceScale;
58 }; 101 };
59 102
60 #endif 103 #endif
OLDNEW
« no previous file with comments | « gm/lighting.cpp ('k') | samplecode/SampleFilterFuzz.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698