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

Side by Side Diff: gm/conicpaths.cpp

Issue 18258005: Add implicit hairline conic rendering to GPU (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | include/core/SkGeometry.h » ('J')
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 namespace skiagm { 12 namespace skiagm {
13 13
14 class ConicPathsGM : public GM { 14 class ConicPathsGM : public GM {
15 protected: 15 protected:
16 16
17 virtual SkString onShortName() SK_OVERRIDE { 17 virtual SkString onShortName() SK_OVERRIDE {
18 return SkString("conicpaths"); 18 return SkString("conicpaths");
19 } 19 }
20 20
21 virtual SkISize onISize() SK_OVERRIDE { 21 virtual SkISize onISize() SK_OVERRIDE {
22 return SkISize::Make(1000, 1000); 22 return SkISize::Make(1000, 1000);
23 } 23 }
24 24
25 virtual void onOnceBeforeDraw() SK_OVERRIDE { 25 virtual void onOnceBeforeDraw() SK_OVERRIDE {
26 /*
26 { 27 {
27 SkPath* conicCirlce = &fPaths.push_back(); 28 SkPath* conicCirlce = &fPaths.push_back();
28 conicCirlce->moveTo(0, -0); 29 conicCirlce->moveTo(0, -0);
29 conicCirlce->conicTo(SkIntToScalar(0), SkIntToScalar(50), 30 conicCirlce->conicTo(SkIntToScalar(0), SkIntToScalar(50),
30 SkIntToScalar(50), SkIntToScalar(50), 31 SkIntToScalar(50), SkIntToScalar(50),
31 SkScalarHalf(SkScalarSqrt(2))); 32 SkScalarHalf(SkScalarSqrt(2)));
32 conicCirlce->rConicTo(SkIntToScalar(50), SkIntToScalar(0), 33 conicCirlce->rConicTo(SkIntToScalar(50), SkIntToScalar(0),
33 SkIntToScalar(50), SkIntToScalar(-50), 34 SkIntToScalar(50), SkIntToScalar(-50),
34 SkScalarHalf(SkScalarSqrt(2))); 35 SkScalarHalf(SkScalarSqrt(2)));
35 conicCirlce->rConicTo(SkIntToScalar(0), SkIntToScalar(-50), 36 conicCirlce->rConicTo(SkIntToScalar(0), SkIntToScalar(-50),
36 SkIntToScalar(-50), SkIntToScalar(-50), 37 SkIntToScalar(-50), SkIntToScalar(-50),
37 SkScalarHalf(SkScalarSqrt(2))); 38 SkScalarHalf(SkScalarSqrt(2)));
38 conicCirlce->rConicTo(SkIntToScalar(-50), SkIntToScalar(0), 39 conicCirlce->rConicTo(SkIntToScalar(-50), SkIntToScalar(0),
39 SkIntToScalar(-50), SkIntToScalar(50), 40 SkIntToScalar(-50), SkIntToScalar(50),
40 SkScalarHalf(SkScalarSqrt(2))); 41 SkScalarHalf(SkScalarSqrt(2)));
41 42
42 } 43 }
44 */
43 { 45 {
44 SkPath* hyperbola = &fPaths.push_back(); 46 SkPath* hyperbola = &fPaths.push_back();
45 hyperbola->moveTo(0, -0); 47 hyperbola->moveTo(0, -0);
46 hyperbola->conicTo(SkIntToScalar(0), SkIntToScalar(100), 48 hyperbola->conicTo(SkIntToScalar(0), SkIntToScalar(100),
47 SkIntToScalar(100), SkIntToScalar(100), 49 SkIntToScalar(100), SkIntToScalar(100),
48 SkIntToScalar(2)); 50 SkIntToScalar(2));
49 } 51 }
52
50 { 53 {
51 SkPath* thinHyperbola = &fPaths.push_back(); 54 SkPath* thinHyperbola = &fPaths.push_back();
52 thinHyperbola->moveTo(0, -0); 55 thinHyperbola->moveTo(0, -0);
53 thinHyperbola->conicTo(SkIntToScalar(100), SkIntToScalar(100), 56 thinHyperbola->conicTo(SkIntToScalar(100), SkIntToScalar(100),
54 SkIntToScalar(5), SkIntToScalar(0), 57 SkIntToScalar(5), SkIntToScalar(0),
55 SkIntToScalar(2)); 58 SkIntToScalar(2));
56 } 59 }
57 { 60 {
58 SkPath* veryThinHyperbola = &fPaths.push_back(); 61 SkPath* veryThinHyperbola = &fPaths.push_back();
59 veryThinHyperbola->moveTo(0, -0); 62 veryThinHyperbola->moveTo(0, -0);
60 veryThinHyperbola->conicTo(SkIntToScalar(100), SkIntToScalar(100), 63 veryThinHyperbola->conicTo(SkIntToScalar(100), SkIntToScalar(100),
61 SkIntToScalar(1), SkIntToScalar(0), 64 SkIntToScalar(1), SkIntToScalar(0),
62 SkIntToScalar(2)); 65 SkIntToScalar(2));
63 } 66 }
64 { 67 {
68 SkPath* lopsidedHyperbola = &fPaths.push_back();
69 lopsidedHyperbola->moveTo(0, -0);
70 lopsidedHyperbola->conicTo(SkIntToScalar(100), SkIntToScalar(100),
71 SkIntToScalar(90), SkIntToScalar(110),
72 SkIntToScalar(2));
73 }
74 {
75 SkPath* lopsidedHyperbola = &fPaths.push_back();
76 lopsidedHyperbola->moveTo(0, -0);
77 lopsidedHyperbola->conicTo(SkIntToScalar(100), SkIntToScalar(100),
78 SkIntToScalar(70), SkIntToScalar(40),
79 SkIntToScalar(2));
80 }
81 {
65 SkPath* closedHyperbola = &fPaths.push_back(); 82 SkPath* closedHyperbola = &fPaths.push_back();
66 closedHyperbola->moveTo(0, -0); 83 closedHyperbola->moveTo(0, -0);
67 closedHyperbola->conicTo(SkIntToScalar(100), SkIntToScalar(100), 84 closedHyperbola->conicTo(SkIntToScalar(100), SkIntToScalar(100),
68 SkIntToScalar(0), SkIntToScalar(0), 85 SkIntToScalar(0), SkIntToScalar(0),
69 SkIntToScalar(2)); 86 SkIntToScalar(2));
70 } 87 }
71 { 88 {
72 // using 1 as weight defaults to using quadTo 89 // using 1 as weight defaults to using quadTo
73 SkPath* nearParabola = &fPaths.push_back(); 90 SkPath* nearParabola = &fPaths.push_back();
74 nearParabola->moveTo(0, -0); 91 nearParabola->moveTo(0, -0);
75 nearParabola->conicTo(SkIntToScalar(0), SkIntToScalar(100), 92 nearParabola->conicTo(SkIntToScalar(0), SkIntToScalar(100),
76 SkIntToScalar(100), SkIntToScalar(100), 93 SkIntToScalar(100), SkIntToScalar(100),
77 0.999f); 94 0.999f);
78 } 95 }
79 { 96 {
80 SkPath* thinEllipse = &fPaths.push_back(); 97 SkPath* thinEllipse = &fPaths.push_back();
81 thinEllipse->moveTo(0, -0); 98 thinEllipse->moveTo(0, -0);
82 thinEllipse->conicTo(SkIntToScalar(100), SkIntToScalar(100), 99 thinEllipse->conicTo(SkIntToScalar(100), SkIntToScalar(100),
83 SkIntToScalar(5), SkIntToScalar(0), 100 SkIntToScalar(5), SkIntToScalar(0),
84 SK_ScalarHalf); 101 SK_ScalarHalf);
85 } 102 }
86 { 103 {
87 SkPath* veryThinEllipse = &fPaths.push_back(); 104 SkPath* veryThinEllipse = &fPaths.push_back();
88 veryThinEllipse->moveTo(0, -0); 105 veryThinEllipse->moveTo(0, -0);
89 veryThinEllipse->conicTo(SkIntToScalar(100), SkIntToScalar(100), 106 veryThinEllipse->conicTo(SkIntToScalar(100), SkIntToScalar(100),
90 SkIntToScalar(1), SkIntToScalar(0), 107 SkIntToScalar(1), SkIntToScalar(0),
91 SK_ScalarHalf); 108 SK_ScalarHalf);
92 } 109 }
110 /*
93 { 111 {
94 SkPath* closedEllipse = &fPaths.push_back(); 112 SkPath* closedEllipse = &fPaths.push_back();
95 closedEllipse->moveTo(0, -0); 113 closedEllipse->moveTo(0, -0);
96 closedEllipse->conicTo(SkIntToScalar(100), SkIntToScalar(100), 114 closedEllipse->conicTo(SkIntToScalar(100), SkIntToScalar(100),
97 SkIntToScalar(0), SkIntToScalar(0), 115 SkIntToScalar(0), SkIntToScalar(0),
98 SK_ScalarHalf); 116 SK_ScalarHalf);
99 } 117 }
118 */
100 } 119 }
101 120
102 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 121 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
103 static const SkAlpha kAlphaValue[] = { 0xFF, 0x40 }; 122 static const SkAlpha kAlphaValue[] = { 0xFF, 0x40 };
104 123
105 enum { 124 enum {
106 kMargin = 15, 125 kMargin = 15,
107 }; 126 };
108 int wrapX = canvas->getDeviceSize().fWidth - kMargin; 127 int wrapX = canvas->getDeviceSize().fWidth - kMargin;
109 128
110 SkScalar maxH = 0; 129 SkScalar maxH = 0;
111 canvas->translate(SkIntToScalar(kMargin), SkIntToScalar(kMargin)); 130 canvas->translate(SkIntToScalar(kMargin), SkIntToScalar(kMargin));
112 canvas->save(); 131 canvas->save();
113 132
114 SkScalar x = SkIntToScalar(kMargin); 133 SkScalar x = SkIntToScalar(kMargin);
115 for (int p = 0; p < fPaths.count(); ++p) { 134 for (int p = 0; p < fPaths.count(); ++p) {
116 for (size_t a = 0; a < SK_ARRAY_COUNT(kAlphaValue); ++a) { 135 for (size_t a = 0; a < SK_ARRAY_COUNT(kAlphaValue); ++a) {
117 for (int aa = 0; aa < 2; ++aa) { 136 for (int aa = 1; aa < 2; ++aa) {
118 for (int fh = 0; fh < 2; ++fh) { 137 for (int fh = 1; fh < 2; ++fh) {
119 138
120 const SkRect& bounds = fPaths[p].getBounds(); 139 const SkRect& bounds = fPaths[p].getBounds();
121 140
122 if (x + bounds.width() > wrapX) { 141 if (x + bounds.width() > wrapX) {
123 canvas->restore(); 142 canvas->restore();
124 canvas->translate(0, maxH + SkIntToScalar(kMargin)); 143 canvas->translate(0, maxH + SkIntToScalar(kMargin));
125 canvas->save(); 144 canvas->save();
126 maxH = 0; 145 maxH = 0;
127 x = SkIntToScalar(kMargin); 146 x = SkIntToScalar(kMargin);
128 } 147 }
(...skipping 30 matching lines...) Expand all
159 178
160 private: 179 private:
161 SkTArray<SkPath> fPaths; 180 SkTArray<SkPath> fPaths;
162 typedef GM INHERITED; 181 typedef GM INHERITED;
163 }; 182 };
164 183
165 ////////////////////////////////////////////////////////////////////////////// 184 //////////////////////////////////////////////////////////////////////////////
166 185
167 DEF_GM( return SkNEW(ConicPathsGM); ) 186 DEF_GM( return SkNEW(ConicPathsGM); )
168 } 187 }
OLDNEW
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | include/core/SkGeometry.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698