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 "SkAnnotation.h" |
10 #include "SkAutoKern.h" | 10 #include "SkAutoKern.h" |
(...skipping 1878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1889 | 1889 |
1890 // left-align the fields of "known" size, and right-align the last (flatFlag
s) so it can easly | 1890 // left-align the fields of "known" size, and right-align the last (flatFlag
s) so it can easly |
1891 // add more bits in the future. | 1891 // add more bits in the future. |
1892 return (flags << 16) | (hint << 14) | (align << 12) | (filter << 10) | flatF
lags; | 1892 return (flags << 16) | (hint << 14) | (align << 12) | (filter << 10) | flatF
lags; |
1893 } | 1893 } |
1894 | 1894 |
1895 static FlatFlags unpack_paint_flags(SkPaint* paint, uint32_t packed) { | 1895 static FlatFlags unpack_paint_flags(SkPaint* paint, uint32_t packed) { |
1896 paint->setFlags(packed >> 16); | 1896 paint->setFlags(packed >> 16); |
1897 paint->setHinting((SkPaint::Hinting)((packed >> 14) & BPF_Mask(kHint_BPF))); | 1897 paint->setHinting((SkPaint::Hinting)((packed >> 14) & BPF_Mask(kHint_BPF))); |
1898 paint->setTextAlign((SkPaint::Align)((packed >> 12) & BPF_Mask(kAlign_BPF)))
; | 1898 paint->setTextAlign((SkPaint::Align)((packed >> 12) & BPF_Mask(kAlign_BPF)))
; |
1899 paint->setFilterLevel((SkPaint::FilterLevel)((packed >> 10) & BPF_Mask(kFilt
er_BPF))); | 1899 paint->setFilterQuality((SkFilterQuality)((packed >> 10) & BPF_Mask(kFilter_
BPF))); |
1900 return (FlatFlags)(packed & kFlatFlagMask); | 1900 return (FlatFlags)(packed & kFlatFlagMask); |
1901 } | 1901 } |
1902 | 1902 |
1903 // The size of a flat paint's POD fields | 1903 // The size of a flat paint's POD fields |
1904 static const uint32_t kPODPaintSize = 5 * sizeof(SkScalar) + | 1904 static const uint32_t kPODPaintSize = 5 * sizeof(SkScalar) + |
1905 1 * sizeof(SkColor) + | 1905 1 * sizeof(SkColor) + |
1906 1 * sizeof(uint16_t) + | 1906 1 * sizeof(uint16_t) + |
1907 6 * sizeof(uint8_t); | 1907 6 * sizeof(uint8_t); |
1908 | 1908 |
1909 /* To save space/time, we analyze the paint, and write a truncated version of | 1909 /* To save space/time, we analyze the paint, and write a truncated version of |
(...skipping 20 matching lines...) Expand all Loading... |
1930 uint32_t* ptr = buffer.reserve(kPODPaintSize); | 1930 uint32_t* ptr = buffer.reserve(kPODPaintSize); |
1931 | 1931 |
1932 ptr = write_scalar(ptr, this->getTextSize()); | 1932 ptr = write_scalar(ptr, this->getTextSize()); |
1933 ptr = write_scalar(ptr, this->getTextScaleX()); | 1933 ptr = write_scalar(ptr, this->getTextScaleX()); |
1934 ptr = write_scalar(ptr, this->getTextSkewX()); | 1934 ptr = write_scalar(ptr, this->getTextSkewX()); |
1935 ptr = write_scalar(ptr, this->getStrokeWidth()); | 1935 ptr = write_scalar(ptr, this->getStrokeWidth()); |
1936 ptr = write_scalar(ptr, this->getStrokeMiter()); | 1936 ptr = write_scalar(ptr, this->getStrokeMiter()); |
1937 *ptr++ = this->getColor(); | 1937 *ptr++ = this->getColor(); |
1938 | 1938 |
1939 *ptr++ = pack_paint_flags(this->getFlags(), this->getHinting(), this->getTex
tAlign(), | 1939 *ptr++ = pack_paint_flags(this->getFlags(), this->getHinting(), this->getTex
tAlign(), |
1940 this->getFilterLevel(), flatFlags); | 1940 this->getFilterQuality(), flatFlags); |
1941 *ptr++ = pack_4(this->getStrokeCap(), this->getStrokeJoin(), | 1941 *ptr++ = pack_4(this->getStrokeCap(), this->getStrokeJoin(), |
1942 this->getStyle(), this->getTextEncoding()); | 1942 this->getStyle(), this->getTextEncoding()); |
1943 | 1943 |
1944 // now we're done with ptr and the (pre)reserved space. If we need to write | 1944 // now we're done with ptr and the (pre)reserved space. If we need to write |
1945 // additional fields, use the buffer directly | 1945 // additional fields, use the buffer directly |
1946 if (flatFlags & kHasTypeface_FlatFlag) { | 1946 if (flatFlags & kHasTypeface_FlatFlag) { |
1947 buffer.writeTypeface(this->getTypeface()); | 1947 buffer.writeTypeface(this->getTypeface()); |
1948 } | 1948 } |
1949 if (flatFlags & kHasEffects_FlatFlag) { | 1949 if (flatFlags & kHasEffects_FlatFlag) { |
1950 buffer.writeFlattenable(this->getPathEffect()); | 1950 buffer.writeFlattenable(this->getPathEffect()); |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2250 SkAddFlagToString(str, this->isAutohinted(), "Autohinted", &needSeparato
r); | 2250 SkAddFlagToString(str, this->isAutohinted(), "Autohinted", &needSeparato
r); |
2251 SkAddFlagToString(str, this->isVerticalText(), "VerticalText", &needSepa
rator); | 2251 SkAddFlagToString(str, this->isVerticalText(), "VerticalText", &needSepa
rator); |
2252 SkAddFlagToString(str, SkToBool(this->getFlags() & SkPaint::kGenA8FromLC
D_Flag), | 2252 SkAddFlagToString(str, SkToBool(this->getFlags() & SkPaint::kGenA8FromLC
D_Flag), |
2253 "GenA8FromLCD", &needSeparator); | 2253 "GenA8FromLCD", &needSeparator); |
2254 } else { | 2254 } else { |
2255 str->append("None"); | 2255 str->append("None"); |
2256 } | 2256 } |
2257 str->append(")</dd>"); | 2257 str->append(")</dd>"); |
2258 | 2258 |
2259 str->append("<dt>FilterLevel:</dt><dd>"); | 2259 str->append("<dt>FilterLevel:</dt><dd>"); |
2260 static const char* gFilterLevelStrings[] = { "None", "Low", "Medium", "High"
}; | 2260 static const char* gFilterQualityStrings[] = { "None", "Low", "Medium", "Hig
h" }; |
2261 str->append(gFilterLevelStrings[this->getFilterLevel()]); | 2261 str->append(gFilterQualityStrings[this->getFilterQuality()]); |
2262 str->append("</dd>"); | 2262 str->append("</dd>"); |
2263 | 2263 |
2264 str->append("<dt>TextAlign:</dt><dd>"); | 2264 str->append("<dt>TextAlign:</dt><dd>"); |
2265 static const char* gTextAlignStrings[SkPaint::kAlignCount] = { "Left", "Cent
er", "Right" }; | 2265 static const char* gTextAlignStrings[SkPaint::kAlignCount] = { "Left", "Cent
er", "Right" }; |
2266 str->append(gTextAlignStrings[this->getTextAlign()]); | 2266 str->append(gTextAlignStrings[this->getTextAlign()]); |
2267 str->append("</dd>"); | 2267 str->append("</dd>"); |
2268 | 2268 |
2269 str->append("<dt>CapType:</dt><dd>"); | 2269 str->append("<dt>CapType:</dt><dd>"); |
2270 static const char* gStrokeCapStrings[SkPaint::kCapCount] = { "Butt", "Round"
, "Square" }; | 2270 static const char* gStrokeCapStrings[SkPaint::kCapCount] = { "Butt", "Round"
, "Square" }; |
2271 str->append(gStrokeCapStrings[this->getStrokeCap()]); | 2271 str->append(gStrokeCapStrings[this->getStrokeCap()]); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2433 } | 2433 } |
2434 | 2434 |
2435 uint32_t SkPaint::getHash() const { | 2435 uint32_t SkPaint::getHash() const { |
2436 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, | 2436 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, |
2437 // so fBitfields should be 10 pointers and 6 32-bit values from the start. | 2437 // so fBitfields should be 10 pointers and 6 32-bit values from the start. |
2438 SK_COMPILE_ASSERT(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 *
sizeof(uint32_t), | 2438 SK_COMPILE_ASSERT(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 *
sizeof(uint32_t), |
2439 SkPaint_notPackedTightly); | 2439 SkPaint_notPackedTightly); |
2440 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), | 2440 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), |
2441 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); | 2441 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); |
2442 } | 2442 } |
OLD | NEW |