| 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; } | 479 SkShader* getShader() const { return fShader.get(); } |
| 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>); |
| 503 | 504 |
| 504 /** Get the paint's colorfilter. If there is a colorfilter, its reference | 505 /** Get the paint's colorfilter. If there is a colorfilter, its reference |
| 505 count is not changed. | 506 count is not changed. |
| 506 @return the paint's colorfilter (or NULL) | 507 @return the paint's colorfilter (or NULL) |
| 507 */ | 508 */ |
| 508 SkColorFilter* getColorFilter() const { return fColorFilter; } | 509 SkColorFilter* getColorFilter() const { return fColorFilter.get(); } |
| 509 | 510 |
| 510 /** Set or clear the paint's colorfilter, returning the parameter. | 511 /** Set or clear the paint's colorfilter, returning the parameter. |
| 511 <p /> | 512 <p /> |
| 512 If the paint already has a filter, its reference count is decremented. | 513 If the paint already has a filter, its reference count is decremented. |
| 513 If filter is not NULL, its reference count is incremented. | 514 If filter is not NULL, its reference count is incremented. |
| 514 @param filter May be NULL. The filter to be installed in the paint | 515 @param filter May be NULL. The filter to be installed in the paint |
| 515 @return filter | 516 @return filter |
| 516 */ | 517 */ |
| 517 SkColorFilter* setColorFilter(SkColorFilter* filter); | 518 SkColorFilter* setColorFilter(SkColorFilter* filter); |
| 519 void setColorFilter(sk_sp<SkColorFilter>); |
| 518 | 520 |
| 519 /** Get the paint's xfermode object. | 521 /** Get the paint's xfermode object. |
| 520 <p /> | 522 <p /> |
| 521 The xfermode's reference count is not affected. | 523 The xfermode's reference count is not affected. |
| 522 @return the paint's xfermode (or NULL) | 524 @return the paint's xfermode (or NULL) |
| 523 */ | 525 */ |
| 524 SkXfermode* getXfermode() const { return fXfermode; } | 526 SkXfermode* getXfermode() const { return fXfermode.get(); } |
| 525 | 527 |
| 526 /** Set or clear the xfermode object. | 528 /** Set or clear the xfermode object. |
| 527 <p /> | 529 <p /> |
| 528 Pass NULL to clear any previous xfermode. | 530 Pass NULL to clear any previous xfermode. |
| 529 As a convenience, the parameter passed is also returned. | 531 As a convenience, the parameter passed is also returned. |
| 530 If a previous xfermode exists, its reference count is decremented. | 532 If a previous xfermode exists, its reference count is decremented. |
| 531 If xfermode is not NULL, its reference count is incremented. | 533 If xfermode is not NULL, its reference count is incremented. |
| 532 @param xfermode May be NULL. The new xfermode to be installed in the | 534 @param xfermode May be NULL. The new xfermode to be installed in the |
| 533 paint | 535 paint |
| 534 @return xfermode | 536 @return xfermode |
| 535 */ | 537 */ |
| 536 SkXfermode* setXfermode(SkXfermode* xfermode); | 538 SkXfermode* setXfermode(SkXfermode* xfermode); |
| 539 void setXfermode(sk_sp<SkXfermode>); |
| 537 | 540 |
| 538 /** Create an xfermode based on the specified Mode, and assign it into the | 541 /** Create an xfermode based on the specified Mode, and assign it into the |
| 539 paint, returning the mode that was set. If the Mode is SrcOver, then | 542 paint, returning the mode that was set. If the Mode is SrcOver, then |
| 540 the paint's xfermode is set to null. | 543 the paint's xfermode is set to null. |
| 541 */ | 544 */ |
| 542 SkXfermode* setXfermodeMode(SkXfermode::Mode); | 545 SkXfermode* setXfermodeMode(SkXfermode::Mode); |
| 543 | 546 |
| 544 /** Get the paint's patheffect object. | 547 /** Get the paint's patheffect object. |
| 545 <p /> | 548 <p /> |
| 546 The patheffect reference count is not affected. | 549 The patheffect reference count is not affected. |
| 547 @return the paint's patheffect (or NULL) | 550 @return the paint's patheffect (or NULL) |
| 548 */ | 551 */ |
| 549 SkPathEffect* getPathEffect() const { return fPathEffect; } | 552 SkPathEffect* getPathEffect() const { return fPathEffect.get(); } |
| 550 | 553 |
| 551 /** Set or clear the patheffect object. | 554 /** Set or clear the patheffect object. |
| 552 <p /> | 555 <p /> |
| 553 Pass NULL to clear any previous patheffect. | 556 Pass NULL to clear any previous patheffect. |
| 554 As a convenience, the parameter passed is also returned. | 557 As a convenience, the parameter passed is also returned. |
| 555 If a previous patheffect exists, its reference count is decremented. | 558 If a previous patheffect exists, its reference count is decremented. |
| 556 If patheffect is not NULL, its reference count is incremented. | 559 If patheffect is not NULL, its reference count is incremented. |
| 557 @param effect May be NULL. The new patheffect to be installed in the | 560 @param effect May be NULL. The new patheffect to be installed in the |
| 558 paint | 561 paint |
| 559 @return effect | 562 @return effect |
| 560 */ | 563 */ |
| 561 SkPathEffect* setPathEffect(SkPathEffect* effect); | 564 SkPathEffect* setPathEffect(SkPathEffect* effect); |
| 565 void setPathEffect(sk_sp<SkPathEffect>); |
| 562 | 566 |
| 563 /** Get the paint's maskfilter object. | 567 /** Get the paint's maskfilter object. |
| 564 <p /> | 568 <p /> |
| 565 The maskfilter reference count is not affected. | 569 The maskfilter reference count is not affected. |
| 566 @return the paint's maskfilter (or NULL) | 570 @return the paint's maskfilter (or NULL) |
| 567 */ | 571 */ |
| 568 SkMaskFilter* getMaskFilter() const { return fMaskFilter; } | 572 SkMaskFilter* getMaskFilter() const { return fMaskFilter.get(); } |
| 569 | 573 |
| 570 /** Set or clear the maskfilter object. | 574 /** Set or clear the maskfilter object. |
| 571 <p /> | 575 <p /> |
| 572 Pass NULL to clear any previous maskfilter. | 576 Pass NULL to clear any previous maskfilter. |
| 573 As a convenience, the parameter passed is also returned. | 577 As a convenience, the parameter passed is also returned. |
| 574 If a previous maskfilter exists, its reference count is decremented. | 578 If a previous maskfilter exists, its reference count is decremented. |
| 575 If maskfilter is not NULL, its reference count is incremented. | 579 If maskfilter is not NULL, its reference count is incremented. |
| 576 @param maskfilter May be NULL. The new maskfilter to be installed in | 580 @param maskfilter May be NULL. The new maskfilter to be installed in |
| 577 the paint | 581 the paint |
| 578 @return maskfilter | 582 @return maskfilter |
| 579 */ | 583 */ |
| 580 SkMaskFilter* setMaskFilter(SkMaskFilter* maskfilter); | 584 SkMaskFilter* setMaskFilter(SkMaskFilter* maskfilter); |
| 585 void setMaskFilter(sk_sp<SkMaskFilter>); |
| 581 | 586 |
| 582 // These attributes are for text/fonts | 587 // These attributes are for text/fonts |
| 583 | 588 |
| 584 /** Get the paint's typeface object. | 589 /** Get the paint's typeface object. |
| 585 <p /> | 590 <p /> |
| 586 The typeface object identifies which font to use when drawing or | 591 The typeface object identifies which font to use when drawing or |
| 587 measuring text. The typeface reference count is not affected. | 592 measuring text. The typeface reference count is not affected. |
| 588 @return the paint's typeface (or NULL) | 593 @return the paint's typeface (or NULL) |
| 589 */ | 594 */ |
| 590 SkTypeface* getTypeface() const { return fTypeface; } | 595 SkTypeface* getTypeface() const { return fTypeface.get(); } |
| 591 | 596 |
| 592 /** Set or clear the typeface object. | 597 /** Set or clear the typeface object. |
| 593 <p /> | 598 <p /> |
| 594 Pass NULL to clear any previous typeface. | 599 Pass NULL to clear any previous typeface. |
| 595 As a convenience, the parameter passed is also returned. | 600 As a convenience, the parameter passed is also returned. |
| 596 If a previous typeface exists, its reference count is decremented. | 601 If a previous typeface exists, its reference count is decremented. |
| 597 If typeface is not NULL, its reference count is incremented. | 602 If typeface is not NULL, its reference count is incremented. |
| 598 @param typeface May be NULL. The new typeface to be installed in the | 603 @param typeface May be NULL. The new typeface to be installed in the |
| 599 paint | 604 paint |
| 600 @return typeface | 605 @return typeface |
| 601 */ | 606 */ |
| 602 SkTypeface* setTypeface(SkTypeface* typeface); | 607 SkTypeface* setTypeface(SkTypeface* typeface); |
| 608 void setTypeface(sk_sp<SkTypeface>); |
| 603 | 609 |
| 604 /** Get the paint's rasterizer (or NULL). | 610 /** Get the paint's rasterizer (or NULL). |
| 605 <p /> | 611 <p /> |
| 606 The raster controls how paths/text are turned into alpha masks. | 612 The raster controls how paths/text are turned into alpha masks. |
| 607 @return the paint's rasterizer (or NULL) | 613 @return the paint's rasterizer (or NULL) |
| 608 */ | 614 */ |
| 609 SkRasterizer* getRasterizer() const { return fRasterizer; } | 615 SkRasterizer* getRasterizer() const { return fRasterizer.get(); } |
| 610 | 616 |
| 611 /** Set or clear the rasterizer object. | 617 /** Set or clear the rasterizer object. |
| 612 <p /> | 618 <p /> |
| 613 Pass NULL to clear any previous rasterizer. | 619 Pass NULL to clear any previous rasterizer. |
| 614 As a convenience, the parameter passed is also returned. | 620 As a convenience, the parameter passed is also returned. |
| 615 If a previous rasterizer exists in the paint, its reference count is | 621 If a previous rasterizer exists in the paint, its reference count is |
| 616 decremented. If rasterizer is not NULL, its reference count is | 622 decremented. If rasterizer is not NULL, its reference count is |
| 617 incremented. | 623 incremented. |
| 618 @param rasterizer May be NULL. The new rasterizer to be installed in | 624 @param rasterizer May be NULL. The new rasterizer to be installed in |
| 619 the paint. | 625 the paint. |
| 620 @return rasterizer | 626 @return rasterizer |
| 621 */ | 627 */ |
| 622 SkRasterizer* setRasterizer(SkRasterizer* rasterizer); | 628 SkRasterizer* setRasterizer(SkRasterizer* rasterizer); |
| 629 void setRasterizer(sk_sp<SkRasterizer>); |
| 623 | 630 |
| 624 SkImageFilter* getImageFilter() const { return fImageFilter; } | 631 SkImageFilter* getImageFilter() const { return fImageFilter.get(); } |
| 625 SkImageFilter* setImageFilter(SkImageFilter*); | 632 SkImageFilter* setImageFilter(SkImageFilter*); |
| 633 void setImageFilter(sk_sp<SkImageFilter>); |
| 626 | 634 |
| 627 /** | 635 /** |
| 628 * Return the paint's SkDrawLooper (if any). Does not affect the looper's | 636 * Return the paint's SkDrawLooper (if any). Does not affect the looper's |
| 629 * reference count. | 637 * reference count. |
| 630 */ | 638 */ |
| 631 SkDrawLooper* getLooper() const { return fLooper; } | 639 SkDrawLooper* getLooper() const { return fLooper.get(); } |
| 632 | 640 |
| 633 /** | 641 /** |
| 634 * Set or clear the looper object. | 642 * Set or clear the looper object. |
| 635 * <p /> | 643 * <p /> |
| 636 * Pass NULL to clear any previous looper. | 644 * Pass NULL to clear any previous looper. |
| 637 * As a convenience, the parameter passed is also returned. | 645 * As a convenience, the parameter passed is also returned. |
| 638 * If a previous looper exists in the paint, its reference count is | 646 * If a previous looper exists in the paint, its reference count is |
| 639 * decremented. If looper is not NULL, its reference count is | 647 * decremented. If looper is not NULL, its reference count is |
| 640 * incremented. | 648 * incremented. |
| 641 * @param looper May be NULL. The new looper to be installed in the paint. | 649 * @param looper May be NULL. The new looper to be installed in the paint. |
| 642 * @return looper | 650 * @return looper |
| 643 */ | 651 */ |
| 644 SkDrawLooper* setLooper(SkDrawLooper* looper); | 652 SkDrawLooper* setLooper(SkDrawLooper* looper); |
| 653 void setLooper(sk_sp<SkDrawLooper>); |
| 645 | 654 |
| 646 enum Align { | 655 enum Align { |
| 647 kLeft_Align, | 656 kLeft_Align, |
| 648 kCenter_Align, | 657 kCenter_Align, |
| 649 kRight_Align, | 658 kRight_Align, |
| 650 }; | 659 }; |
| 651 enum { | 660 enum { |
| 652 kAlignCount = 3 | 661 kAlignCount = 3 |
| 653 }; | 662 }; |
| 654 | 663 |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1019 | 1028 |
| 1020 SkMatrix* setTextMatrix(SkMatrix* matrix) const { | 1029 SkMatrix* setTextMatrix(SkMatrix* matrix) const { |
| 1021 return SetTextMatrix(matrix, fTextSize, fTextScaleX, fTextSkewX); | 1030 return SetTextMatrix(matrix, fTextSize, fTextScaleX, fTextSkewX); |
| 1022 } | 1031 } |
| 1023 | 1032 |
| 1024 typedef const SkGlyph& (*GlyphCacheProc)(SkGlyphCache*, const char**); | 1033 typedef const SkGlyph& (*GlyphCacheProc)(SkGlyphCache*, const char**); |
| 1025 | 1034 |
| 1026 SK_TO_STRING_NONVIRT() | 1035 SK_TO_STRING_NONVIRT() |
| 1027 | 1036 |
| 1028 private: | 1037 private: |
| 1029 SkTypeface* fTypeface; | 1038 sk_sp<SkTypeface> fTypeface; |
| 1030 SkPathEffect* fPathEffect; | 1039 sk_sp<SkPathEffect> fPathEffect; |
| 1031 SkShader* fShader; | 1040 sk_sp<SkShader> fShader; |
| 1032 SkXfermode* fXfermode; | 1041 sk_sp<SkXfermode> fXfermode; |
| 1033 SkMaskFilter* fMaskFilter; | 1042 sk_sp<SkMaskFilter> fMaskFilter; |
| 1034 SkColorFilter* fColorFilter; | 1043 sk_sp<SkColorFilter> fColorFilter; |
| 1035 SkRasterizer* fRasterizer; | 1044 sk_sp<SkRasterizer> fRasterizer; |
| 1036 SkDrawLooper* fLooper; | 1045 sk_sp<SkDrawLooper> fLooper; |
| 1037 SkImageFilter* fImageFilter; | 1046 sk_sp<SkImageFilter> fImageFilter; |
| 1038 | 1047 |
| 1039 SkScalar fTextSize; | 1048 SkScalar fTextSize; |
| 1040 SkScalar fTextScaleX; | 1049 SkScalar fTextScaleX; |
| 1041 SkScalar fTextSkewX; | 1050 SkScalar fTextSkewX; |
| 1042 SkColor fColor; | 1051 SkColor fColor; |
| 1043 SkScalar fWidth; | 1052 SkScalar fWidth; |
| 1044 SkScalar fMiterLimit; | 1053 SkScalar fMiterLimit; |
| 1045 union { | 1054 union { |
| 1046 struct { | 1055 struct { |
| 1047 // all of these bitfields should add up to 32 | 1056 // all of these bitfields should add up to 32 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 friend class GrStencilAndCoverTextContext; | 1146 friend class GrStencilAndCoverTextContext; |
| 1138 friend class GrPathRendering; | 1147 friend class GrPathRendering; |
| 1139 friend class GrTextUtils; | 1148 friend class GrTextUtils; |
| 1140 friend class GrGLPathRendering; | 1149 friend class GrGLPathRendering; |
| 1141 friend class SkScalerContext; | 1150 friend class SkScalerContext; |
| 1142 friend class SkTextBaseIter; | 1151 friend class SkTextBaseIter; |
| 1143 friend class SkCanonicalizePaint; | 1152 friend class SkCanonicalizePaint; |
| 1144 }; | 1153 }; |
| 1145 | 1154 |
| 1146 #endif | 1155 #endif |
| OLD | NEW |