| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 The Android Open Source Project | 3 * Copyright 2012 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "SkPaintOptionsAndroid.h" | 9 #include "SkPaintOptionsAndroid.h" |
| 10 #include "SkFlattenableBuffers.h" | 10 #include "SkReadBuffer.h" |
| 11 #include "SkWriteBuffer.h" |
| 11 #include "SkTDict.h" | 12 #include "SkTDict.h" |
| 12 #include "SkThread.h" | 13 #include "SkThread.h" |
| 13 #include <cstring> | 14 #include <cstring> |
| 14 | 15 |
| 15 SkLanguage SkLanguage::getParent() const { | 16 SkLanguage SkLanguage::getParent() const { |
| 16 SkASSERT(!fTag.isEmpty()); | 17 SkASSERT(!fTag.isEmpty()); |
| 17 const char* tag = fTag.c_str(); | 18 const char* tag = fTag.c_str(); |
| 18 | 19 |
| 19 // strip off the rightmost "-.*" | 20 // strip off the rightmost "-.*" |
| 20 const char* parentTagEnd = strrchr(tag, '-'); | 21 const char* parentTagEnd = strrchr(tag, '-'); |
| 21 if (parentTagEnd == NULL) { | 22 if (parentTagEnd == NULL) { |
| 22 return SkLanguage(); | 23 return SkLanguage(); |
| 23 } | 24 } |
| 24 size_t parentTagLen = parentTagEnd - tag; | 25 size_t parentTagLen = parentTagEnd - tag; |
| 25 return SkLanguage(tag, parentTagLen); | 26 return SkLanguage(tag, parentTagLen); |
| 26 } | 27 } |
| 27 | 28 |
| 28 void SkPaintOptionsAndroid::flatten(SkFlattenableWriteBuffer& buffer) const { | 29 void SkPaintOptionsAndroid::flatten(SkWriteBuffer& buffer) const { |
| 29 buffer.writeUInt(fFontVariant); | 30 buffer.writeUInt(fFontVariant); |
| 30 buffer.writeString(fLanguage.getTag().c_str()); | 31 buffer.writeString(fLanguage.getTag().c_str()); |
| 31 buffer.writeBool(fUseFontFallbacks); | 32 buffer.writeBool(fUseFontFallbacks); |
| 32 } | 33 } |
| 33 | 34 |
| 34 void SkPaintOptionsAndroid::unflatten(SkFlattenableReadBuffer& buffer) { | 35 void SkPaintOptionsAndroid::unflatten(SkReadBuffer& buffer) { |
| 35 fFontVariant = (FontVariant)buffer.readUInt(); | 36 fFontVariant = (FontVariant)buffer.readUInt(); |
| 36 SkString tag; | 37 SkString tag; |
| 37 buffer.readString(&tag); | 38 buffer.readString(&tag); |
| 38 fLanguage = SkLanguage(tag); | 39 fLanguage = SkLanguage(tag); |
| 39 fUseFontFallbacks = buffer.readBool(); | 40 fUseFontFallbacks = buffer.readBool(); |
| 40 } | 41 } |
| OLD | NEW |