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 #ifdef SK_BUILD_FOR_ANDROID | |
10 | |
11 #include "SkPaintOptionsAndroid.h" | 9 #include "SkPaintOptionsAndroid.h" |
12 #include "SkFlattenableBuffers.h" | 10 #include "SkFlattenableBuffers.h" |
13 #include "SkTDict.h" | 11 #include "SkTDict.h" |
14 #include "SkThread.h" | 12 #include "SkThread.h" |
15 #include <cstring> | 13 #include <cstring> |
16 | 14 |
| 15 #ifdef SK_BUILD_FOR_ANDROID |
| 16 |
17 SkLanguage SkLanguage::getParent() const { | 17 SkLanguage SkLanguage::getParent() const { |
18 SkASSERT(!fTag.isEmpty()); | 18 SkASSERT(!fTag.isEmpty()); |
19 const char* tag = fTag.c_str(); | 19 const char* tag = fTag.c_str(); |
20 | 20 |
21 // strip off the rightmost "-.*" | 21 // strip off the rightmost "-.*" |
22 char* parentTagEnd = strrchr(tag, '-'); | 22 char* parentTagEnd = strrchr(tag, '-'); |
23 if (parentTagEnd == NULL) { | 23 if (parentTagEnd == NULL) { |
24 return SkLanguage(); | 24 return SkLanguage(); |
25 } | 25 } |
26 size_t parentTagLen = parentTagEnd - tag; | 26 size_t parentTagLen = parentTagEnd - tag; |
27 return SkLanguage(tag, parentTagLen); | 27 return SkLanguage(tag, parentTagLen); |
28 } | 28 } |
29 | 29 |
30 void SkPaintOptionsAndroid::flatten(SkFlattenableWriteBuffer& buffer) const { | 30 void SkPaintOptionsAndroid::flatten(SkFlattenableWriteBuffer& buffer) const { |
31 buffer.writeUInt(fFontVariant); | 31 buffer.writeUInt(fFontVariant); |
32 buffer.writeString(fLanguage.getTag().c_str()); | 32 buffer.writeString(fLanguage.getTag().c_str()); |
33 buffer.writeBool(fUseFontFallbacks); | 33 buffer.writeBool(fUseFontFallbacks); |
34 } | 34 } |
35 | 35 |
36 void SkPaintOptionsAndroid::unflatten(SkFlattenableReadBuffer& buffer) { | 36 void SkPaintOptionsAndroid::unflatten(SkFlattenableReadBuffer& buffer) { |
37 fFontVariant = (FontVariant)buffer.readUInt(); | 37 fFontVariant = (FontVariant)buffer.readUInt(); |
38 SkString tag; | 38 SkString tag; |
39 buffer.readString(&tag); | 39 buffer.readString(&tag); |
40 fLanguage = SkLanguage(tag); | 40 fLanguage = SkLanguage(tag); |
41 fUseFontFallbacks = buffer.readBool(); | 41 fUseFontFallbacks = buffer.readBool(); |
42 } | 42 } |
43 | 43 |
44 #endif | 44 #endif |
OLD | NEW |