| 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 #include "SkTwoPointConicalGradient_gpu.h" | 9 #include "SkTwoPointConicalGradient_gpu.h" |
| 10 | 10 |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 TwoPtRadialContext rec(twoPointConicalGradient.fRec, srcPt.fX, srcPt
.fY, 0, 0); | 285 TwoPtRadialContext rec(twoPointConicalGradient.fRec, srcPt.fX, srcPt
.fY, 0, 0); |
| 286 (*shadeProc)(&rec, dstC, cache, toggle, 1); | 286 (*shadeProc)(&rec, dstC, cache, toggle, 1); |
| 287 | 287 |
| 288 dstX += SK_Scalar1; | 288 dstX += SK_Scalar1; |
| 289 toggle = next_dither_toggle(toggle); | 289 toggle = next_dither_toggle(toggle); |
| 290 dstC += 1; | 290 dstC += 1; |
| 291 } | 291 } |
| 292 } | 292 } |
| 293 } | 293 } |
| 294 | 294 |
| 295 SkShader::BitmapType SkTwoPointConicalGradient::asABitmap( | |
| 296 SkBitmap* bitmap, SkMatrix* matrix, SkShader::TileMode* xy) const { | |
| 297 SkPoint diff = fCenter2 - fCenter1; | |
| 298 SkScalar diffLen = 0; | |
| 299 | |
| 300 if (bitmap) { | |
| 301 this->getGradientTableBitmap(bitmap); | |
| 302 } | |
| 303 if (matrix) { | |
| 304 diffLen = diff.length(); | |
| 305 } | |
| 306 if (matrix) { | |
| 307 if (diffLen) { | |
| 308 SkScalar invDiffLen = SkScalarInvert(diffLen); | |
| 309 // rotate to align circle centers with the x-axis | |
| 310 matrix->setSinCos(-SkScalarMul(invDiffLen, diff.fY), | |
| 311 SkScalarMul(invDiffLen, diff.fX)); | |
| 312 } else { | |
| 313 matrix->reset(); | |
| 314 } | |
| 315 matrix->preTranslate(-fCenter1.fX, -fCenter1.fY); | |
| 316 } | |
| 317 if (xy) { | |
| 318 xy[0] = fTileMode; | |
| 319 xy[1] = kClamp_TileMode; | |
| 320 } | |
| 321 return kTwoPointConical_BitmapType; | |
| 322 } | |
| 323 | |
| 324 // Returns the original non-sorted version of the gradient | 295 // Returns the original non-sorted version of the gradient |
| 325 SkShader::GradientType SkTwoPointConicalGradient::asAGradient( | 296 SkShader::GradientType SkTwoPointConicalGradient::asAGradient( |
| 326 GradientInfo* info) const { | 297 GradientInfo* info) const { |
| 327 if (info) { | 298 if (info) { |
| 328 commonAsAGradient(info, fFlippedGrad); | 299 commonAsAGradient(info, fFlippedGrad); |
| 329 info->fPoint[0] = fCenter1; | 300 info->fPoint[0] = fCenter1; |
| 330 info->fPoint[1] = fCenter2; | 301 info->fPoint[1] = fCenter2; |
| 331 info->fRadius[0] = fRadius1; | 302 info->fRadius[0] = fRadius1; |
| 332 info->fRadius[1] = fRadius2; | 303 info->fRadius[1] = fRadius2; |
| 333 if (fFlippedGrad) { | 304 if (fFlippedGrad) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 str->appendScalar(fCenter2.fY); | 406 str->appendScalar(fCenter2.fY); |
| 436 str->append(") radius2: "); | 407 str->append(") radius2: "); |
| 437 str->appendScalar(fRadius2); | 408 str->appendScalar(fRadius2); |
| 438 str->append(" "); | 409 str->append(" "); |
| 439 | 410 |
| 440 this->INHERITED::toString(str); | 411 this->INHERITED::toString(str); |
| 441 | 412 |
| 442 str->append(")"); | 413 str->append(")"); |
| 443 } | 414 } |
| 444 #endif | 415 #endif |
| OLD | NEW |