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


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

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


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

示例1:

    static unsigned long sk_stream_read(FT_Stream       stream,
                                        unsigned long   offset,
                                        unsigned char*  buffer,
                                        unsigned long   count ) {
        SkStream* str = (SkStream*)stream->descriptor.pointer;

        if (count) {
            if (!str->rewind()) {
                return 0;
            } else {
                unsigned long ret;
                if (offset) {
                    ret = str->read(NULL, offset);
                    if (ret != offset) {
                        return 0;
                    }
                }
                ret = str->read(buffer, count);
                if (ret != count) {
                    return 0;
                }
                count = ret;
            }
        }
        return count;
    }
开发者ID:ACSOP,项目名称:android_external_skia,代码行数:26,代码来源:SkFontHost_FreeType.cpp

示例2: parse

bool SkXMLParser::parse(SkStream& input)
{
    size_t          len = input.read(NULL, 0);
    SkAutoMalloc    am(len);
    char*           doc = (char*)am.get();

    input.rewind();
    size_t  len2 = input.read(doc, len);
    SkASSERT(len2 == len);

    return this->parse(doc, len2);
}
开发者ID:ghub,项目名称:NVprSDK,代码行数:12,代码来源:SkXMLParser_expat.cpp

示例3: decodeBounds

bool AutoCleanPng::decodeBounds() {
    if (setjmp(png_jmpbuf(fPng_ptr))) {
        return false;
    }

    png_set_progressive_read_fn(fPng_ptr, this, InfoCallback, nullptr, nullptr);

    // Arbitrary buffer size, though note that it matches (below)
    // SkPngCodec::processData(). FIXME: Can we better suit this to the size of
    // the PNG header?
    constexpr size_t kBufferSize = 4096;
    char buffer[kBufferSize];

    while (true) {
        const size_t bytesRead = fStream->read(buffer, kBufferSize);
        if (!bytesRead) {
            // We have read to the end of the input without decoding bounds.
            break;
        }

        png_process_data(fPng_ptr, fInfo_ptr, (png_bytep) buffer, bytesRead);
        if (fDecodedBounds) {
            break;
        }
    }

    // For safety, clear the pointer to this object.
    png_set_progressive_read_fn(fPng_ptr, nullptr, nullptr, nullptr, nullptr);
    return fDecodedBounds;
}
开发者ID:ydzydz,项目名称:skia,代码行数:30,代码来源:SkPngCodec.cpp

示例4: rbyte

static uint8_t rbyte(SkStream& s)
{
    uint8_t b;
    SkDEBUGCODE(size_t size = ) s.read(&b, 1);
    SkASSERT(size == 1);
    return b;
}
开发者ID:3rdexp,项目名称:soui,代码行数:7,代码来源:SkBML_XMLParser.cpp

示例5: rbyte

static uint8_t rbyte(SkStream& s)
{
    uint8_t b;
    size_t size = s.read(&b, 1);
    SkASSERT(size == 1);
    return b;
}
开发者ID:ghub,项目名称:NVprSDK,代码行数:7,代码来源:SkBML_XMLParser.cpp

示例6: sk_read_fn

static void sk_read_fn(png_structp png_ptr, png_bytep data,
                       png_size_t length) {
    SkStream* stream = static_cast<SkStream*>(png_get_io_ptr(png_ptr));
    const size_t bytes = stream->read(data, length);
    if (bytes != length) {
        // FIXME: We want to report the fact that the stream was truncated.
        // One way to do that might be to pass a enum to longjmp so setjmp can
        // specify the failure.
        png_error(png_ptr, "Read Error!");
    }
}
开发者ID:pk-codebox-evo,项目名称:google-skia,代码行数:11,代码来源:SkPngCodec.cpp

示例7: set

static void set(char* array[256], int index, SkStream& s, int data)
{
    SkASSERT((unsigned)index <= 255);

    size_t size = rdata(s, data);

    if (array[index] == NULL)
        array[index] = (char*)sk_malloc_throw(size + 1);
    else
    {
        if (strlen(array[index]) < size)
            array[index] = (char*)sk_realloc_throw(array[index], size + 1);
    }

    s.read(array[index], size);
    array[index][size] = 0;
}
开发者ID:ghub,项目名称:NVprSDK,代码行数:17,代码来源:SkBML_XMLParser.cpp

