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


C++ SharedBuffer::ref方法代码示例

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


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

示例1:

FontCustomPlatformData::FontCustomPlatformData(FT_Face freeTypeFace, SharedBuffer& buffer)
    : m_freeTypeFace(freeTypeFace)
    , m_fontFace(cairo_ft_font_face_create_for_ft_face(freeTypeFace, 0))
{
    // FIXME Should we be setting some hinting options here?

    buffer.ref(); // This is balanced by the buffer->deref() in releaseCustomFontData.
    static cairo_user_data_key_t bufferKey;
    cairo_font_face_set_user_data(m_fontFace, &bufferKey, &buffer,
                                  static_cast<cairo_destroy_func_t>(releaseCustomFontData));

    // Cairo doesn't do FreeType reference counting, so we need to ensure that when
    // this cairo_font_face_t is destroyed, it cleans up the FreeType face as well.
    static cairo_user_data_key_t freeTypeFaceKey;
    cairo_font_face_set_user_data(m_fontFace, &freeTypeFaceKey, freeTypeFace,
                                  reinterpret_cast<cairo_destroy_func_t>(FT_Done_Face));
}
开发者ID:jeremysjones,项目名称:webkit,代码行数:17,代码来源:FontCustomPlatformDataFreeType.cpp

示例2: imageForPageURL

PassRefPtr<API::Data> WebIconDatabase::iconDataForPageURL(const String& pageURL)
{
    auto* image = imageForPageURL(pageURL);
    if (!image)
        return nullptr;

    SharedBuffer* sharedBuffer = image->data();
    if (!sharedBuffer)
        return nullptr;

    // Balanced by deref() below.
    sharedBuffer->ref();
    return API::Data::createWithoutCopying(reinterpret_cast<const unsigned char*>(sharedBuffer->data()), sharedBuffer->size(),
        [](unsigned char*, const void* untypedSharedBuffer) {
            // Balanced by ref() above.
            static_cast<SharedBuffer*>(const_cast<void*>(untypedSharedBuffer))->deref();
        }, sharedBuffer);
}
开发者ID:AndriyKalashnykov,项目名称:webkit,代码行数:18,代码来源:WebIconDatabase.cpp

示例3: setData

void ImageDecoder::setData(SharedBuffer& data, bool allDataReceived)
{
    m_isAllDataReceived = allDataReceived;

#if PLATFORM(COCOA)
    // On Mac the NSData inside the SharedBuffer can be secretly appended to without the SharedBuffer's knowledge.
    // We use SharedBuffer's ability to wrap itself inside CFData to get around this, ensuring that ImageIO is
    // really looking at the SharedBuffer.
    CGImageSourceUpdateData(m_nativeDecoder.get(), data.createCFData().get(), allDataReceived);
#else
    // Create a CGDataProvider to wrap the SharedBuffer.
    data.ref();
    // We use the GetBytesAtPosition callback rather than the GetBytePointer one because SharedBuffer
    // does not provide a way to lock down the byte pointer and guarantee that it won't move, which
    // is a requirement for using the GetBytePointer callback.
    CGDataProviderDirectCallbacks providerCallbacks = { 0, 0, 0, sharedBufferGetBytesAtPosition, sharedBufferRelease };
    RetainPtr<CGDataProviderRef> dataProvider = adoptCF(CGDataProviderCreateDirect(&data, data.size(), &providerCallbacks));
    CGImageSourceUpdateDataProvider(m_nativeDecoder.get(), dataProvider.get(), allDataReceived);
#endif
}
开发者ID:ollie314,项目名称:webkit,代码行数:20,代码来源:ImageDecoderCG.cpp

示例4: getData

const void* getData(void* info)
{
    SharedBuffer* buffer = static_cast<SharedBuffer*>(info);
    buffer->ref();
    return (void*)buffer->data();
}
开发者ID:acss,项目名称:owb-mirror,代码行数:6,代码来源:FontCustomPlatformData.cpp


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