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