OLD | NEW |
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 "SkTwoPointConicalGradient.h" | 8 #include "SkTwoPointConicalGradient.h" |
9 | 9 |
10 #include "SkTwoPointConicalGradient_gpu.h" | 10 #include "SkTwoPointConicalGradient_gpu.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 fRelY = SkScalarToFloat(fy) - fCenterY; | 88 fRelY = SkScalarToFloat(fy) - fCenterY; |
89 fIncX = SkScalarToFloat(dfx); | 89 fIncX = SkScalarToFloat(dfx); |
90 fIncY = SkScalarToFloat(dfy); | 90 fIncY = SkScalarToFloat(dfy); |
91 fB = -2 * (fDCenterX * fRelX + fDCenterY * fRelY + fRDR); | 91 fB = -2 * (fDCenterX * fRelX + fDCenterY * fRelY + fRDR); |
92 fDB = -2 * (fDCenterX * fIncX + fDCenterY * fIncY); | 92 fDB = -2 * (fDCenterX * fIncX + fDCenterY * fIncY); |
93 } | 93 } |
94 | 94 |
95 SkFixed TwoPtRadial::nextT() { | 95 SkFixed TwoPtRadial::nextT() { |
96 float roots[2]; | 96 float roots[2]; |
97 | 97 |
98 float C = sqr(fRelX) + sqr(fRelY) - fRec.fRadius2; | 98 float C = sqr(fRelX) + sqr(fRelY) - fRadius2; |
99 int countRoots = find_quad_roots(fRec.fA, fB, C, roots, fRec.fFlipped); | 99 int countRoots = find_quad_roots(fA, fB, C, roots, fFlipped); |
100 | 100 |
101 fRelX += fIncX; | 101 fRelX += fIncX; |
102 fRelY += fIncY; | 102 fRelY += fIncY; |
103 fB += fDB; | 103 fB += fDB; |
104 | 104 |
105 if (0 == countRoots) { | 105 if (0 == countRoots) { |
106 return kDontDrawT; | 106 return kDontDrawT; |
107 } | 107 } |
108 | 108 |
109 // Prefer the bigger t value if both give a radius(t) > 0 | 109 // Prefer the bigger t value if both give a radius(t) > 0 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 } | 299 } |
300 matrix->preTranslate(-fCenter1.fX, -fCenter1.fY); | 300 matrix->preTranslate(-fCenter1.fX, -fCenter1.fY); |
301 } | 301 } |
302 if (xy) { | 302 if (xy) { |
303 xy[0] = fTileMode; | 303 xy[0] = fTileMode; |
304 xy[1] = kClamp_TileMode; | 304 xy[1] = kClamp_TileMode; |
305 } | 305 } |
306 return kTwoPointConical_BitmapType; | 306 return kTwoPointConical_BitmapType; |
307 } | 307 } |
308 | 308 |
| 309 // Returns the original non-sorted version of the gradient |
309 SkShader::GradientType SkTwoPointConicalGradient::asAGradient( | 310 SkShader::GradientType SkTwoPointConicalGradient::asAGradient( |
310 GradientInfo* info) const { | 311 GradientInfo* info) const { |
311 if (info) { | 312 if (info) { |
312 commonAsAGradient(info); | 313 commonAsAGradient(info, fFlippedGrad); |
313 info->fPoint[0] = fCenter1; | 314 info->fPoint[0] = fCenter1; |
314 info->fPoint[1] = fCenter2; | 315 info->fPoint[1] = fCenter2; |
315 info->fRadius[0] = fRadius1; | 316 info->fRadius[0] = fRadius1; |
316 info->fRadius[1] = fRadius2; | 317 info->fRadius[1] = fRadius2; |
| 318 if (fFlippedGrad) { |
| 319 SkTSwap(info->fPoint[0], info->fPoint[1]); |
| 320 SkTSwap(info->fRadius[0], info->fRadius[1]); |
| 321 } |
317 } | 322 } |
318 return kConical_GradientType; | 323 return kConical_GradientType; |
319 } | 324 } |
320 | 325 |
321 SkTwoPointConicalGradient::SkTwoPointConicalGradient( | 326 SkTwoPointConicalGradient::SkTwoPointConicalGradient( |
322 SkReadBuffer& buffer) | 327 SkReadBuffer& buffer) |
323 : INHERITED(buffer), | 328 : INHERITED(buffer), |
324 fCenter1(buffer.readPoint()), | 329 fCenter1(buffer.readPoint()), |
325 fCenter2(buffer.readPoint()), | 330 fCenter2(buffer.readPoint()), |
326 fRadius1(buffer.readScalar()), | 331 fRadius1(buffer.readScalar()), |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 str->appendScalar(fCenter2.fY); | 393 str->appendScalar(fCenter2.fY); |
389 str->append(") radius2: "); | 394 str->append(") radius2: "); |
390 str->appendScalar(fRadius2); | 395 str->appendScalar(fRadius2); |
391 str->append(" "); | 396 str->append(" "); |
392 | 397 |
393 this->INHERITED::toString(str); | 398 this->INHERITED::toString(str); |
394 | 399 |
395 str->append(")"); | 400 str->append(")"); |
396 } | 401 } |
397 #endif | 402 #endif |
OLD | NEW |