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

Side by Side Diff: samplecode/SampleDitherBitmap.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/SampleDither.cpp ('k') | samplecode/SampleDraw.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 2011 Google Inc. 2 * Copyright 2011 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 "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
11 #include "SkGradientShader.h" 11 #include "SkGradientShader.h"
12 #include "SkPath.h" 12 #include "SkPath.h"
13 #include "SkUtils.h" 13 #include "SkUtils.h"
14 #include "SkView.h" 14 #include "SkView.h"
15 15
16 static void draw_rect(SkCanvas* canvas, const SkRect& r, const SkPaint& p) { 16 static void draw_rect(SkCanvas* canvas, const SkRect& r, const SkPaint& p) {
17 canvas->drawRect(r, p); 17 canvas->drawRect(r, p);
18 18
19 SkPaint frame(p); 19 SkPaint frame(p);
20 frame.setShader(NULL); 20 frame.setShader(nullptr);
21 frame.setStyle(SkPaint::kStroke_Style); 21 frame.setStyle(SkPaint::kStroke_Style);
22 canvas->drawRect(r, frame); 22 canvas->drawRect(r, frame);
23 } 23 }
24 24
25 static void draw_gradient(SkCanvas* canvas) { 25 static void draw_gradient(SkCanvas* canvas) {
26 SkRect r = { 0, 0, SkIntToScalar(256), SkIntToScalar(32) }; 26 SkRect r = { 0, 0, SkIntToScalar(256), SkIntToScalar(32) };
27 SkPoint pts[] = { { r.fLeft, r.fTop }, { r.fRight, r.fTop } }; 27 SkPoint pts[] = { { r.fLeft, r.fTop }, { r.fRight, r.fTop } };
28 SkColor colors[] = { 0xFF000000, 0xFFFF0000 }; 28 SkColor colors[] = { 0xFF000000, 0xFFFF0000 };
29 SkShader* s = SkGradientShader::CreateLinear(pts, colors, NULL, 2, 29 SkShader* s = SkGradientShader::CreateLinear(pts, colors, nullptr, 2,
30 SkShader::kClamp_TileMode); 30 SkShader::kClamp_TileMode);
31 31
32 SkPaint p; 32 SkPaint p;
33 p.setShader(s)->unref(); 33 p.setShader(s)->unref();
34 draw_rect(canvas, r, p); 34 draw_rect(canvas, r, p);
35 35
36 canvas->translate(0, SkIntToScalar(40)); 36 canvas->translate(0, SkIntToScalar(40));
37 p.setDither(true); 37 p.setDither(true);
38 draw_rect(canvas, r, p); 38 draw_rect(canvas, r, p);
39 } 39 }
(...skipping 15 matching lines...) Expand all
55 55
56 static SkBitmap make_bitmap() { 56 static SkBitmap make_bitmap() {
57 SkPMColor c[256]; 57 SkPMColor c[256];
58 for (int i = 0; i < 256; i++) { 58 for (int i = 0; i < 256; i++) {
59 c[i] = SkPackARGB32(0xFF, i, 0, 0); 59 c[i] = SkPackARGB32(0xFF, i, 0, 0);
60 } 60 }
61 SkColorTable* ctable = new SkColorTable(c, 256); 61 SkColorTable* ctable = new SkColorTable(c, 256);
62 62
63 SkBitmap bm; 63 SkBitmap bm;
64 bm.allocPixels(SkImageInfo::Make(256, 32, kIndex_8_SkColorType, kPremul_SkAl phaType), 64 bm.allocPixels(SkImageInfo::Make(256, 32, kIndex_8_SkColorType, kPremul_SkAl phaType),
65 NULL, ctable); 65 nullptr, ctable);
66 ctable->unref(); 66 ctable->unref();
67 67
68 bm.lockPixels(); 68 bm.lockPixels();
69 for (int y = 0; y < bm.height(); y++) { 69 for (int y = 0; y < bm.height(); y++) {
70 uint8_t* p = bm.getAddr8(0, y); 70 uint8_t* p = bm.getAddr8(0, y);
71 for (int x = 0; x < 256; x++) { 71 for (int x = 0; x < 256; x++) {
72 p[x] = x; 72 p[x] = x;
73 } 73 }
74 } 74 }
75 bm.unlockPixels(); 75 bm.unlockPixels();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 142 }
143 143
144 private: 144 private:
145 typedef SampleView INHERITED; 145 typedef SampleView INHERITED;
146 }; 146 };
147 147
148 ////////////////////////////////////////////////////////////////////////////// 148 //////////////////////////////////////////////////////////////////////////////
149 149
150 static SkView* MyFactory() { return new DitherBitmapView; } 150 static SkView* MyFactory() { return new DitherBitmapView; }
151 static SkViewRegister reg(MyFactory); 151 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleDither.cpp ('k') | samplecode/SampleDraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698