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

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

Issue 394603003: patch from issue 383923002 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 5 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 | « no previous file | src/core/SkPaint.cpp » ('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 2
3 /* 3 /*
4 * Copyright 2006 The Android Open Source Project 4 * Copyright 2006 The Android Open Source Project
5 * 5 *
6 * Use of this source code is governed by a BSD-style license that can be 6 * Use of this source code is governed by a BSD-style license that can be
7 * found in the LICENSE file. 7 * found in the LICENSE file.
8 */ 8 */
9 9
10 10
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 TARGET_LCD_V is used> 82 TARGET_LCD_V is used>
83 */ 83 */
84 enum Hinting { 84 enum Hinting {
85 kNo_Hinting = 0, 85 kNo_Hinting = 0,
86 kSlight_Hinting = 1, 86 kSlight_Hinting = 1,
87 kNormal_Hinting = 2, //!< this is the default 87 kNormal_Hinting = 2, //!< this is the default
88 kFull_Hinting = 3 88 kFull_Hinting = 3
89 }; 89 };
90 90
91 Hinting getHinting() const { 91 Hinting getHinting() const {
92 return static_cast<Hinting>(fHinting); 92 return static_cast<Hinting>(fBitfields.fHinting);
93 } 93 }
94 94
95 void setHinting(Hinting hintingLevel); 95 void setHinting(Hinting hintingLevel);
96 96
97 /** Specifies the bit values that are stored in the paint's flags. 97 /** Specifies the bit values that are stored in the paint's flags.
98 */ 98 */
99 enum Flags { 99 enum Flags {
100 kAntiAlias_Flag = 0x01, //!< mask to enable antialiasing 100 kAntiAlias_Flag = 0x01, //!< mask to enable antialiasing
101 kDither_Flag = 0x04, //!< mask to enable dithering 101 kDither_Flag = 0x04, //!< mask to enable dithering
102 kUnderlineText_Flag = 0x08, //!< mask to enable underline text 102 kUnderlineText_Flag = 0x08, //!< mask to enable underline text
(...skipping 11 matching lines...) Expand all
114 // currently overrides LCD and sub pixel rendering 114 // currently overrides LCD and sub pixel rendering
115 // when adding extra flags, note that the fFlags member is specified 115 // when adding extra flags, note that the fFlags member is specified
116 // with a bit-width and you'll have to expand it. 116 // with a bit-width and you'll have to expand it.
117 117
118 kAllFlags = 0xFFFF 118 kAllFlags = 0xFFFF
119 }; 119 };
120 120
121 /** Return the paint's flags. Use the Flag enum to test flag values. 121 /** Return the paint's flags. Use the Flag enum to test flag values.
122 @return the paint's flags (see enums ending in _Flag for bit masks) 122 @return the paint's flags (see enums ending in _Flag for bit masks)
123 */ 123 */
124 uint32_t getFlags() const { return fFlags; } 124 uint32_t getFlags() const { return fBitfields.fFlags; }
125 125
126 /** Set the paint's flags. Use the Flag enum to specific flag values. 126 /** Set the paint's flags. Use the Flag enum to specific flag values.
127 @param flags The new flag bits for the paint (see Flags enum) 127 @param flags The new flag bits for the paint (see Flags enum)
128 */ 128 */
129 void setFlags(uint32_t flags); 129 void setFlags(uint32_t flags);
130 130
131 /** Helper for getFlags(), returning true if kAntiAlias_Flag bit is set 131 /** Helper for getFlags(), returning true if kAntiAlias_Flag bit is set
132 @return true if the antialias bit is set in the paint's flags. 132 @return true if the antialias bit is set in the paint's flags.
133 */ 133 */
134 bool isAntiAlias() const { 134 bool isAntiAlias() const {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 kNone_FilterLevel, 295 kNone_FilterLevel,
296 kLow_FilterLevel, 296 kLow_FilterLevel,
297 kMedium_FilterLevel, 297 kMedium_FilterLevel,
298 kHigh_FilterLevel 298 kHigh_FilterLevel
299 }; 299 };
300 300
301 /** 301 /**
302 * Return the filter level. This affects the quality (and performance) of 302 * Return the filter level. This affects the quality (and performance) of
303 * drawing scaled images. 303 * drawing scaled images.
304 */ 304 */
305 FilterLevel getFilterLevel() const { return (FilterLevel)fFilterLevel; } 305 FilterLevel getFilterLevel() const {
306 return (FilterLevel)fBitfields.fFilterLevel;
307 }
306 308
307 /** 309 /**
308 * Set the filter level. This affects the quality (and performance) of 310 * Set the filter level. This affects the quality (and performance) of
309 * drawing scaled images. 311 * drawing scaled images.
310 */ 312 */
311 void setFilterLevel(FilterLevel); 313 void setFilterLevel(FilterLevel);
312 314
313 /** 315 /**
314 * If the predicate is true, set the filterLevel to Low, else set it to 316 * If the predicate is true, set the filterLevel to Low, else set it to
315 * None. 317 * None.
(...skipping 27 matching lines...) Expand all
343 }; 345 };
344 enum { 346 enum {
345 kStyleCount = kStrokeAndFill_Style + 1 347 kStyleCount = kStrokeAndFill_Style + 1
346 }; 348 };
347 349
348 /** Return the paint's style, used for controlling how primitives' 350 /** Return the paint's style, used for controlling how primitives'
349 geometries are interpreted (except for drawBitmap, which always assumes 351 geometries are interpreted (except for drawBitmap, which always assumes
350 kFill_Style). 352 kFill_Style).
351 @return the paint's Style 353 @return the paint's Style
352 */ 354 */
353 Style getStyle() const { return (Style)fStyle; } 355 Style getStyle() const { return (Style)fBitfields.fStyle; }
354 356
355 /** Set the paint's style, used for controlling how primitives' 357 /** Set the paint's style, used for controlling how primitives'
356 geometries are interpreted (except for drawBitmap, which always assumes 358 geometries are interpreted (except for drawBitmap, which always assumes
357 Fill). 359 Fill).
358 @param style The new style to set in the paint 360 @param style The new style to set in the paint
359 */ 361 */
360 void setStyle(Style style); 362 void setStyle(Style style);
361 363
362 /** Return the paint's color. Note that the color is a 32bit value 364 /** Return the paint's color. Note that the color is a 32bit value
363 containing alpha as well as r,g,b. This 32bit value is not 365 containing alpha as well as r,g,b. This 32bit value is not
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 451
450 kJoinCount, 452 kJoinCount,
451 kDefault_Join = kMiter_Join 453 kDefault_Join = kMiter_Join
452 }; 454 };
453 455
454 /** Return the paint's stroke cap type, controlling how the start and end 456 /** Return the paint's stroke cap type, controlling how the start and end
455 of stroked lines and paths are treated. 457 of stroked lines and paths are treated.
456 @return the line cap style for the paint, used whenever the paint's 458 @return the line cap style for the paint, used whenever the paint's
457 style is Stroke or StrokeAndFill. 459 style is Stroke or StrokeAndFill.
458 */ 460 */
459 Cap getStrokeCap() const { return (Cap)fCapType; } 461 Cap getStrokeCap() const { return (Cap)fBitfields.fCapType; }
460 462
461 /** Set the paint's stroke cap type. 463 /** Set the paint's stroke cap type.
462 @param cap set the paint's line cap style, used whenever the paint's 464 @param cap set the paint's line cap style, used whenever the paint's
463 style is Stroke or StrokeAndFill. 465 style is Stroke or StrokeAndFill.
464 */ 466 */
465 void setStrokeCap(Cap cap); 467 void setStrokeCap(Cap cap);
466 468
467 /** Return the paint's stroke join type. 469 /** Return the paint's stroke join type.
468 @return the paint's line join style, used whenever the paint's style is 470 @return the paint's line join style, used whenever the paint's style is
469 Stroke or StrokeAndFill. 471 Stroke or StrokeAndFill.
470 */ 472 */
471 Join getStrokeJoin() const { return (Join)fJoinType; } 473 Join getStrokeJoin() const { return (Join)fBitfields.fJoinType; }
472 474
473 /** Set the paint's stroke join type. 475 /** Set the paint's stroke join type.
474 @param join set the paint's line join style, used whenever the paint's 476 @param join set the paint's line join style, used whenever the paint's
475 style is Stroke or StrokeAndFill. 477 style is Stroke or StrokeAndFill.
476 */ 478 */
477 void setStrokeJoin(Join join); 479 void setStrokeJoin(Join join);
478 480
479 /** 481 /**
480 * Applies any/all effects (patheffect, stroking) to src, returning the 482 * Applies any/all effects (patheffect, stroking) to src, returning the
481 * result in dst. The result is that drawing src with this paint will be 483 * result in dst. The result is that drawing src with this paint will be
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 kCenter_Align, 680 kCenter_Align,
679 kRight_Align, 681 kRight_Align,
680 }; 682 };
681 enum { 683 enum {
682 kAlignCount = 3 684 kAlignCount = 3
683 }; 685 };
684 686
685 /** Return the paint's Align value for drawing text. 687 /** Return the paint's Align value for drawing text.
686 @return the paint's Align value for drawing text. 688 @return the paint's Align value for drawing text.
687 */ 689 */
688 Align getTextAlign() const { return (Align)fTextAlign; } 690 Align getTextAlign() const { return (Align)fBitfields.fTextAlign; }
689 691
690 /** Set the paint's text alignment. 692 /** Set the paint's text alignment.
691 @param align set the paint's Align value for drawing text. 693 @param align set the paint's Align value for drawing text.
692 */ 694 */
693 void setTextAlign(Align align); 695 void setTextAlign(Align align);
694 696
695 /** Return the paint's text size. 697 /** Return the paint's text size.
696 @return the paint's text size. 698 @return the paint's text size.
697 */ 699 */
698 SkScalar getTextSize() const { return fTextSize; } 700 SkScalar getTextSize() const { return fTextSize; }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 /** Describes how to interpret the text parameters that are passed to paint 733 /** Describes how to interpret the text parameters that are passed to paint
732 methods like measureText() and getTextWidths(). 734 methods like measureText() and getTextWidths().
733 */ 735 */
734 enum TextEncoding { 736 enum TextEncoding {
735 kUTF8_TextEncoding, //!< the text parameters are UTF8 737 kUTF8_TextEncoding, //!< the text parameters are UTF8
736 kUTF16_TextEncoding, //!< the text parameters are UTF16 738 kUTF16_TextEncoding, //!< the text parameters are UTF16
737 kUTF32_TextEncoding, //!< the text parameters are UTF32 739 kUTF32_TextEncoding, //!< the text parameters are UTF32
738 kGlyphID_TextEncoding //!< the text parameters are glyph indices 740 kGlyphID_TextEncoding //!< the text parameters are glyph indices
739 }; 741 };
740 742
741 TextEncoding getTextEncoding() const { return (TextEncoding)fTextEncoding; } 743 TextEncoding getTextEncoding() const {
744 return (TextEncoding)fBitfields.fTextEncoding;
745 }
742 746
743 void setTextEncoding(TextEncoding encoding); 747 void setTextEncoding(TextEncoding encoding);
744 748
745 struct FontMetrics { 749 struct FontMetrics {
746 /** Flags which indicate the confidence level of various metrics. 750 /** Flags which indicate the confidence level of various metrics.
747 A set flag indicates that the metric may be trusted. 751 A set flag indicates that the metric may be trusted.
748 */ 752 */
749 enum FontMetricsFlags { 753 enum FontMetricsFlags {
750 kUnderlineThinknessIsValid_Flag = 1 << 0, 754 kUnderlineThinknessIsValid_Flag = 1 << 0,
751 kUnderlinePositionIsValid_Flag = 1 << 1, 755 kUnderlinePositionIsValid_Flag = 1 << 1,
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 // all of these bitfields should add up to 32 1063 // all of these bitfields should add up to 32
1060 unsigned fFlags : 16; 1064 unsigned fFlags : 16;
1061 unsigned fTextAlign : 2; 1065 unsigned fTextAlign : 2;
1062 unsigned fCapType : 2; 1066 unsigned fCapType : 2;
1063 unsigned fJoinType : 2; 1067 unsigned fJoinType : 2;
1064 unsigned fStyle : 2; 1068 unsigned fStyle : 2;
1065 unsigned fTextEncoding : 2; // 3 values 1069 unsigned fTextEncoding : 2; // 3 values
1066 unsigned fHinting : 2; 1070 unsigned fHinting : 2;
1067 unsigned fFilterLevel : 2; 1071 unsigned fFilterLevel : 2;
1068 //unsigned fFreeBits : 2; 1072 //unsigned fFreeBits : 2;
1069 }; 1073 } fBitfields;
1070 uint32_t fBitfields; 1074 uint32_t fBitfieldsUInt;
1071 }; 1075 };
1072 uint32_t fDirtyBits; 1076 uint32_t fDirtyBits;
1073 1077
1074 uint32_t getBitfields() const { return fBitfields; }
1075 void setBitfields(uint32_t bitfields);
1076
1077 SkDrawCacheProc getDrawCacheProc() const; 1078 SkDrawCacheProc getDrawCacheProc() const;
1078 SkMeasureCacheProc getMeasureCacheProc(TextBufferDirection dir, 1079 SkMeasureCacheProc getMeasureCacheProc(TextBufferDirection dir,
1079 bool needFullMetrics) const; 1080 bool needFullMetrics) const;
1080 1081
1081 SkScalar measure_text(SkGlyphCache*, const char* text, size_t length, 1082 SkScalar measure_text(SkGlyphCache*, const char* text, size_t length,
1082 int* count, SkRect* bounds) const; 1083 int* count, SkRect* bounds) const;
1083 1084
1084 SkGlyphCache* detachCache(const SkDeviceProperties* deviceProperties, const SkMatrix*, 1085 SkGlyphCache* detachCache(const SkDeviceProperties* deviceProperties, const SkMatrix*,
1085 bool ignoreGamma) const; 1086 bool ignoreGamma) const;
1086 1087
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 #ifdef SK_BUILD_FOR_ANDROID 1144 #ifdef SK_BUILD_FOR_ANDROID
1144 SkPaintOptionsAndroid fPaintOptionsAndroid; 1145 SkPaintOptionsAndroid fPaintOptionsAndroid;
1145 1146
1146 // In order for the == operator to work properly this must be the last field 1147 // In order for the == operator to work properly this must be the last field
1147 // in the struct so that we can do a memcmp to this field's offset. 1148 // in the struct so that we can do a memcmp to this field's offset.
1148 uint32_t fGenerationID; 1149 uint32_t fGenerationID;
1149 #endif 1150 #endif
1150 }; 1151 };
1151 1152
1152 #endif 1153 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkPaint.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698