OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "gm.h" | 8 #include "gm.h" |
9 #include "SkLightingImageFilter.h" | 9 #include "SkLightingImageFilter.h" |
10 #include "SkOffsetImageFilter.h" | 10 #include "SkOffsetImageFilter.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 SkColor white(0xFFFFFFFF); | 78 SkColor white(0xFFFFFFFF); |
79 SkPaint paint; | 79 SkPaint paint; |
80 | 80 |
81 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(20, 10, 60, 65)); | 81 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(20, 10, 60, 65)); |
82 SkImageFilter::CropRect fullSizeCropRect(SkRect::MakeXYWH(0, 0, 100, 100
)); | 82 SkImageFilter::CropRect fullSizeCropRect(SkRect::MakeXYWH(0, 0, 100, 100
)); |
83 sk_sp<SkImageFilter> noopCropped(SkOffsetImageFilter::Make(0, 0, nullptr
, &cropRect)); | 83 sk_sp<SkImageFilter> noopCropped(SkOffsetImageFilter::Make(0, 0, nullptr
, &cropRect)); |
84 | 84 |
85 int y = 0; | 85 int y = 0; |
86 for (int i = 0; i < 3; i++) { | 86 for (int i = 0; i < 3; i++) { |
87 const SkImageFilter::CropRect* cr = (i == 1) ? &cropRect : (i == 2)
? &fullSizeCropRect : nullptr; | 87 const SkImageFilter::CropRect* cr = (i == 1) ? &cropRect : (i == 2)
? &fullSizeCropRect : nullptr; |
88 SkImageFilter* input = (i == 2) ? noopCropped.get() : nullptr; | 88 sk_sp<SkImageFilter> input = (i == 2) ? noopCropped : nullptr; |
89 paint.setImageFilter(SkLightingImageFilter::CreatePointLitDiffuse(po
intLocation, | 89 paint.setImageFilter(SkLightingImageFilter::MakePointLitDiffuse(poin
tLocation, |
| 90 whit
e, |
| 91 surf
aceScale, |
| 92 kd, |
| 93 inpu
t, |
| 94 cr))
; |
| 95 drawClippedBitmap(canvas, paint, 0, y); |
| 96 |
| 97 paint.setImageFilter(SkLightingImageFilter::MakeDistantLitDiffuse(di
stantDirection, |
90 wh
ite, | 98 wh
ite, |
91 su
rfaceScale, | 99 su
rfaceScale, |
92 kd
, | 100 kd
, |
93 in
put, | 101 in
put, |
94 cr
))->unref(); | 102 cr
)); |
95 drawClippedBitmap(canvas, paint, 0, y); | |
96 | |
97 paint.setImageFilter(SkLightingImageFilter::CreateDistantLitDiffuse(
distantDirection, | |
98
white, | |
99
surfaceScale, | |
100
kd, | |
101
input, | |
102
cr))->unref(); | |
103 drawClippedBitmap(canvas, paint, 110, y); | 103 drawClippedBitmap(canvas, paint, 110, y); |
104 | 104 |
105 paint.setImageFilter(SkLightingImageFilter::CreateSpotLitDiffuse(spo
tLocation, | 105 paint.setImageFilter(SkLightingImageFilter::MakeSpotLitDiffuse(spotL
ocation, |
106 spo
tTarget, | 106 spotT
arget, |
107 spo
tExponent, | 107 spotE
xponent, |
108 cut
offAngle, | 108 cutof
fAngle, |
109 whi
te, | 109 white
, |
110 sur
faceScale, | 110 surfa
ceScale, |
111 kd, | 111 kd, |
112 inp
ut, | 112 input
, |
113 cr)
)->unref(); | 113 cr)); |
114 drawClippedBitmap(canvas, paint, 220, y); | 114 drawClippedBitmap(canvas, paint, 220, y); |
115 | 115 |
116 y += 110; | 116 y += 110; |
117 | 117 |
118 paint.setImageFilter(SkLightingImageFilter::CreatePointLitSpecular(p
ointLocation, | 118 paint.setImageFilter(SkLightingImageFilter::MakePointLitSpecular(poi
ntLocation, |
| 119 whi
te, |
| 120 sur
faceScale, |
| 121 ks, |
| 122 shi
niness, |
| 123 inp
ut, |
| 124 cr)
); |
| 125 drawClippedBitmap(canvas, paint, 0, y); |
| 126 |
| 127 paint.setImageFilter(SkLightingImageFilter::MakeDistantLitSpecular(d
istantDirection, |
119 w
hite, | 128 w
hite, |
120 s
urfaceScale, | 129 s
urfaceScale, |
121 k
s, | 130 k
s, |
122 s
hininess, | 131 s
hininess, |
123 i
nput, | 132 i
nput, |
124 c
r))->unref(); | 133 c
r)); |
125 drawClippedBitmap(canvas, paint, 0, y); | |
126 | |
127 paint.setImageFilter(SkLightingImageFilter::CreateDistantLitSpecular
(distantDirection, | |
128
white, | |
129
surfaceScale, | |
130
ks, | |
131
shininess, | |
132
input, | |
133
cr))->unref(); | |
134 drawClippedBitmap(canvas, paint, 110, y); | 134 drawClippedBitmap(canvas, paint, 110, y); |
135 | 135 |
136 paint.setImageFilter(SkLightingImageFilter::CreateSpotLitSpecular(sp
otLocation, | 136 paint.setImageFilter(SkLightingImageFilter::MakeSpotLitSpecular(spot
Location, |
137 sp
otTarget, | 137 spot
Target, |
138 sp
otExponent, | 138 spot
Exponent, |
139 cu
toffAngle, | 139 cuto
ffAngle, |
140 wh
ite, | 140 whit
e, |
141 su
rfaceScale, | 141 surf
aceScale, |
142 ks
, | 142 ks, |
143 sh
ininess, | 143 shin
iness, |
144 in
put, | 144 inpu
t, |
145 cr
))->unref(); | 145 cr))
; |
146 drawClippedBitmap(canvas, paint, 220, y); | 146 drawClippedBitmap(canvas, paint, 220, y); |
147 | 147 |
148 y += 110; | 148 y += 110; |
149 } | 149 } |
150 } | 150 } |
151 | 151 |
152 private: | 152 private: |
153 SkBitmap fBitmap; | 153 SkBitmap fBitmap; |
154 | 154 |
155 typedef GM INHERITED; | 155 typedef GM INHERITED; |
156 }; | 156 }; |
157 | 157 |
158 ////////////////////////////////////////////////////////////////////////////// | 158 ////////////////////////////////////////////////////////////////////////////// |
159 | 159 |
160 DEF_GM(return new ImageLightingGM;) | 160 DEF_GM(return new ImageLightingGM;) |
161 } | 161 } |
OLD | NEW |