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

Side by Side Diff: samplecode/SampleQuadStroker.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/SamplePicture.cpp ('k') | samplecode/SampleRectanizer.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 2012 Google Inc. 2 * Copyright 2012 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 "SampleCode.h" 9 #include "SampleCode.h"
10 #include "SkView.h" 10 #include "SkView.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 case '-': 189 case '-':
190 fTextSize = SkTMax(1.0f, fTextSize - 1); 190 fTextSize = SkTMax(1.0f, fTextSize - 1);
191 break; 191 break;
192 case '+': 192 case '+':
193 case '=': 193 case '=':
194 fTextSize += 1; 194 fTextSize += 1;
195 break; 195 break;
196 default: 196 default:
197 fText.appendUnichar(uni); 197 fText.appendUnichar(uni);
198 } 198 }
199 this->inval(NULL); 199 this->inval(nullptr);
200 return true; 200 return true;
201 } 201 }
202 return this->INHERITED::onQuery(evt); 202 return this->INHERITED::onQuery(evt);
203 } 203 }
204 204
205 void onSizeChange() override { 205 void onSizeChange() override {
206 fWeightControl.setXYWH(this->width() - 150, 30, 30, 400); 206 fWeightControl.setXYWH(this->width() - 150, 30, 30, 400);
207 fErrorControl.setXYWH(this->width() - 100, 30, 30, 400); 207 fErrorControl.setXYWH(this->width() - 100, 30, 30, 400);
208 fWidthControl.setXYWH(this->width() - 50, 30, 30, 400); 208 fWidthControl.setXYWH(this->width() - 50, 30, 30, 400);
209 int buttonOffset = 450; 209 int buttonOffset = 450;
210 fCubicButton.fBounds.setXYWH(this->width() - 50, SkIntToScalar(buttonOff set), 30, 30); 210 fCubicButton.fBounds.setXYWH(this->width() - 50, SkIntToScalar(buttonOff set), 30, 30);
211 buttonOffset += 50; 211 buttonOffset += 50;
212 fConicButton.fBounds.setXYWH(this->width() - 50, SkIntToScalar(buttonOff set), 30, 30); 212 fConicButton.fBounds.setXYWH(this->width() - 50, SkIntToScalar(buttonOff set), 30, 30);
213 buttonOffset += 50; 213 buttonOffset += 50;
214 fQuadButton.fBounds.setXYWH(this->width() - 50, SkIntToScalar(buttonOffs et), 30, 30); 214 fQuadButton.fBounds.setXYWH(this->width() - 50, SkIntToScalar(buttonOffs et), 30, 30);
215 buttonOffset += 50; 215 buttonOffset += 50;
216 fRRectButton.fBounds.setXYWH(this->width() - 50, SkIntToScalar(buttonOff set), 30, 30); 216 fRRectButton.fBounds.setXYWH(this->width() - 50, SkIntToScalar(buttonOff set), 30, 30);
217 buttonOffset += 50; 217 buttonOffset += 50;
218 fCircleButton.fBounds.setXYWH(this->width() - 50, SkIntToScalar(buttonOf fset), 30, 30); 218 fCircleButton.fBounds.setXYWH(this->width() - 50, SkIntToScalar(buttonOf fset), 30, 30);
219 buttonOffset += 50; 219 buttonOffset += 50;
220 fTextButton.fBounds.setXYWH(this->width() - 50, SkIntToScalar(buttonOffs et), 30, 30); 220 fTextButton.fBounds.setXYWH(this->width() - 50, SkIntToScalar(buttonOffs et), 30, 30);
221 this->INHERITED::onSizeChange(); 221 this->INHERITED::onSizeChange();
222 } 222 }
223 223
224 void copyMinToMax() { 224 void copyMinToMax() {
225 erase(fMaxSurface); 225 erase(fMaxSurface);
226 SkCanvas* canvas = fMaxSurface->getCanvas(); 226 SkCanvas* canvas = fMaxSurface->getCanvas();
227 canvas->save(); 227 canvas->save();
228 canvas->concat(fMatrix); 228 canvas->concat(fMatrix);
229 fMinSurface->draw(canvas, 0, 0, NULL); 229 fMinSurface->draw(canvas, 0, 0, nullptr);
230 canvas->restore(); 230 canvas->restore();
231 231
232 SkPaint paint; 232 SkPaint paint;
233 paint.setXfermodeMode(SkXfermode::kClear_Mode); 233 paint.setXfermodeMode(SkXfermode::kClear_Mode);
234 for (int iy = 1; iy < fH; ++iy) { 234 for (int iy = 1; iy < fH; ++iy) {
235 SkScalar y = SkIntToScalar(iy * fZoom); 235 SkScalar y = SkIntToScalar(iy * fZoom);
236 canvas->drawLine(0, y - SK_ScalarHalf, 999, y - SK_ScalarHalf, paint ); 236 canvas->drawLine(0, y - SK_ScalarHalf, 999, y - SK_ScalarHalf, paint );
237 } 237 }
238 for (int ix = 1; ix < fW; ++ix) { 238 for (int ix = 1; ix < fW; ++ix) {
239 SkScalar x = SkIntToScalar(ix * fZoom); 239 SkScalar x = SkIntToScalar(ix * fZoom);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 SkScalarRoundToInt(950.0f / scale)); 313 SkScalarRoundToInt(950.0f / scale));
314 erase(fMinSurface); 314 erase(fMinSurface);
315 SkPaint paint; 315 SkPaint paint;
316 paint.setColor(0x1f1f0f0f); 316 paint.setColor(0x1f1f0f0f);
317 paint.setStyle(SkPaint::kStroke_Style); 317 paint.setStyle(SkPaint::kStroke_Style);
318 paint.setStrokeWidth(width * scale * scale); 318 paint.setStrokeWidth(width * scale * scale);
319 paint.setColor(0x3f0f1f3f); 319 paint.setColor(0x3f0f1f3f);
320 if (drawText) { 320 if (drawText) {
321 fMinSurface->getCanvas()->drawPath(path, paint); 321 fMinSurface->getCanvas()->drawPath(path, paint);
322 this->copyMinToMax(); 322 this->copyMinToMax();
323 fMaxSurface->draw(canvas, 0, 0, NULL); 323 fMaxSurface->draw(canvas, 0, 0, nullptr);
324 } 324 }
325 paint.setAntiAlias(true); 325 paint.setAntiAlias(true);
326 paint.setStyle(SkPaint::kStroke_Style); 326 paint.setStyle(SkPaint::kStroke_Style);
327 paint.setStrokeWidth(1); 327 paint.setStrokeWidth(1);
328 328
329 paint.setColor(SKELETON_COLOR); 329 paint.setColor(SKELETON_COLOR);
330 SkPath scaled; 330 SkPath scaled;
331 SkMatrix matrix; 331 SkMatrix matrix;
332 matrix.reset(); 332 matrix.reset();
333 matrix.setScale(950 / scale, 950 / scale); 333 matrix.setScale(950 / scale, 950 / scale);
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 "error"); 534 "error");
535 #endif 535 #endif
536 draw_control(canvas, fWidthControl, fWidth * fWidthScale, kWidthMin * fW idthScale, 536 draw_control(canvas, fWidthControl, fWidth * fWidthScale, kWidthMin * fW idthScale,
537 kWidthMax * fWidthScale, "width"); 537 kWidthMax * fWidthScale, "width");
538 draw_button(canvas, fQuadButton); 538 draw_button(canvas, fQuadButton);
539 draw_button(canvas, fCubicButton); 539 draw_button(canvas, fCubicButton);
540 draw_button(canvas, fConicButton); 540 draw_button(canvas, fConicButton);
541 draw_button(canvas, fRRectButton); 541 draw_button(canvas, fRRectButton);
542 draw_button(canvas, fCircleButton); 542 draw_button(canvas, fCircleButton);
543 draw_button(canvas, fTextButton); 543 draw_button(canvas, fTextButton);
544 this->inval(NULL); 544 this->inval(nullptr);
545 } 545 }
546 546
547 class MyClick : public Click { 547 class MyClick : public Click {
548 public: 548 public:
549 int fIndex; 549 int fIndex;
550 MyClick(SkView* target, int index) : Click(target), fIndex(index) {} 550 MyClick(SkView* target, int index) : Click(target), fIndex(index) {}
551 }; 551 };
552 552
553 virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, 553 virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y,
554 unsigned modi) override { 554 unsigned modi) override {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 static SkScalar MapScreenYtoValue(int y, const SkRect& control, SkScalar min , 601 static SkScalar MapScreenYtoValue(int y, const SkRect& control, SkScalar min ,
602 SkScalar max) { 602 SkScalar max) {
603 return (SkIntToScalar(y) - control.fTop) / control.height() * (max - min ) + min; 603 return (SkIntToScalar(y) - control.fTop) / control.height() * (max - min ) + min;
604 } 604 }
605 605
606 bool onClick(Click* click) override { 606 bool onClick(Click* click) override {
607 int index = ((MyClick*)click)->fIndex; 607 int index = ((MyClick*)click)->fIndex;
608 if (index < (int) SK_ARRAY_COUNT(fPts)) { 608 if (index < (int) SK_ARRAY_COUNT(fPts)) {
609 fPts[index].offset(SkIntToScalar(click->fICurr.fX - click->fIPrev.fX ), 609 fPts[index].offset(SkIntToScalar(click->fICurr.fX - click->fIPrev.fX ),
610 SkIntToScalar(click->fICurr.fY - click->fIPrev.fY )); 610 SkIntToScalar(click->fICurr.fY - click->fIPrev.fY ));
611 this->inval(NULL); 611 this->inval(nullptr);
612 } else if (index == (int) SK_ARRAY_COUNT(fPts) + 1) { 612 } else if (index == (int) SK_ARRAY_COUNT(fPts) + 1) {
613 fWeight = MapScreenYtoValue(click->fICurr.fY, fWeightControl, 0, 5); 613 fWeight = MapScreenYtoValue(click->fICurr.fY, fWeightControl, 0, 5);
614 } 614 }
615 #ifdef SK_DEBUG 615 #ifdef SK_DEBUG
616 else if (index == (int) SK_ARRAY_COUNT(fPts) + 2) { 616 else if (index == (int) SK_ARRAY_COUNT(fPts) + 2) {
617 gDebugStrokerError = SkTMax(FLT_EPSILON, MapScreenYtoValue(click->fI Curr.fY, 617 gDebugStrokerError = SkTMax(FLT_EPSILON, MapScreenYtoValue(click->fI Curr.fY,
618 fErrorControl, kStrokerErrorMin, kStrokerErrorMax)); 618 fErrorControl, kStrokerErrorMin, kStrokerErrorMax));
619 gDebugStrokerErrorSet = true; 619 gDebugStrokerErrorSet = true;
620 } 620 }
621 #endif 621 #endif
622 else if (index == (int) SK_ARRAY_COUNT(fPts) + 3) { 622 else if (index == (int) SK_ARRAY_COUNT(fPts) + 3) {
623 fWidth = SkTMax(FLT_EPSILON, MapScreenYtoValue(click->fICurr.fY, fWi dthControl, 623 fWidth = SkTMax(FLT_EPSILON, MapScreenYtoValue(click->fICurr.fY, fWi dthControl,
624 kWidthMin, kWidthMax)); 624 kWidthMin, kWidthMax));
625 fAnimate = fWidth <= kWidthMin; 625 fAnimate = fWidth <= kWidthMin;
626 } 626 }
627 return true; 627 return true;
628 } 628 }
629 629
630 private: 630 private:
631 typedef SkView INHERITED; 631 typedef SkView INHERITED;
632 }; 632 };
633 633
634 /////////////////////////////////////////////////////////////////////////////// 634 ///////////////////////////////////////////////////////////////////////////////
635 635
636 static SkView* F2() { return new QuadStrokerView; } 636 static SkView* F2() { return new QuadStrokerView; }
637 static SkViewRegister gR2(F2); 637 static SkViewRegister gR2(F2);
OLDNEW
« no previous file with comments | « samplecode/SamplePicture.cpp ('k') | samplecode/SampleRectanizer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698