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

Side by Side Diff: gm/conicpaths.cpp

Issue 811863006: Revert of enable conics gm (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 11 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 | gyp/gmslides.gypi » ('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 2013 Google Inc. 2 * Copyright 2013 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 "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkTArray.h" 10 #include "SkTArray.h"
11 11
12 class ConicPathsGM : public skiagm::GM { 12 class ConicPathsGM : public skiagm::GM {
13 protected: 13 protected:
14 14
15 SkString onShortName() SK_OVERRIDE { 15 SkString onShortName() SK_OVERRIDE {
16 return SkString("conicpaths"); 16 return SkString("conicpaths");
17 } 17 }
18 18
19 SkISize onISize() SK_OVERRIDE { 19 SkISize onISize() SK_OVERRIDE {
20 return SkISize::Make(920, 960); 20 return SkISize::Make(950, 1000);
21 } 21 }
22 22
23 void onOnceBeforeDraw() SK_OVERRIDE { 23 void onOnceBeforeDraw() SK_OVERRIDE {
24 { 24 {
25 const SkScalar w = SkScalarSqrt(2)/2; 25 const SkScalar w = SkScalarSqrt(2)/2;
26 SkPath* conicCirlce = &fPaths.push_back(); 26 SkPath* conicCirlce = &fPaths.push_back();
27 conicCirlce->moveTo(0, 0); 27 conicCirlce->moveTo(0, -0);
28 conicCirlce->conicTo(0, 50, 50, 50, w); 28 conicCirlce->conicTo(0, 50, 50, 50, w);
29 conicCirlce->rConicTo(50, 0, 50, -50, w); 29 conicCirlce->rConicTo(50, 0, 50, -50, w);
30 conicCirlce->rConicTo(0, -50, -50, -50, w); 30 conicCirlce->rConicTo(0, -50, -50, -50, w);
31 conicCirlce->rConicTo(-50, 0, -50, 50, w); 31 conicCirlce->rConicTo(-50, 0, -50, 50, w);
32 32
33 } 33 }
34 { 34 {
35 SkPath* hyperbola = &fPaths.push_back(); 35 SkPath* hyperbola = &fPaths.push_back();
36 hyperbola->moveTo(0, 0); 36 hyperbola->moveTo(0, -0);
37 hyperbola->conicTo(0, 100, 100, 100, 2); 37 hyperbola->conicTo(0, 100, 100, 100, 2);
38 } 38 }
39 { 39 {
40 SkPath* thinHyperbola = &fPaths.push_back(); 40 SkPath* thinHyperbola = &fPaths.push_back();
41 thinHyperbola->moveTo(0, 0); 41 thinHyperbola->moveTo(0, -0);
42 thinHyperbola->conicTo(100, 100, 5, 0, 2); 42 thinHyperbola->conicTo(100, 100, 5, 0, 2);
43 } 43 }
44 { 44 {
45 SkPath* veryThinHyperbola = &fPaths.push_back(); 45 SkPath* veryThinHyperbola = &fPaths.push_back();
46 veryThinHyperbola->moveTo(0, 0); 46 veryThinHyperbola->moveTo(0, -0);
47 veryThinHyperbola->conicTo(100, 100, 1, 0, 2); 47 veryThinHyperbola->conicTo(100, 100, 1, 0, 2);
48 } 48 }
49 { 49 {
50 SkPath* closedHyperbola = &fPaths.push_back(); 50 SkPath* closedHyperbola = &fPaths.push_back();
51 closedHyperbola->moveTo(0, 0); 51 closedHyperbola->moveTo(0, -0);
52 closedHyperbola->conicTo(100, 100, 0, 0, 2); 52 closedHyperbola->conicTo(100, 100, 0, 0, 2);
53 } 53 }
54 { 54 {
55 // using 1 as weight defaults to using quadTo 55 // using 1 as weight defaults to using quadTo
56 SkPath* nearParabola = &fPaths.push_back(); 56 SkPath* nearParabola = &fPaths.push_back();
57 nearParabola->moveTo(0, 0); 57 nearParabola->moveTo(0, -0);
58 nearParabola->conicTo(0, 100, 100, 100, 0.999f); 58 nearParabola->conicTo(0, 100, 100, 100, 0.999f);
59 } 59 }
60 { 60 {
61 SkPath* thinEllipse = &fPaths.push_back(); 61 SkPath* thinEllipse = &fPaths.push_back();
62 thinEllipse->moveTo(0, 0); 62 thinEllipse->moveTo(0, -0);
63 thinEllipse->conicTo(100, 100, 5, 0, SK_ScalarHalf); 63 thinEllipse->conicTo(100, 100, 5, 0, SK_ScalarHalf);
64 } 64 }
65 { 65 {
66 SkPath* veryThinEllipse = &fPaths.push_back(); 66 SkPath* veryThinEllipse = &fPaths.push_back();
67 veryThinEllipse->moveTo(0, 0); 67 veryThinEllipse->moveTo(0, -0);
68 veryThinEllipse->conicTo(100, 100, 1, 0, SK_ScalarHalf); 68 veryThinEllipse->conicTo(100, 100, 1, 0, SK_ScalarHalf);
69 } 69 }
70 { 70 {
71 SkPath* closedEllipse = &fPaths.push_back(); 71 SkPath* closedEllipse = &fPaths.push_back();
72 closedEllipse->moveTo(0, 0); 72 closedEllipse->moveTo(0, -0);
73 closedEllipse->conicTo(100, 100, 0, 0, SK_ScalarHalf); 73 closedEllipse->conicTo(100, 100, 0, 0, SK_ScalarHalf);
74 } 74 }
75 } 75 }
76 76
77 void onDraw(SkCanvas* canvas) SK_OVERRIDE { 77 void onDraw(SkCanvas* canvas) SK_OVERRIDE {
78 const SkAlpha kAlphaValue[] = { 0xFF, 0x40 }; 78 const SkAlpha kAlphaValue[] = { 0xFF, 0x40 };
79 79
80 SkScalar maxH = 0;
80 const SkScalar margin = 15; 81 const SkScalar margin = 15;
81 canvas->translate(margin, margin); 82 canvas->translate(margin, margin);
83 canvas->save();
82 84
83 SkPaint paint; 85 SkScalar x = margin;
86 int counter = 0;
84 for (int p = 0; p < fPaths.count(); ++p) { 87 for (int p = 0; p < fPaths.count(); ++p) {
85 canvas->save();
86 for (size_t a = 0; a < SK_ARRAY_COUNT(kAlphaValue); ++a) { 88 for (size_t a = 0; a < SK_ARRAY_COUNT(kAlphaValue); ++a) {
87 paint.setARGB(kAlphaValue[a], 0, 0, 0);
88 for (int aa = 0; aa < 2; ++aa) { 89 for (int aa = 0; aa < 2; ++aa) {
89 paint.setAntiAlias(SkToBool(aa));
90 for (int fh = 0; fh < 2; ++fh) { 90 for (int fh = 0; fh < 2; ++fh) {
91 paint.setStyle(fh ? SkPaint::kStroke_Style : SkPaint::kF ill_Style);
92 91
93 const SkRect& bounds = fPaths[p].getBounds(); 92 const SkRect& bounds = fPaths[p].getBounds();
93
94 SkPaint paint;
95 paint.setARGB(kAlphaValue[a], 0, 0, 0);
96 paint.setAntiAlias(SkToBool(aa));
97 if (fh == 1) {
98 paint.setStyle(SkPaint::kStroke_Style);
99 paint.setStrokeWidth(0);
100 } else if (fh == 0) {
101 paint.setStyle(SkPaint::kFill_Style);
102 }
94 canvas->save(); 103 canvas->save();
95 canvas->translate(-bounds.fLeft, -bounds.fTop); 104 canvas->translate(-bounds.fLeft, -bounds.fTop);
96 canvas->drawPath(fPaths[p], paint); 105 canvas->drawPath(fPaths[p], paint);
97 canvas->restore(); 106 canvas->restore();
98 107
99 canvas->translate(110, 0); 108 maxH = SkMaxScalar(maxH, bounds.height());
109
110 SkScalar dx = bounds.width() + margin;
111 x += dx;
112 canvas->translate(dx, 0);
113
114 if (++counter == 8) {
115 counter = 0;
116
117 canvas->restore();
118 canvas->translate(0, maxH + margin);
119 canvas->save();
120 maxH = 0;
121 x = margin;
122 }
100 } 123 }
101 } 124 }
102 } 125 }
103 canvas->restore();
104 canvas->translate(0, 110);
105 } 126 }
106 canvas->restore(); 127 canvas->restore();
107 } 128 }
108 129
109 uint32_t onGetFlags() const SK_OVERRIDE { 130 uint32_t onGetFlags() const SK_OVERRIDE {
110 // tiling w/ non-antialias paths can cause off-by-1-pixels differences w hich are 131 return kSkipPDF_Flag;
111 // unavoidable (chopping in floats -vs- stepping in scan-converter).
112 return kSkipTiled_Flag;
113 } 132 }
114 133
115 private: 134 private:
116 SkTArray<SkPath> fPaths; 135 SkTArray<SkPath> fPaths;
117 typedef skiagm::GM INHERITED; 136 typedef skiagm::GM INHERITED;
118 }; 137 };
119 DEF_GM( return SkNEW(ConicPathsGM); ) 138 DEF_GM( return SkNEW(ConicPathsGM); )
120 139
121 ////////////////////////////////////////////////////////////////////////////// 140 //////////////////////////////////////////////////////////////////////////////
122 141
OLDNEW
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698