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

Side by Side Diff: gm/lighting.cpp

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/imagefiltersscaled.cpp ('k') | include/effects/SkLightingImageFilter.h » ('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 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 "SkAnimTimer.h" 9 #include "SkAnimTimer.h"
10 #include "SkLightingImageFilter.h" 10 #include "SkLightingImageFilter.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 SkColor white(0xFFFFFFFF); 86 SkColor white(0xFFFFFFFF);
87 SkPaint paint; 87 SkPaint paint;
88 88
89 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(20, 10, 60, 65)); 89 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(20, 10, 60, 65));
90 SkImageFilter::CropRect fullSizeCropRect(SkRect::MakeXYWH(0, 0, 100, 100 )); 90 SkImageFilter::CropRect fullSizeCropRect(SkRect::MakeXYWH(0, 0, 100, 100 ));
91 sk_sp<SkImageFilter> noopCropped(SkOffsetImageFilter::Make(0, 0, nullptr , &cropRect)); 91 sk_sp<SkImageFilter> noopCropped(SkOffsetImageFilter::Make(0, 0, nullptr , &cropRect));
92 92
93 int y = 0; 93 int y = 0;
94 for (int i = 0; i < 3; i++) { 94 for (int i = 0; i < 3; i++) {
95 const SkImageFilter::CropRect* cr = (i == 1) ? &cropRect : (i == 2) ? &fullSizeCropRect : nullptr; 95 const SkImageFilter::CropRect* cr = (i == 1) ? &cropRect : (i == 2) ? &fullSizeCropRect : nullptr;
96 SkImageFilter* input = (i == 2) ? noopCropped.get() : nullptr; 96 sk_sp<SkImageFilter> input = (i == 2) ? noopCropped : nullptr;
97 paint.setImageFilter(SkLightingImageFilter::CreatePointLitDiffuse(po intLocation, 97 paint.setImageFilter(SkLightingImageFilter::MakePointLitDiffuse(poin tLocation,
98 whit e,
99 surf aceScale,
100 kd,
101 inpu t,
102 cr)) ;
103 drawClippedBitmap(canvas, paint, 0, y);
104
105 paint.setImageFilter(SkLightingImageFilter::MakeDistantLitDiffuse(di stantDirection,
98 wh ite, 106 wh ite,
99 su rfaceScale, 107 su rfaceScale,
100 kd , 108 kd ,
101 in put, 109 in put,
102 cr ))->unref(); 110 cr ));
103 drawClippedBitmap(canvas, paint, 0, y);
104
105 paint.setImageFilter(SkLightingImageFilter::CreateDistantLitDiffuse( distantDirection,
106 white,
107 surfaceScale,
108 kd,
109 input,
110 cr))->unref();
111 drawClippedBitmap(canvas, paint, 110, y); 111 drawClippedBitmap(canvas, paint, 110, y);
112 112
113 paint.setImageFilter(SkLightingImageFilter::CreateSpotLitDiffuse(spo tLocation, 113 paint.setImageFilter(SkLightingImageFilter::MakeSpotLitDiffuse(spotL ocation,
114 spo tTarget, 114 spotT arget,
115 spo tExponent, 115 spotE xponent,
116 cut offAngle, 116 cutof fAngle,
117 whi te, 117 white ,
118 sur faceScale, 118 surfa ceScale,
119 kd, 119 kd,
120 inp ut, 120 input ,
121 cr) )->unref(); 121 cr));
122 drawClippedBitmap(canvas, paint, 220, y); 122 drawClippedBitmap(canvas, paint, 220, y);
123 123
124 y += 110; 124 y += 110;
125 125
126 paint.setImageFilter(SkLightingImageFilter::CreatePointLitSpecular(p ointLocation, 126 paint.setImageFilter(SkLightingImageFilter::MakePointLitSpecular(poi ntLocation,
127 whi te,
128 sur faceScale,
129 ks,
130 shi niness,
131 inp ut,
132 cr) );
133 drawClippedBitmap(canvas, paint, 0, y);
134
135 paint.setImageFilter(SkLightingImageFilter::MakeDistantLitSpecular(d istantDirection,
127 w hite, 136 w hite,
128 s urfaceScale, 137 s urfaceScale,
129 k s, 138 k s,
130 s hininess, 139 s hininess,
131 i nput, 140 i nput,
132 c r))->unref(); 141 c r));
133 drawClippedBitmap(canvas, paint, 0, y);
134
135 paint.setImageFilter(SkLightingImageFilter::CreateDistantLitSpecular (distantDirection,
136 white,
137 surfaceScale,
138 ks,
139 shininess,
140 input,
141 cr))->unref();
142 drawClippedBitmap(canvas, paint, 110, y); 142 drawClippedBitmap(canvas, paint, 110, y);
143 143
144 paint.setImageFilter(SkLightingImageFilter::CreateSpotLitSpecular(sp otLocation, 144 paint.setImageFilter(SkLightingImageFilter::MakeSpotLitSpecular(spot Location,
145 sp otTarget, 145 spot Target,
146 sp otExponent, 146 spot Exponent,
147 cu toffAngle, 147 cuto ffAngle,
148 wh ite, 148 whit e,
149 su rfaceScale, 149 surf aceScale,
150 ks , 150 ks,
151 sh ininess, 151 shin iness,
152 in put, 152 inpu t,
153 cr ))->unref(); 153 cr)) ;
154 drawClippedBitmap(canvas, paint, 220, y); 154 drawClippedBitmap(canvas, paint, 220, y);
155 155
156 y += 110; 156 y += 110;
157 } 157 }
158 } 158 }
159 159
160 bool onAnimate(const SkAnimTimer& timer) override { 160 bool onAnimate(const SkAnimTimer& timer) override {
161 static const SkScalar kDesiredDurationSecs = 15.0f; 161 static const SkScalar kDesiredDurationSecs = 15.0f;
162 162
163 fAzimuth = kStartAzimuth + timer.scaled(360.0f/kDesiredDurationSecs, 360 .0f); 163 fAzimuth = kStartAzimuth + timer.scaled(360.0f/kDesiredDurationSecs, 360 .0f);
164 return true; 164 return true;
165 } 165 }
166 166
167 private: 167 private:
168 static const int kStartAzimuth = 225; 168 static const int kStartAzimuth = 225;
169 169
170 SkBitmap fBitmap; 170 SkBitmap fBitmap;
171 SkScalar fAzimuth; 171 SkScalar fAzimuth;
172 172
173 typedef GM INHERITED; 173 typedef GM INHERITED;
174 }; 174 };
175 175
176 ////////////////////////////////////////////////////////////////////////////// 176 //////////////////////////////////////////////////////////////////////////////
177 177
178 DEF_GM(return new ImageLightingGM;) 178 DEF_GM(return new ImageLightingGM;)
179 } 179 }
OLDNEW
« no previous file with comments | « gm/imagefiltersscaled.cpp ('k') | include/effects/SkLightingImageFilter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698