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 2105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2116 #ifndef SK_IGNORE_TO_STRING | 2116 #ifndef SK_IGNORE_TO_STRING |
2117 | 2117 |
2118 void SkPaint::toString(SkString* str) const { | 2118 void SkPaint::toString(SkString* str) const { |
2119 str->append("<dl><dt>SkPaint:</dt><dd><dl>"); | 2119 str->append("<dl><dt>SkPaint:</dt><dd><dl>"); |
2120 | 2120 |
2121 SkTypeface* typeface = this->getTypeface(); | 2121 SkTypeface* typeface = this->getTypeface(); |
2122 if (typeface) { | 2122 if (typeface) { |
2123 SkDynamicMemoryWStream ostream; | 2123 SkDynamicMemoryWStream ostream; |
2124 typeface->serialize(&ostream); | 2124 typeface->serialize(&ostream); |
2125 SkAutoTDelete<SkStreamAsset> istream(ostream.detachAsStream()); | 2125 SkAutoTDelete<SkStreamAsset> istream(ostream.detachAsStream()); |
2126 SkFontDescriptor descriptor(istream); | |
2127 | 2126 |
2128 str->append("<dt>Font Family Name:</dt><dd>"); | 2127 SkFontDescriptor descriptor; |
2129 str->append(descriptor.getFamilyName()); | 2128 if (!SkFontDescriptor::Deserialize(istream, &descriptor)) { |
2130 str->append("</dd><dt>Font Full Name:</dt><dd>"); | 2129 str->append("<dt>FontDescriptor deserialization failed</dt>"); |
2131 str->append(descriptor.getFullName()); | 2130 } else { |
2132 str->append("</dd><dt>Font PS Name:</dt><dd>"); | 2131 str->append("<dt>Font Family Name:</dt><dd>"); |
2133 str->append(descriptor.getPostscriptName()); | 2132 str->append(descriptor.getFamilyName()); |
2134 str->append("</dd>"); | 2133 str->append("</dd><dt>Font Full Name:</dt><dd>"); |
| 2134 str->append(descriptor.getFullName()); |
| 2135 str->append("</dd><dt>Font PS Name:</dt><dd>"); |
| 2136 str->append(descriptor.getPostscriptName()); |
| 2137 str->append("</dd>"); |
| 2138 } |
2135 } | 2139 } |
2136 | 2140 |
2137 str->append("<dt>TextSize:</dt><dd>"); | 2141 str->append("<dt>TextSize:</dt><dd>"); |
2138 str->appendScalar(this->getTextSize()); | 2142 str->appendScalar(this->getTextSize()); |
2139 str->append("</dd>"); | 2143 str->append("</dd>"); |
2140 | 2144 |
2141 str->append("<dt>TextScaleX:</dt><dd>"); | 2145 str->append("<dt>TextScaleX:</dt><dd>"); |
2142 str->appendScalar(this->getTextScaleX()); | 2146 str->appendScalar(this->getTextScaleX()); |
2143 str->append("</dd>"); | 2147 str->append("</dd>"); |
2144 | 2148 |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2431 } | 2435 } |
2432 | 2436 |
2433 uint32_t SkPaint::getHash() const { | 2437 uint32_t SkPaint::getHash() const { |
2434 // 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, |
2435 // 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. |
2436 static_assert(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 * size
of(uint32_t), | 2440 static_assert(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 * size
of(uint32_t), |
2437 "SkPaint_notPackedTightly"); | 2441 "SkPaint_notPackedTightly"); |
2438 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), | 2442 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), |
2439 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); | 2443 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); |
2440 } | 2444 } |
OLD | NEW |