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 #include "SkPaint.h" | 8 #include "SkPaint.h" |
| 9 #include "SkAnnotation.h" |
9 #include "SkAutoKern.h" | 10 #include "SkAutoKern.h" |
10 #include "SkChecksum.h" | 11 #include "SkChecksum.h" |
11 #include "SkColorFilter.h" | 12 #include "SkColorFilter.h" |
12 #include "SkData.h" | 13 #include "SkData.h" |
13 #include "SkDraw.h" | 14 #include "SkDraw.h" |
14 #include "SkFontDescriptor.h" | 15 #include "SkFontDescriptor.h" |
15 #include "SkGlyphCache.h" | 16 #include "SkGlyphCache.h" |
16 #include "SkImageFilter.h" | 17 #include "SkImageFilter.h" |
17 #include "SkMaskFilter.h" | 18 #include "SkMaskFilter.h" |
18 #include "SkMaskGamma.h" | 19 #include "SkMaskGamma.h" |
(...skipping 27 matching lines...) Expand all Loading... |
46 SkPaint::SkPaint() { | 47 SkPaint::SkPaint() { |
47 fTypeface = nullptr; | 48 fTypeface = nullptr; |
48 fPathEffect = nullptr; | 49 fPathEffect = nullptr; |
49 fShader = nullptr; | 50 fShader = nullptr; |
50 fXfermode = nullptr; | 51 fXfermode = nullptr; |
51 fMaskFilter = nullptr; | 52 fMaskFilter = nullptr; |
52 fColorFilter = nullptr; | 53 fColorFilter = nullptr; |
53 fRasterizer = nullptr; | 54 fRasterizer = nullptr; |
54 fLooper = nullptr; | 55 fLooper = nullptr; |
55 fImageFilter = nullptr; | 56 fImageFilter = nullptr; |
| 57 fAnnotation = nullptr; |
56 | 58 |
57 fTextSize = SkPaintDefaults_TextSize; | 59 fTextSize = SkPaintDefaults_TextSize; |
58 fTextScaleX = SK_Scalar1; | 60 fTextScaleX = SK_Scalar1; |
59 fTextSkewX = 0; | 61 fTextSkewX = 0; |
60 fColor = SK_ColorBLACK; | 62 fColor = SK_ColorBLACK; |
61 fWidth = 0; | 63 fWidth = 0; |
62 fMiterLimit = SkPaintDefaults_MiterLimit; | 64 fMiterLimit = SkPaintDefaults_MiterLimit; |
63 | 65 |
64 // Zero all bitfields, then set some non-zero defaults. | 66 // Zero all bitfields, then set some non-zero defaults. |
65 fBitfieldsUInt = 0; | 67 fBitfieldsUInt = 0; |
(...skipping 12 matching lines...) Expand all Loading... |
78 | 80 |
79 REF_COPY(fTypeface); | 81 REF_COPY(fTypeface); |
80 REF_COPY(fPathEffect); | 82 REF_COPY(fPathEffect); |
81 REF_COPY(fShader); | 83 REF_COPY(fShader); |
82 REF_COPY(fXfermode); | 84 REF_COPY(fXfermode); |
83 REF_COPY(fMaskFilter); | 85 REF_COPY(fMaskFilter); |
84 REF_COPY(fColorFilter); | 86 REF_COPY(fColorFilter); |
85 REF_COPY(fRasterizer); | 87 REF_COPY(fRasterizer); |
86 REF_COPY(fLooper); | 88 REF_COPY(fLooper); |
87 REF_COPY(fImageFilter); | 89 REF_COPY(fImageFilter); |
| 90 REF_COPY(fAnnotation); |
88 | 91 |
89 COPY(fTextSize); | 92 COPY(fTextSize); |
90 COPY(fTextScaleX); | 93 COPY(fTextScaleX); |
91 COPY(fTextSkewX); | 94 COPY(fTextSkewX); |
92 COPY(fColor); | 95 COPY(fColor); |
93 COPY(fWidth); | 96 COPY(fWidth); |
94 COPY(fMiterLimit); | 97 COPY(fMiterLimit); |
95 COPY(fBitfields); | 98 COPY(fBitfields); |
96 | 99 |
97 #undef COPY | 100 #undef COPY |
98 #undef REF_COPY | 101 #undef REF_COPY |
99 } | 102 } |
100 | 103 |
101 SkPaint::SkPaint(SkPaint&& src) { | 104 SkPaint::SkPaint(SkPaint&& src) { |
102 #define MOVE(field) field = std::move(src.field) | 105 #define MOVE(field) field = std::move(src.field) |
103 #define REF_MOVE(field) field = src.field; src.field = nullptr | 106 #define REF_MOVE(field) field = src.field; src.field = nullptr |
104 | 107 |
105 REF_MOVE(fTypeface); | 108 REF_MOVE(fTypeface); |
106 REF_MOVE(fPathEffect); | 109 REF_MOVE(fPathEffect); |
107 REF_MOVE(fShader); | 110 REF_MOVE(fShader); |
108 REF_MOVE(fXfermode); | 111 REF_MOVE(fXfermode); |
109 REF_MOVE(fMaskFilter); | 112 REF_MOVE(fMaskFilter); |
110 REF_MOVE(fColorFilter); | 113 REF_MOVE(fColorFilter); |
111 REF_MOVE(fRasterizer); | 114 REF_MOVE(fRasterizer); |
112 REF_MOVE(fLooper); | 115 REF_MOVE(fLooper); |
113 REF_MOVE(fImageFilter); | 116 REF_MOVE(fImageFilter); |
| 117 REF_MOVE(fAnnotation); |
114 | 118 |
115 MOVE(fTextSize); | 119 MOVE(fTextSize); |
116 MOVE(fTextScaleX); | 120 MOVE(fTextScaleX); |
117 MOVE(fTextSkewX); | 121 MOVE(fTextSkewX); |
118 MOVE(fColor); | 122 MOVE(fColor); |
119 MOVE(fWidth); | 123 MOVE(fWidth); |
120 MOVE(fMiterLimit); | 124 MOVE(fMiterLimit); |
121 MOVE(fBitfields); | 125 MOVE(fBitfields); |
122 | 126 |
123 #undef MOVE | 127 #undef MOVE |
124 #undef REF_MOVE | 128 #undef REF_MOVE |
125 } | 129 } |
126 | 130 |
127 SkPaint::~SkPaint() { | 131 SkPaint::~SkPaint() { |
128 SkSafeUnref(fTypeface); | 132 SkSafeUnref(fTypeface); |
129 SkSafeUnref(fPathEffect); | 133 SkSafeUnref(fPathEffect); |
130 SkSafeUnref(fShader); | 134 SkSafeUnref(fShader); |
131 SkSafeUnref(fXfermode); | 135 SkSafeUnref(fXfermode); |
132 SkSafeUnref(fMaskFilter); | 136 SkSafeUnref(fMaskFilter); |
133 SkSafeUnref(fColorFilter); | 137 SkSafeUnref(fColorFilter); |
134 SkSafeUnref(fRasterizer); | 138 SkSafeUnref(fRasterizer); |
135 SkSafeUnref(fLooper); | 139 SkSafeUnref(fLooper); |
136 SkSafeUnref(fImageFilter); | 140 SkSafeUnref(fImageFilter); |
| 141 SkSafeUnref(fAnnotation); |
137 } | 142 } |
138 | 143 |
139 SkPaint& SkPaint::operator=(const SkPaint& src) { | 144 SkPaint& SkPaint::operator=(const SkPaint& src) { |
140 if (this == &src) { | 145 if (this == &src) { |
141 return *this; | 146 return *this; |
142 } | 147 } |
143 | 148 |
144 #define COPY(field) field = src.field | 149 #define COPY(field) field = src.field |
145 #define REF_COPY(field) SkSafeUnref(field); field = SkSafeRef(src.field) | 150 #define REF_COPY(field) SkSafeUnref(field); field = SkSafeRef(src.field) |
146 | 151 |
147 REF_COPY(fTypeface); | 152 REF_COPY(fTypeface); |
148 REF_COPY(fPathEffect); | 153 REF_COPY(fPathEffect); |
149 REF_COPY(fShader); | 154 REF_COPY(fShader); |
150 REF_COPY(fXfermode); | 155 REF_COPY(fXfermode); |
151 REF_COPY(fMaskFilter); | 156 REF_COPY(fMaskFilter); |
152 REF_COPY(fColorFilter); | 157 REF_COPY(fColorFilter); |
153 REF_COPY(fRasterizer); | 158 REF_COPY(fRasterizer); |
154 REF_COPY(fLooper); | 159 REF_COPY(fLooper); |
155 REF_COPY(fImageFilter); | 160 REF_COPY(fImageFilter); |
| 161 REF_COPY(fAnnotation); |
156 | 162 |
157 COPY(fTextSize); | 163 COPY(fTextSize); |
158 COPY(fTextScaleX); | 164 COPY(fTextScaleX); |
159 COPY(fTextSkewX); | 165 COPY(fTextSkewX); |
160 COPY(fColor); | 166 COPY(fColor); |
161 COPY(fWidth); | 167 COPY(fWidth); |
162 COPY(fMiterLimit); | 168 COPY(fMiterLimit); |
163 COPY(fBitfields); | 169 COPY(fBitfields); |
164 | 170 |
165 return *this; | 171 return *this; |
(...skipping 12 matching lines...) Expand all Loading... |
178 | 184 |
179 REF_MOVE(fTypeface); | 185 REF_MOVE(fTypeface); |
180 REF_MOVE(fPathEffect); | 186 REF_MOVE(fPathEffect); |
181 REF_MOVE(fShader); | 187 REF_MOVE(fShader); |
182 REF_MOVE(fXfermode); | 188 REF_MOVE(fXfermode); |
183 REF_MOVE(fMaskFilter); | 189 REF_MOVE(fMaskFilter); |
184 REF_MOVE(fColorFilter); | 190 REF_MOVE(fColorFilter); |
185 REF_MOVE(fRasterizer); | 191 REF_MOVE(fRasterizer); |
186 REF_MOVE(fLooper); | 192 REF_MOVE(fLooper); |
187 REF_MOVE(fImageFilter); | 193 REF_MOVE(fImageFilter); |
| 194 REF_MOVE(fAnnotation); |
188 | 195 |
189 MOVE(fTextSize); | 196 MOVE(fTextSize); |
190 MOVE(fTextScaleX); | 197 MOVE(fTextScaleX); |
191 MOVE(fTextSkewX); | 198 MOVE(fTextSkewX); |
192 MOVE(fColor); | 199 MOVE(fColor); |
193 MOVE(fWidth); | 200 MOVE(fWidth); |
194 MOVE(fMiterLimit); | 201 MOVE(fMiterLimit); |
195 MOVE(fBitfields); | 202 MOVE(fBitfields); |
196 | 203 |
197 return *this; | 204 return *this; |
198 | 205 |
199 #undef MOVE | 206 #undef MOVE |
200 #undef REF_MOVE | 207 #undef REF_MOVE |
201 } | 208 } |
202 | 209 |
203 bool operator==(const SkPaint& a, const SkPaint& b) { | 210 bool operator==(const SkPaint& a, const SkPaint& b) { |
204 #define EQUAL(field) (a.field == b.field) | 211 #define EQUAL(field) (a.field == b.field) |
205 return EQUAL(fTypeface) | 212 return EQUAL(fTypeface) |
206 && EQUAL(fPathEffect) | 213 && EQUAL(fPathEffect) |
207 && EQUAL(fShader) | 214 && EQUAL(fShader) |
208 && EQUAL(fXfermode) | 215 && EQUAL(fXfermode) |
209 && EQUAL(fMaskFilter) | 216 && EQUAL(fMaskFilter) |
210 && EQUAL(fColorFilter) | 217 && EQUAL(fColorFilter) |
211 && EQUAL(fRasterizer) | 218 && EQUAL(fRasterizer) |
212 && EQUAL(fLooper) | 219 && EQUAL(fLooper) |
213 && EQUAL(fImageFilter) | 220 && EQUAL(fImageFilter) |
| 221 && EQUAL(fAnnotation) |
214 && EQUAL(fTextSize) | 222 && EQUAL(fTextSize) |
215 && EQUAL(fTextScaleX) | 223 && EQUAL(fTextScaleX) |
216 && EQUAL(fTextSkewX) | 224 && EQUAL(fTextSkewX) |
217 && EQUAL(fColor) | 225 && EQUAL(fColor) |
218 && EQUAL(fWidth) | 226 && EQUAL(fWidth) |
219 && EQUAL(fMiterLimit) | 227 && EQUAL(fMiterLimit) |
220 && EQUAL(fBitfieldsUInt) | 228 && EQUAL(fBitfieldsUInt) |
221 ; | 229 ; |
222 #undef EQUAL | 230 #undef EQUAL |
223 } | 231 } |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 SkDrawLooper* SkPaint::setLooper(SkDrawLooper* looper) { | 413 SkDrawLooper* SkPaint::setLooper(SkDrawLooper* looper) { |
406 SkRefCnt_SafeAssign(fLooper, looper); | 414 SkRefCnt_SafeAssign(fLooper, looper); |
407 return looper; | 415 return looper; |
408 } | 416 } |
409 | 417 |
410 SkImageFilter* SkPaint::setImageFilter(SkImageFilter* imageFilter) { | 418 SkImageFilter* SkPaint::setImageFilter(SkImageFilter* imageFilter) { |
411 SkRefCnt_SafeAssign(fImageFilter, imageFilter); | 419 SkRefCnt_SafeAssign(fImageFilter, imageFilter); |
412 return imageFilter; | 420 return imageFilter; |
413 } | 421 } |
414 | 422 |
| 423 SkAnnotation* SkPaint::setAnnotation(SkAnnotation* annotation) { |
| 424 SkRefCnt_SafeAssign(fAnnotation, annotation); |
| 425 return annotation; |
| 426 } |
| 427 |
415 /////////////////////////////////////////////////////////////////////////////// | 428 /////////////////////////////////////////////////////////////////////////////// |
416 | 429 |
417 static SkScalar mag2(SkScalar x, SkScalar y) { | 430 static SkScalar mag2(SkScalar x, SkScalar y) { |
418 return x * x + y * y; | 431 return x * x + y * y; |
419 } | 432 } |
420 | 433 |
421 static bool tooBig(const SkMatrix& m, SkScalar ma2max) { | 434 static bool tooBig(const SkMatrix& m, SkScalar ma2max) { |
422 return mag2(m[SkMatrix::kMScaleX], m[SkMatrix::kMSkewY]) > ma2max | 435 return mag2(m[SkMatrix::kMScaleX], m[SkMatrix::kMSkewY]) > ma2max |
423 || | 436 || |
424 mag2(m[SkMatrix::kMSkewX], m[SkMatrix::kMScaleY]) > ma2max; | 437 mag2(m[SkMatrix::kMSkewX], m[SkMatrix::kMScaleY]) > ma2max; |
(...skipping 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1877 if (this->getTypeface()) { | 1890 if (this->getTypeface()) { |
1878 flatFlags |= kHasTypeface_FlatFlag; | 1891 flatFlags |= kHasTypeface_FlatFlag; |
1879 } | 1892 } |
1880 if (asint(this->getPathEffect()) | | 1893 if (asint(this->getPathEffect()) | |
1881 asint(this->getShader()) | | 1894 asint(this->getShader()) | |
1882 asint(this->getXfermode()) | | 1895 asint(this->getXfermode()) | |
1883 asint(this->getMaskFilter()) | | 1896 asint(this->getMaskFilter()) | |
1884 asint(this->getColorFilter()) | | 1897 asint(this->getColorFilter()) | |
1885 asint(this->getRasterizer()) | | 1898 asint(this->getRasterizer()) | |
1886 asint(this->getLooper()) | | 1899 asint(this->getLooper()) | |
| 1900 asint(this->getAnnotation()) | |
1887 asint(this->getImageFilter())) { | 1901 asint(this->getImageFilter())) { |
1888 flatFlags |= kHasEffects_FlatFlag; | 1902 flatFlags |= kHasEffects_FlatFlag; |
1889 } | 1903 } |
1890 | 1904 |
1891 SkASSERT(SkAlign4(kPODPaintSize) == kPODPaintSize); | 1905 SkASSERT(SkAlign4(kPODPaintSize) == kPODPaintSize); |
1892 uint32_t* ptr = buffer.reserve(kPODPaintSize); | 1906 uint32_t* ptr = buffer.reserve(kPODPaintSize); |
1893 | 1907 |
1894 ptr = write_scalar(ptr, this->getTextSize()); | 1908 ptr = write_scalar(ptr, this->getTextSize()); |
1895 ptr = write_scalar(ptr, this->getTextScaleX()); | 1909 ptr = write_scalar(ptr, this->getTextScaleX()); |
1896 ptr = write_scalar(ptr, this->getTextSkewX()); | 1910 ptr = write_scalar(ptr, this->getTextSkewX()); |
(...skipping 13 matching lines...) Expand all Loading... |
1910 } | 1924 } |
1911 if (flatFlags & kHasEffects_FlatFlag) { | 1925 if (flatFlags & kHasEffects_FlatFlag) { |
1912 buffer.writeFlattenable(this->getPathEffect()); | 1926 buffer.writeFlattenable(this->getPathEffect()); |
1913 buffer.writeFlattenable(this->getShader()); | 1927 buffer.writeFlattenable(this->getShader()); |
1914 buffer.writeFlattenable(this->getXfermode()); | 1928 buffer.writeFlattenable(this->getXfermode()); |
1915 buffer.writeFlattenable(this->getMaskFilter()); | 1929 buffer.writeFlattenable(this->getMaskFilter()); |
1916 buffer.writeFlattenable(this->getColorFilter()); | 1930 buffer.writeFlattenable(this->getColorFilter()); |
1917 buffer.writeFlattenable(this->getRasterizer()); | 1931 buffer.writeFlattenable(this->getRasterizer()); |
1918 buffer.writeFlattenable(this->getLooper()); | 1932 buffer.writeFlattenable(this->getLooper()); |
1919 buffer.writeFlattenable(this->getImageFilter()); | 1933 buffer.writeFlattenable(this->getImageFilter()); |
| 1934 |
| 1935 if (fAnnotation) { |
| 1936 buffer.writeBool(true); |
| 1937 fAnnotation->writeToBuffer(buffer); |
| 1938 } else { |
| 1939 buffer.writeBool(false); |
| 1940 } |
1920 } | 1941 } |
1921 } | 1942 } |
1922 | 1943 |
1923 void SkPaint::unflatten(SkReadBuffer& buffer) { | 1944 void SkPaint::unflatten(SkReadBuffer& buffer) { |
1924 SkASSERT(SkAlign4(kPODPaintSize) == kPODPaintSize); | 1945 SkASSERT(SkAlign4(kPODPaintSize) == kPODPaintSize); |
1925 if (!buffer.validateAvailable(kPODPaintSize)) { | 1946 if (!buffer.validateAvailable(kPODPaintSize)) { |
1926 return; | 1947 return; |
1927 } | 1948 } |
1928 const void* podData = buffer.skip(kPODPaintSize); | 1949 const void* podData = buffer.skip(kPODPaintSize); |
1929 const uint32_t* pod = reinterpret_cast<const uint32_t*>(podData); | 1950 const uint32_t* pod = reinterpret_cast<const uint32_t*>(podData); |
(...skipping 23 matching lines...) Expand all Loading... |
1953 if (flatFlags & kHasEffects_FlatFlag) { | 1974 if (flatFlags & kHasEffects_FlatFlag) { |
1954 SkSafeUnref(this->setPathEffect(buffer.readPathEffect())); | 1975 SkSafeUnref(this->setPathEffect(buffer.readPathEffect())); |
1955 SkSafeUnref(this->setShader(buffer.readShader())); | 1976 SkSafeUnref(this->setShader(buffer.readShader())); |
1956 SkSafeUnref(this->setXfermode(buffer.readXfermode())); | 1977 SkSafeUnref(this->setXfermode(buffer.readXfermode())); |
1957 SkSafeUnref(this->setMaskFilter(buffer.readMaskFilter())); | 1978 SkSafeUnref(this->setMaskFilter(buffer.readMaskFilter())); |
1958 SkSafeUnref(this->setColorFilter(buffer.readColorFilter())); | 1979 SkSafeUnref(this->setColorFilter(buffer.readColorFilter())); |
1959 SkSafeUnref(this->setRasterizer(buffer.readRasterizer())); | 1980 SkSafeUnref(this->setRasterizer(buffer.readRasterizer())); |
1960 SkSafeUnref(this->setLooper(buffer.readDrawLooper())); | 1981 SkSafeUnref(this->setLooper(buffer.readDrawLooper())); |
1961 SkSafeUnref(this->setImageFilter(buffer.readImageFilter())); | 1982 SkSafeUnref(this->setImageFilter(buffer.readImageFilter())); |
1962 | 1983 |
1963 if (buffer.isVersionLT(SkReadBuffer::kAnnotationsMovedToCanvas_Version))
{ | 1984 if (buffer.readBool()) { |
1964 // We used to store annotations here (string+skdata) if this bool wa
s true | 1985 this->setAnnotation(SkAnnotation::Create(buffer))->unref(); |
1965 if (buffer.readBool()) { | |
1966 // Annotations have moved to drawAnnotation, so we just drop thi
s one on the floor. | |
1967 SkString key; | |
1968 buffer.readString(&key); | |
1969 SkSafeUnref(buffer.readByteArrayAsData()); | |
1970 } | |
1971 } | 1986 } |
1972 } else { | 1987 } else { |
1973 this->setPathEffect(nullptr); | 1988 this->setPathEffect(nullptr); |
1974 this->setShader(nullptr); | 1989 this->setShader(nullptr); |
1975 this->setXfermode(nullptr); | 1990 this->setXfermode(nullptr); |
1976 this->setMaskFilter(nullptr); | 1991 this->setMaskFilter(nullptr); |
1977 this->setColorFilter(nullptr); | 1992 this->setColorFilter(nullptr); |
1978 this->setRasterizer(nullptr); | 1993 this->setRasterizer(nullptr); |
1979 this->setLooper(nullptr); | 1994 this->setLooper(nullptr); |
1980 this->setImageFilter(nullptr); | 1995 this->setImageFilter(nullptr); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2183 str->append("</dd>"); | 2198 str->append("</dd>"); |
2184 } | 2199 } |
2185 | 2200 |
2186 SkImageFilter* imageFilter = this->getImageFilter(); | 2201 SkImageFilter* imageFilter = this->getImageFilter(); |
2187 if (imageFilter) { | 2202 if (imageFilter) { |
2188 str->append("<dt>ImageFilter:</dt><dd>"); | 2203 str->append("<dt>ImageFilter:</dt><dd>"); |
2189 imageFilter->toString(str); | 2204 imageFilter->toString(str); |
2190 str->append("</dd>"); | 2205 str->append("</dd>"); |
2191 } | 2206 } |
2192 | 2207 |
| 2208 SkAnnotation* annotation = this->getAnnotation(); |
| 2209 if (annotation) { |
| 2210 str->append("<dt>Annotation:</dt><dd>"); |
| 2211 str->append("</dd>"); |
| 2212 } |
| 2213 |
2193 str->append("<dt>Color:</dt><dd>0x"); | 2214 str->append("<dt>Color:</dt><dd>0x"); |
2194 SkColor color = this->getColor(); | 2215 SkColor color = this->getColor(); |
2195 str->appendHex(color); | 2216 str->appendHex(color); |
2196 str->append("</dd>"); | 2217 str->append("</dd>"); |
2197 | 2218 |
2198 str->append("<dt>Stroke Width:</dt><dd>"); | 2219 str->append("<dt>Stroke Width:</dt><dd>"); |
2199 str->appendScalar(this->getStrokeWidth()); | 2220 str->appendScalar(this->getStrokeWidth()); |
2200 str->append("</dd>"); | 2221 str->append("</dd>"); |
2201 | 2222 |
2202 str->append("<dt>Stroke Miter:</dt><dd>"); | 2223 str->append("<dt>Stroke Miter:</dt><dd>"); |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2409 default: | 2430 default: |
2410 break; | 2431 break; |
2411 } | 2432 } |
2412 } | 2433 } |
2413 return false; | 2434 return false; |
2414 } | 2435 } |
2415 | 2436 |
2416 uint32_t SkPaint::getHash() const { | 2437 uint32_t SkPaint::getHash() const { |
2417 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, | 2438 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, |
2418 // so fBitfields should be 10 pointers and 6 32-bit values from the start. | 2439 // so fBitfields should be 10 pointers and 6 32-bit values from the start. |
2419 static_assert(offsetof(SkPaint, fBitfields) == 9 * sizeof(void*) + 6 * sizeo
f(uint32_t), | 2440 static_assert(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 * size
of(uint32_t), |
2420 "SkPaint_notPackedTightly"); | 2441 "SkPaint_notPackedTightly"); |
2421 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), | 2442 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), |
2422 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); | 2443 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); |
2423 } | 2444 } |
OLD | NEW |