当前位置: 首页>>代码示例>>C++>>正文


C++ SkStream::getLength方法代码示例

本文整理汇总了C++中SkStream::getLength方法的典型用法代码示例。如果您正苦于以下问题:C++ SkStream::getLength方法的具体用法?C++ SkStream::getLength怎么用?C++ SkStream::getLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SkStream的用法示例。


在下文中一共展示了SkStream::getLength方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: openStream

    // overrides
    virtual SkStream* openStream() {
        SkStream* stream = SkNEW_ARGS(SkMMAPStream, (fPath.c_str()));

        // check for failure
        if (stream->getLength() <= 0) {
            SkDELETE(stream);
            // maybe MMAP isn't supported. try FILE
            stream = SkNEW_ARGS(SkFILEStream, (fPath.c_str()));
            if (stream->getLength() <= 0) {
                SkDELETE(stream);
                stream = NULL;
            }
        }
        return stream;
    }
开发者ID:Krylon360,项目名称:android_external_skia,代码行数:16,代码来源:SkFontHost_android.cpp

示例2: delete_stream_proc

static void delete_stream_proc(void* info, const void* addr, size_t size) {
    SkASSERT(info);
    SkStream* stream = (SkStream*)info;
    SkASSERT(stream->getMemoryBase() == addr);
    SkASSERT(stream->getLength() == size);
    SkDELETE(stream);
}
开发者ID:Arternis,项目名称:skia,代码行数:7,代码来源:SkStream_mac.cpp

示例3: Serialize

void SkFontHost::Serialize(const SkTypeface* face, SkWStream* stream) {

    SkFontDescriptor descriptor;
    {
        SkAutoMutexAcquire ac(gFamilyHeadAndNameListMutex);
        descriptor.setFamilyName(find_family_name(face));
        descriptor.setStyle(face->style());
        descriptor.setFontFileName(((FamilyTypeface*)face)->getUniqueString());
    }

    descriptor.serialize(stream);

    const bool isCustomFont = !((FamilyTypeface*)face)->isSysFont();
    if (isCustomFont) {
        // store the entire font in the fontData
        SkStream* fontStream = ((FamilyTypeface*)face)->openStream();
        const uint32_t length = fontStream->getLength();

        stream->writePackedUInt(length);
        stream->writeStream(fontStream, length);

        fontStream->unref();
    } else {
        stream->writePackedUInt(0);
    }
}
开发者ID:bunhere,项目名称:skia,代码行数:26,代码来源:SkFontHost_android.cpp

示例4: create_from_path

static FTMacTypeface* create_from_path(const char path[]) {
    SkStream* stream = new SkMMAPStream(path);
    size_t size = stream->getLength();
    SkASSERT(size);
    FTMacTypeface* tf = new FTMacTypeface(SkTypeface::kNormal,
                                          SkTypefaceCache::NewFontID(),
                                          stream);
    SkTypefaceCache::Add(tf, SkTypeface::kNormal);
    return tf;
}
开发者ID:AliFarahnak,项目名称:XobotOS,代码行数:10,代码来源:SkFontHost_freetype_mac.cpp

示例5: ref_ft_face

