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

Side by Side Diff: samplecode/SampleAndroidShadows.cpp

Issue 2255863002: Fix SampleAndroidShadows warnings (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 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 | « no previous file | no next file » | 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 /* 2 /*
3 * Copyright 2016 Google Inc. 3 * Copyright 2016 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkBlurMask.h" 9 #include "SkBlurMask.h"
10 #include "SkBlurMaskFilter.h" 10 #include "SkBlurMaskFilter.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 SkScalar maxScale = canvas->getTotalMatrix().getMaxScale(); 175 SkScalar maxScale = canvas->getTotalMatrix().getMaxScale();
176 radius *= maxScale; 176 radius *= maxScale;
177 unsigned char gray = (unsigned char)(ambientAlpha*umbraAlpha*255.999f); 177 unsigned char gray = (unsigned char)(ambientAlpha*umbraAlpha*255.999f);
178 SkASSERT(radius < 256); 178 SkASSERT(radius < 256);
179 // convert the radius to fixed point 8.8 and 179 // convert the radius to fixed point 8.8 and
180 // place it in the G,B components of the color 180 // place it in the G,B components of the color
181 unsigned char intPart = (unsigned char)radius; 181 unsigned char intPart = (unsigned char)radius;
182 SkScalar fracPart = radius - intPart; 182 SkScalar fracPart = radius - intPart;
183 paint.setColor(SkColorSetARGB(1, gray, intPart, (unsigned char)(fracPart *256.f))); 183 paint.setColor(SkColorSetARGB(1, gray, intPart, (unsigned char)(fracPart *256.f)));
184 184
185 sk_sp<SkShader> gaussShader = std::move(SkGaussianEdgeShader::Make()); 185 sk_sp<SkShader> gaussShader = SkGaussianEdgeShader::Make();
186 paint.setShader(gaussShader); 186 paint.setShader(gaussShader);
187 canvas->drawRRect(pathRRect, paint); 187 canvas->drawRRect(pathRRect, paint);
188 } 188 }
189 189
190 void drawSpotShadow(SkCanvas* canvas, const SkPath& path, SkScalar zValue, 190 void drawSpotShadow(SkCanvas* canvas, const SkPath& path, SkScalar zValue,
191 SkPoint3 lightPos, SkScalar lightWidth, SkScalar spotAlp ha) { 191 SkPoint3 lightPos, SkScalar lightWidth, SkScalar spotAlp ha) {
192 if (spotAlpha <= 0) { 192 if (spotAlpha <= 0) {
193 return; 193 return;
194 } 194 }
195 195
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 295
296 // compute the transformation params 296 // compute the transformation params
297 SkPoint center = SkPoint::Make(path.getBounds().centerX(), path.getBound s().centerY()); 297 SkPoint center = SkPoint::Make(path.getBounds().centerX(), path.getBound s().centerY());
298 canvas->getTotalMatrix().mapPoints(&center, 1); 298 canvas->getTotalMatrix().mapPoints(&center, 1);
299 SkPoint offset = SkPoint::Make(-zRatio*(lightPos.fX - center.fX), 299 SkPoint offset = SkPoint::Make(-zRatio*(lightPos.fX - center.fX),
300 -zRatio*(lightPos.fY - center.fY)); 300 -zRatio*(lightPos.fY - center.fY));
301 SkAutoCanvasRestore acr(canvas, true); 301 SkAutoCanvasRestore acr(canvas, true);
302 302
303 SkPaint paint; 303 SkPaint paint;
304 paint.setAntiAlias(true); 304 paint.setAntiAlias(true);
305 sk_sp<SkShader> gaussShader = std::move(SkGaussianEdgeShader::Make()); 305 sk_sp<SkShader> gaussShader = SkGaussianEdgeShader::Make();
306 paint.setShader(gaussShader); 306 paint.setShader(gaussShader);
307 // handle scale of radius due to CTM 307 // handle scale of radius due to CTM
308 SkScalar maxScale = canvas->getTotalMatrix().getMaxScale(); 308 SkScalar maxScale = canvas->getTotalMatrix().getMaxScale();
309 radius *= maxScale; 309 radius *= maxScale;
310 unsigned char gray = (unsigned char)(spotAlpha*255.999f); 310 unsigned char gray = (unsigned char)(spotAlpha*255.999f);
311 SkASSERT(radius < 256); 311 SkASSERT(radius < 256);
312 // convert the radius to fixed point 8.8 and 312 // convert the radius to fixed point 8.8 and
313 // place it in the G,B components of the color 313 // place it in the G,B components of the color
314 unsigned char intPart = (unsigned char)radius; 314 unsigned char intPart = (unsigned char)radius;
315 SkScalar fracPart = radius - intPart; 315 SkScalar fracPart = radius - intPart;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 } 412 }
413 413
414 private: 414 private:
415 typedef SkView INHERITED; 415 typedef SkView INHERITED;
416 }; 416 };
417 417
418 ////////////////////////////////////////////////////////////////////////////// 418 //////////////////////////////////////////////////////////////////////////////
419 419
420 static SkView* MyFactory() { return new ShadowsView; } 420 static SkView* MyFactory() { return new ShadowsView; }
421 static SkViewRegister reg(MyFactory); 421 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698