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

Side by Side Diff: samplecode/SampleSlides.cpp

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 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 | « samplecode/SampleShaders.cpp ('k') | samplecode/SampleStringArt.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 paint->setPathEffect(SkPath1DPathEffect::Create(path, SkIntToScalar(21), 0, 86 paint->setPathEffect(SkPath1DPathEffect::Create(path, SkIntToScalar(21), 0,
87 SkPath1DPathEffect::kRotate_ Style))->unref(); 87 SkPath1DPathEffect::kRotate_ Style))->unref();
88 compose_pe(paint); 88 compose_pe(paint);
89 } 89 }
90 90
91 typedef void (*PE_Proc)(SkPaint*); 91 typedef void (*PE_Proc)(SkPaint*);
92 static const PE_Proc gPE[] = { hair_pe, hair2_pe, stroke_pe, dash_pe, one_d_pe } ; 92 static const PE_Proc gPE[] = { hair_pe, hair2_pe, stroke_pe, dash_pe, one_d_pe } ;
93 93
94 static void fill_pe(SkPaint* paint) { 94 static void fill_pe(SkPaint* paint) {
95 paint->setStyle(SkPaint::kFill_Style); 95 paint->setStyle(SkPaint::kFill_Style);
96 paint->setPathEffect(NULL); 96 paint->setPathEffect(nullptr);
97 } 97 }
98 98
99 static void discrete_pe(SkPaint* paint) { 99 static void discrete_pe(SkPaint* paint) {
100 paint->setPathEffect(SkDiscretePathEffect::Create(10, 4))->unref(); 100 paint->setPathEffect(SkDiscretePathEffect::Create(10, 4))->unref();
101 } 101 }
102 102
103 static SkPathEffect* MakeTileEffect() { 103 static SkPathEffect* MakeTileEffect() {
104 SkMatrix m; 104 SkMatrix m;
105 m.setScale(SkIntToScalar(12), SkIntToScalar(12)); 105 m.setScale(SkIntToScalar(12), SkIntToScalar(12));
106 106
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 static const SkColor gColors[] = { 164 static const SkColor gColors[] = {
165 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK 165 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK
166 }; 166 };
167 static const SkScalar gPos0[] = { 0, SK_Scalar1 }; 167 static const SkScalar gPos0[] = { 0, SK_Scalar1 };
168 static const SkScalar gPos1[] = { SK_Scalar1/4, SK_Scalar1*3/4 }; 168 static const SkScalar gPos1[] = { SK_Scalar1/4, SK_Scalar1*3/4 };
169 static const SkScalar gPos2[] = { 169 static const SkScalar gPos2[] = {
170 0, SK_Scalar1/8, SK_Scalar1/2, SK_Scalar1*7/8, SK_Scalar1 170 0, SK_Scalar1/8, SK_Scalar1/2, SK_Scalar1*7/8, SK_Scalar1
171 }; 171 };
172 172
173 static const GradData gGradData[] = { 173 static const GradData gGradData[] = {
174 { 2, gColors, NULL }, 174 { 2, gColors, nullptr },
175 { 2, gColors, gPos0 }, 175 { 2, gColors, gPos0 },
176 { 2, gColors, gPos1 }, 176 { 2, gColors, gPos1 },
177 { 5, gColors, NULL }, 177 { 5, gColors, nullptr },
178 { 5, gColors, gPos2 } 178 { 5, gColors, gPos2 }
179 }; 179 };
180 180
181 static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data, SkShader ::TileMode tm) { 181 static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data, SkShader ::TileMode tm) {
182 return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos, data.fCo unt, tm); 182 return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos, data.fCo unt, tm);
183 } 183 }
184 184
185 static SkShader* MakeRadial(const SkPoint pts[2], const GradData& data, SkShader ::TileMode tm) { 185 static SkShader* MakeRadial(const SkPoint pts[2], const GradData& data, SkShader ::TileMode tm) {
186 SkPoint center; 186 SkPoint center;
187 center.set(SkScalarAve(pts[0].fX, pts[1].fX), 187 center.set(SkScalarAve(pts[0].fX, pts[1].fX),
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 len = strlen(text); 283 len = strlen(text);
284 SkScalar pathLen = getpathlen(path); 284 SkScalar pathLen = getpathlen(path);
285 SkMatrix matrix; 285 SkMatrix matrix;
286 286
287 paint.setColor(SK_ColorBLACK); 287 paint.setColor(SK_ColorBLACK);
288 paint.setStyle(SkPaint::kStroke_Style); 288 paint.setStyle(SkPaint::kStroke_Style);
289 canvas->drawPath(path, paint); 289 canvas->drawPath(path, paint);
290 paint.setStyle(SkPaint::kFill_Style); 290 paint.setStyle(SkPaint::kFill_Style);
291 291
292 paint.setTextSize(50); 292 paint.setTextSize(50);
293 canvas->drawTextOnPath(text, len, path, NULL, paint); 293 canvas->drawTextOnPath(text, len, path, nullptr, paint);
294 294
295 paint.setColor(SK_ColorRED); 295 paint.setColor(SK_ColorRED);
296 matrix.setScale(-SK_Scalar1, SK_Scalar1); 296 matrix.setScale(-SK_Scalar1, SK_Scalar1);
297 matrix.postTranslate(pathLen, 0); 297 matrix.postTranslate(pathLen, 0);
298 canvas->drawTextOnPath(text, len, path, &matrix, paint); 298 canvas->drawTextOnPath(text, len, path, &matrix, paint);
299 299
300 paint.setColor(SK_ColorBLUE); 300 paint.setColor(SK_ColorBLUE);
301 matrix.setScale(SK_Scalar1, -SK_Scalar1); 301 matrix.setScale(SK_Scalar1, -SK_Scalar1);
302 canvas->drawTextOnPath(text, len, path, &matrix, paint); 302 canvas->drawTextOnPath(text, len, path, &matrix, paint);
303 303
(...skipping 16 matching lines...) Expand all
320 SkImageDecoder::DecodeFile("/skimages/logo.gif", &bm); 320 SkImageDecoder::DecodeFile("/skimages/logo.gif", &bm);
321 size->set(bm.width(), bm.height()); 321 size->set(bm.width(), bm.height());
322 return SkShader::CreateBitmapShader(bm, SkShader::kClamp_TileMode, 322 return SkShader::CreateBitmapShader(bm, SkShader::kClamp_TileMode,
323 SkShader::kClamp_TileMode); 323 SkShader::kClamp_TileMode);
324 } 324 }
325 325
326 static SkShader* make_shader1(const SkIPoint& size) { 326 static SkShader* make_shader1(const SkIPoint& size) {
327 SkPoint pts[] = { { 0, 0 }, 327 SkPoint pts[] = { { 0, 0 },
328 { SkIntToScalar(size.fX), SkIntToScalar(size.fY) } }; 328 { SkIntToScalar(size.fX), SkIntToScalar(size.fY) } };
329 SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorRED } ; 329 SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorRED } ;
330 return SkGradientShader::CreateLinear(pts, colors, NULL, 330 return SkGradientShader::CreateLinear(pts, colors, nullptr,
331 SK_ARRAY_COUNT(colors), SkShader::kMir ror_TileMode); 331 SK_ARRAY_COUNT(colors), SkShader::kMir ror_TileMode);
332 } 332 }
333 333
334 class Rec { 334 class Rec {
335 public: 335 public:
336 SkCanvas::VertexMode fMode; 336 SkCanvas::VertexMode fMode;
337 int fCount; 337 int fCount;
338 SkPoint* fVerts; 338 SkPoint* fVerts;
339 SkPoint* fTexs; 339 SkPoint* fTexs;
340 340
341 Rec() : fCount(0), fVerts(NULL), fTexs(NULL) {} 341 Rec() : fCount(0), fVerts(nullptr), fTexs(nullptr) {}
342 ~Rec() { delete[] fVerts; delete[] fTexs; } 342 ~Rec() { delete[] fVerts; delete[] fTexs; }
343 }; 343 };
344 344
345 static void make_tris(Rec* rec) { 345 static void make_tris(Rec* rec) {
346 int n = 10; 346 int n = 10;
347 SkRandom rand; 347 SkRandom rand;
348 348
349 rec->fMode = SkCanvas::kTriangles_VertexMode; 349 rec->fMode = SkCanvas::kTriangles_VertexMode;
350 rec->fCount = n * 3; 350 rec->fCount = n * 3;
351 rec->fVerts = new SkPoint[rec->fCount]; 351 rec->fVerts = new SkPoint[rec->fCount];
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 make_fan(&fRecs[1], size.fX, size.fY); 436 make_fan(&fRecs[1], size.fX, size.fY);
437 make_tris(&fRecs[2]); 437 make_tris(&fRecs[2]);
438 438
439 SkPaint paint; 439 SkPaint paint;
440 paint.setDither(true); 440 paint.setDither(true);
441 paint.setFilterQuality(kLow_SkFilterQuality); 441 paint.setFilterQuality(kLow_SkFilterQuality);
442 442
443 for (size_t i = 0; i < SK_ARRAY_COUNT(fRecs); i++) { 443 for (size_t i = 0; i < SK_ARRAY_COUNT(fRecs); i++) {
444 canvas->save(); 444 canvas->save();
445 445
446 paint.setShader(NULL); 446 paint.setShader(nullptr);
447 canvas->drawVertices(fRecs[i].fMode, fRecs[i].fCount, 447 canvas->drawVertices(fRecs[i].fMode, fRecs[i].fCount,
448 fRecs[i].fVerts, fRecs[i].fTexs, 448 fRecs[i].fVerts, fRecs[i].fTexs,
449 NULL, NULL, NULL, 0, paint); 449 nullptr, nullptr, nullptr, 0, paint);
450 450
451 canvas->translate(SkIntToScalar(210), 0); 451 canvas->translate(SkIntToScalar(210), 0);
452 452
453 paint.setShader(fShader0); 453 paint.setShader(fShader0);
454 canvas->drawVertices(fRecs[i].fMode, fRecs[i].fCount, 454 canvas->drawVertices(fRecs[i].fMode, fRecs[i].fCount,
455 fRecs[i].fVerts, fRecs[i].fTexs, 455 fRecs[i].fVerts, fRecs[i].fTexs,
456 NULL, NULL, NULL, 0, paint); 456 nullptr, nullptr, nullptr, 0, paint);
457 457
458 canvas->translate(SkIntToScalar(210), 0); 458 canvas->translate(SkIntToScalar(210), 0);
459 459
460 paint.setShader(fShader1); 460 paint.setShader(fShader1);
461 canvas->drawVertices(fRecs[i].fMode, fRecs[i].fCount, 461 canvas->drawVertices(fRecs[i].fMode, fRecs[i].fCount,
462 fRecs[i].fVerts, fRecs[i].fTexs, 462 fRecs[i].fVerts, fRecs[i].fTexs,
463 NULL, NULL, NULL, 0, paint); 463 nullptr, nullptr, nullptr, 0, paint);
464 canvas->restore(); 464 canvas->restore();
465 465
466 canvas->translate(0, SkIntToScalar(250)); 466 canvas->translate(0, SkIntToScalar(250));
467 } 467 }
468 } 468 }
469 469
470 /////////////////////////////////////////////////////////////////////////////// 470 ///////////////////////////////////////////////////////////////////////////////
471 471
472 static void r0(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) 472 static void r0(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p)
473 { 473 {
474 p.setMaskFilter(SkBlurMaskFilter::Create(kNormal_SkBlurStyle, 474 p.setMaskFilter(SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
475 SkBlurMask::ConvertRadiusToSigma(Sk IntToScalar(3))))->unref(); 475 SkBlurMask::ConvertRadiusToSigma(Sk IntToScalar(3))))->unref();
476 rastBuilder->addLayer(p, SkIntToScalar(3), SkIntToScalar(3)); 476 rastBuilder->addLayer(p, SkIntToScalar(3), SkIntToScalar(3));
477 477
478 p.setMaskFilter(NULL); 478 p.setMaskFilter(nullptr);
479 p.setStyle(SkPaint::kStroke_Style); 479 p.setStyle(SkPaint::kStroke_Style);
480 p.setStrokeWidth(SK_Scalar1); 480 p.setStrokeWidth(SK_Scalar1);
481 rastBuilder->addLayer(p); 481 rastBuilder->addLayer(p);
482 482
483 p.setAlpha(0x11); 483 p.setAlpha(0x11);
484 p.setStyle(SkPaint::kFill_Style); 484 p.setStyle(SkPaint::kFill_Style);
485 p.setXfermodeMode(SkXfermode::kSrc_Mode); 485 p.setXfermodeMode(SkXfermode::kSrc_Mode);
486 rastBuilder->addLayer(p); 486 rastBuilder->addLayer(p);
487 } 487 }
488 488
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 523
524 static void r4(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) 524 static void r4(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p)
525 { 525 {
526 p.setAlpha(0x60); 526 p.setAlpha(0x60);
527 rastBuilder->addLayer(p, SkIntToScalar(3), SkIntToScalar(3)); 527 rastBuilder->addLayer(p, SkIntToScalar(3), SkIntToScalar(3));
528 528
529 p.setAlpha(0xFF); 529 p.setAlpha(0xFF);
530 p.setXfermodeMode(SkXfermode::kClear_Mode); 530 p.setXfermodeMode(SkXfermode::kClear_Mode);
531 rastBuilder->addLayer(p, SK_Scalar1*3/2, SK_Scalar1*3/2); 531 rastBuilder->addLayer(p, SK_Scalar1*3/2, SK_Scalar1*3/2);
532 532
533 p.setXfermode(NULL); 533 p.setXfermode(nullptr);
534 rastBuilder->addLayer(p); 534 rastBuilder->addLayer(p);
535 } 535 }
536 536
537 #include "SkDiscretePathEffect.h" 537 #include "SkDiscretePathEffect.h"
538 538
539 static void r5(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) 539 static void r5(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p)
540 { 540 {
541 rastBuilder->addLayer(p); 541 rastBuilder->addLayer(p);
542 542
543 p.setPathEffect(SkDiscretePathEffect::Create(SK_Scalar1*4, SK_Scalar1*3))->u nref(); 543 p.setPathEffect(SkDiscretePathEffect::Create(SK_Scalar1*4, SK_Scalar1*3))->u nref();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 { 578 {
579 rastBuilder->addLayer(p); 579 rastBuilder->addLayer(p);
580 580
581 SkMatrix lattice; 581 SkMatrix lattice;
582 lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0); 582 lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0);
583 lattice.postSkew(SK_Scalar1/3, 0, 0, 0); 583 lattice.postSkew(SK_Scalar1/3, 0, 0, 0);
584 p.setPathEffect(MakeDotEffect(SK_Scalar1*2, lattice))->unref(); 584 p.setPathEffect(MakeDotEffect(SK_Scalar1*2, lattice))->unref();
585 p.setXfermodeMode(SkXfermode::kClear_Mode); 585 p.setXfermodeMode(SkXfermode::kClear_Mode);
586 rastBuilder->addLayer(p); 586 rastBuilder->addLayer(p);
587 587
588 p.setPathEffect(NULL); 588 p.setPathEffect(nullptr);
589 p.setXfermode(NULL); 589 p.setXfermode(nullptr);
590 p.setStyle(SkPaint::kStroke_Style); 590 p.setStyle(SkPaint::kStroke_Style);
591 p.setStrokeWidth(SK_Scalar1); 591 p.setStrokeWidth(SK_Scalar1);
592 rastBuilder->addLayer(p); 592 rastBuilder->addLayer(p);
593 } 593 }
594 594
595 static void r9(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) 595 static void r9(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p)
596 { 596 {
597 rastBuilder->addLayer(p); 597 rastBuilder->addLayer(p);
598 598
599 SkMatrix lattice; 599 SkMatrix lattice;
600 lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0); 600 lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0);
601 lattice.postRotate(SkIntToScalar(30), 0, 0); 601 lattice.postRotate(SkIntToScalar(30), 0, 0);
602 p.setPathEffect(SkLine2DPathEffect::Create(SK_Scalar1*2, lattice))->unref(); 602 p.setPathEffect(SkLine2DPathEffect::Create(SK_Scalar1*2, lattice))->unref();
603 p.setXfermodeMode(SkXfermode::kClear_Mode); 603 p.setXfermodeMode(SkXfermode::kClear_Mode);
604 rastBuilder->addLayer(p); 604 rastBuilder->addLayer(p);
605 605
606 p.setPathEffect(NULL); 606 p.setPathEffect(nullptr);
607 p.setXfermode(NULL); 607 p.setXfermode(nullptr);
608 p.setStyle(SkPaint::kStroke_Style); 608 p.setStyle(SkPaint::kStroke_Style);
609 p.setStrokeWidth(SK_Scalar1); 609 p.setStrokeWidth(SK_Scalar1);
610 rastBuilder->addLayer(p); 610 rastBuilder->addLayer(p);
611 } 611 }
612 612
613 typedef void (*raster_proc)(SkLayerRasterizer::Builder*, SkPaint&); 613 typedef void (*raster_proc)(SkLayerRasterizer::Builder*, SkPaint&);
614 614
615 static const raster_proc gRastProcs[] = { 615 static const raster_proc gRastProcs[] = {
616 r0, r1, r2, r3, r4, r5, r6, r7, r8, r9 616 r0, r1, r2, r3, r4, r5, r6, r7, r8, r9
617 }; 617 };
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 } 706 }
707 707
708 void onDrawContent(SkCanvas* canvas) override { 708 void onDrawContent(SkCanvas* canvas) override {
709 this->init(); 709 this->init();
710 gProc[fIndex](canvas); 710 gProc[fIndex](canvas);
711 } 711 }
712 712
713 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned) override { 713 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned) override {
714 this->init(); 714 this->init();
715 fIndex = (fIndex + 1) % SK_ARRAY_COUNT(gProc); 715 fIndex = (fIndex + 1) % SK_ARRAY_COUNT(gProc);
716 this->inval(NULL); 716 this->inval(nullptr);
717 return NULL; 717 return nullptr;
718 } 718 }
719 719
720 private: 720 private:
721 typedef SampleView INHERITED; 721 typedef SampleView INHERITED;
722 }; 722 };
723 723
724 ////////////////////////////////////////////////////////////////////////////// 724 //////////////////////////////////////////////////////////////////////////////
725 725
726 static SkView* MyFactory() { return new SlideView; } 726 static SkView* MyFactory() { return new SlideView; }
727 static SkViewRegister reg(MyFactory); 727 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleShaders.cpp ('k') | samplecode/SampleStringArt.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698