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

Side by Side Diff: gm/drawatlas.cpp

Issue 2131043002: update path->rsxform to correctly interp dy (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | no next file » | 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 2015 Google Inc. 2 * Copyright 2015 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 "SkRSXform.h" 10 #include "SkRSXform.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 114
115 for (int i = 0; i < count; ++i) { 115 for (int i = 0; i < count; ++i) {
116 SkPoint pos; 116 SkPoint pos;
117 SkVector tan; 117 SkVector tan;
118 if (!meas.getPosTan(xy[i].x(), &pos, &tan)) { 118 if (!meas.getPosTan(xy[i].x(), &pos, &tan)) {
119 pos = xy[i]; 119 pos = xy[i];
120 tan.set(1, 0); 120 tan.set(1, 0);
121 } 121 }
122 xform[i].fSCos = tan.x(); 122 xform[i].fSCos = tan.x();
123 xform[i].fSSin = tan.y(); 123 xform[i].fSSin = tan.y();
124 xform[i].fTx = pos.x(); 124 xform[i].fTx = pos.x() - tan.y() * xy[i].y();
125 xform[i].fTy = pos.y(); 125 xform[i].fTy = pos.y() + tan.x() * xy[i].y();
126 } 126 }
127 127
128 canvas->drawTextRSXform(text, length, &xform[0], nullptr, paint); 128 canvas->drawTextRSXform(text, length, &xform[0], nullptr, paint);
129 } 129 }
130 130
131 DEF_SIMPLE_GM(drawTextRSXform, canvas, 510, 310) { 131 DEF_SIMPLE_GM(drawTextRSXform, canvas, 510, 370) {
132 const char text[] = "ABCDFGHJKLMNOPQRSTUVWXYZ"; 132 const char text0[] = "ABCDFGHJKLMNOPQRSTUVWXYZ";
133 const int N = sizeof(text) - 1; 133 const char text1[] = "AAAAAAAAAAAAAAAAAAAAAAAAAA";
134 const int N = sizeof(text0) - 1;
134 SkPoint pos[N]; 135 SkPoint pos[N];
135 SkRSXform xform[N]; 136 SkRSXform xform[N];
136 137
137 canvas->translate(0, 30); 138 canvas->translate(0, 30);
138 139
139 SkScalar x = 20; 140 SkScalar x = 20;
140 SkScalar dx = 20; 141 SkScalar dx = 20;
141 SkScalar rad = 0; 142 SkScalar rad = 0;
142 SkScalar drad = 2 * SK_ScalarPI / (N - 1); 143 SkScalar drad = 2 * SK_ScalarPI / (N - 1);
143 for (int i = 0; i < N; ++i) { 144 for (int i = 0; i < N; ++i) {
144 xform[i].fSCos = SkScalarCos(rad); 145 xform[i].fSCos = SkScalarCos(rad);
145 xform[i].fSSin = SkScalarSin(rad); 146 xform[i].fSSin = SkScalarSin(rad);
146 xform[i].fTx = x; 147 xform[i].fTx = x;
147 xform[i].fTy = 0; 148 xform[i].fTy = 0;
148 pos[i].set(x, 0); 149 pos[i].set(x, -10);
149 x += dx; 150 x += dx;
150 rad += drad; 151 rad += drad;
151 } 152 }
152 153
153 SkPaint paint; 154 SkPaint paint;
154 paint.setAntiAlias(true); 155 paint.setAntiAlias(true);
155 paint.setTextSize(20); 156 paint.setTextSize(20);
156 canvas->drawTextRSXform(text, N, xform, nullptr, paint); 157 canvas->drawTextRSXform(text0, N, xform, nullptr, paint);
157 158
158 SkPath path; 159 SkPath path;
159 path.addOval(SkRect::MakeXYWH(150, 50, 200, 200)); 160 path.addOval(SkRect::MakeXYWH(150, 100, 200, 200));
160 161
161 draw_text_on_path_rigid(canvas, text, N, pos, path, paint); 162 draw_text_on_path_rigid(canvas, text1, N, pos, path, paint);
162 163
163 paint.setStyle(SkPaint::kStroke_Style); 164 paint.setStyle(SkPaint::kStroke_Style);
164 canvas->drawPath(path, paint); 165 canvas->drawPath(path, paint);
165 } 166 }
166 167
167 168
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698