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

Side by Side Diff: src/utils/SkPatchGrid.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 | « src/utils/SkPatchGrid.h ('k') | src/utils/SkPatchUtils.h » ('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 "SkPatchGrid.h" 8 #include "SkPatchGrid.h"
9 #include "SkPatchUtils.h" 9 #include "SkPatchUtils.h"
10 10
11 SkPatchGrid::SkPatchGrid(int rows, int cols, VertexType flags, SkXfermode* xfer) 11 SkPatchGrid::SkPatchGrid(int rows, int cols, VertexType flags, SkXfermode* xfer)
12 : fRows(0) 12 : fRows(0)
13 , fCols(0) 13 , fCols(0)
14 , fModeFlags(kNone_VertexType) 14 , fModeFlags(kNone_VertexType)
15 , fCornerPts(NULL) 15 , fCornerPts(nullptr)
16 , fCornerColors(NULL) 16 , fCornerColors(nullptr)
17 , fTexCoords(NULL) 17 , fTexCoords(nullptr)
18 , fHrzCtrlPts(NULL) 18 , fHrzCtrlPts(nullptr)
19 , fVrtCtrlPts(NULL) 19 , fVrtCtrlPts(nullptr)
20 , fXferMode(NULL) { 20 , fXferMode(nullptr) {
21 this->reset(rows, cols, flags, xfer); 21 this->reset(rows, cols, flags, xfer);
22 } 22 }
23 23
24 SkPatchGrid::~SkPatchGrid() { 24 SkPatchGrid::~SkPatchGrid() {
25 delete[] fCornerPts; 25 delete[] fCornerPts;
26 delete[] fCornerColors; 26 delete[] fCornerColors;
27 delete[] fTexCoords; 27 delete[] fTexCoords;
28 delete[] fHrzCtrlPts; 28 delete[] fHrzCtrlPts;
29 delete[] fVrtCtrlPts; 29 delete[] fVrtCtrlPts;
30 } 30 }
31 31
32 bool SkPatchGrid::setPatch(int x, int y, const SkPoint cubics[12], const SkColor colors[4], 32 bool SkPatchGrid::setPatch(int x, int y, const SkPoint cubics[12], const SkColor colors[4],
33 const SkPoint texCoords[4]) { 33 const SkPoint texCoords[4]) {
34 // Check for the passed paramaters to be within the range of the grid dimens ions and a valid 34 // Check for the passed paramaters to be within the range of the grid dimens ions and a valid
35 // pointer for the cubics' control points. 35 // pointer for the cubics' control points.
36 if (x < 0 || y < 0 || x > fCols - 1 || y > fRows - 1 || NULL == cubics) { 36 if (x < 0 || y < 0 || x > fCols - 1 || y > fRows - 1 || nullptr == cubics) {
37 return false; 37 return false;
38 } 38 }
39 39
40 // setup corners and colors 40 // setup corners and colors
41 int cornerPos = y * (fCols + 1) + x; 41 int cornerPos = y * (fCols + 1) + x;
42 fCornerPts[cornerPos] = cubics[SkPatchUtils::kTopP0_CubicCtrlPts]; 42 fCornerPts[cornerPos] = cubics[SkPatchUtils::kTopP0_CubicCtrlPts];
43 fCornerPts[cornerPos + 1] = cubics[SkPatchUtils::kTopP3_CubicCtrlPts]; 43 fCornerPts[cornerPos + 1] = cubics[SkPatchUtils::kTopP3_CubicCtrlPts];
44 fCornerPts[cornerPos + (fCols + 1)] = cubics[SkPatchUtils::kBottomP0_CubicCt rlPts]; 44 fCornerPts[cornerPos + (fCols + 1)] = cubics[SkPatchUtils::kBottomP0_CubicCt rlPts];
45 fCornerPts[cornerPos + (fCols + 1) + 1] = cubics[SkPatchUtils::kBottomP3_Cub icCtrlPts]; 45 fCornerPts[cornerPos + (fCols + 1) + 1] = cubics[SkPatchUtils::kBottomP3_Cub icCtrlPts];
46 46
(...skipping 25 matching lines...) Expand all
72 fTexCoords[cornerPos + (fCols + 1)] = texCoords[3]; 72 fTexCoords[cornerPos + (fCols + 1)] = texCoords[3];
73 fTexCoords[cornerPos + (fCols + 1) + 1] = texCoords[2]; 73 fTexCoords[cornerPos + (fCols + 1) + 1] = texCoords[2];
74 } 74 }
75 75
76 return true; 76 return true;
77 } 77 }
78 78
79 bool SkPatchGrid::getPatch(int x, int y, SkPoint cubics[12], SkColor colors[4], 79 bool SkPatchGrid::getPatch(int x, int y, SkPoint cubics[12], SkColor colors[4],
80 SkPoint texCoords[4]) const { 80 SkPoint texCoords[4]) const {
81 81
82 if (x < 0 || y < 0 || x > fCols - 1 || y > fRows - 1 || NULL == cubics) { 82 if (x < 0 || y < 0 || x > fCols - 1 || y > fRows - 1 || nullptr == cubics) {
83 return false; 83 return false;
84 } 84 }
85 85
86 // set the patch by building the array of points and colors with the corresp onding values. 86 // set the patch by building the array of points and colors with the corresp onding values.
87 int cornerPos = y * (fCols + 1) + x; 87 int cornerPos = y * (fCols + 1) + x;
88 cubics[SkPatchUtils::kTopP0_CubicCtrlPts] = fCornerPts[cornerPos]; 88 cubics[SkPatchUtils::kTopP0_CubicCtrlPts] = fCornerPts[cornerPos];
89 cubics[SkPatchUtils::kTopP3_CubicCtrlPts] = fCornerPts[cornerPos + 1]; 89 cubics[SkPatchUtils::kTopP3_CubicCtrlPts] = fCornerPts[cornerPos + 1];
90 cubics[SkPatchUtils::kBottomP0_CubicCtrlPts] = fCornerPts[cornerPos + (fCols + 1)]; 90 cubics[SkPatchUtils::kBottomP0_CubicCtrlPts] = fCornerPts[cornerPos + (fCols + 1)];
91 cubics[SkPatchUtils::kBottomP3_CubicCtrlPts] = fCornerPts[cornerPos + (fCols + 1) + 1]; 91 cubics[SkPatchUtils::kBottomP3_CubicCtrlPts] = fCornerPts[cornerPos + (fCols + 1) + 1];
92 92
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 void SkPatchGrid::draw(SkCanvas* canvas, SkPaint& paint) { 152 void SkPatchGrid::draw(SkCanvas* canvas, SkPaint& paint) {
153 int* maxCols = new int[fCols]; 153 int* maxCols = new int[fCols];
154 int* maxRows = new int[fRows]; 154 int* maxRows = new int[fRows];
155 memset(maxCols, 0, fCols * sizeof(int)); 155 memset(maxCols, 0, fCols * sizeof(int));
156 memset(maxRows, 0, fRows * sizeof(int)); 156 memset(maxRows, 0, fRows * sizeof(int));
157 157
158 // Get the maximum level of detail per axis for each row and column 158 // Get the maximum level of detail per axis for each row and column
159 for (int y = 0; y < fRows; y++) { 159 for (int y = 0; y < fRows; y++) {
160 for (int x = 0; x < fCols; x++) { 160 for (int x = 0; x < fCols; x++) {
161 SkPoint cubics[12]; 161 SkPoint cubics[12];
162 this->getPatch(x, y, cubics, NULL, NULL); 162 this->getPatch(x, y, cubics, nullptr, nullptr);
163 SkMatrix matrix = canvas->getTotalMatrix(); 163 SkMatrix matrix = canvas->getTotalMatrix();
164 SkISize lod = SkPatchUtils::GetLevelOfDetail(cubics, &matrix); 164 SkISize lod = SkPatchUtils::GetLevelOfDetail(cubics, &matrix);
165 maxCols[x] = SkMax32(maxCols[x], lod.width()); 165 maxCols[x] = SkMax32(maxCols[x], lod.width());
166 maxRows[y] = SkMax32(maxRows[y], lod.height()); 166 maxRows[y] = SkMax32(maxRows[y], lod.height());
167 } 167 }
168 } 168 }
169 // Draw the patches by generating their geometry with the maximum level of d etail per axis. 169 // Draw the patches by generating their geometry with the maximum level of d etail per axis.
170 for (int x = 0; x < fCols; x++) { 170 for (int x = 0; x < fCols; x++) {
171 for (int y = 0; y < fRows; y++) { 171 for (int y = 0; y < fRows; y++) {
172 SkPoint cubics[12]; 172 SkPoint cubics[12];
173 SkPoint texCoords[4]; 173 SkPoint texCoords[4];
174 SkColor colors[4]; 174 SkColor colors[4];
175 this->getPatch(x, y, cubics, colors, texCoords); 175 this->getPatch(x, y, cubics, colors, texCoords);
176 SkPatchUtils::VertexData data; 176 SkPatchUtils::VertexData data;
177 if (SkPatchUtils::getVertexData(&data, cubics, 177 if (SkPatchUtils::getVertexData(&data, cubics,
178 fModeFlags & kColors_VertexType ? co lors : NULL, 178 fModeFlags & kColors_VertexType ? co lors : nullptr,
179 fModeFlags & kTexs_VertexType ? texC oords : NULL, 179 fModeFlags & kTexs_VertexType ? texC oords : nullptr,
180 maxCols[x], maxRows[y])) { 180 maxCols[x], maxRows[y])) {
181 canvas->drawVertices(SkCanvas::kTriangles_VertexMode, data.fVert exCount, 181 canvas->drawVertices(SkCanvas::kTriangles_VertexMode, data.fVert exCount,
182 data.fPoints, data.fTexCoords, data.fColors , fXferMode, 182 data.fPoints, data.fTexCoords, data.fColors , fXferMode,
183 data.fIndices, data.fIndexCount, paint); 183 data.fIndices, data.fIndexCount, paint);
184 } 184 }
185 } 185 }
186 } 186 }
187 delete[] maxCols; 187 delete[] maxCols;
188 delete[] maxRows; 188 delete[] maxRows;
189 } 189 }
OLDNEW
« no previous file with comments | « src/utils/SkPatchGrid.h ('k') | src/utils/SkPatchUtils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698