// Will return 0 on failure
static SkFaceRec* ref_ft_face(uint32_t fontID) {
    SkFaceRec* rec = gFaceRecHead;
    while (rec) {
        if (rec->fFontID == fontID) {
            SkASSERT(rec->fFace);
            rec->fRefCnt += 1;
            return rec;
        }
        rec = rec->fNext;
    }

    SkStream* strm = SkFontHost::OpenStream(fontID);
    if (NULL == strm) {
        SkDEBUGF(("SkFontHost::OpenStream failed opening %x\n", fontID));
        return 0;
    }

    // this passes ownership of strm to the rec
    rec = SkNEW_ARGS(SkFaceRec, (strm, fontID));

    FT_Open_Args    args;
    memset(&args, 0, sizeof(args));
    const void* memoryBase = strm->getMemoryBase();

    if (NULL != memoryBase) {
//printf("mmap(%s)\n", keyString.c_str());
        args.flags = FT_OPEN_MEMORY;
        args.memory_base = (const FT_Byte*)memoryBase;
        args.memory_size = strm->getLength();
    } else {
//printf("fopen(%s)\n", keyString.c_str());
        args.flags = FT_OPEN_STREAM;
        args.stream = &rec->fFTStream;
    }

    int face_index;
    int length = SkFontHost::GetFileName(fontID, NULL, 0, &face_index);
    FT_Error err = FT_Open_Face(gFTLibrary, &args, length ? face_index : 0,
                                &rec->fFace);

    if (err) {    // bad filename, try the default font
        fprintf(stderr, "ERROR: unable to open font '%x'\n", fontID);
        SkDELETE(rec);
        return 0;
    } else {
        SkASSERT(rec->fFace);
        //fprintf(stderr, "Opened font '%s'\n", filename.c_str());
        rec->fNext = gFaceRecHead;
        gFaceRecHead = rec;
        rec->fRefCnt = 1;
        return rec;
    }
}
开发者ID:ACSOP,项目名称:android_external_skia,代码行数:54,代码来源:SkFontHost_FreeType.cpp

示例6: OpenStream

SkStream* SkFontHost::OpenStream(uint32_t fontID) {
    SkAutoMutexAcquire  ac(gFamilyHeadAndNameListMutex);

    FamilyTypeface* tf = (FamilyTypeface*)find_from_uniqueID(fontID);
    SkStream* stream = tf ? tf->openStream() : NULL;

    if (stream && stream->getLength() == 0) {
        stream->unref();
        stream = NULL;
    }
    return stream;
}
开发者ID:bunhere,项目名称:skia,代码行数:12,代码来源:SkFontHost_android.cpp

示例7: Serialize

void SkFontHost::Serialize(const SkTypeface* face, SkWStream* stream) {
    SkStream* fontStream = ((FamilyTypeface*)face)->openStream();

    // store the length of the custom font
    uint32_t len = fontStream->getLength();
    stream->write32(len);

    // store the entire font in the serialized stream
    void* fontData = malloc(len);

    fontStream->read(fontData, len);
    stream->write(fontData, len);

    fontStream->unref();
    free(fontData);


//    sk_throw();
}
开发者ID:Carbon2011,项目名称:android_external_skia,代码行数:19,代码来源:SkFontHost_linux.cpp

示例8: onOpenStream

SkStream* FontConfigTypeface::onOpenStream(int* ttcIndex) const {
    SkStream* stream = this->getLocalStream();
    if (stream) {
        // should have been provided by CreateFromStream()
        *ttcIndex = 0;

        SkAutoTUnref<SkStream> dupStream(stream->duplicate());
        if (dupStream) {
            return dupStream.detach();
        }

        // TODO: update interface use, remove the following code in this block.
        size_t length = stream->getLength();

        const void* memory = stream->getMemoryBase();
        if (NULL != memory) {
            return new SkMemoryStream(memory, length, true);
        }

        SkAutoTMalloc<uint8_t> allocMemory(length);
        stream->rewind();
        if (length == stream->read(allocMemory.get(), length)) {
            SkAutoTUnref<SkMemoryStream> copyStream(new SkMemoryStream());
            copyStream->setMemoryOwned(allocMemory.detach(), length);
            return copyStream.detach();
        }

        stream->rewind();
        stream->ref();
    } else {
        SkAutoTUnref<SkFontConfigInterface> fci(RefFCI());
        if (NULL == fci.get()) {
            return NULL;
        }
        stream = fci->openStream(this->getIdentity());
        *ttcIndex = this->getIdentity().fTTCIndex;
    }
    return stream;
}
开发者ID:3rdexp,项目名称:soui,代码行数:39,代码来源:SkFontHost_fontconfig.cpp

示例9:

 static unsigned int file_getsize(FPDFEMB_FILE_ACCESS* file) {
     SkStream* stream = (SkStream*)file->user;
     return stream->getLength();
 }
开发者ID:jamesyan84,项目名称:mt36k_android_4.0.4,代码行数:4,代码来源:SkImageDecoder_fpdfemb.cpp


注:本文中的SkStream::getLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。