のねのBlog

パソコンの問題や、ソフトウェアの開発で起きた問題など書いていきます。よろしくお願いします^^。

readTypeface

   1875 void SkPaint::unflatten(SkFlattenableReadBuffer& buffer) {
   1876     SkASSERT(SkAlign4(kPODPaintSize) == kPODPaintSize);
   1877     const void* podData = buffer.skip(kPODPaintSize);
   1878     const uint32_t* pod = reinterpret_cast<const uint32_t*>(podData);
   1879 
   1880     // the order we read must match the order we wrote in flatten()
   1881     this->setTextSize(read_scalar(pod));
   1882     this->setTextScaleX(read_scalar(pod));
   1883     this->setTextSkewX(read_scalar(pod));
   1884     this->setStrokeWidth(read_scalar(pod));
   1885     this->setStrokeMiter(read_scalar(pod));
   1886     this->setColor(*pod++);
   1887 
   1888     // previously flags:16, textAlign:8, flatFlags:8
   1889     // now flags:16, hinting:4, textAlign:4, flatFlags:8
   1890     uint32_t tmp = *pod++;
   1891     this->setFlags(tmp >> 16);
   1892 
   1893     if (buffer.getPictureVersion() == PICTURE_VERSION_ICS) {
   1894         this->setTextAlign(static_cast<Align>((tmp >> 8) & 0xFF));
   1895         this->setHinting(SkPaintDefaults_Hinting);
   1896     } else {
   1897         // hinting added later. 0 in this nibble means use the default.
   1898         uint32_t hinting = (tmp >> 12) & 0xF;
   1899         this->setHinting(0 == hinting ? kNormal_Hinting : static_cast<Hinting>(hinting-1));
   1900 
   1901         this->setTextAlign(static_cast<Align>((tmp >> 8) & 0xF));
   1902     }
   1903 
   1904     uint8_t flatFlags = tmp & 0xFF;
   1905 
   1906     tmp = *pod++;
   1907     this->setStrokeCap(static_cast<Cap>((tmp >> 24) & 0xFF));
   1908     this->setStrokeJoin(static_cast<Join>((tmp >> 16) & 0xFF));
   1909     this->setStyle(static_cast<Style>((tmp >> 8) & 0xFF));
   1910     this->setTextEncoding(static_cast<TextEncoding>((tmp >> 0) & 0xFF));
   1911 
   1912 #ifdef SK_BUILD_FOR_ANDROID
   1913     this->setFontVariant(SkPaint::FontVariant(buffer.readInt()));
   1914     this->setLanguage(SkLanguage(buffer.readString()));
   1915 #endif
   1916 
   1917     if (flatFlags & kHasTypeface_FlatFlag) {
   1918         this->setTypeface(buffer.readTypeface()); <=====
   1919     } else {
   1920         this->setTypeface(NULL);
   1921     }
   1922 
   1923     if (flatFlags & kHasEffects_FlatFlag) {
   1924         SkSafeUnref(this->setPathEffect((SkPathEffect*) buffer.readFlattenable()));
   1925         SkSafeUnref(this->setShader((SkShader*) buffer.readFlattenable()));
   1926         SkSafeUnref(this->setXfermode((SkXfermode*) buffer.readFlattenable()));
   1927         SkSafeUnref(this->setMaskFilter((SkMaskFilter*) buffer.readFlattenable()));
   1928         SkSafeUnref(this->setColorFilter((SkColorFilter*) buffer.readFlattenable()));
   1929         SkSafeUnref(this->setRasterizer((SkRasterizer*) buffer.readFlattenable()));
   1930         SkSafeUnref(this->setLooper((SkDrawLooper*) buffer.readFlattenable()));
   1931         if (buffer.getPictureVersion() != PICTURE_VERSION_ICS)
   1932             SkSafeUnref(this->setImageFilter((SkImageFilter*) buffer.readFlattenable()));
   1933         else
   1934             this->setImageFilter(NULL);
   1935     } else {
   1936         this->setPathEffect(NULL);
   1937         this->setShader(NULL);
   1938         this->setXfermode(NULL);
   1939         this->setMaskFilter(NULL);
   1940         this->setColorFilter(NULL);
   1941         this->setRasterizer(NULL);
   1942         this->setLooper(NULL);
   1943         this->setImageFilter(NULL);
   1944     }
   1945 }

></blockquote><

><blockquote cite="http://tools.oesf.biz/android-4.2.0_r1.0/xref/external/skia/src/core/SkFlattenable.cpp#92" title="Cross Reference: /external/skia/src/core/SkFlattenable.cpp"><
>|cpp|
     92 SkTypeface* SkFlattenableReadBuffer::readTypeface() {
     93     uint32_t index = this->readU32();
     94     if (0 == index || index > (unsigned)fTFCount) {
     95         if (index) {
     96             SkDebugf("====== typeface index %d\n", index);
     97         }
     98         return NULL;
     99     } else {
    100         SkASSERT(fTFArray);
    101         return fTFArray[index - 1];
    102     }
    103 }