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

Side by Side Diff: samplecode/SampleQuadStroker.cpp

Issue 1157623003: remove SK_LEGACY_STROKE_CURVES (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: work in progress Created 5 years, 7 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 | « no previous file | src/core/SkStroke.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 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 StrokeTypeButton fTextButton; 115 StrokeTypeButton fTextButton;
116 SkString fText; 116 SkString fText;
117 SkScalar fTextSize; 117 SkScalar fTextSize;
118 SkScalar fWeight; 118 SkScalar fWeight;
119 SkScalar fWidth, fDWidth; 119 SkScalar fWidth, fDWidth;
120 SkScalar fWidthScale; 120 SkScalar fWidthScale;
121 int fW, fH, fZoom; 121 int fW, fH, fZoom;
122 bool fAnimate; 122 bool fAnimate;
123 bool fDrawRibs; 123 bool fDrawRibs;
124 bool fDrawTangents; 124 bool fDrawTangents;
125 #if !defined SK_LEGACY_STROKE_CURVES && defined(SK_DEBUG) 125 #ifdef SK_DEBUG
126 #define kStrokerErrorMin 0.001f 126 #define kStrokerErrorMin 0.001f
127 #define kStrokerErrorMax 5 127 #define kStrokerErrorMax 5
128 #endif 128 #endif
129 #define kWidthMin 1 129 #define kWidthMin 1
130 #define kWidthMax 100 130 #define kWidthMax 100
131 public: 131 public:
132 QuadStrokerView() { 132 QuadStrokerView() {
133 this->setBGColor(SK_ColorLTGRAY); 133 this->setBGColor(SK_ColorLTGRAY);
134 134
135 fPts[0].set(50, 200); // cubic 135 fPts[0].set(50, 200); // cubic
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 if (fDWidth > 0 && fWidth > kWidthMax) { 522 if (fDWidth > 0 && fWidth > kWidthMax) {
523 fDWidth = -fDWidth; 523 fDWidth = -fDWidth;
524 } else if (fDWidth < 0 && fWidth < kWidthMin) { 524 } else if (fDWidth < 0 && fWidth < kWidthMin) {
525 fDWidth = -fDWidth; 525 fDWidth = -fDWidth;
526 } 526 }
527 } 527 }
528 setAsNeeded(); 528 setAsNeeded();
529 if (fConicButton.fEnabled) { 529 if (fConicButton.fEnabled) {
530 draw_control(canvas, fWeightControl, fWeight, 0, 5, "weight"); 530 draw_control(canvas, fWeightControl, fWeight, 0, 5, "weight");
531 } 531 }
532 #if !defined SK_LEGACY_STROKE_CURVES && defined(SK_DEBUG) 532 #ifdef SK_DEBUG
533 draw_control(canvas, fErrorControl, gDebugStrokerError, kStrokerErrorMin , kStrokerErrorMax, 533 draw_control(canvas, fErrorControl, gDebugStrokerError, kStrokerErrorMin , kStrokerErrorMax,
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);
(...skipping 11 matching lines...) Expand all
554 unsigned modi) override { 554 unsigned modi) override {
555 for (size_t i = 0; i < SK_ARRAY_COUNT(fPts); ++i) { 555 for (size_t i = 0; i < SK_ARRAY_COUNT(fPts); ++i) {
556 if (hittest(fPts[i], x, y)) { 556 if (hittest(fPts[i], x, y)) {
557 return new MyClick(this, (int)i); 557 return new MyClick(this, (int)i);
558 } 558 }
559 } 559 }
560 const SkRect& rectPt = SkRect::MakeXYWH(x, y, 1, 1); 560 const SkRect& rectPt = SkRect::MakeXYWH(x, y, 1, 1);
561 if (fWeightControl.contains(rectPt)) { 561 if (fWeightControl.contains(rectPt)) {
562 return new MyClick(this, (int) SK_ARRAY_COUNT(fPts) + 1); 562 return new MyClick(this, (int) SK_ARRAY_COUNT(fPts) + 1);
563 } 563 }
564 #if !defined SK_LEGACY_STROKE_CURVES && defined(SK_DEBUG) 564 #ifdef SK_DEBUG
565 if (fErrorControl.contains(rectPt)) { 565 if (fErrorControl.contains(rectPt)) {
566 return new MyClick(this, (int) SK_ARRAY_COUNT(fPts) + 2); 566 return new MyClick(this, (int) SK_ARRAY_COUNT(fPts) + 2);
567 } 567 }
568 #endif 568 #endif
569 if (fWidthControl.contains(rectPt)) { 569 if (fWidthControl.contains(rectPt)) {
570 return new MyClick(this, (int) SK_ARRAY_COUNT(fPts) + 3); 570 return new MyClick(this, (int) SK_ARRAY_COUNT(fPts) + 3);
571 } 571 }
572 if (fCubicButton.fBounds.contains(rectPt)) { 572 if (fCubicButton.fBounds.contains(rectPt)) {
573 fCubicButton.fEnabled ^= true; 573 fCubicButton.fEnabled ^= true;
574 return new MyClick(this, (int) SK_ARRAY_COUNT(fPts) + 4); 574 return new MyClick(this, (int) SK_ARRAY_COUNT(fPts) + 4);
(...skipping 30 matching lines...) Expand all
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(NULL);
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 #if !defined SK_LEGACY_STROKE_CURVES && defined(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 | « no previous file | src/core/SkStroke.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698