| 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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 info->fRadius[0] = fRadius1; | 336 info->fRadius[0] = fRadius1; |
| 337 info->fRadius[1] = fRadius2; | 337 info->fRadius[1] = fRadius2; |
| 338 if (fFlippedGrad) { | 338 if (fFlippedGrad) { |
| 339 SkTSwap(info->fPoint[0], info->fPoint[1]); | 339 SkTSwap(info->fPoint[0], info->fPoint[1]); |
| 340 SkTSwap(info->fRadius[0], info->fRadius[1]); | 340 SkTSwap(info->fRadius[0], info->fRadius[1]); |
| 341 } | 341 } |
| 342 } | 342 } |
| 343 return kConical_GradientType; | 343 return kConical_GradientType; |
| 344 } | 344 } |
| 345 | 345 |
| 346 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
| 346 SkTwoPointConicalGradient::SkTwoPointConicalGradient( | 347 SkTwoPointConicalGradient::SkTwoPointConicalGradient( |
| 347 SkReadBuffer& buffer) | 348 SkReadBuffer& buffer) |
| 348 : INHERITED(buffer), | 349 : INHERITED(buffer), |
| 349 fCenter1(buffer.readPoint()), | 350 fCenter1(buffer.readPoint()), |
| 350 fCenter2(buffer.readPoint()), | 351 fCenter2(buffer.readPoint()), |
| 351 fRadius1(buffer.readScalar()), | 352 fRadius1(buffer.readScalar()), |
| 352 fRadius2(buffer.readScalar()) { | 353 fRadius2(buffer.readScalar()) { |
| 353 if (buffer.isVersionLT(SkReadBuffer::kGradientFlippedFlag_Version)) { | 354 if (buffer.isVersionLT(SkReadBuffer::kGradientFlippedFlag_Version)) { |
| 354 // V23_COMPATIBILITY_CODE | 355 // V23_COMPATIBILITY_CODE |
| 355 // Sort gradient by radius size for old pictures | 356 // Sort gradient by radius size for old pictures |
| 356 if (fRadius2 < fRadius1) { | 357 if (fRadius2 < fRadius1) { |
| 357 SkTSwap(fCenter1, fCenter2); | 358 SkTSwap(fCenter1, fCenter2); |
| 358 SkTSwap(fRadius1, fRadius2); | 359 SkTSwap(fRadius1, fRadius2); |
| 359 this->flipGradientColors(); | 360 this->flipGradientColors(); |
| 360 fFlippedGrad = true; | 361 fFlippedGrad = true; |
| 361 } else { | 362 } else { |
| 362 fFlippedGrad = false; | 363 fFlippedGrad = false; |
| 363 } | 364 } |
| 364 } else { | 365 } else { |
| 365 fFlippedGrad = buffer.readBool(); | 366 fFlippedGrad = buffer.readBool(); |
| 366 } | 367 } |
| 367 this->init(); | 368 this->init(); |
| 368 }; | 369 }; |
| 370 #endif |
| 369 | 371 |
| 370 void SkTwoPointConicalGradient::flatten( | 372 SkFlattenable* SkTwoPointConicalGradient::CreateProc(SkReadBuffer& buffer) { |
| 371 SkWriteBuffer& buffer) const { | 373 DescriptorScope desc; |
| 374 if (!desc.unflatten(buffer)) { |
| 375 return NULL; |
| 376 } |
| 377 const SkPoint c1 = buffer.readPoint(); |
| 378 const SkPoint c2 = buffer.readPoint(); |
| 379 const SkScalar r1 = buffer.readScalar(); |
| 380 const SkScalar r2 = buffer.readScalar(); |
| 381 /* flippedGrad = */ buffer.readBool(); |
| 382 |
| 383 return SkGradientShader::CreateTwoPointConical(c1, r1, c2, r2, desc.fColors,
desc.fPos, |
| 384 desc.fCount, desc.fTileMode,
desc.fGradFlags, |
| 385 desc.fLocalMatrix); |
| 386 } |
| 387 |
| 388 void SkTwoPointConicalGradient::flatten(SkWriteBuffer& buffer) const { |
| 372 this->INHERITED::flatten(buffer); | 389 this->INHERITED::flatten(buffer); |
| 373 buffer.writePoint(fCenter1); | 390 buffer.writePoint(fCenter1); |
| 374 buffer.writePoint(fCenter2); | 391 buffer.writePoint(fCenter2); |
| 375 buffer.writeScalar(fRadius1); | 392 buffer.writeScalar(fRadius1); |
| 376 buffer.writeScalar(fRadius2); | 393 buffer.writeScalar(fRadius2); |
| 377 buffer.writeBool(fFlippedGrad); | 394 buffer.writeBool(fFlippedGrad); |
| 378 } | 395 } |
| 379 | 396 |
| 380 #if SK_SUPPORT_GPU | 397 #if SK_SUPPORT_GPU |
| 381 | 398 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 str->appendScalar(fCenter2.fY); | 438 str->appendScalar(fCenter2.fY); |
| 422 str->append(") radius2: "); | 439 str->append(") radius2: "); |
| 423 str->appendScalar(fRadius2); | 440 str->appendScalar(fRadius2); |
| 424 str->append(" "); | 441 str->append(" "); |
| 425 | 442 |
| 426 this->INHERITED::toString(str); | 443 this->INHERITED::toString(str); |
| 427 | 444 |
| 428 str->append(")"); | 445 str->append(")"); |
| 429 } | 446 } |
| 430 #endif | 447 #endif |
| OLD | NEW |