OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "sk_canvas.h" | 8 #include "sk_canvas.h" |
9 #include "sk_data.h" | 9 #include "sk_data.h" |
10 #include "sk_image.h" | 10 #include "sk_image.h" |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 from_c_matrix(cmatrix, &matrix); | 544 from_c_matrix(cmatrix, &matrix); |
545 } else { | 545 } else { |
546 matrix.setIdentity(); | 546 matrix.setIdentity(); |
547 } | 547 } |
548 SkShader* s = SkGradientShader::CreateLinear(reinterpret_cast<const SkPoint*
>(pts), | 548 SkShader* s = SkGradientShader::CreateLinear(reinterpret_cast<const SkPoint*
>(pts), |
549 reinterpret_cast<const SkColor*
>(colors), | 549 reinterpret_cast<const SkColor*
>(colors), |
550 colorPos, colorCount, mode, 0,
&matrix); | 550 colorPos, colorCount, mode, 0,
&matrix); |
551 return (sk_shader_t*)s; | 551 return (sk_shader_t*)s; |
552 } | 552 } |
553 | 553 |
| 554 static const SkPoint& to_skpoint(const sk_point_t& p) { |
| 555 return reinterpret_cast<const SkPoint&>(p); |
| 556 } |
| 557 |
| 558 sk_shader_t* sk_shader_new_radial_gradient(const sk_point_t* ccenter, |
| 559 float radius, |
| 560 const sk_color_t colors[], |
| 561 const float colorPos[], |
| 562 int colorCount, |
| 563 sk_shader_tilemode_t cmode, |
| 564 const sk_matrix_t* cmatrix) { |
| 565 SkShader::TileMode mode; |
| 566 if (!from_c_tilemode(cmode, &mode)) { |
| 567 return NULL; |
| 568 } |
| 569 SkMatrix matrix; |
| 570 if (cmatrix) { |
| 571 from_c_matrix(cmatrix, &matrix); |
| 572 } else { |
| 573 matrix.setIdentity(); |
| 574 } |
| 575 SkPoint center = to_skpoint(*ccenter); |
| 576 SkShader* s = SkGradientShader::CreateRadial( |
| 577 center, (SkScalar)radius, |
| 578 reinterpret_cast<const SkColor*>(colors), |
| 579 reinterpret_cast<const SkScalar*>(colorPos), |
| 580 colorCount, mode, 0, &matrix); |
| 581 return (sk_shader_t*)s; |
| 582 } |
| 583 |
| 584 sk_shader_t* sk_shader_new_sweep_gradient(const sk_point_t* ccenter, |
| 585 const sk_color_t colors[], |
| 586 const float colorPos[], |
| 587 int colorCount, |
| 588 const sk_matrix_t* cmatrix) { |
| 589 SkMatrix matrix; |
| 590 if (cmatrix) { |
| 591 from_c_matrix(cmatrix, &matrix); |
| 592 } else { |
| 593 matrix.setIdentity(); |
| 594 } |
| 595 SkShader* s = SkGradientShader::CreateSweep( |
| 596 (SkScalar)(ccenter->x), |
| 597 (SkScalar)(ccenter->y), |
| 598 reinterpret_cast<const SkColor*>(colors), |
| 599 reinterpret_cast<const SkScalar*>(colorPos), |
| 600 colorCount, 0, &matrix); |
| 601 return (sk_shader_t*)s; |
| 602 } |
| 603 |
| 604 sk_shader_t* sk_shader_new_two_point_conical_gradient(const sk_point_t* start, |
| 605 float startRadius, |
| 606 const sk_point_t* end, |
| 607 float endRadius, |
| 608 const sk_color_t colors[], |
| 609 const float colorPos[], |
| 610 int colorCount, |
| 611 sk_shader_tilemode_t cmode
, |
| 612 const sk_matrix_t* cmatrix
) { |
| 613 SkShader::TileMode mode; |
| 614 if (!from_c_tilemode(cmode, &mode)) { |
| 615 return NULL; |
| 616 } |
| 617 SkMatrix matrix; |
| 618 if (cmatrix) { |
| 619 from_c_matrix(cmatrix, &matrix); |
| 620 } else { |
| 621 matrix.setIdentity(); |
| 622 } |
| 623 SkPoint skstart = to_skpoint(*start); |
| 624 SkPoint skend = to_skpoint(*end); |
| 625 SkShader* s = SkGradientShader::CreateTwoPointConical( |
| 626 skstart, (SkScalar)startRadius, |
| 627 skend, (SkScalar)endRadius, |
| 628 reinterpret_cast<const SkColor*>(colors), |
| 629 reinterpret_cast<const SkScalar*>(colorPos), |
| 630 colorCount, mode, 0, &matrix); |
| 631 return (sk_shader_t*)s; |
| 632 } |
| 633 |
554 ////////////////////////////////////////////////////////////////////////////////
/////////// | 634 ////////////////////////////////////////////////////////////////////////////////
/////////// |
555 | 635 |
556 #include "../../include/effects/SkBlurMaskFilter.h" | 636 #include "../../include/effects/SkBlurMaskFilter.h" |
557 #include "sk_maskfilter.h" | 637 #include "sk_maskfilter.h" |
558 | 638 |
559 const struct { | 639 const struct { |
560 sk_blurstyle_t fC; | 640 sk_blurstyle_t fC; |
561 SkBlurStyle fSk; | 641 SkBlurStyle fSk; |
562 } gBlurStylePairs[] = { | 642 } gBlurStylePairs[] = { |
563 { NORMAL_SK_BLUR_STYLE, kNormal_SkBlurStyle }, | 643 { NORMAL_SK_BLUR_STYLE, kNormal_SkBlurStyle }, |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 sk_image_t* cimage = sk_surface_new_image_snapshot(csurface); | 745 sk_image_t* cimage = sk_surface_new_image_snapshot(csurface); |
666 | 746 |
667 // HERE WE CROSS THE C..C++ boundary | 747 // HERE WE CROSS THE C..C++ boundary |
668 canvas->drawImage((const SkImage*)cimage, 20, 20, NULL); | 748 canvas->drawImage((const SkImage*)cimage, 20, 20, NULL); |
669 | 749 |
670 sk_path_delete(cpath); | 750 sk_path_delete(cpath); |
671 sk_paint_delete(cpaint); | 751 sk_paint_delete(cpaint); |
672 sk_image_unref(cimage); | 752 sk_image_unref(cimage); |
673 sk_surface_unref(csurface); | 753 sk_surface_unref(csurface); |
674 } | 754 } |
OLD | NEW |