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

Side by Side Diff: samplecode/SampleAll.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/SampleAARectModes.cpp ('k') | samplecode/SampleAnimator.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 "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 }; 77 };
78 78
79 /////////////////////////////////////////////////////////// 79 ///////////////////////////////////////////////////////////
80 80
81 static void r0(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { 81 static void r0(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
82 p.setMaskFilter(SkBlurMaskFilter::Create(kNormal_SkBlurStyle, 82 p.setMaskFilter(SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
83 SkBlurMask::ConvertRadiusToSigma(Sk IntToScalar(3)), 83 SkBlurMask::ConvertRadiusToSigma(Sk IntToScalar(3)),
84 SkBlurMaskFilter::kNone_BlurFlag))- >unref(); 84 SkBlurMaskFilter::kNone_BlurFlag))- >unref();
85 rastBuilder->addLayer(p, SkIntToScalar(3), SkIntToScalar(3)); 85 rastBuilder->addLayer(p, SkIntToScalar(3), SkIntToScalar(3));
86 86
87 p.setMaskFilter(NULL); 87 p.setMaskFilter(nullptr);
88 p.setStyle(SkPaint::kStroke_Style); 88 p.setStyle(SkPaint::kStroke_Style);
89 p.setStrokeWidth(SK_Scalar1); 89 p.setStrokeWidth(SK_Scalar1);
90 rastBuilder->addLayer(p); 90 rastBuilder->addLayer(p);
91 91
92 p.setAlpha(0x11); 92 p.setAlpha(0x11);
93 p.setStyle(SkPaint::kFill_Style); 93 p.setStyle(SkPaint::kFill_Style);
94 p.setXfermodeMode(SkXfermode::kSrc_Mode); 94 p.setXfermodeMode(SkXfermode::kSrc_Mode);
95 rastBuilder->addLayer(p); 95 rastBuilder->addLayer(p);
96 } 96 }
97 97
(...skipping 30 matching lines...) Expand all
128 } 128 }
129 129
130 static void r4(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { 130 static void r4(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
131 p.setAlpha(0x60); 131 p.setAlpha(0x60);
132 rastBuilder->addLayer(p, SkIntToScalar(3), SkIntToScalar(3)); 132 rastBuilder->addLayer(p, SkIntToScalar(3), SkIntToScalar(3));
133 133
134 p.setAlpha(0xFF); 134 p.setAlpha(0xFF);
135 p.setXfermodeMode(SkXfermode::kClear_Mode); 135 p.setXfermodeMode(SkXfermode::kClear_Mode);
136 rastBuilder->addLayer(p, SK_Scalar1*3/2, SK_Scalar1*3/2); 136 rastBuilder->addLayer(p, SK_Scalar1*3/2, SK_Scalar1*3/2);
137 137
138 p.setXfermode(NULL); 138 p.setXfermode(nullptr);
139 rastBuilder->addLayer(p); 139 rastBuilder->addLayer(p);
140 } 140 }
141 141
142 static void r5(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { 142 static void r5(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
143 rastBuilder->addLayer(p); 143 rastBuilder->addLayer(p);
144 144
145 p.setPathEffect(SkDiscretePathEffect::Create(SK_Scalar1*4, SK_Scalar1*3))->u nref(); 145 p.setPathEffect(SkDiscretePathEffect::Create(SK_Scalar1*4, SK_Scalar1*3))->u nref();
146 p.setXfermodeMode(SkXfermode::kSrcOut_Mode); 146 p.setXfermodeMode(SkXfermode::kSrcOut_Mode);
147 rastBuilder->addLayer(p); 147 rastBuilder->addLayer(p);
148 } 148 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 static void r8(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { 192 static void r8(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
193 rastBuilder->addLayer(p); 193 rastBuilder->addLayer(p);
194 194
195 SkMatrix lattice; 195 SkMatrix lattice;
196 lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0); 196 lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0);
197 lattice.postSkew(SK_Scalar1/3, 0, 0, 0); 197 lattice.postSkew(SK_Scalar1/3, 0, 0, 0);
198 p.setPathEffect(new Dot2DPathEffect(SK_Scalar1*2, lattice))->unref(); 198 p.setPathEffect(new Dot2DPathEffect(SK_Scalar1*2, lattice))->unref();
199 p.setXfermodeMode(SkXfermode::kClear_Mode); 199 p.setXfermodeMode(SkXfermode::kClear_Mode);
200 rastBuilder->addLayer(p); 200 rastBuilder->addLayer(p);
201 201
202 p.setPathEffect(NULL); 202 p.setPathEffect(nullptr);
203 p.setXfermode(NULL); 203 p.setXfermode(nullptr);
204 p.setStyle(SkPaint::kStroke_Style); 204 p.setStyle(SkPaint::kStroke_Style);
205 p.setStrokeWidth(SK_Scalar1); 205 p.setStrokeWidth(SK_Scalar1);
206 rastBuilder->addLayer(p); 206 rastBuilder->addLayer(p);
207 } 207 }
208 208
209 static void r9(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { 209 static void r9(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
210 rastBuilder->addLayer(p); 210 rastBuilder->addLayer(p);
211 211
212 SkMatrix lattice; 212 SkMatrix lattice;
213 lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0); 213 lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0);
214 lattice.postRotate(SkIntToScalar(30), 0, 0); 214 lattice.postRotate(SkIntToScalar(30), 0, 0);
215 p.setPathEffect(SkLine2DPathEffect::Create(SK_Scalar1*2, lattice))->unref(); 215 p.setPathEffect(SkLine2DPathEffect::Create(SK_Scalar1*2, lattice))->unref();
216 p.setXfermodeMode(SkXfermode::kClear_Mode); 216 p.setXfermodeMode(SkXfermode::kClear_Mode);
217 rastBuilder->addLayer(p); 217 rastBuilder->addLayer(p);
218 218
219 p.setPathEffect(NULL); 219 p.setPathEffect(nullptr);
220 p.setXfermode(NULL); 220 p.setXfermode(nullptr);
221 p.setStyle(SkPaint::kStroke_Style); 221 p.setStyle(SkPaint::kStroke_Style);
222 p.setStrokeWidth(SK_Scalar1); 222 p.setStrokeWidth(SK_Scalar1);
223 rastBuilder->addLayer(p); 223 rastBuilder->addLayer(p);
224 } 224 }
225 225
226 typedef void (*raster_proc)(SkLayerRasterizer::Builder*, SkPaint&); 226 typedef void (*raster_proc)(SkLayerRasterizer::Builder*, SkPaint&);
227 227
228 static const raster_proc gRastProcs[] = { 228 static const raster_proc gRastProcs[] = {
229 r0, r1, r2, r3, r4, r5, r6, r7, r8, r9 229 r0, r1, r2, r3, r4, r5, r6, r7, r8, r9
230 }; 230 };
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 } 296 }
297 297
298 virtual void onDrawContent(SkCanvas* canvas) { 298 virtual void onDrawContent(SkCanvas* canvas) {
299 canvas->save(); 299 canvas->save();
300 this->drawPicture(canvas, 0); 300 this->drawPicture(canvas, 0);
301 canvas->restore(); 301 canvas->restore();
302 302
303 { 303 {
304 SkPictureRecorder recorder; 304 SkPictureRecorder recorder;
305 { 305 {
306 SkCanvas* record = recorder.beginRecording(320, 480, NULL, 0); 306 SkCanvas* record = recorder.beginRecording(320, 480, nullptr, 0) ;
307 this->drawPicture(record, 120); 307 this->drawPicture(record, 120);
308 } 308 }
309 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); 309 SkAutoTUnref<SkPicture> picture(recorder.endRecording());
310 310
311 canvas->translate(0, SkIntToScalar(120)); 311 canvas->translate(0, SkIntToScalar(120));
312 312
313 SkRect clip; 313 SkRect clip;
314 clip.set(0, 0, SkIntToScalar(160), SkIntToScalar(160)); 314 clip.set(0, 0, SkIntToScalar(160), SkIntToScalar(160));
315 do { 315 do {
316 canvas->save(); 316 canvas->save();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 SkIntToScalar((unsigned int)index * 2)); 352 SkIntToScalar((unsigned int)index * 2));
353 SkTDArray<SkPoint>(pos2); 353 SkTDArray<SkPoint>(pos2);
354 pos2.setCount(asciiLength); 354 pos2.setCount(asciiLength);
355 for (index = 0; index < asciiLength; index++) 355 for (index = 0; index < asciiLength; index++)
356 pos2[index].set(SkIntToScalar((unsigned int)index * 10), 356 pos2[index].set(SkIntToScalar((unsigned int)index * 10),
357 SkIntToScalar(20)); 357 SkIntToScalar(20));
358 358
359 // shaders 359 // shaders
360 SkPoint linearPoints[] = { { 0, 0, }, { SkIntToScalar(40), SkIntToScalar (40) } }; 360 SkPoint linearPoints[] = { { 0, 0, }, { SkIntToScalar(40), SkIntToScalar (40) } };
361 SkColor linearColors[] = { SK_ColorRED, SK_ColorBLUE }; 361 SkColor linearColors[] = { SK_ColorRED, SK_ColorBLUE };
362 SkScalar* linearPos = NULL; 362 SkScalar* linearPos = nullptr;
363 int linearCount = 2; 363 int linearCount = 2;
364 SkShader::TileMode linearMode = SkShader::kMirror_TileMode; 364 SkShader::TileMode linearMode = SkShader::kMirror_TileMode;
365 SkShader* linear = SkGradientShader::CreateLinear(linearPoints, 365 SkShader* linear = SkGradientShader::CreateLinear(linearPoints,
366 linearColors, linearPos, linearCount, linearMode); 366 linearColors, linearPos, linearCount, linearMode);
367 367
368 SkPoint radialCenter = { SkIntToScalar(25), SkIntToScalar(25) }; 368 SkPoint radialCenter = { SkIntToScalar(25), SkIntToScalar(25) };
369 SkScalar radialRadius = SkIntToScalar(25); 369 SkScalar radialRadius = SkIntToScalar(25);
370 SkColor radialColors[] = { SK_ColorGREEN, SK_ColorGRAY, SK_ColorRED }; 370 SkColor radialColors[] = { SK_ColorGREEN, SK_ColorGRAY, SK_ColorRED };
371 SkScalar radialPos[] = { 0, SkIntToScalar(3) / 5, SkIntToScalar(1)}; 371 SkScalar radialPos[] = { 0, SkIntToScalar(3) / 5, SkIntToScalar(1)};
372 int radialCount = 3; 372 int radialCount = 3;
(...skipping 29 matching lines...) Expand all
402 canvas->drawPaint(paint); 402 canvas->drawPaint(paint);
403 canvas->save(); 403 canvas->save();
404 404
405 // line (exercises xfermode, colorShader, colorFilter, filterShader) 405 // line (exercises xfermode, colorShader, colorFilter, filterShader)
406 paint.setColor(SK_ColorGREEN); 406 paint.setColor(SK_ColorGREEN);
407 paint.setStrokeWidth(SkIntToScalar(10)); 407 paint.setStrokeWidth(SkIntToScalar(10));
408 paint.setStyle(SkPaint::kStroke_Style); 408 paint.setStyle(SkPaint::kStroke_Style);
409 paint.setXfermode(xfermode)->unref(); 409 paint.setXfermode(xfermode)->unref();
410 paint.setColorFilter(lightingFilter)->unref(); 410 paint.setColorFilter(lightingFilter)->unref();
411 canvas->drawLine(start.fX, start.fY, stop.fX, stop.fY, paint); // should not be green 411 canvas->drawLine(start.fX, start.fY, stop.fX, stop.fY, paint); // should not be green
412 paint.setXfermode(NULL); 412 paint.setXfermode(nullptr);
413 paint.setColorFilter(NULL); 413 paint.setColorFilter(nullptr);
414 414
415 // rectangle 415 // rectangle
416 paint.setStyle(SkPaint::kFill_Style); 416 paint.setStyle(SkPaint::kFill_Style);
417 canvas->translate(SkIntToScalar(50), 0); 417 canvas->translate(SkIntToScalar(50), 0);
418 paint.setColor(SK_ColorYELLOW); 418 paint.setColor(SK_ColorYELLOW);
419 paint.setShader(linear)->unref(); 419 paint.setShader(linear)->unref();
420 paint.setPathEffect(pathEffectTest())->unref(); 420 paint.setPathEffect(pathEffectTest())->unref();
421 canvas->drawRect(rect, paint); 421 canvas->drawRect(rect, paint);
422 paint.setPathEffect(NULL); 422 paint.setPathEffect(nullptr);
423 423
424 // circle w/ emboss & transparent (exercises 3dshader) 424 // circle w/ emboss & transparent (exercises 3dshader)
425 canvas->translate(SkIntToScalar(50), 0); 425 canvas->translate(SkIntToScalar(50), 0);
426 paint.setMaskFilter(embossFilter)->unref(); 426 paint.setMaskFilter(embossFilter)->unref();
427 canvas->drawOval(rect, paint); 427 canvas->drawOval(rect, paint);
428 canvas->translate(SkIntToScalar(10), SkIntToScalar(10)); 428 canvas->translate(SkIntToScalar(10), SkIntToScalar(10));
429 // paint.setShader(transparentShader)->unref(); 429 // paint.setShader(transparentShader)->unref();
430 canvas->drawOval(rect, paint); 430 canvas->drawOval(rect, paint);
431 canvas->translate(0, SkIntToScalar(-10)); 431 canvas->translate(0, SkIntToScalar(-10));
432 432
433 // path 433 // path
434 canvas->translate(SkIntToScalar(50), 0); 434 canvas->translate(SkIntToScalar(50), 0);
435 paint.setColor(SK_ColorRED); 435 paint.setColor(SK_ColorRED);
436 paint.setStyle(SkPaint::kStroke_Style); 436 paint.setStyle(SkPaint::kStroke_Style);
437 paint.setStrokeWidth(SkIntToScalar(5)); 437 paint.setStrokeWidth(SkIntToScalar(5));
438 paint.setShader(radial)->unref(); 438 paint.setShader(radial)->unref();
439 paint.setMaskFilter(NULL); 439 paint.setMaskFilter(nullptr);
440 canvas->drawPath(path, paint); 440 canvas->drawPath(path, paint);
441 441
442 paint.setShader(NULL); 442 paint.setShader(nullptr);
443 // bitmap, sprite 443 // bitmap, sprite
444 canvas->translate(SkIntToScalar(50), 0); 444 canvas->translate(SkIntToScalar(50), 0);
445 paint.setStyle(SkPaint::kFill_Style); 445 paint.setStyle(SkPaint::kFill_Style);
446 canvas->drawBitmap(fBug, left, top, &paint); 446 canvas->drawBitmap(fBug, left, top, &paint);
447 canvas->translate(SkIntToScalar(30), 0); 447 canvas->translate(SkIntToScalar(30), 0);
448 canvas->drawSprite(fTb, 448 canvas->drawSprite(fTb,
449 SkScalarRoundToInt(canvas->getTotalMatrix().getTranslateX()), 449 SkScalarRoundToInt(canvas->getTotalMatrix().getTranslateX()),
450 spriteOffset + 10, &paint); 450 spriteOffset + 10, &paint);
451 451
452 canvas->translate(-SkIntToScalar(30), SkIntToScalar(30)); 452 canvas->translate(-SkIntToScalar(30), SkIntToScalar(30));
453 paint.setShader(shaderTest())->unref(); // test compose shader 453 paint.setShader(shaderTest())->unref(); // test compose shader
454 canvas->drawRect(rect2, paint); 454 canvas->drawRect(rect2, paint);
455 paint.setShader(NULL); 455 paint.setShader(nullptr);
456 456
457 canvas->restore(); 457 canvas->restore();
458 // text 458 // text
459 canvas->translate(0, SkIntToScalar(60)); 459 canvas->translate(0, SkIntToScalar(60));
460 canvas->save(); 460 canvas->save();
461 paint.setColor(SK_ColorGRAY); 461 paint.setColor(SK_ColorGRAY);
462 canvas->drawPosText(ascii, asciiLength, pos.begin(), paint); 462 canvas->drawPosText(ascii, asciiLength, pos.begin(), paint);
463 canvas->drawPosText(ascii, asciiLength, pos2.begin(), paint); 463 canvas->drawPosText(ascii, asciiLength, pos2.begin(), paint);
464 464
465 canvas->translate(SkIntToScalar(50), 0); 465 canvas->translate(SkIntToScalar(50), 0);
466 paint.setColor(SK_ColorCYAN); 466 paint.setColor(SK_ColorCYAN);
467 canvas->drawText(utf8, sizeof(utf8) - 1, x, y, paint); 467 canvas->drawText(utf8, sizeof(utf8) - 1, x, y, paint);
468 468
469 canvas->translate(SkIntToScalar(30), 0); 469 canvas->translate(SkIntToScalar(30), 0);
470 paint.setColor(SK_ColorMAGENTA); 470 paint.setColor(SK_ColorMAGENTA);
471 paint.setTextEncoding(SkPaint::kUTF16_TextEncoding); 471 paint.setTextEncoding(SkPaint::kUTF16_TextEncoding);
472 matrix.setTranslate(SkIntToScalar(10), SkIntToScalar(10)); 472 matrix.setTranslate(SkIntToScalar(10), SkIntToScalar(10));
473 canvas->drawTextOnPath((void*) utf16, sizeof(utf16), path, &matrix, pain t); 473 canvas->drawTextOnPath((void*) utf16, sizeof(utf16), path, &matrix, pain t);
474 canvas->translate(0, SkIntToScalar(20)); 474 canvas->translate(0, SkIntToScalar(20));
475 canvas->drawTextOnPath((void*) utf16simple, sizeof(utf16simple), path, & matrix, paint); 475 canvas->drawTextOnPath((void*) utf16simple, sizeof(utf16simple), path, & matrix, paint);
476 canvas->restore(); 476 canvas->restore();
477 477
478 canvas->translate(0, SkIntToScalar(60)); 478 canvas->translate(0, SkIntToScalar(60));
479 paint.setTextEncoding(SkPaint::kUTF8_TextEncoding); 479 paint.setTextEncoding(SkPaint::kUTF8_TextEncoding);
480 canvas->restore(); 480 canvas->restore();
481 } 481 }
482 482
483 virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned m odi) { 483 virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned m odi) {
484 fClickPt.set(x, y); 484 fClickPt.set(x, y);
485 this->inval(NULL); 485 this->inval(nullptr);
486 return this->INHERITED::onFindClickHandler(x, y, modi); 486 return this->INHERITED::onFindClickHandler(x, y, modi);
487 } 487 }
488 488
489 SkPathEffect* pathEffectTest() { 489 SkPathEffect* pathEffectTest() {
490 static const int gXY[] = { 1, 0, 0, -1, 2, -1, 3, 0, 2, 1, 0, 1 }; 490 static const int gXY[] = { 1, 0, 0, -1, 2, -1, 3, 0, 2, 1, 0, 1 };
491 SkScalar gPhase = 0; 491 SkScalar gPhase = 0;
492 SkPath path; 492 SkPath path;
493 path.moveTo(SkIntToScalar(gXY[0]), SkIntToScalar(gXY[1])); 493 path.moveTo(SkIntToScalar(gXY[0]), SkIntToScalar(gXY[1]));
494 for (unsigned i = 2; i < SK_ARRAY_COUNT(gXY); i += 2) 494 for (unsigned i = 2; i < SK_ARRAY_COUNT(gXY); i += 2)
495 path.lineTo(SkIntToScalar(gXY[i]), SkIntToScalar(gXY[i+1])); 495 path.lineTo(SkIntToScalar(gXY[i]), SkIntToScalar(gXY[i+1]));
496 path.close(); 496 path.close();
497 path.offset(SkIntToScalar(-6), 0); 497 path.offset(SkIntToScalar(-6), 0);
498 SkPathEffect* outer = SkPath1DPathEffect::Create(path, SkIntToScalar(12) , 498 SkPathEffect* outer = SkPath1DPathEffect::Create(path, SkIntToScalar(12) ,
499 gPhase, SkPath1DPathEffect::kRotate_Style); 499 gPhase, SkPath1DPathEffect::kRotate_Style);
500 SkPathEffect* inner = SkDiscretePathEffect::Create(SkIntToScalar(2), 500 SkPathEffect* inner = SkDiscretePathEffect::Create(SkIntToScalar(2),
501 SkIntToScalar(1)/10); // SkCornerPathEffect(SkIntToScalar(2)); 501 SkIntToScalar(1)/10); // SkCornerPathEffect(SkIntToScalar(2));
502 SkPathEffect* result = SkComposePathEffect::Create(outer, inner); 502 SkPathEffect* result = SkComposePathEffect::Create(outer, inner);
503 outer->unref(); 503 outer->unref();
504 inner->unref(); 504 inner->unref();
505 return result; 505 return result;
506 } 506 }
507 507
508 SkShader* shaderTest() { 508 SkShader* shaderTest() {
509 SkPoint pts[] = { { 0, 0, }, { SkIntToScalar(100), 0 } }; 509 SkPoint pts[] = { { 0, 0, }, { SkIntToScalar(100), 0 } };
510 SkColor colors[] = { SK_ColorRED, SK_ColorBLUE }; 510 SkColor colors[] = { SK_ColorRED, SK_ColorBLUE };
511 SkShader* shaderA = SkGradientShader::CreateLinear(pts, colors, NULL, 511 SkShader* shaderA = SkGradientShader::CreateLinear(pts, colors, nullptr,
512 2, SkShader::kClamp_TileMode); 512 2, SkShader::kClamp_TileMode);
513 pts[1].set(0, SkIntToScalar(100)); 513 pts[1].set(0, SkIntToScalar(100));
514 SkColor colors2[] = {SK_ColorBLACK, SkColorSetARGB(0x80, 0, 0, 0)}; 514 SkColor colors2[] = {SK_ColorBLACK, SkColorSetARGB(0x80, 0, 0, 0)};
515 SkShader* shaderB = SkGradientShader::CreateLinear(pts, colors2, NULL, 515 SkShader* shaderB = SkGradientShader::CreateLinear(pts, colors2, nullptr ,
516 2, SkShader::kClamp_TileMode); 516 2, SkShader::kClamp_TileMode);
517 SkXfermode* mode = SkXfermode::Create(SkXfermode::kDstIn_Mode); 517 SkXfermode* mode = SkXfermode::Create(SkXfermode::kDstIn_Mode);
518 SkShader* result = new SkComposeShader(shaderA, shaderB, mode); 518 SkShader* result = new SkComposeShader(shaderA, shaderB, mode);
519 shaderA->unref(); 519 shaderA->unref();
520 shaderB->unref(); 520 shaderB->unref();
521 mode->unref(); 521 mode->unref();
522 return result; 522 return result;
523 } 523 }
524 524
525 virtual void startTest() { 525 virtual void startTest() {
(...skipping 17 matching lines...) Expand all
543 paint.setAntiAlias(true); 543 paint.setAntiAlias(true);
544 paint.setTextSize(SkIntToScalar(48)); 544 paint.setTextSize(SkIntToScalar(48));
545 paint.setTypeface(SkTypeface::CreateFromName("sans-serif", 545 paint.setTypeface(SkTypeface::CreateFromName("sans-serif",
546 SkTypeface::kBold)); 546 SkTypeface::kBold));
547 547
548 SkString str("GOOGLE"); 548 SkString str("GOOGLE");
549 549
550 for (size_t i = 0; i < SK_ARRAY_COUNT(gRastProcs); i++) { 550 for (size_t i = 0; i < SK_ARRAY_COUNT(gRastProcs); i++) {
551 apply_shader(&paint, (int)i); 551 apply_shader(&paint, (int)i);
552 552
553 // paint.setMaskFilter(NULL); 553 // paint.setMaskFilter(nullptr);
554 // paint.setColor(SK_ColorBLACK); 554 // paint.setColor(SK_ColorBLACK);
555 555
556 #if 01 556 #if 01
557 int index = i % SK_ARRAY_COUNT(gLightingColors); 557 int index = i % SK_ARRAY_COUNT(gLightingColors);
558 paint.setColorFilter(SkColorFilter::CreateLightingFilter( 558 paint.setColorFilter(SkColorFilter::CreateLightingFilter(
559 gLightingColors[index].fMul, 559 gLightingColors[index].fMul,
560 gLightingColors[index].fAdd))->unref(); 560 gLightingColors[index].fAdd))->unref();
561 #endif 561 #endif
562 562
563 canvas->drawText(str.c_str(), str.size(), x, y, paint); 563 canvas->drawText(str.c_str(), str.size(), x, y, paint);
(...skipping 11 matching lines...) Expand all
575 private: 575 private:
576 SkPoint fClickPt; 576 SkPoint fClickPt;
577 SkBitmap fBug, fTb, fTx; 577 SkBitmap fBug, fTb, fTx;
578 typedef SampleView INHERITED; 578 typedef SampleView INHERITED;
579 }; 579 };
580 580
581 ////////////////////////////////////////////////////////////////////////////// 581 //////////////////////////////////////////////////////////////////////////////
582 582
583 static SkView* MyFactory() { return new DemoView; } 583 static SkView* MyFactory() { return new DemoView; }
584 static SkViewRegister reg(MyFactory); 584 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleAARectModes.cpp ('k') | samplecode/SampleAnimator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698