Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: src/c/sk_surface.cpp

Issue 1772463002: use Make instead of Create to return a shared shader (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: partial update of skia call-sites Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkData.h" 9 #include "SkData.h"
10 #include "SkImage.h" 10 #include "SkImage.h"
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 SkShader::TileMode mode; 544 SkShader::TileMode mode;
545 if (!from_c_tilemode(cmode, &mode)) { 545 if (!from_c_tilemode(cmode, &mode)) {
546 return NULL; 546 return NULL;
547 } 547 }
548 SkMatrix matrix; 548 SkMatrix matrix;
549 if (cmatrix) { 549 if (cmatrix) {
550 from_c_matrix(cmatrix, &matrix); 550 from_c_matrix(cmatrix, &matrix);
551 } else { 551 } else {
552 matrix.setIdentity(); 552 matrix.setIdentity();
553 } 553 }
554 SkShader* s = SkGradientShader::CreateLinear(reinterpret_cast<const SkPoint* >(pts), 554 return (sk_shader_t*)SkGradientShader::MakeLinear(reinterpret_cast<const SkP oint*>(pts),
555 reinterpret_cast<const SkColor* >(colors), 555 reinterpret_cast<const SkC olor*>(colors),
556 colorPos, colorCount, mode, 0, &matrix); 556 colorPos, colorCount,
557 return (sk_shader_t*)s; 557 mode, 0, &matrix).release( );
558 } 558 }
559 559
560 static const SkPoint& to_skpoint(const sk_point_t& p) { 560 static const SkPoint& to_skpoint(const sk_point_t& p) {
561 return reinterpret_cast<const SkPoint&>(p); 561 return reinterpret_cast<const SkPoint&>(p);
562 } 562 }
563 563
564 sk_shader_t* sk_shader_new_radial_gradient(const sk_point_t* ccenter, 564 sk_shader_t* sk_shader_new_radial_gradient(const sk_point_t* ccenter,
565 float radius, 565 float radius,
566 const sk_color_t colors[], 566 const sk_color_t colors[],
567 const float colorPos[], 567 const float colorPos[],
568 int colorCount, 568 int colorCount,
569 sk_shader_tilemode_t cmode, 569 sk_shader_tilemode_t cmode,
570 const sk_matrix_t* cmatrix) { 570 const sk_matrix_t* cmatrix) {
571 SkShader::TileMode mode; 571 SkShader::TileMode mode;
572 if (!from_c_tilemode(cmode, &mode)) { 572 if (!from_c_tilemode(cmode, &mode)) {
573 return NULL; 573 return NULL;
574 } 574 }
575 SkMatrix matrix; 575 SkMatrix matrix;
576 if (cmatrix) { 576 if (cmatrix) {
577 from_c_matrix(cmatrix, &matrix); 577 from_c_matrix(cmatrix, &matrix);
578 } else { 578 } else {
579 matrix.setIdentity(); 579 matrix.setIdentity();
580 } 580 }
581 SkPoint center = to_skpoint(*ccenter); 581 SkPoint center = to_skpoint(*ccenter);
582 SkShader* s = SkGradientShader::CreateRadial( 582 return (sk_shader_t*)SkGradientShader::MakeRadial(center, (SkScalar)radius,
583 center, (SkScalar)radius, 583 reinterpret_cast<const SkC olor*>(colors),
584 reinterpret_cast<const SkColor*>(colors), 584 reinterpret_cast<const SkS calar*>(colorPos),
585 reinterpret_cast<const SkScalar*>(colorPos), 585 colorCount, mode, 0, &matr ix).release();
586 colorCount, mode, 0, &matrix);
587 return (sk_shader_t*)s;
588 } 586 }
589 587
590 sk_shader_t* sk_shader_new_sweep_gradient(const sk_point_t* ccenter, 588 sk_shader_t* sk_shader_new_sweep_gradient(const sk_point_t* ccenter,
591 const sk_color_t colors[], 589 const sk_color_t colors[],
592 const float colorPos[], 590 const float colorPos[],
593 int colorCount, 591 int colorCount,
594 const sk_matrix_t* cmatrix) { 592 const sk_matrix_t* cmatrix) {
595 SkMatrix matrix; 593 SkMatrix matrix;
596 if (cmatrix) { 594 if (cmatrix) {
597 from_c_matrix(cmatrix, &matrix); 595 from_c_matrix(cmatrix, &matrix);
598 } else { 596 } else {
599 matrix.setIdentity(); 597 matrix.setIdentity();
600 } 598 }
601 SkShader* s = SkGradientShader::CreateSweep( 599 return (sk_shader_t*)SkGradientShader::MakeSweep((SkScalar)(ccenter->x),
602 (SkScalar)(ccenter->x), 600 (SkScalar)(ccenter->y),
603 (SkScalar)(ccenter->y), 601 reinterpret_cast<const SkCo lor*>(colors),
604 reinterpret_cast<const SkColor*>(colors), 602 reinterpret_cast<const SkSc alar*>(colorPos),
605 reinterpret_cast<const SkScalar*>(colorPos), 603 colorCount, 0, &matrix).rel ease();
606 colorCount, 0, &matrix);
607 return (sk_shader_t*)s;
608 } 604 }
609 605
610 sk_shader_t* sk_shader_new_two_point_conical_gradient(const sk_point_t* start, 606 sk_shader_t* sk_shader_new_two_point_conical_gradient(const sk_point_t* start,
611 float startRadius, 607 float startRadius,
612 const sk_point_t* end, 608 const sk_point_t* end,
613 float endRadius, 609 float endRadius,
614 const sk_color_t colors[], 610 const sk_color_t colors[],
615 const float colorPos[], 611 const float colorPos[],
616 int colorCount, 612 int colorCount,
617 sk_shader_tilemode_t cmode , 613 sk_shader_tilemode_t cmode ,
618 const sk_matrix_t* cmatrix ) { 614 const sk_matrix_t* cmatrix ) {
619 SkShader::TileMode mode; 615 SkShader::TileMode mode;
620 if (!from_c_tilemode(cmode, &mode)) { 616 if (!from_c_tilemode(cmode, &mode)) {
621 return NULL; 617 return NULL;
622 } 618 }
623 SkMatrix matrix; 619 SkMatrix matrix;
624 if (cmatrix) { 620 if (cmatrix) {
625 from_c_matrix(cmatrix, &matrix); 621 from_c_matrix(cmatrix, &matrix);
626 } else { 622 } else {
627 matrix.setIdentity(); 623 matrix.setIdentity();
628 } 624 }
629 SkPoint skstart = to_skpoint(*start); 625 SkPoint skstart = to_skpoint(*start);
630 SkPoint skend = to_skpoint(*end); 626 SkPoint skend = to_skpoint(*end);
631 SkShader* s = SkGradientShader::CreateTwoPointConical( 627 return (sk_shader_t*)SkGradientShader::MakeTwoPointConical(skstart, (SkScala r)startRadius,
632 skstart, (SkScalar)startRadius, 628 skend, (SkScalar)endRadi us,
633 skend, (SkScalar)endRadius, 629 reinterpret_cast<const S kColor*>(colors),
634 reinterpret_cast<const SkColor*>(colors), 630 reinterpret_cast<const S kScalar*>(colorPos),
635 reinterpret_cast<const SkScalar*>(colorPos), 631 colorCount, mode, 0, &ma trix).release();
636 colorCount, mode, 0, &matrix);
637 return (sk_shader_t*)s;
638 } 632 }
639 633
640 //////////////////////////////////////////////////////////////////////////////// /////////// 634 //////////////////////////////////////////////////////////////////////////////// ///////////
641 635
642 #include "../../include/effects/SkBlurMaskFilter.h" 636 #include "../../include/effects/SkBlurMaskFilter.h"
643 #include "sk_maskfilter.h" 637 #include "sk_maskfilter.h"
644 638
645 const struct { 639 const struct {
646 sk_blurstyle_t fC; 640 sk_blurstyle_t fC;
647 SkBlurStyle fSk; 641 SkBlurStyle fSk;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 698
705 size_t sk_data_get_size(const sk_data_t* cdata) { 699 size_t sk_data_get_size(const sk_data_t* cdata) {
706 return AsData(cdata)->size(); 700 return AsData(cdata)->size();
707 } 701 }
708 702
709 const void* sk_data_get_data(const sk_data_t* cdata) { 703 const void* sk_data_get_data(const sk_data_t* cdata) {
710 return AsData(cdata)->data(); 704 return AsData(cdata)->data();
711 } 705 }
712 706
713 //////////////////////////////////////////////////////////////////////////////// /////////// 707 //////////////////////////////////////////////////////////////////////////////// ///////////
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698