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


C++ OwnArrayPtr类代码示例

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


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

示例1: adoptArrayPtr

void GraphicsContext3D::paintRenderingResultsToCanvas(CanvasRenderingContext* context, DrawingBuffer*)
{
    HTMLCanvasElement* canvas = context->canvas();
    ImageBuffer* imageBuffer = canvas->buffer();

    int rowBytes = m_currentWidth * 4;
    int totalBytes = rowBytes * m_currentHeight;

    OwnArrayPtr<unsigned char> pixels = adoptArrayPtr(new unsigned char[totalBytes]);
    if (!pixels)
        return;

    readRenderingResults(pixels.get(), totalBytes);

    if (!m_attrs.premultipliedAlpha) {
        for (int i = 0; i < totalBytes; i += 4) {
            // Premultiply alpha.
            pixels[i + 0] = std::min(255, pixels[i + 0] * pixels[i + 3] / 255);
            pixels[i + 1] = std::min(255, pixels[i + 1] * pixels[i + 3] / 255);
            pixels[i + 2] = std::min(255, pixels[i + 2] * pixels[i + 3] / 255);
        }
    }

    paintToCanvas(pixels.get(), m_currentWidth, m_currentHeight,
                  canvas->width(), canvas->height(), imageBuffer->context()->platformContext());
}
开发者ID:CannedFish,项目名称:deepin-webkit,代码行数:26,代码来源:GraphicsContext3DOpenGLCommon.cpp

示例2: OS

void ContextMenu::getContextMenuItems(HMENU menu, Vector<ContextMenuItem>& items)
{
#if OS(WINCE)
    notImplemented();
#else
    int count = ::GetMenuItemCount(menu);
    if (count <= 0)
        return;

    for (int i = 0; i < count; ++i) {
        MENUITEMINFO info = {0};
        info.cbSize = sizeof(MENUITEMINFO);
        info.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STRING | MIIM_STATE | MIIM_SUBMENU;

        if (!::GetMenuItemInfo(menu, i, TRUE, &info))
            continue;

        if (info.fType == MFT_SEPARATOR) {
            items.append(ContextMenuItem(SeparatorType, ContextMenuItemTagNoAction, String()));
            continue;
        }

        int menuStringLength = info.cch + 1;
        OwnArrayPtr<WCHAR> menuString = adoptArrayPtr(new WCHAR[menuStringLength]);
        info.dwTypeData = menuString.get();
        info.cch = menuStringLength;

        if (::GetMenuItemInfo(menu, i, TRUE, &info))
           items.append(ContextMenuItem(info));
    }
#endif
}
开发者ID:DreamOnTheGo,项目名称:src,代码行数:32,代码来源:ContextMenuWin.cpp

示例3: newLengthArray

PassOwnArrayPtr<Length> newLengthArray(const String& string, int& len)
{
    RefPtr<StringImpl> str = string.impl()->simplifyWhiteSpace();
    if (!str->length()) {
        len = 1;
        return nullptr;
    }

    len = countCharacter(str->characters(), str->length(), ',') + 1;
    OwnArrayPtr<Length> r = adoptArrayPtr(new Length[len]);

    int i = 0;
    unsigned pos = 0;
    size_t pos2;

    while ((pos2 = str->find(',', pos)) != notFound) {
        r[i++] = parseLength(str->characters() + pos, pos2 - pos);
        pos = pos2+1;
    }

    ASSERT(i == len - 1);

    // IE Quirk: If the last comma is the last char skip it and reduce len by one.
    if (str->length()-pos > 0)
        r[i] = parseLength(str->characters() + pos, str->length() - pos);
    else
        len--;

    return r.release();
}
开发者ID:dzhshf,项目名称:WebKit,代码行数:30,代码来源:Length.cpp

示例4: keyPadName

