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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
347 SkTwoPointConicalGradient::SkTwoPointConicalGradient( | 347 SkTwoPointConicalGradient::SkTwoPointConicalGradient( |
348 SkReadBuffer& buffer) | 348 SkReadBuffer& buffer) |
349 : INHERITED(buffer), | 349 : INHERITED(buffer) |
350 fCenter1(buffer.readPoint()), | 350 , fCenter1(buffer.readPoint()) |
351 fCenter2(buffer.readPoint()), | 351 , fCenter2(buffer.readPoint()) |
352 fRadius1(buffer.readScalar()), | 352 , fRadius1(buffer.readScalar()) |
353 fRadius2(buffer.readScalar()) { | 353 , fRadius2(buffer.readScalar()) |
354 if (buffer.isVersionLT(SkReadBuffer::kGradientFlippedFlag_Version)) { | 354 , fFlippedGrad(buffer.readBool()) { |
355 // V23_COMPATIBILITY_CODE | |
356 // Sort gradient by radius size for old pictures | |
357 if (fRadius2 < fRadius1) { | |
358 SkTSwap(fCenter1, fCenter2); | |
359 SkTSwap(fRadius1, fRadius2); | |
360 this->flipGradientColors(); | |
361 fFlippedGrad = true; | |
362 } else { | |
363 fFlippedGrad = false; | |
364 } | |
365 } else { | |
366 fFlippedGrad = buffer.readBool(); | |
367 } | |
368 this->init(); | 355 this->init(); |
369 }; | 356 } |
370 #endif | 357 #endif |
371 | 358 |
372 SkFlattenable* SkTwoPointConicalGradient::CreateProc(SkReadBuffer& buffer) { | 359 SkFlattenable* SkTwoPointConicalGradient::CreateProc(SkReadBuffer& buffer) { |
373 DescriptorScope desc; | 360 DescriptorScope desc; |
374 if (!desc.unflatten(buffer)) { | 361 if (!desc.unflatten(buffer)) { |
375 return NULL; | 362 return NULL; |
376 } | 363 } |
377 SkPoint c1 = buffer.readPoint(); | 364 SkPoint c1 = buffer.readPoint(); |
378 SkPoint c2 = buffer.readPoint(); | 365 SkPoint c2 = buffer.readPoint(); |
379 SkScalar r1 = buffer.readScalar(); | 366 SkScalar r1 = buffer.readScalar(); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 str->appendScalar(fCenter2.fY); | 448 str->appendScalar(fCenter2.fY); |
462 str->append(") radius2: "); | 449 str->append(") radius2: "); |
463 str->appendScalar(fRadius2); | 450 str->appendScalar(fRadius2); |
464 str->append(" "); | 451 str->append(" "); |
465 | 452 |
466 this->INHERITED::toString(str); | 453 this->INHERITED::toString(str); |
467 | 454 |
468 str->append(")"); | 455 str->append(")"); |
469 } | 456 } |
470 #endif | 457 #endif |
OLD | NEW |