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

Side by Side Diff: gm/composeshader.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 | « gm/complexclip.cpp ('k') | gm/constcolorprocessor.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 * 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 9
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkComposeShader.h" 11 #include "SkComposeShader.h"
12 #include "SkGradientShader.h" 12 #include "SkGradientShader.h"
13 #include "SkGraphics.h" 13 #include "SkGraphics.h"
14 #include "SkShader.h" 14 #include "SkShader.h"
15 #include "SkString.h" 15 #include "SkString.h"
16 #include "SkXfermode.h" 16 #include "SkXfermode.h"
17 17
18 static SkShader* make_shader(SkXfermode::Mode mode) { 18 static SkShader* make_shader(SkXfermode::Mode mode) {
19 SkPoint pts[2]; 19 SkPoint pts[2];
20 SkColor colors[2]; 20 SkColor colors[2];
21 21
22 pts[0].set(0, 0); 22 pts[0].set(0, 0);
23 pts[1].set(SkIntToScalar(100), 0); 23 pts[1].set(SkIntToScalar(100), 0);
24 colors[0] = SK_ColorRED; 24 colors[0] = SK_ColorRED;
25 colors[1] = SK_ColorBLUE; 25 colors[1] = SK_ColorBLUE;
26 SkAutoTUnref<SkShader> shaderA(SkGradientShader::CreateLinear(pts, colors, N ULL, 2, 26 SkAutoTUnref<SkShader> shaderA(SkGradientShader::CreateLinear(pts, colors, n ullptr, 2,
27 SkShader::kCla mp_TileMode)); 27 SkShader::kCla mp_TileMode));
28 28
29 pts[0].set(0, 0); 29 pts[0].set(0, 0);
30 pts[1].set(0, SkIntToScalar(100)); 30 pts[1].set(0, SkIntToScalar(100));
31 colors[0] = SK_ColorBLACK; 31 colors[0] = SK_ColorBLACK;
32 colors[1] = SkColorSetARGB(0x80, 0, 0, 0); 32 colors[1] = SkColorSetARGB(0x80, 0, 0, 0);
33 SkAutoTUnref<SkShader> shaderB(SkGradientShader::CreateLinear(pts, colors, N ULL, 2, 33 SkAutoTUnref<SkShader> shaderB(SkGradientShader::CreateLinear(pts, colors, n ullptr, 2,
34 SkShader::kCla mp_TileMode)); 34 SkShader::kCla mp_TileMode));
35 35
36 SkAutoTUnref<SkXfermode> xfer(SkXfermode::Create(mode)); 36 SkAutoTUnref<SkXfermode> xfer(SkXfermode::Create(mode));
37 37
38 return new SkComposeShader(shaderA, shaderB, xfer); 38 return new SkComposeShader(shaderA, shaderB, xfer);
39 } 39 }
40 40
41 class ComposeShaderGM : public skiagm::GM { 41 class ComposeShaderGM : public skiagm::GM {
42 public: 42 public:
43 ComposeShaderGM() { 43 ComposeShaderGM() {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 SkPaint paint; 95 SkPaint paint;
96 paint.setColor(SK_ColorGREEN); 96 paint.setColor(SK_ColorGREEN);
97 97
98 const SkRect r = SkRect::MakeXYWH(5, 5, 100, 100); 98 const SkRect r = SkRect::MakeXYWH(5, 5, 100, 100);
99 99
100 for (size_t y = 0; y < SK_ARRAY_COUNT(shaders); ++y) { 100 for (size_t y = 0; y < SK_ARRAY_COUNT(shaders); ++y) {
101 SkShader* shader = shaders[y]; 101 SkShader* shader = shaders[y];
102 canvas->save(); 102 canvas->save();
103 for (int alpha = 0xFF; alpha > 0; alpha -= 0x28) { 103 for (int alpha = 0xFF; alpha > 0; alpha -= 0x28) {
104 paint.setAlpha(0xFF); 104 paint.setAlpha(0xFF);
105 paint.setShader(NULL); 105 paint.setShader(nullptr);
106 canvas->drawRect(r, paint); 106 canvas->drawRect(r, paint);
107 107
108 paint.setAlpha(alpha); 108 paint.setAlpha(alpha);
109 paint.setShader(shader); 109 paint.setShader(shader);
110 canvas->drawRect(r, paint); 110 canvas->drawRect(r, paint);
111 111
112 canvas->translate(r.width() + 5, 0); 112 canvas->translate(r.width() + 5, 0);
113 } 113 }
114 canvas->restore(); 114 canvas->restore();
115 canvas->translate(0, r.height() + 5); 115 canvas->translate(0, r.height() + 5);
116 } 116 }
117 } 117 }
118 }; 118 };
119 119
120 ////////////////////////////////////////////////////////////////////////////// 120 //////////////////////////////////////////////////////////////////////////////
121 121
122 DEF_GM( return new ComposeShaderGM; ) 122 DEF_GM( return new ComposeShaderGM; )
123 DEF_GM( return new ComposeShaderAlphaGM; ) 123 DEF_GM( return new ComposeShaderAlphaGM; )
OLDNEW
« no previous file with comments | « gm/complexclip.cpp ('k') | gm/constcolorprocessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698