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

Side by Side Diff: samplecode/SampleHairCurves.cpp

Issue 21036008: Add Loop Blinn hairline conics to GPU (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 4 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 | src/gpu/GrAAHairLinePathRenderer.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkView.h" 9 #include "SkView.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 17 matching lines...) Expand all
28 28
29 29
30 virtual void onDrawContent(SkCanvas* canvas) { 30 virtual void onDrawContent(SkCanvas* canvas) {
31 SkPaint paint; 31 SkPaint paint;
32 paint.setAntiAlias(true); 32 paint.setAntiAlias(true);
33 paint.setStyle(SkPaint::kStroke_Style); 33 paint.setStyle(SkPaint::kStroke_Style);
34 paint.setStrokeWidth(0); 34 paint.setStrokeWidth(0);
35 canvas->save(); 35 canvas->save();
36 canvas->scale(1000 * SK_Scalar1, 1000 * SK_Scalar1); 36 canvas->scale(1000 * SK_Scalar1, 1000 * SK_Scalar1);
37 SkRandom rand; 37 SkRandom rand;
38 SkRandom randW;
38 SkPath curves; 39 SkPath curves;
39 SkPath hulls; 40 SkPath hulls;
40 SkPath ctrlPts; 41 SkPath ctrlPts;
41 for (int i = 0; i < 100; ++i) { 42 for (int i = 0; i < 100; ++i) {
42 SkScalar pts[] = { 43 SkScalar pts[] = {
43 rand.nextUScalar1(), rand.nextUScalar1(), 44 rand.nextUScalar1(), rand.nextUScalar1(),
44 rand.nextUScalar1(), rand.nextUScalar1(), 45 rand.nextUScalar1(), rand.nextUScalar1(),
45 rand.nextUScalar1(), rand.nextUScalar1(), 46 rand.nextUScalar1(), rand.nextUScalar1(),
46 rand.nextUScalar1(), rand.nextUScalar1() 47 rand.nextUScalar1(), rand.nextUScalar1()
47 }; 48 };
(...skipping 27 matching lines...) Expand all
75 hulls.lineTo(pts[4], pts[5]); 76 hulls.lineTo(pts[4], pts[5]);
76 77
77 ctrlPts.addCircle(pts[0], pts[1], SK_Scalar1 / 200); 78 ctrlPts.addCircle(pts[0], pts[1], SK_Scalar1 / 200);
78 ctrlPts.addCircle(pts[2], pts[3], SK_Scalar1 / 200); 79 ctrlPts.addCircle(pts[2], pts[3], SK_Scalar1 / 200);
79 ctrlPts.addCircle(pts[4], pts[5], SK_Scalar1 / 200); 80 ctrlPts.addCircle(pts[4], pts[5], SK_Scalar1 / 200);
80 } 81 }
81 for (int i = 0; i < 100; ++i) { 82 for (int i = 0; i < 100; ++i) {
82 SkScalar pts[] = { 83 SkScalar pts[] = {
83 rand.nextUScalar1(), rand.nextUScalar1(), 84 rand.nextUScalar1(), rand.nextUScalar1(),
84 rand.nextUScalar1(), rand.nextUScalar1(), 85 rand.nextUScalar1(), rand.nextUScalar1(),
86 rand.nextUScalar1(), rand.nextUScalar1(),
87 };
88 SkScalar weight = randW.nextUScalar1() * 2.0f;
89
90 curves.moveTo(pts[0], pts[1]);
91 curves.conicTo(pts[2], pts[3],
92 pts[4], pts[5],
93 weight);
94
95 hulls.moveTo(pts[0], pts[1]);
96 hulls.lineTo(pts[2], pts[3]);
97 hulls.lineTo(pts[4], pts[5]);
98
99 ctrlPts.addCircle(pts[0], pts[1], SK_Scalar1 / 200);
100 ctrlPts.addCircle(pts[2], pts[3], SK_Scalar1 / 200);
101 ctrlPts.addCircle(pts[4], pts[5], SK_Scalar1 / 200);
102 }
103 for (int i = 0; i < 100; ++i) {
104 SkScalar pts[] = {
105 rand.nextUScalar1(), rand.nextUScalar1(),
106 rand.nextUScalar1(), rand.nextUScalar1(),
85 }; 107 };
86 curves.moveTo(pts[0], pts[1]); 108 curves.moveTo(pts[0], pts[1]);
87 curves.lineTo(pts[2], pts[3]); 109 curves.lineTo(pts[2], pts[3]);
88 110
89 ctrlPts.addCircle(pts[0], pts[1], SK_Scalar1 / 200); 111 ctrlPts.addCircle(pts[0], pts[1], SK_Scalar1 / 200);
90 ctrlPts.addCircle(pts[2], pts[3], SK_Scalar1 / 200); 112 ctrlPts.addCircle(pts[2], pts[3], SK_Scalar1 / 200);
91 } 113 }
92 114
93 paint.setColor(SK_ColorBLACK); 115 paint.setColor(SK_ColorBLACK);
94 canvas->drawPath(curves, paint); 116 canvas->drawPath(curves, paint);
95 paint.setColor(SK_ColorRED); 117 paint.setColor(SK_ColorRED);
96 //canvas->drawPath(hulls, paint); 118 //canvas->drawPath(hulls, paint);
97 paint.setStyle(SkPaint::kFill_Style); 119 paint.setStyle(SkPaint::kFill_Style);
98 paint.setColor(SK_ColorBLUE); 120 paint.setColor(SK_ColorBLUE);
99 //canvas->drawPath(ctrlPts, paint); 121 //canvas->drawPath(ctrlPts, paint);
100 122
101 canvas->restore(); 123 canvas->restore();
102 } 124 }
103 125
104 private: 126 private:
105 typedef SampleView INHERITED; 127 typedef SampleView INHERITED;
106 }; 128 };
107 129
108 ////////////////////////////////////////////////////////////////////////////// 130 //////////////////////////////////////////////////////////////////////////////
109 131
110 static SkView* MyFactory() { return new HairCurvesView; } 132 static SkView* MyFactory() { return new HairCurvesView; }
111 static SkViewRegister reg(MyFactory); 133 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrAAHairLinePathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698