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

Side by Side Diff: include/core/SkPaint.h

Issue 2396953002: Revert[8] "replace SkXfermode obj with SkBlendMode enum in paints" (Closed)
Patch Set: add tmp virtual to unroll legacy arithmodes Created 4 years, 2 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
« no previous file with comments | « include/core/SkColorFilter.h ('k') | include/core/SkPicture.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "SkBlendMode.h"
11 #include "SkColor.h" 12 #include "SkColor.h"
12 #include "SkFilterQuality.h" 13 #include "SkFilterQuality.h"
13 #include "SkMatrix.h" 14 #include "SkMatrix.h"
14 #include "SkXfermode.h" 15 #include "SkXfermode.h"
15 16
17 //#define SK_SUPPORT_LEGACY_XFERMODE_OBJECT
18
16 class SkAutoDescriptor; 19 class SkAutoDescriptor;
17 class SkAutoGlyphCache; 20 class SkAutoGlyphCache;
18 class SkColorFilter; 21 class SkColorFilter;
19 class SkData; 22 class SkData;
20 class SkDescriptor; 23 class SkDescriptor;
21 class SkDrawLooper; 24 class SkDrawLooper;
22 class SkReadBuffer; 25 class SkReadBuffer;
23 class SkWriteBuffer; 26 class SkWriteBuffer;
24 class SkGlyph; 27 class SkGlyph;
25 struct SkRect; 28 struct SkRect;
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 If the paint already has a filter, its reference count is decremented. 521 If the paint already has a filter, its reference count is decremented.
519 If filter is not NULL, its reference count is incremented. 522 If filter is not NULL, its reference count is incremented.
520 @param filter May be NULL. The filter to be installed in the paint 523 @param filter May be NULL. The filter to be installed in the paint
521 @return filter 524 @return filter
522 */ 525 */
523 #ifdef SK_SUPPORT_LEGACY_COLORFILTER_PTR 526 #ifdef SK_SUPPORT_LEGACY_COLORFILTER_PTR
524 SkColorFilter* setColorFilter(SkColorFilter* filter); 527 SkColorFilter* setColorFilter(SkColorFilter* filter);
525 #endif 528 #endif
526 void setColorFilter(sk_sp<SkColorFilter>); 529 void setColorFilter(sk_sp<SkColorFilter>);
527 530
531 #ifdef SK_SUPPORT_LEGACY_XFERMODE_OBJECT
528 /** Get the paint's xfermode object. 532 /** Get the paint's xfermode object.
529 <p /> 533 <p />
530 The xfermode's reference count is not affected. 534 The xfermode's reference count is not affected.
531 @return the paint's xfermode (or NULL) 535 @return the paint's xfermode (or NULL)
532 */ 536 */
533 SkXfermode* getXfermode() const { return fXfermode.get(); } 537 SkXfermode* getXfermode() const;
534 538
535 /** Set or clear the xfermode object. 539 /** Set or clear the xfermode object.
536 <p /> 540 <p />
537 Pass NULL to clear any previous xfermode. 541 Pass NULL to clear any previous xfermode.
538 As a convenience, the parameter passed is also returned. 542 As a convenience, the parameter passed is also returned.
539 If a previous xfermode exists, its reference count is decremented. 543 If a previous xfermode exists, its reference count is decremented.
540 If xfermode is not NULL, its reference count is incremented. 544 If xfermode is not NULL, its reference count is incremented.
541 @param xfermode May be NULL. The new xfermode to be installed in the 545 @param xfermode May be NULL. The new xfermode to be installed in the
542 paint 546 paint
543 @return xfermode 547 @return xfermode
544 */ 548 */
545 void setXfermode(sk_sp<SkXfermode>); 549 void setXfermode(sk_sp<SkXfermode>);
546 #ifdef SK_SUPPORT_LEGACY_XFERMODE_PTR 550 #ifdef SK_SUPPORT_LEGACY_XFERMODE_PTR
547 SkXfermode* setXfermode(SkXfermode* xfermode); 551 SkXfermode* setXfermode(SkXfermode* xfermode);
548 #endif 552 #endif
549 553
550 /** Create an xfermode based on the specified Mode, and assign it into the 554 /** Create an xfermode based on the specified Mode, and assign it into the
551 paint, returning the mode that was set. If the Mode is SrcOver, then 555 paint, returning the mode that was set. If the Mode is SrcOver, then
552 the paint's xfermode is set to null. 556 the paint's xfermode is set to null.
553 */ 557 */
554 SkXfermode* setXfermodeMode(SkXfermode::Mode); 558 SkXfermode* setXfermodeMode(SkXfermode::Mode);
559 #endif
560
561 SkBlendMode getBlendMode() const { return (SkBlendMode)fBlendMode; }
562 bool isSrcOver() const { return (SkBlendMode)fBlendMode == SkBlendMode::kSrc Over; }
563 void setBlendMode(SkBlendMode mode) { fBlendMode = (unsigned)mode; }
555 564
556 /** Get the paint's patheffect object. 565 /** Get the paint's patheffect object.
557 <p /> 566 <p />
558 The patheffect reference count is not affected. 567 The patheffect reference count is not affected.
559 @return the paint's patheffect (or NULL) 568 @return the paint's patheffect (or NULL)
560 */ 569 */
561 SkPathEffect* getPathEffect() const { return fPathEffect.get(); } 570 SkPathEffect* getPathEffect() const { return fPathEffect.get(); }
562 571
563 /** Set or clear the patheffect object. 572 /** Set or clear the patheffect object.
564 <p /> 573 <p />
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 } 1092 }
1084 1093
1085 typedef const SkGlyph& (*GlyphCacheProc)(SkGlyphCache*, const char**); 1094 typedef const SkGlyph& (*GlyphCacheProc)(SkGlyphCache*, const char**);
1086 1095
1087 SK_TO_STRING_NONVIRT() 1096 SK_TO_STRING_NONVIRT()
1088 1097
1089 private: 1098 private:
1090 sk_sp<SkTypeface> fTypeface; 1099 sk_sp<SkTypeface> fTypeface;
1091 sk_sp<SkPathEffect> fPathEffect; 1100 sk_sp<SkPathEffect> fPathEffect;
1092 sk_sp<SkShader> fShader; 1101 sk_sp<SkShader> fShader;
1093 sk_sp<SkXfermode> fXfermode;
1094 sk_sp<SkMaskFilter> fMaskFilter; 1102 sk_sp<SkMaskFilter> fMaskFilter;
1095 sk_sp<SkColorFilter> fColorFilter; 1103 sk_sp<SkColorFilter> fColorFilter;
1096 sk_sp<SkRasterizer> fRasterizer; 1104 sk_sp<SkRasterizer> fRasterizer;
1097 sk_sp<SkDrawLooper> fDrawLooper; 1105 sk_sp<SkDrawLooper> fDrawLooper;
1098 sk_sp<SkImageFilter> fImageFilter; 1106 sk_sp<SkImageFilter> fImageFilter;
1099 1107
1100 SkScalar fTextSize; 1108 SkScalar fTextSize;
1101 SkScalar fTextScaleX; 1109 SkScalar fTextScaleX;
1102 SkScalar fTextSkewX; 1110 SkScalar fTextSkewX;
1103 SkColor fColor; 1111 SkColor fColor;
1104 SkScalar fWidth; 1112 SkScalar fWidth;
1105 SkScalar fMiterLimit; 1113 SkScalar fMiterLimit;
1114 uint32_t fBlendMode; // just need 5-6 bits for SkXfermode::Mode
1106 union { 1115 union {
1107 struct { 1116 struct {
1108 // all of these bitfields should add up to 32 1117 // all of these bitfields should add up to 32
1109 unsigned fFlags : 16; 1118 unsigned fFlags : 16;
1110 unsigned fTextAlign : 2; 1119 unsigned fTextAlign : 2;
1111 unsigned fCapType : 2; 1120 unsigned fCapType : 2;
1112 unsigned fJoinType : 2; 1121 unsigned fJoinType : 2;
1113 unsigned fStyle : 2; 1122 unsigned fStyle : 2;
1114 unsigned fTextEncoding : 2; // 3 values 1123 unsigned fTextEncoding : 2; // 3 values
1115 unsigned fHinting : 2; 1124 unsigned fHinting : 2;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 friend class GrStencilAndCoverTextContext; 1217 friend class GrStencilAndCoverTextContext;
1209 friend class GrPathRendering; 1218 friend class GrPathRendering;
1210 friend class GrTextUtils; 1219 friend class GrTextUtils;
1211 friend class GrGLPathRendering; 1220 friend class GrGLPathRendering;
1212 friend class SkScalerContext; 1221 friend class SkScalerContext;
1213 friend class SkTextBaseIter; 1222 friend class SkTextBaseIter;
1214 friend class SkCanonicalizePaint; 1223 friend class SkCanonicalizePaint;
1215 }; 1224 };
1216 1225
1217 #endif 1226 #endif
OLDNEW
« no previous file with comments | « include/core/SkColorFilter.h ('k') | include/core/SkPicture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698