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

Side by Side Diff: gm/all_bitmap_configs.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/addarc.cpp ('k') | gm/alphagradients.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 2015 Google Inc. 2 * Copyright 2015 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 "sk_tool_utils.h" 8 #include "sk_tool_utils.h"
9 #include "SkSurface.h" 9 #include "SkSurface.h"
10 #include "Resources.h" 10 #include "Resources.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 SkPaint p; 68 SkPaint p;
69 p.setAntiAlias(false); 69 p.setAntiAlias(false);
70 p.setColor(SK_ColorWHITE); 70 p.setColor(SK_ColorWHITE);
71 canvas->drawCircle(0.0f, 0.0f, SCALE * 0.5f, p); 71 canvas->drawCircle(0.0f, 0.0f, SCALE * 0.5f, p);
72 72
73 const double sqrt_3_over_2 = 0.8660254037844387; 73 const double sqrt_3_over_2 = 0.8660254037844387;
74 const SkScalar Z = 0.0f; 74 const SkScalar Z = 0.0f;
75 const SkScalar D = 0.3f * SkIntToScalar(SCALE); 75 const SkScalar D = 0.3f * SkIntToScalar(SCALE);
76 const SkScalar X = SkDoubleToScalar(D * sqrt_3_over_2); 76 const SkScalar X = SkDoubleToScalar(D * sqrt_3_over_2);
77 const SkScalar Y = D * SK_ScalarHalf; 77 const SkScalar Y = D * SK_ScalarHalf;
78 sk_tool_utils::set_portable_typeface(&p, NULL, SkTypeface::kBold); 78 sk_tool_utils::set_portable_typeface(&p, nullptr, SkTypeface::kBold);
79 p.setTextSize(0.28125f * SCALE); 79 p.setTextSize(0.28125f * SCALE);
80 draw_center_letter('K', &p, SK_ColorBLACK, Z, Z, canvas); 80 draw_center_letter('K', &p, SK_ColorBLACK, Z, Z, canvas);
81 draw_center_letter('R', &p, SK_ColorRED, Z, D, canvas); 81 draw_center_letter('R', &p, SK_ColorRED, Z, D, canvas);
82 draw_center_letter('G', &p, SK_ColorGREEN, -X, -Y, canvas); 82 draw_center_letter('G', &p, SK_ColorGREEN, -X, -Y, canvas);
83 draw_center_letter('B', &p, SK_ColorBLUE, X, -Y, canvas); 83 draw_center_letter('B', &p, SK_ColorBLUE, X, -Y, canvas);
84 draw_center_letter('C', &p, SK_ColorCYAN, Z, -D, canvas); 84 draw_center_letter('C', &p, SK_ColorCYAN, Z, -D, canvas);
85 draw_center_letter('M', &p, SK_ColorMAGENTA, X, Y, canvas); 85 draw_center_letter('M', &p, SK_ColorMAGENTA, X, Y, canvas);
86 draw_center_letter('Y', &p, SK_ColorYELLOW, -X, Y, canvas); 86 draw_center_letter('Y', &p, SK_ColorYELLOW, -X, Y, canvas);
87 } 87 }
88 88
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 SK_ColorYELLOW, 120 SK_ColorYELLOW,
121 }; 121 };
122 SkPMColor pmColors[SK_ARRAY_COUNT(colors)]; 122 SkPMColor pmColors[SK_ARRAY_COUNT(colors)];
123 for (size_t i = 0; i < SK_ARRAY_COUNT(colors); ++i) { 123 for (size_t i = 0; i < SK_ARRAY_COUNT(colors); ++i) {
124 pmColors[i] = premultiply_color(colors[i]); 124 pmColors[i] = premultiply_color(colors[i]);
125 } 125 }
126 SkBitmap bm; 126 SkBitmap bm;
127 SkAutoTUnref<SkColorTable> ctable(new SkColorTable(pmColors, SK_ARRAY_COUNT( pmColors))); 127 SkAutoTUnref<SkColorTable> ctable(new SkColorTable(pmColors, SK_ARRAY_COUNT( pmColors)));
128 SkImageInfo info = SkImageInfo::Make(SCALE, SCALE, kIndex_8_SkColorType, 128 SkImageInfo info = SkImageInfo::Make(SCALE, SCALE, kIndex_8_SkColorType,
129 kPremul_SkAlphaType); 129 kPremul_SkAlphaType);
130 bm.allocPixels(info, NULL, ctable); 130 bm.allocPixels(info, nullptr, ctable);
131 SkAutoLockPixels autoLockPixels1(n32bitmap); 131 SkAutoLockPixels autoLockPixels1(n32bitmap);
132 SkAutoLockPixels autoLockPixels2(bm); 132 SkAutoLockPixels autoLockPixels2(bm);
133 for (int y = 0; y < SCALE; ++y) { 133 for (int y = 0; y < SCALE; ++y) {
134 for (int x = 0; x < SCALE; ++x) { 134 for (int x = 0; x < SCALE; ++x) {
135 SkPMColor c = *n32bitmap.getAddr32(x, y); 135 SkPMColor c = *n32bitmap.getAddr32(x, y);
136 int idx = find(pmColors, SK_ARRAY_COUNT(pmColors), c); 136 int idx = find(pmColors, SK_ARRAY_COUNT(pmColors), c);
137 *bm.getAddr8(x, y) = SkClampMax(idx, SK_ARRAY_COUNT(pmColors) - 1); 137 *bm.getAddr8(x, y) = SkClampMax(idx, SK_ARRAY_COUNT(pmColors) - 1);
138 } 138 }
139 } 139 }
140 return bm; 140 return bm;
141 } 141 }
142 142
143 static void draw(SkCanvas* canvas, 143 static void draw(SkCanvas* canvas,
144 const SkPaint& p, 144 const SkPaint& p,
145 const SkBitmap& src, 145 const SkBitmap& src,
146 SkColorType colorType, 146 SkColorType colorType,
147 const char text[]) { 147 const char text[]) {
148 SkASSERT(src.colorType() == colorType); 148 SkASSERT(src.colorType() == colorType);
149 canvas->drawBitmap(src, 0.0f, 0.0f); 149 canvas->drawBitmap(src, 0.0f, 0.0f);
150 canvas->drawText(text, strlen(text), 0.0f, 12.0f, p); 150 canvas->drawText(text, strlen(text), 0.0f, 12.0f, p);
151 } 151 }
152 152
153 DEF_SIMPLE_GM(all_bitmap_configs, canvas, SCALE, 6 * SCALE) { 153 DEF_SIMPLE_GM(all_bitmap_configs, canvas, SCALE, 6 * SCALE) {
154 SkAutoCanvasRestore autoCanvasRestore(canvas, true); 154 SkAutoCanvasRestore autoCanvasRestore(canvas, true);
155 SkPaint p; 155 SkPaint p;
156 p.setColor(SK_ColorBLACK); 156 p.setColor(SK_ColorBLACK);
157 p.setAntiAlias(true); 157 p.setAntiAlias(true);
158 sk_tool_utils::set_portable_typeface(&p, NULL); 158 sk_tool_utils::set_portable_typeface(&p, nullptr);
159 159
160 sk_tool_utils::draw_checkerboard(canvas, SK_ColorLTGRAY, SK_ColorWHITE, 8); 160 sk_tool_utils::draw_checkerboard(canvas, SK_ColorLTGRAY, SK_ColorWHITE, 8);
161 161
162 SkBitmap bitmap; 162 SkBitmap bitmap;
163 if (GetResourceAsBitmap("color_wheel.png", &bitmap)) { 163 if (GetResourceAsBitmap("color_wheel.png", &bitmap)) {
164 bitmap.setImmutable(); 164 bitmap.setImmutable();
165 draw(canvas, p, bitmap, kN32_SkColorType, "Native 32"); 165 draw(canvas, p, bitmap, kN32_SkColorType, "Native 32");
166 166
167 canvas->translate(0.0f, SkIntToScalar(SCALE)); 167 canvas->translate(0.0f, SkIntToScalar(SCALE));
168 SkBitmap copy565 = copy_bitmap(bitmap, kRGB_565_SkColorType); 168 SkBitmap copy565 = copy_bitmap(bitmap, kRGB_565_SkColorType);
(...skipping 14 matching lines...) Expand all
183 183
184 canvas->translate(0.0f, SkIntToScalar(SCALE)); 184 canvas->translate(0.0f, SkIntToScalar(SCALE));
185 SkBitmap bitmapA8 = make_bitmap(kAlpha_8_SkColorType); 185 SkBitmap bitmapA8 = make_bitmap(kAlpha_8_SkColorType);
186 draw(canvas, p, bitmapA8, kAlpha_8_SkColorType, "Alpha 8"); 186 draw(canvas, p, bitmapA8, kAlpha_8_SkColorType, "Alpha 8");
187 187
188 p.setColor(SK_ColorRED); 188 p.setColor(SK_ColorRED);
189 canvas->translate(0.0f, SkIntToScalar(SCALE)); 189 canvas->translate(0.0f, SkIntToScalar(SCALE));
190 SkBitmap bitmapG8 = make_bitmap(kGray_8_SkColorType); 190 SkBitmap bitmapG8 = make_bitmap(kGray_8_SkColorType);
191 draw(canvas, p, bitmapG8, kGray_8_SkColorType, "Gray 8"); 191 draw(canvas, p, bitmapG8, kGray_8_SkColorType, "Gray 8");
192 } 192 }
OLDNEW
« no previous file with comments | « gm/addarc.cpp ('k') | gm/alphagradients.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698