OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 #ifndef SkPaint_DEFINED | 8 #ifndef SkPaint_DEFINED |
9 #define SkPaint_DEFINED | 9 #define SkPaint_DEFINED |
10 | 10 |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 | 469 |
470 bool getFillPath(const SkPath& src, SkPath* dst) const { | 470 bool getFillPath(const SkPath& src, SkPath* dst) const { |
471 return this->getFillPath(src, dst, NULL, 1); | 471 return this->getFillPath(src, dst, NULL, 1); |
472 } | 472 } |
473 | 473 |
474 /** Get the paint's shader object. | 474 /** Get the paint's shader object. |
475 <p /> | 475 <p /> |
476 The shader's reference count is not affected. | 476 The shader's reference count is not affected. |
477 @return the paint's shader (or NULL) | 477 @return the paint's shader (or NULL) |
478 */ | 478 */ |
479 SkShader* getShader() const { return fShader.get(); } | 479 SkShader* getShader() const { return fShader; } |
480 | 480 |
481 /** Set or clear the shader object. | 481 /** Set or clear the shader object. |
482 * Shaders specify the source color(s) for what is being drawn. If a paint | 482 * Shaders specify the source color(s) for what is being drawn. If a paint |
483 * has no shader, then the paint's color is used. If the paint has a | 483 * has no shader, then the paint's color is used. If the paint has a |
484 * shader, then the shader's color(s) are use instead, but they are | 484 * shader, then the shader's color(s) are use instead, but they are |
485 * modulated by the paint's alpha. This makes it easy to create a shader | 485 * modulated by the paint's alpha. This makes it easy to create a shader |
486 * once (e.g. bitmap tiling or gradient) and then change its transparency | 486 * once (e.g. bitmap tiling or gradient) and then change its transparency |
487 * w/o having to modify the original shader... only the paint's alpha needs | 487 * w/o having to modify the original shader... only the paint's alpha needs |
488 * to be modified. | 488 * to be modified. |
489 * | 489 * |
490 * There is an exception to this only-respect-paint's-alpha rule: If the sh
ader only generates | 490 * There is an exception to this only-respect-paint's-alpha rule: If the sh
ader only generates |
491 * alpha (e.g. SkShader::CreateBitmapShader(bitmap, ...) where bitmap's col
ortype is kAlpha_8) | 491 * alpha (e.g. SkShader::CreateBitmapShader(bitmap, ...) where bitmap's col
ortype is kAlpha_8) |
492 * then the shader will use the paint's entire color to "colorize" its outp
ut (modulating the | 492 * then the shader will use the paint's entire color to "colorize" its outp
ut (modulating the |
493 * bitmap's alpha with the paint's color+alpha). | 493 * bitmap's alpha with the paint's color+alpha). |
494 * | 494 * |
495 * Pass NULL to clear any previous shader. | 495 * Pass NULL to clear any previous shader. |
496 * As a convenience, the parameter passed is also returned. | 496 * As a convenience, the parameter passed is also returned. |
497 * If a previous shader exists, its reference count is decremented. | 497 * If a previous shader exists, its reference count is decremented. |
498 * If shader is not NULL, its reference count is incremented. | 498 * If shader is not NULL, its reference count is incremented. |
499 * @param shader May be NULL. The shader to be installed in the paint | 499 * @param shader May be NULL. The shader to be installed in the paint |
500 * @return shader | 500 * @return shader |
501 */ | 501 */ |
502 SkShader* setShader(SkShader* shader); | 502 SkShader* setShader(SkShader* shader); |
503 void setShader(sk_sp<SkShader>); | |
504 | 503 |
505 /** Get the paint's colorfilter. If there is a colorfilter, its reference | 504 /** Get the paint's colorfilter. If there is a colorfilter, its reference |
506 count is not changed. | 505 count is not changed. |
507 @return the paint's colorfilter (or NULL) | 506 @return the paint's colorfilter (or NULL) |
508 */ | 507 */ |
509 SkColorFilter* getColorFilter() const { return fColorFilter.get(); } | 508 SkColorFilter* getColorFilter() const { return fColorFilter; } |
510 | 509 |
511 /** Set or clear the paint's colorfilter, returning the parameter. | 510 /** Set or clear the paint's colorfilter, returning the parameter. |
512 <p /> | 511 <p /> |
513 If the paint already has a filter, its reference count is decremented. | 512 If the paint already has a filter, its reference count is decremented. |
514 If filter is not NULL, its reference count is incremented. | 513 If filter is not NULL, its reference count is incremented. |
515 @param filter May be NULL. The filter to be installed in the paint | 514 @param filter May be NULL. The filter to be installed in the paint |
516 @return filter | 515 @return filter |
517 */ | 516 */ |
518 SkColorFilter* setColorFilter(SkColorFilter* filter); | 517 SkColorFilter* setColorFilter(SkColorFilter* filter); |
519 void setColorFilter(sk_sp<SkColorFilter>); | |
520 | 518 |
521 /** Get the paint's xfermode object. | 519 /** Get the paint's xfermode object. |
522 <p /> | 520 <p /> |
523 The xfermode's reference count is not affected. | 521 The xfermode's reference count is not affected. |
524 @return the paint's xfermode (or NULL) | 522 @return the paint's xfermode (or NULL) |
525 */ | 523 */ |
526 SkXfermode* getXfermode() const { return fXfermode.get(); } | 524 SkXfermode* getXfermode() const { return fXfermode; } |
527 | 525 |
528 /** Set or clear the xfermode object. | 526 /** Set or clear the xfermode object. |
529 <p /> | 527 <p /> |
530 Pass NULL to clear any previous xfermode. | 528 Pass NULL to clear any previous xfermode. |
531 As a convenience, the parameter passed is also returned. | 529 As a convenience, the parameter passed is also returned. |
532 If a previous xfermode exists, its reference count is decremented. | 530 If a previous xfermode exists, its reference count is decremented. |
533 If xfermode is not NULL, its reference count is incremented. | 531 If xfermode is not NULL, its reference count is incremented. |
534 @param xfermode May be NULL. The new xfermode to be installed in the | 532 @param xfermode May be NULL. The new xfermode to be installed in the |
535 paint | 533 paint |
536 @return xfermode | 534 @return xfermode |
537 */ | 535 */ |
538 SkXfermode* setXfermode(SkXfermode* xfermode); | 536 SkXfermode* setXfermode(SkXfermode* xfermode); |
539 void setXfermode(sk_sp<SkXfermode>); | |
540 | 537 |
541 /** Create an xfermode based on the specified Mode, and assign it into the | 538 /** Create an xfermode based on the specified Mode, and assign it into the |
542 paint, returning the mode that was set. If the Mode is SrcOver, then | 539 paint, returning the mode that was set. If the Mode is SrcOver, then |
543 the paint's xfermode is set to null. | 540 the paint's xfermode is set to null. |
544 */ | 541 */ |
545 SkXfermode* setXfermodeMode(SkXfermode::Mode); | 542 SkXfermode* setXfermodeMode(SkXfermode::Mode); |
546 | 543 |
547 /** Get the paint's patheffect object. | 544 /** Get the paint's patheffect object. |
548 <p /> | 545 <p /> |
549 The patheffect reference count is not affected. | 546 The patheffect reference count is not affected. |
550 @return the paint's patheffect (or NULL) | 547 @return the paint's patheffect (or NULL) |
551 */ | 548 */ |
552 SkPathEffect* getPathEffect() const { return fPathEffect.get(); } | 549 SkPathEffect* getPathEffect() const { return fPathEffect; } |
553 | 550 |
554 /** Set or clear the patheffect object. | 551 /** Set or clear the patheffect object. |
555 <p /> | 552 <p /> |
556 Pass NULL to clear any previous patheffect. | 553 Pass NULL to clear any previous patheffect. |
557 As a convenience, the parameter passed is also returned. | 554 As a convenience, the parameter passed is also returned. |
558 If a previous patheffect exists, its reference count is decremented. | 555 If a previous patheffect exists, its reference count is decremented. |
559 If patheffect is not NULL, its reference count is incremented. | 556 If patheffect is not NULL, its reference count is incremented. |
560 @param effect May be NULL. The new patheffect to be installed in the | 557 @param effect May be NULL. The new patheffect to be installed in the |
561 paint | 558 paint |
562 @return effect | 559 @return effect |
563 */ | 560 */ |
564 SkPathEffect* setPathEffect(SkPathEffect* effect); | 561 SkPathEffect* setPathEffect(SkPathEffect* effect); |
565 void setPathEffect(sk_sp<SkPathEffect>); | |
566 | 562 |
567 /** Get the paint's maskfilter object. | 563 /** Get the paint's maskfilter object. |
568 <p /> | 564 <p /> |
569 The maskfilter reference count is not affected. | 565 The maskfilter reference count is not affected. |
570 @return the paint's maskfilter (or NULL) | 566 @return the paint's maskfilter (or NULL) |
571 */ | 567 */ |
572 SkMaskFilter* getMaskFilter() const { return fMaskFilter.get(); } | 568 SkMaskFilter* getMaskFilter() const { return fMaskFilter; } |
573 | 569 |
574 /** Set or clear the maskfilter object. | 570 /** Set or clear the maskfilter object. |
575 <p /> | 571 <p /> |
576 Pass NULL to clear any previous maskfilter. | 572 Pass NULL to clear any previous maskfilter. |
577 As a convenience, the parameter passed is also returned. | 573 As a convenience, the parameter passed is also returned. |
578 If a previous maskfilter exists, its reference count is decremented. | 574 If a previous maskfilter exists, its reference count is decremented. |
579 If maskfilter is not NULL, its reference count is incremented. | 575 If maskfilter is not NULL, its reference count is incremented. |
580 @param maskfilter May be NULL. The new maskfilter to be installed in | 576 @param maskfilter May be NULL. The new maskfilter to be installed in |
581 the paint | 577 the paint |
582 @return maskfilter | 578 @return maskfilter |
583 */ | 579 */ |
584 SkMaskFilter* setMaskFilter(SkMaskFilter* maskfilter); | 580 SkMaskFilter* setMaskFilter(SkMaskFilter* maskfilter); |
585 void setMaskFilter(sk_sp<SkMaskFilter>); | |
586 | 581 |
587 // These attributes are for text/fonts | 582 // These attributes are for text/fonts |
588 | 583 |
589 /** Get the paint's typeface object. | 584 /** Get the paint's typeface object. |
590 <p /> | 585 <p /> |
591 The typeface object identifies which font to use when drawing or | 586 The typeface object identifies which font to use when drawing or |
592 measuring text. The typeface reference count is not affected. | 587 measuring text. The typeface reference count is not affected. |
593 @return the paint's typeface (or NULL) | 588 @return the paint's typeface (or NULL) |
594 */ | 589 */ |
595 SkTypeface* getTypeface() const { return fTypeface.get(); } | 590 SkTypeface* getTypeface() const { return fTypeface; } |
596 | 591 |
597 /** Set or clear the typeface object. | 592 /** Set or clear the typeface object. |
598 <p /> | 593 <p /> |
599 Pass NULL to clear any previous typeface. | 594 Pass NULL to clear any previous typeface. |
600 As a convenience, the parameter passed is also returned. | 595 As a convenience, the parameter passed is also returned. |
601 If a previous typeface exists, its reference count is decremented. | 596 If a previous typeface exists, its reference count is decremented. |
602 If typeface is not NULL, its reference count is incremented. | 597 If typeface is not NULL, its reference count is incremented. |
603 @param typeface May be NULL. The new typeface to be installed in the | 598 @param typeface May be NULL. The new typeface to be installed in the |
604 paint | 599 paint |
605 @return typeface | 600 @return typeface |
606 */ | 601 */ |
607 SkTypeface* setTypeface(SkTypeface* typeface); | 602 SkTypeface* setTypeface(SkTypeface* typeface); |
608 void setTypeface(sk_sp<SkTypeface>); | |
609 | 603 |
610 /** Get the paint's rasterizer (or NULL). | 604 /** Get the paint's rasterizer (or NULL). |
611 <p /> | 605 <p /> |
612 The raster controls how paths/text are turned into alpha masks. | 606 The raster controls how paths/text are turned into alpha masks. |
613 @return the paint's rasterizer (or NULL) | 607 @return the paint's rasterizer (or NULL) |
614 */ | 608 */ |
615 SkRasterizer* getRasterizer() const { return fRasterizer.get(); } | 609 SkRasterizer* getRasterizer() const { return fRasterizer; } |
616 | 610 |
617 /** Set or clear the rasterizer object. | 611 /** Set or clear the rasterizer object. |
618 <p /> | 612 <p /> |
619 Pass NULL to clear any previous rasterizer. | 613 Pass NULL to clear any previous rasterizer. |
620 As a convenience, the parameter passed is also returned. | 614 As a convenience, the parameter passed is also returned. |
621 If a previous rasterizer exists in the paint, its reference count is | 615 If a previous rasterizer exists in the paint, its reference count is |
622 decremented. If rasterizer is not NULL, its reference count is | 616 decremented. If rasterizer is not NULL, its reference count is |
623 incremented. | 617 incremented. |
624 @param rasterizer May be NULL. The new rasterizer to be installed in | 618 @param rasterizer May be NULL. The new rasterizer to be installed in |
625 the paint. | 619 the paint. |
626 @return rasterizer | 620 @return rasterizer |
627 */ | 621 */ |
628 SkRasterizer* setRasterizer(SkRasterizer* rasterizer); | 622 SkRasterizer* setRasterizer(SkRasterizer* rasterizer); |
629 void setRasterizer(sk_sp<SkRasterizer>); | |
630 | 623 |
631 SkImageFilter* getImageFilter() const { return fImageFilter.get(); } | 624 SkImageFilter* getImageFilter() const { return fImageFilter; } |
632 SkImageFilter* setImageFilter(SkImageFilter*); | 625 SkImageFilter* setImageFilter(SkImageFilter*); |
633 void setImageFilter(sk_sp<SkImageFilter>); | |
634 | 626 |
635 /** | 627 /** |
636 * Return the paint's SkDrawLooper (if any). Does not affect the looper's | 628 * Return the paint's SkDrawLooper (if any). Does not affect the looper's |
637 * reference count. | 629 * reference count. |
638 */ | 630 */ |
639 SkDrawLooper* getLooper() const { return fLooper.get(); } | 631 SkDrawLooper* getLooper() const { return fLooper; } |
640 | 632 |
641 /** | 633 /** |
642 * Set or clear the looper object. | 634 * Set or clear the looper object. |
643 * <p /> | 635 * <p /> |
644 * Pass NULL to clear any previous looper. | 636 * Pass NULL to clear any previous looper. |
645 * As a convenience, the parameter passed is also returned. | 637 * As a convenience, the parameter passed is also returned. |
646 * If a previous looper exists in the paint, its reference count is | 638 * If a previous looper exists in the paint, its reference count is |
647 * decremented. If looper is not NULL, its reference count is | 639 * decremented. If looper is not NULL, its reference count is |
648 * incremented. | 640 * incremented. |
649 * @param looper May be NULL. The new looper to be installed in the paint. | 641 * @param looper May be NULL. The new looper to be installed in the paint. |
650 * @return looper | 642 * @return looper |
651 */ | 643 */ |
652 SkDrawLooper* setLooper(SkDrawLooper* looper); | 644 SkDrawLooper* setLooper(SkDrawLooper* looper); |
653 void setLooper(sk_sp<SkDrawLooper>); | |
654 | 645 |
655 enum Align { | 646 enum Align { |
656 kLeft_Align, | 647 kLeft_Align, |
657 kCenter_Align, | 648 kCenter_Align, |
658 kRight_Align, | 649 kRight_Align, |
659 }; | 650 }; |
660 enum { | 651 enum { |
661 kAlignCount = 3 | 652 kAlignCount = 3 |
662 }; | 653 }; |
663 | 654 |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 | 1019 |
1029 SkMatrix* setTextMatrix(SkMatrix* matrix) const { | 1020 SkMatrix* setTextMatrix(SkMatrix* matrix) const { |
1030 return SetTextMatrix(matrix, fTextSize, fTextScaleX, fTextSkewX); | 1021 return SetTextMatrix(matrix, fTextSize, fTextScaleX, fTextSkewX); |
1031 } | 1022 } |
1032 | 1023 |
1033 typedef const SkGlyph& (*GlyphCacheProc)(SkGlyphCache*, const char**); | 1024 typedef const SkGlyph& (*GlyphCacheProc)(SkGlyphCache*, const char**); |
1034 | 1025 |
1035 SK_TO_STRING_NONVIRT() | 1026 SK_TO_STRING_NONVIRT() |
1036 | 1027 |
1037 private: | 1028 private: |
1038 sk_sp<SkTypeface> fTypeface; | 1029 SkTypeface* fTypeface; |
1039 sk_sp<SkPathEffect> fPathEffect; | 1030 SkPathEffect* fPathEffect; |
1040 sk_sp<SkShader> fShader; | 1031 SkShader* fShader; |
1041 sk_sp<SkXfermode> fXfermode; | 1032 SkXfermode* fXfermode; |
1042 sk_sp<SkMaskFilter> fMaskFilter; | 1033 SkMaskFilter* fMaskFilter; |
1043 sk_sp<SkColorFilter> fColorFilter; | 1034 SkColorFilter* fColorFilter; |
1044 sk_sp<SkRasterizer> fRasterizer; | 1035 SkRasterizer* fRasterizer; |
1045 sk_sp<SkDrawLooper> fLooper; | 1036 SkDrawLooper* fLooper; |
1046 sk_sp<SkImageFilter> fImageFilter; | 1037 SkImageFilter* fImageFilter; |
1047 | 1038 |
1048 SkScalar fTextSize; | 1039 SkScalar fTextSize; |
1049 SkScalar fTextScaleX; | 1040 SkScalar fTextScaleX; |
1050 SkScalar fTextSkewX; | 1041 SkScalar fTextSkewX; |
1051 SkColor fColor; | 1042 SkColor fColor; |
1052 SkScalar fWidth; | 1043 SkScalar fWidth; |
1053 SkScalar fMiterLimit; | 1044 SkScalar fMiterLimit; |
1054 union { | 1045 union { |
1055 struct { | 1046 struct { |
1056 // all of these bitfields should add up to 32 | 1047 // all of these bitfields should add up to 32 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1146 friend class GrStencilAndCoverTextContext; | 1137 friend class GrStencilAndCoverTextContext; |
1147 friend class GrPathRendering; | 1138 friend class GrPathRendering; |
1148 friend class GrTextUtils; | 1139 friend class GrTextUtils; |
1149 friend class GrGLPathRendering; | 1140 friend class GrGLPathRendering; |
1150 friend class SkScalerContext; | 1141 friend class SkScalerContext; |
1151 friend class SkTextBaseIter; | 1142 friend class SkTextBaseIter; |
1152 friend class SkCanonicalizePaint; | 1143 friend class SkCanonicalizePaint; |
1153 }; | 1144 }; |
1154 | 1145 |
1155 #endif | 1146 #endif |
OLD | NEW |