示例8: file_readblock

    static FPDFEMB_RESULT file_readblock(FPDFEMB_FILE_ACCESS* file, void* dst,
                                    unsigned int offset, unsigned int size) {
        SkStream* stream = (SkStream*)file->user;
//        SkDebugf("---- readblock %p %p %d %d\n", stream, dst, offset, size);
        if (!stream->rewind()) {
            SkDebugf("---- rewind failed\n");
            return FPDFERR_ERROR;
        }
        if (stream->skip(offset) != offset) {
            SkDebugf("---- skip failed\n");
            return FPDFERR_ERROR;
        }
        if (stream->read(dst, size) != size) {
            SkDebugf("---- read failed\n");
            return FPDFERR_ERROR;
        }
        return FPDFERR_SUCCESS;
    }
开发者ID:jamesyan84,项目名称:mt36k_android_4.0.4,代码行数:18,代码来源:SkImageDecoder_fpdfemb.cpp

示例9: GetTableData

size_t SkFontHost::GetTableData(SkFontID fontID, SkFontTableTag tag,
                                size_t offset, size_t length, void* data) {
    SkStream* stream = SkFontHost::OpenStream(fontID);
    if (NULL == stream) {
        return 0;
    }

    SkAutoUnref au(stream);
    SfntHeader  header;
    if (!header.init(stream)) {
        return 0;
    }

    for (int i = 0; i < header.fCount; i++) {
        if (SkEndian_SwapBE32(header.fDir[i].fTag) == tag) {
            size_t realOffset = SkEndian_SwapBE32(header.fDir[i].fOffset);
            size_t realLength = SkEndian_SwapBE32(header.fDir[i].fLength);
            // now sanity check the caller's offset/length
            if (offset >= realLength) {
                return 0;
            }
            // if the caller is trusting the length from the file, then a
            // hostile file might choose a value which would overflow offset +
            // length.
            if (offset + length < offset) {
                return 0;
            }
            if (offset + length > realLength) {
                length = realLength - offset;
            }
            // skip the stream to the part of the table we want to copy from
            stream->rewind();
            size_t bytesToSkip = realOffset + offset;
            if (stream->skip(bytesToSkip) != bytesToSkip) {
                return 0;
            }
            if (stream->read(data, length) != length) {
                return 0;
            }
            return length;
        }
    }
    return 0;
}
开发者ID:gaojunchen,项目名称:android-4.3-1,代码行数:44,代码来源:SkFontHost_tables.cpp

示例10: 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

示例11: parse

bool SkXMLParser::parse(SkStream& docStream)
{
    ParsingContext ctx(this);
    if (!ctx.fXMLParser) {
        SkDebugf("could not create XML parser\n");
        return false;
    }

    XML_SetUserData(ctx.fXMLParser, &ctx);
    XML_SetElementHandler(ctx.fXMLParser, start_element_handler, end_element_handler);
    XML_SetCharacterDataHandler(ctx.fXMLParser, text_handler);

    // Disable entity processing, to inhibit internal entity expansion. See expat CVE-2013-0340.
    XML_SetEntityDeclHandler(ctx.fXMLParser, entity_decl_handler);

    static const int kBufferSize = 512 SkDEBUGCODE( - 507);
    bool done = false;
    do {
        void* buffer = XML_GetBuffer(ctx.fXMLParser, kBufferSize);
        if (!buffer) {
            SkDebugf("could not buffer enough to continue\n");
            return false;
        }

        size_t len = docStream.read(buffer, kBufferSize);
        done = docStream.isAtEnd();
        XML_Status status = XML_ParseBuffer(ctx.fXMLParser, SkToS32(len), done);
        if (XML_STATUS_ERROR == status) {
            XML_Error error = XML_GetErrorCode(ctx.fXMLParser);
            int line = XML_GetCurrentLineNumber(ctx.fXMLParser);
            int column = XML_GetCurrentColumnNumber(ctx.fXMLParser);
            const XML_LChar* errorString = XML_ErrorString(error);
            SkDebugf("parse error @%d:%d: %d (%s).\n", line, column, error, errorString);
            return false;
        }
    } while (!done);

    return true;
}
开发者ID:03050903,项目名称:skia,代码行数:39,代码来源:SkXMLParser.cpp

示例12: 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

示例13: Decode

static int Decode(GifFileType* fileType, GifByteType* out, int size) {
    SkStream* stream = (SkStream*) fileType->UserData;
    return (int) stream->read(out, size);
}
开发者ID:0omega,项目名称:platform_external_skia,代码行数:4,代码来源:SkMovie_gif.cpp

示例14: return

/*
 * Read function that will be passed to gif_lib
 */
static int32_t read_bytes_callback(GifFileType* fileType, GifByteType* out, int32_t size) {
    SkStream* stream = (SkStream*) fileType->UserData;
    return (int32_t) stream->read(out, size);
}
开发者ID:crabfang,项目名称:skia,代码行数:7,代码来源:SkGifCodec.cpp


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