| 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 struct TwoPtRadialContext { | 10 struct TwoPtRadialContext { |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 } | 311 } |
| 312 SkPoint c1 = buffer.readPoint(); | 312 SkPoint c1 = buffer.readPoint(); |
| 313 SkPoint c2 = buffer.readPoint(); | 313 SkPoint c2 = buffer.readPoint(); |
| 314 SkScalar r1 = buffer.readScalar(); | 314 SkScalar r1 = buffer.readScalar(); |
| 315 SkScalar r2 = buffer.readScalar(); | 315 SkScalar r2 = buffer.readScalar(); |
| 316 | 316 |
| 317 if (buffer.readBool()) { // flipped | 317 if (buffer.readBool()) { // flipped |
| 318 SkTSwap(c1, c2); | 318 SkTSwap(c1, c2); |
| 319 SkTSwap(r1, r2); | 319 SkTSwap(r1, r2); |
| 320 | 320 |
| 321 SkColor* colors = desc.mutableColors(); | 321 SkColor4f* colors = desc.mutableColors(); |
| 322 SkScalar* pos = desc.mutablePos(); | 322 SkScalar* pos = desc.mutablePos(); |
| 323 const int last = desc.fCount - 1; | 323 const int last = desc.fCount - 1; |
| 324 const int half = desc.fCount >> 1; | 324 const int half = desc.fCount >> 1; |
| 325 for (int i = 0; i < half; ++i) { | 325 for (int i = 0; i < half; ++i) { |
| 326 SkTSwap(colors[i], colors[last - i]); | 326 SkTSwap(colors[i], colors[last - i]); |
| 327 if (pos) { | 327 if (pos) { |
| 328 SkScalar tmp = pos[i]; | 328 SkScalar tmp = pos[i]; |
| 329 pos[i] = SK_Scalar1 - pos[last - i]; | 329 pos[i] = SK_Scalar1 - pos[last - i]; |
| 330 pos[last - i] = SK_Scalar1 - tmp; | 330 pos[last - i] = SK_Scalar1 - tmp; |
| 331 } | 331 } |
| 332 } | 332 } |
| 333 if (pos) { | 333 if (pos) { |
| 334 if (desc.fCount & 1) { | 334 if (desc.fCount & 1) { |
| 335 pos[half] = SK_Scalar1 - pos[half]; | 335 pos[half] = SK_Scalar1 - pos[half]; |
| 336 } | 336 } |
| 337 } | 337 } |
| 338 } | 338 } |
| 339 | 339 |
| 340 return SkGradientShader::MakeTwoPointConical(c1, r1, c2, r2, desc.fColors, d
esc.fPos, | 340 return SkGradientShader::MakeTwoPointConical(c1, r1, c2, r2, desc.fColors, |
| 341 std::move(desc.fColorSpace), de
sc.fPos, |
| 341 desc.fCount, desc.fTileMode, de
sc.fGradFlags, | 342 desc.fCount, desc.fTileMode, de
sc.fGradFlags, |
| 342 desc.fLocalMatrix); | 343 desc.fLocalMatrix); |
| 343 } | 344 } |
| 344 | 345 |
| 345 void SkTwoPointConicalGradient::flatten(SkWriteBuffer& buffer) const { | 346 void SkTwoPointConicalGradient::flatten(SkWriteBuffer& buffer) const { |
| 346 this->INHERITED::flatten(buffer); | 347 this->INHERITED::flatten(buffer); |
| 347 buffer.writePoint(fCenter1); | 348 buffer.writePoint(fCenter1); |
| 348 buffer.writePoint(fCenter2); | 349 buffer.writePoint(fCenter2); |
| 349 buffer.writeScalar(fRadius1); | 350 buffer.writeScalar(fRadius1); |
| 350 buffer.writeScalar(fRadius2); | 351 buffer.writeScalar(fRadius2); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 str->appendScalar(fCenter2.fY); | 389 str->appendScalar(fCenter2.fY); |
| 389 str->append(") radius2: "); | 390 str->append(") radius2: "); |
| 390 str->appendScalar(fRadius2); | 391 str->appendScalar(fRadius2); |
| 391 str->append(" "); | 392 str->append(" "); |
| 392 | 393 |
| 393 this->INHERITED::toString(str); | 394 this->INHERITED::toString(str); |
| 394 | 395 |
| 395 str->append(")"); | 396 str->append(")"); |
| 396 } | 397 } |
| 397 #endif | 398 #endif |
| OLD | NEW |