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

Side by Side Diff: samplecode/SampleShaders.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/SampleShaderText.cpp ('k') | samplecode/SampleSlides.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 "SkView.h" 9 #include "SkView.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 13 matching lines...) Expand all
24 24
25 static SkShader* make_bitmapfade(const SkBitmap& bm) 25 static SkShader* make_bitmapfade(const SkBitmap& bm)
26 { 26 {
27 SkPoint pts[2]; 27 SkPoint pts[2];
28 SkColor colors[2]; 28 SkColor colors[2];
29 29
30 pts[0].set(0, 0); 30 pts[0].set(0, 0);
31 pts[1].set(0, SkIntToScalar(bm.height())); 31 pts[1].set(0, SkIntToScalar(bm.height()));
32 colors[0] = SK_ColorBLACK; 32 colors[0] = SK_ColorBLACK;
33 colors[1] = SkColorSetARGB(0, 0, 0, 0); 33 colors[1] = SkColorSetARGB(0, 0, 0, 0);
34 SkShader* shaderA = SkGradientShader::CreateLinear(pts, colors, NULL, 2, SkS hader::kClamp_TileMode); 34 SkShader* shaderA = SkGradientShader::CreateLinear(pts, colors, nullptr, 2, SkShader::kClamp_TileMode);
35 35
36 SkShader* shaderB = SkShader::CreateBitmapShader(bm, 36 SkShader* shaderB = SkShader::CreateBitmapShader(bm,
37 SkShader::kClamp_TileMode, SkShader::kClamp_TileMode); 37 SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);
38 38
39 SkXfermode* mode = SkXfermode::Create(SkXfermode::kDstIn_Mode); 39 SkXfermode* mode = SkXfermode::Create(SkXfermode::kDstIn_Mode);
40 40
41 SkShader* shader = new SkComposeShader(shaderB, shaderA, mode); 41 SkShader* shader = new SkComposeShader(shaderB, shaderA, mode);
42 shaderA->unref(); 42 shaderA->unref();
43 shaderB->unref(); 43 shaderB->unref();
44 mode->unref(); 44 mode->unref();
45 45
46 return shader; 46 return shader;
47 } 47 }
48 48
49 class ShaderView : public SampleView { 49 class ShaderView : public SampleView {
50 public: 50 public:
51 SkShader* fShader; 51 SkShader* fShader;
52 SkBitmap fBitmap; 52 SkBitmap fBitmap;
53 53
54 ShaderView() { 54 ShaderView() {
55 SkImageDecoder::DecodeFile("/skimages/logo.gif", &fBitmap); 55 SkImageDecoder::DecodeFile("/skimages/logo.gif", &fBitmap);
56 56
57 SkPoint pts[2]; 57 SkPoint pts[2];
58 SkColor colors[2]; 58 SkColor colors[2];
59 59
60 pts[0].set(0, 0); 60 pts[0].set(0, 0);
61 pts[1].set(SkIntToScalar(100), 0); 61 pts[1].set(SkIntToScalar(100), 0);
62 colors[0] = SK_ColorRED; 62 colors[0] = SK_ColorRED;
63 colors[1] = SK_ColorBLUE; 63 colors[1] = SK_ColorBLUE;
64 SkShader* shaderA = SkGradientShader::CreateLinear(pts, colors, NULL, 2, SkShader::kClamp_TileMode); 64 SkShader* shaderA = SkGradientShader::CreateLinear(pts, colors, nullptr, 2, SkShader::kClamp_TileMode);
65 65
66 pts[0].set(0, 0); 66 pts[0].set(0, 0);
67 pts[1].set(0, SkIntToScalar(100)); 67 pts[1].set(0, SkIntToScalar(100));
68 colors[0] = SK_ColorBLACK; 68 colors[0] = SK_ColorBLACK;
69 colors[1] = SkColorSetARGB(0x80, 0, 0, 0); 69 colors[1] = SkColorSetARGB(0x80, 0, 0, 0);
70 SkShader* shaderB = SkGradientShader::CreateLinear(pts, colors, NULL, 2, SkShader::kClamp_TileMode); 70 SkShader* shaderB = SkGradientShader::CreateLinear(pts, colors, nullptr, 2, SkShader::kClamp_TileMode);
71 71
72 SkXfermode* mode = SkXfermode::Create(SkXfermode::kDstIn_Mode); 72 SkXfermode* mode = SkXfermode::Create(SkXfermode::kDstIn_Mode);
73 73
74 fShader = new SkComposeShader(shaderA, shaderB, mode); 74 fShader = new SkComposeShader(shaderA, shaderB, mode);
75 shaderA->unref(); 75 shaderA->unref();
76 shaderB->unref(); 76 shaderB->unref();
77 mode->unref(); 77 mode->unref();
78 } 78 }
79 virtual ~ShaderView() { 79 virtual ~ShaderView() {
80 SkSafeUnref(fShader); 80 SkSafeUnref(fShader);
(...skipping 23 matching lines...) Expand all
104 canvas->drawRectCoords(0, 0, SkIntToScalar(100), SkIntToScalar(100), pai nt); 104 canvas->drawRectCoords(0, 0, SkIntToScalar(100), SkIntToScalar(100), pai nt);
105 105
106 canvas->translate(SkIntToScalar(110), 0); 106 canvas->translate(SkIntToScalar(110), 0);
107 107
108 int w = fBitmap.width(); 108 int w = fBitmap.width();
109 int h = fBitmap.height(); 109 int h = fBitmap.height();
110 w = 120; 110 w = 120;
111 h = 80; 111 h = 80;
112 r.set(0, 0, SkIntToScalar(w), SkIntToScalar(h)); 112 r.set(0, 0, SkIntToScalar(w), SkIntToScalar(h));
113 113
114 paint.setShader(NULL); 114 paint.setShader(nullptr);
115 canvas->drawRect(r, paint); 115 canvas->drawRect(r, paint);
116 paint.setShader(make_bitmapfade(fBitmap))->unref(); 116 paint.setShader(make_bitmapfade(fBitmap))->unref();
117 canvas->drawRect(r, paint); 117 canvas->drawRect(r, paint);
118 } 118 }
119 119
120 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) ove rride { 120 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) ove rride {
121 this->inval(NULL); 121 this->inval(nullptr);
122 return this->INHERITED::onFindClickHandler(x, y, modi); 122 return this->INHERITED::onFindClickHandler(x, y, modi);
123 } 123 }
124 124
125 bool onClick(Click* click) override { 125 bool onClick(Click* click) override {
126 return this->INHERITED::onClick(click); 126 return this->INHERITED::onClick(click);
127 } 127 }
128 128
129 private: 129 private:
130 typedef SampleView INHERITED; 130 typedef SampleView INHERITED;
131 }; 131 };
132 132
133 ////////////////////////////////////////////////////////////////////////////// 133 //////////////////////////////////////////////////////////////////////////////
134 134
135 static SkView* MyFactory() { return new ShaderView; } 135 static SkView* MyFactory() { return new ShaderView; }
136 static SkViewRegister reg(MyFactory); 136 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleShaderText.cpp ('k') | samplecode/SampleSlides.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698