static const PassRefPtr<KeyEventInfo> keyPadName(WKStringRef keyRef)
{
    if (WKStringIsEqualToUTF8CString(keyRef, "leftArrow"))
        return adoptRef(new KeyEventInfo("KP_Left", ""));
    if (WKStringIsEqualToUTF8CString(keyRef, "rightArrow"))
        return adoptRef(new KeyEventInfo("KP_Right", ""));
    if (WKStringIsEqualToUTF8CString(keyRef, "upArrow"))
        return adoptRef(new KeyEventInfo("KP_Up", ""));
    if (WKStringIsEqualToUTF8CString(keyRef, "downArrow"))
        return adoptRef(new KeyEventInfo("KP_Down", ""));
    if (WKStringIsEqualToUTF8CString(keyRef, "pageUp"))
        return adoptRef(new KeyEventInfo("KP_Prior", ""));
    if (WKStringIsEqualToUTF8CString(keyRef, "pageDown"))
        return adoptRef(new KeyEventInfo("KP_Next", ""));
    if (WKStringIsEqualToUTF8CString(keyRef, "home"))
        return adoptRef(new KeyEventInfo("KP_Home", ""));
    if (WKStringIsEqualToUTF8CString(keyRef, "end"))
        return adoptRef(new KeyEventInfo("KP_End", ""));
    if (WKStringIsEqualToUTF8CString(keyRef, "insert"))
        return adoptRef(new KeyEventInfo("KP_Insert", ""));
    if (WKStringIsEqualToUTF8CString(keyRef, "delete"))
        return adoptRef(new KeyEventInfo("KP_Delete", ""));

    size_t bufferSize = WKStringGetMaximumUTF8CStringSize(keyRef);
    OwnArrayPtr<char> buffer = adoptArrayPtr(new char[bufferSize]);
    WKStringGetUTF8CString(keyRef, buffer.get(), bufferSize);
    return adoptRef(new KeyEventInfo(buffer.get(), buffer.get()));
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:28,代码来源:EventSenderProxyEfl.cpp

示例5: toSTD

std::string toSTD(WKStringRef string)
{
    size_t bufferSize = WKStringGetMaximumUTF8CStringSize(string);
    OwnArrayPtr<char> buffer = adoptArrayPtr(new char[bufferSize]);
    size_t stringLength = WKStringGetUTF8CString(string, buffer.get(), bufferSize);
    return std::string(buffer.get(), stringLength - 1);
}
开发者ID:0x4d52,项目名称:JavaScriptCore-X,代码行数:7,代码来源:PlatformUtilities.cpp

示例6: ASSERT_ARG

void WebPreferences::copyWebKitPreferencesToCFPreferences(CFDictionaryRef dict)
{
    ASSERT_ARG(dict, dict);

    int count = CFDictionaryGetCount(dict);
    if (count <= 0)
        return;

    CFStringRef didRemoveDefaultsKey = CFSTR(WebKitDidMigrateDefaultSettingsFromSafari3BetaPreferenceKey);
    bool omitDefaults = !booleanValueForPreferencesValue(CFDictionaryGetValue(dict, didRemoveDefaultsKey));

    OwnArrayPtr<CFTypeRef> keys = adoptArrayPtr(new CFTypeRef[count]);
    OwnArrayPtr<CFTypeRef> values = adoptArrayPtr(new CFTypeRef[count]);
    CFDictionaryGetKeysAndValues(dict, keys.get(), values.get());

    for (int i = 0; i < count; ++i) {
        if (!keys[i] || !values[i] || CFGetTypeID(keys[i]) != CFStringGetTypeID())
            continue;

        if (omitDefaults) {
            CFTypeRef defaultValue = CFDictionaryGetValue(defaultSettings, keys[i]);
            if (defaultValue && CFEqual(defaultValue, values[i]))
                continue;
        }

        setValueForKey(static_cast<CFStringRef>(keys[i]), values[i]);
    }
}
开发者ID:KDE,项目名称:android-qtwebkit,代码行数:28,代码来源:WebPreferences.cpp

示例7: newCoordsArray

PassOwnArrayPtr<Length> newCoordsArray(const String& string, int& len)
{
    unsigned length = string.length();
    const UChar* data = string.characters();
    StringBuffer<UChar> spacified(length);
    for (unsigned i = 0; i < length; i++) {
        UChar cc = data[i];
        if (cc > '9' || (cc < '0' && cc != '-' && cc != '*' && cc != '.'))
            spacified[i] = ' ';
        else
            spacified[i] = cc;
    }
    RefPtr<StringImpl> str = StringImpl::adopt(spacified);

    str = str->simplifyWhiteSpace();

    len = countCharacter(str->characters(), str->length(), ' ') + 1;
    OwnArrayPtr<Length> r = adoptArrayPtr(new Length[len]);

    int i = 0;
    unsigned pos = 0;
    size_t pos2;

    while ((pos2 = str->find(' ', pos)) != notFound) {
        r[i++] = parseLength(str->characters() + pos, pos2 - pos);
        pos = pos2+1;
    }
    r[i] = parseLength(str->characters() + pos, str->length() - pos);

    ASSERT(i == len - 1);

    return r.release();
}
开发者ID:dzhshf,项目名称:WebKit,代码行数:33,代码来源:Length.cpp

示例8: createValueListFromVariantArgs

static PassOwnArrayPtr<v8::Handle<v8::Value> > createValueListFromVariantArgs(const NPVariant* arguments, uint32_t argumentCount, NPObject* owner, v8::Isolate* isolate)
{
    OwnArrayPtr<v8::Handle<v8::Value> > argv = adoptArrayPtr(new v8::Handle<v8::Value>[argumentCount]);
    for (uint32_t index = 0; index < argumentCount; index++) {
        const NPVariant* arg = &arguments[index];
        argv[index] = convertNPVariantToV8Object(arg, owner, isolate);
    }
    return argv.release();
}
开发者ID:fmalita,项目名称:webkit,代码行数:9,代码来源:NPV8Object.cpp

示例9: JSStringGetMaximumUTF8CStringSize

bool ScriptItem::invoke() const
{
    BlackBerry::WebKit::JavaScriptDataType type;
    BlackBerry::WebKit::WebString result;
    size_t scriptArrSize = JSStringGetMaximumUTF8CStringSize(m_script.get());
    OwnArrayPtr<char> script = adoptArrayPtr(new char[scriptArrSize]);
    JSStringGetUTF8CString(m_script.get(), script.get(), scriptArrSize);
    BlackBerry::WebKit::DumpRenderTree::currentInstance()->page()->executeJavaScript(script.get(), type, result);
    return true;
}
开发者ID:Moondee,项目名称:Artemis,代码行数:10,代码来源:WorkQueueItemBlackBerry.cpp

示例10: encodeImpl

static bool encodeImpl(const unsigned char* input, int imageWidth, int imageHeight, int bytesPerRow, Vector<unsigned char>* output, PixelConversionFunc conversionFunc)
{
    int inputColorComponents = 4;
    int outputColorComponents = 4;
    int pngOutputColorType = PNG_COLOR_TYPE_RGB_ALPHA;

    if (imageWidth < 0)
        imageWidth = 0;

    if (imageHeight < 0)
        imageHeight = 0;

    // Row stride should be at least as long as the length of the data.
    if (inputColorComponents * imageWidth > bytesPerRow) {
        ASSERT(false);
        return false;
    }

    png_struct* pngPtr = png_create_write_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
    if (!pngPtr)
        return false;

    png_info* infoPtr = png_create_info_struct(pngPtr);
    if (!infoPtr) {
        png_destroy_write_struct(&pngPtr, 0);
        return false;
    }
    PNGWriteStructDestroyer destroyer(&pngPtr, &infoPtr);

    if (setjmp(png_jmpbuf(pngPtr))) {
        // The destroyer will ensure that the structures are cleaned up in this
        // case, even though we may get here as a jump from random parts of the
        // PNG library called below.
        return false;
    }

    // Set our callback for libpng to give us the data.
    PNGEncoderState state(output);
    png_set_write_fn(pngPtr, &state, encoderWriteCallback, 0);

    png_set_IHDR(pngPtr, infoPtr, imageWidth, imageHeight, 8, pngOutputColorType,
                 PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
                 PNG_FILTER_TYPE_DEFAULT);
    png_write_info(pngPtr, infoPtr);

    OwnArrayPtr<unsigned char> rowPixels = adoptArrayPtr(new unsigned char[imageWidth * outputColorComponents]);
    for (int y = 0; y < imageHeight; y ++) {
        conversionFunc(&input[y * bytesPerRow], imageWidth, rowPixels.get());
        png_write_row(pngPtr, rowPixels.get());
    }

    png_write_end(pngPtr, infoPtr);
    return true;
}
开发者ID:Moondee,项目名称:Artemis,代码行数:54,代码来源:PNGImageEncoder.cpp

示例11: runJSTest

::testing::AssertionResult runJSTest(const char*, const char*, const char*, WKPageRef page, const char* script, const char* expectedResult)
{
    JavaScriptCallbackContext context;
    WKPageRunJavaScriptInMainFrame(page, Util::toWK(script).get(), &context, javaScriptCallback);
    Util::run(&context.didFinish);

    size_t bufferSize = JSStringGetMaximumUTF8CStringSize(context.actualString.get());
    OwnArrayPtr<char> buffer = adoptArrayPtr(new char[bufferSize]);
    JSStringGetUTF8CString(context.actualString.get(), buffer.get(), bufferSize);
    
    return compareJSResult(script, buffer.get(), expectedResult);
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:12,代码来源:JavaScriptTest.cpp

示例12: stringArrayToJS

static inline JSValueRef stringArrayToJS(JSContextRef context, WKArrayRef strings)
{
    const size_t count = WKArrayGetSize(strings);

    OwnArrayPtr<JSValueRef> jsStringsArray = adoptArrayPtr(new JSValueRef[count]);
    for (size_t i = 0; i < count; ++i) {
        WKStringRef stringRef = static_cast<WKStringRef>(WKArrayGetItemAtIndex(strings, i));
        JSRetainPtr<JSStringRef> stringJS = toJS(stringRef);
        jsStringsArray[i] = JSValueMakeString(context, stringJS.get());
    }

    return JSObjectMakeArray(context, count, jsStringsArray.get(), 0);
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:13,代码来源:TestRunner.cpp

示例13: ASSERT

void JSGlobalObject::copyGlobalsFrom(RegisterFile& registerFile)
{
    ASSERT(!m_registerArray);
    ASSERT(!m_registerArraySize);

    int numGlobals = registerFile.numGlobals();
    if (!numGlobals) {
        m_registers = 0;
        return;
    }

    OwnArrayPtr<WriteBarrier<Unknown> > registerArray = copyRegisterArray(globalData(), reinterpret_cast<WriteBarrier<Unknown>*>(registerFile.lastGlobal()), numGlobals, numGlobals);
    WriteBarrier<Unknown>* registers = registerArray.get() + numGlobals;
    setRegisters(registers, registerArray.release(), numGlobals);
}
开发者ID:1d10t,项目名称:phantomjs,代码行数:15,代码来源:JSGlobalObject.cpp

示例14: craeteFromStdin

    // Creates the image from stdin with the given data length. On success, it
    // will return true. On failure, no other methods should be accessed.
    bool craeteFromStdin(size_t byteLength)
    {
        if (!byteLength)
            return false;

        OwnArrayPtr<unsigned char> source = adoptArrayPtr(new unsigned char[byteLength]);
        if (fread(source.get(), 1, byteLength, stdin) != byteLength)
            return false;

        if (!webkit_support::DecodePNG(source.get(), byteLength, &m_data, &m_width, &m_height)) {
            clear();
            return false;
        }
        return true;
    }
开发者ID:0x4d52,项目名称:JavaScriptCore-X,代码行数:17,代码来源:ImageDiff.cpp


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