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

Side by Side Diff: gm/surface.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/strokefill.cpp ('k') | gm/tablecolorfilter.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 2014 Google Inc. 2 * Copyright 2014 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 #include "SkGradientShader.h" 9 #include "SkGradientShader.h"
10 #include "SkSurface.h" 10 #include "SkSurface.h"
11 #include "SkSurfaceProps.h" 11 #include "SkSurfaceProps.h"
12 12
13 #define W 200 13 #define W 200
14 #define H 100 14 #define H 100
15 15
16 static SkShader* make_shader() { 16 static SkShader* make_shader() {
17 int a = 0x99; 17 int a = 0x99;
18 int b = 0xBB; 18 int b = 0xBB;
19 SkPoint pts[] = { { 0, 0 }, { W, H } }; 19 SkPoint pts[] = { { 0, 0 }, { W, H } };
20 SkColor colors[] = { SkColorSetRGB(a, a, a), SkColorSetRGB(b, b, b) }; 20 SkColor colors[] = { SkColorSetRGB(a, a, a), SkColorSetRGB(b, b, b) };
21 return SkGradientShader::CreateLinear(pts, colors, NULL, 2, SkShader::kClamp _TileMode); 21 return SkGradientShader::CreateLinear(pts, colors, nullptr, 2, SkShader::kCl amp_TileMode);
22 } 22 }
23 23
24 static SkSurface* make_surface(GrContext* ctx, const SkImageInfo& info, SkPixelG eometry geo, 24 static SkSurface* make_surface(GrContext* ctx, const SkImageInfo& info, SkPixelG eometry geo,
25 int disallowAA, int disallowDither) { 25 int disallowAA, int disallowDither) {
26 uint32_t flags = 0; 26 uint32_t flags = 0;
27 if (disallowAA) { 27 if (disallowAA) {
28 flags |= SkSurfaceProps::kDisallowAntiAlias_Flag; 28 flags |= SkSurfaceProps::kDisallowAntiAlias_Flag;
29 } 29 }
30 if (disallowDither) { 30 if (disallowDither) {
31 flags |= SkSurfaceProps::kDisallowDither_Flag; 31 flags |= SkSurfaceProps::kDisallowDither_Flag;
32 } 32 }
33 33
34 SkSurfaceProps props(flags, geo); 34 SkSurfaceProps props(flags, geo);
35 if (ctx) { 35 if (ctx) {
36 return SkSurface::NewRenderTarget(ctx, SkSurface::kNo_Budgeted, info, 0, &props); 36 return SkSurface::NewRenderTarget(ctx, SkSurface::kNo_Budgeted, info, 0, &props);
37 } else { 37 } else {
38 return SkSurface::NewRaster(info, &props); 38 return SkSurface::NewRaster(info, &props);
39 } 39 }
40 } 40 }
41 41
42 static void test_draw(SkCanvas* canvas, const char label[]) { 42 static void test_draw(SkCanvas* canvas, const char label[]) {
43 SkPaint paint; 43 SkPaint paint;
44 44
45 paint.setAntiAlias(true); 45 paint.setAntiAlias(true);
46 paint.setLCDRenderText(true); 46 paint.setLCDRenderText(true);
47 paint.setDither(true); 47 paint.setDither(true);
48 48
49 paint.setShader(make_shader())->unref(); 49 paint.setShader(make_shader())->unref();
50 canvas->drawRect(SkRect::MakeWH(W, H), paint); 50 canvas->drawRect(SkRect::MakeWH(W, H), paint);
51 paint.setShader(NULL); 51 paint.setShader(nullptr);
52 52
53 paint.setColor(SK_ColorWHITE); 53 paint.setColor(SK_ColorWHITE);
54 paint.setTextSize(32); 54 paint.setTextSize(32);
55 paint.setTextAlign(SkPaint::kCenter_Align); 55 paint.setTextAlign(SkPaint::kCenter_Align);
56 sk_tool_utils::set_portable_typeface(&paint); 56 sk_tool_utils::set_portable_typeface(&paint);
57 canvas->drawText(label, strlen(label), W / 2, H * 3 / 4, paint); 57 canvas->drawText(label, strlen(label), W / 2, H * 3 / 4, paint);
58 } 58 }
59 59
60 class SurfacePropsGM : public skiagm::GM { 60 class SurfacePropsGM : public skiagm::GM {
61 public: 61 public:
(...skipping 26 matching lines...) Expand all
88 }; 88 };
89 89
90 SkScalar x = 0; 90 SkScalar x = 0;
91 for (int disallowAA = 0; disallowAA <= 1; ++disallowAA) { 91 for (int disallowAA = 0; disallowAA <= 1; ++disallowAA) {
92 for (int disallowDither = 0; disallowDither <= 1; ++disallowDither) { 92 for (int disallowDither = 0; disallowDither <= 1; ++disallowDither) {
93 SkScalar y = 0; 93 SkScalar y = 0;
94 for (size_t i = 0; i < SK_ARRAY_COUNT(rec); ++i) { 94 for (size_t i = 0; i < SK_ARRAY_COUNT(rec); ++i) {
95 SkAutoTUnref<SkSurface> surface(make_surface(ctx, info, rec[ i].fGeo, 95 SkAutoTUnref<SkSurface> surface(make_surface(ctx, info, rec[ i].fGeo,
96 disallowAA, dis allowDither)); 96 disallowAA, dis allowDither));
97 test_draw(surface->getCanvas(), rec[i].fLabel); 97 test_draw(surface->getCanvas(), rec[i].fLabel);
98 surface->draw(canvas, x, y, NULL); 98 surface->draw(canvas, x, y, nullptr);
99 y += H; 99 y += H;
100 } 100 }
101 x += W; 101 x += W;
102 } 102 }
103 } 103 }
104 } 104 }
105 105
106 private: 106 private:
107 typedef GM INHERITED; 107 typedef GM INHERITED;
108 }; 108 };
(...skipping 18 matching lines...) Expand all
127 return SkISize::Make(300, 140); 127 return SkISize::Make(300, 140);
128 } 128 }
129 129
130 static void drawInto(SkCanvas* canvas) { 130 static void drawInto(SkCanvas* canvas) {
131 canvas->drawColor(SK_ColorRED); 131 canvas->drawColor(SK_ColorRED);
132 } 132 }
133 133
134 void onDraw(SkCanvas* canvas) override { 134 void onDraw(SkCanvas* canvas) override {
135 SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); 135 SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
136 136
137 SkAutoTUnref<SkSurface> surf(canvas->newSurface(info, NULL)); 137 SkAutoTUnref<SkSurface> surf(canvas->newSurface(info, nullptr));
138 if (!surf.get()) { 138 if (!surf.get()) {
139 surf.reset(SkSurface::NewRaster(info)); 139 surf.reset(SkSurface::NewRaster(info));
140 } 140 }
141 drawInto(surf->getCanvas()); 141 drawInto(surf->getCanvas());
142 142
143 SkAutoTUnref<SkImage> image(surf->newImageSnapshot()); 143 SkAutoTUnref<SkImage> image(surf->newImageSnapshot());
144 canvas->drawImage(image, 10, 10, NULL); 144 canvas->drawImage(image, 10, 10, nullptr);
145 145
146 SkAutoTUnref<SkSurface> surf2(image->newSurface(info, NULL)); 146 SkAutoTUnref<SkSurface> surf2(image->newSurface(info, nullptr));
147 drawInto(surf2->getCanvas()); 147 drawInto(surf2->getCanvas());
148 148
149 // Assert that the props were communicated transitively through the firs t image 149 // Assert that the props were communicated transitively through the firs t image
150 SkASSERT(equal(surf->props(), surf2->props())); 150 SkASSERT(equal(surf->props(), surf2->props()));
151 151
152 SkAutoTUnref<SkImage> image2(surf2->newImageSnapshot()); 152 SkAutoTUnref<SkImage> image2(surf2->newImageSnapshot());
153 canvas->drawImage(image2, 10 + SkIntToScalar(image->width()) + 10, 10, N ULL); 153 canvas->drawImage(image2, 10 + SkIntToScalar(image->width()) + 10, 10, n ullptr);
154 } 154 }
155 155
156 private: 156 private:
157 typedef GM INHERITED; 157 typedef GM INHERITED;
158 }; 158 };
159 DEF_GM( return new NewSurfaceGM ) 159 DEF_GM( return new NewSurfaceGM )
160 160
OLDNEW
« no previous file with comments | « gm/strokefill.cpp ('k') | gm/tablecolorfilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698