1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/core/SkPaintOptionsAndroid.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,41 @@ 1.4 + 1.5 +/* 1.6 + * Copyright 2012 The Android Open Source Project 1.7 + * 1.8 + * Use of this source code is governed by a BSD-style license that can be 1.9 + * found in the LICENSE file. 1.10 + */ 1.11 + 1.12 +#include "SkPaintOptionsAndroid.h" 1.13 +#include "SkReadBuffer.h" 1.14 +#include "SkWriteBuffer.h" 1.15 +#include "SkTDict.h" 1.16 +#include "SkThread.h" 1.17 +#include <cstring> 1.18 + 1.19 +SkLanguage SkLanguage::getParent() const { 1.20 + SkASSERT(!fTag.isEmpty()); 1.21 + const char* tag = fTag.c_str(); 1.22 + 1.23 + // strip off the rightmost "-.*" 1.24 + const char* parentTagEnd = strrchr(tag, '-'); 1.25 + if (parentTagEnd == NULL) { 1.26 + return SkLanguage(); 1.27 + } 1.28 + size_t parentTagLen = parentTagEnd - tag; 1.29 + return SkLanguage(tag, parentTagLen); 1.30 +} 1.31 + 1.32 +void SkPaintOptionsAndroid::flatten(SkWriteBuffer& buffer) const { 1.33 + buffer.writeUInt(fFontVariant); 1.34 + buffer.writeString(fLanguage.getTag().c_str()); 1.35 + buffer.writeBool(fUseFontFallbacks); 1.36 +} 1.37 + 1.38 +void SkPaintOptionsAndroid::unflatten(SkReadBuffer& buffer) { 1.39 + fFontVariant = (FontVariant)buffer.readUInt(); 1.40 + SkString tag; 1.41 + buffer.readString(&tag); 1.42 + fLanguage = SkLanguage(tag); 1.43 + fUseFontFallbacks = buffer.readBool(); 1.44 +}