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


C++ Vector::size方法代码示例

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


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

示例1: waitMultiple

size_t WaitableEvent::waitMultiple(const WTF::Vector<WaitableEvent*>& events)
{
    std::vector<base::WaitableEvent*> baseEvents;
    for (size_t i = 0; i < events.size(); ++i)
        baseEvents.push_back(events[i]->m_impl.get());
    size_t idx = base::WaitableEvent::WaitMany(baseEvents.data(), baseEvents.size());
    DCHECK_LT(idx, events.size());
    return idx;
}
开发者ID:aobzhirov,项目名称:ChromiumGStreamerBackend,代码行数:9,代码来源:WaitableEvent.cpp

示例2: getOptionalConstraints

void MediaConstraints::getOptionalConstraints(std::vector<MediaConstraint>& constraints) const
{
    ASSERT(!isNull());
    WTF::Vector<WebCore::MediaConstraint> optionalConstraints;
    m_private->getOptionalConstraints(optionalConstraints);
    std::vector<MediaConstraint> result(optionalConstraints.size());
    for (size_t i = 0; i < optionalConstraints.size(); ++i)
        result[i] = toNixMediaConstraint(optionalConstraints[i]);
    constraints.swap(result);
}
开发者ID:,项目名称:,代码行数:10,代码来源:

示例3: Flatten

jbyteArray WebHistory::Flatten(JNIEnv* env, WTF::Vector<char>& v, WebCore::HistoryItem* item)
{
    if (!item)
        return NULL;

    // Reserve a vector of chars with an initial size of HISTORY_MIN_SIZE.
    v.reserveCapacity(HISTORY_MIN_SIZE);

    // Write the top-level history item and then write all the children
    // recursively.
    LOG_ASSERT(item->bridge(), "Why don't we have a bridge object here?");
    write_item(v, item);
    write_children_recursive(v, item);

//SAMSUNG - CRASH FIX BEGIN

    int size = v.size();
    if (size > 0) 
    {
        long availableMemory = GetVmAvailableMemory(env);

        if(size > availableMemory)
        {
            LOGV("WebHistory::Flatten(): load size=%d, availableMemory=%ld, still larger, return NULL", size, availableMemory);		
            return NULL;
        }

        checkException(env);
    }

//SAMSUNG - CRASH FIX END
    // Try to create a new java byte array.
    jbyteArray b = env->NewByteArray(v.size());
    if (!b)
    {
//SAMSUNG - CRASH FIX BEGIN
        if (checkException(env))
        {
            LOGV("WebHistory::Flatten(): env exception happened while allocating %d bytes, clear pending exception", v.size());
            env->ExceptionClear();
        }
//SAMSUNG - CRASH FIX END
        return NULL;
    }

    // Write our flattened data to the java array.
    env->SetByteArrayRegion(b, 0, v.size(), (const jbyte*)v.data());
    return b;
}
开发者ID:,项目名称:,代码行数:49,代码来源:

示例4: checkGrammarOfString

void SpellCheckerClientImpl::checkGrammarOfString(const String& text, WTF::Vector<GrammarDetail>& details, int* badGrammarLocation, int* badGrammarLength)
{
    if (badGrammarLocation)
        *badGrammarLocation = -1;
    if (badGrammarLength)
        *badGrammarLength = 0;

    if (!m_webView->spellCheckClient())
        return;
    WebVector<WebTextCheckingResult> webResults;
    m_webView->spellCheckClient()->checkTextOfParagraph(text, WebTextCheckingTypeGrammar, &webResults);
    if (!webResults.size())
        return;

    // Convert a list of WebTextCheckingResults to a list of GrammarDetails. If
    // the converted vector of GrammarDetails has grammar errors, we set
    // badGrammarLocation and badGrammarLength to tell WebKit that the input
    // text has grammar errors.
    for (size_t i = 0; i < webResults.size(); ++i) {
        if (webResults[i].decoration == WebTextDecorationTypeGrammar) {
            GrammarDetail detail;
            detail.location = webResults[i].location;
            detail.length = webResults[i].length;
            detail.userDescription = webResults[i].replacement;
            details.append(detail);
        }
    }
    if (!details.size())
        return;
    if (badGrammarLocation)
        *badGrammarLocation = 0;
    if (badGrammarLength)
        *badGrammarLength = text.length();
}
开发者ID:,项目名称:,代码行数:34,代码来源:

示例5: write_string

static void write_string(WTF::Vector<char>& v, const WebCore::String& str)
{
    unsigned strLen = str.length();
    // Only do work if the string has data.
    if (strLen) {
        // Determine how much to grow the vector. Use the worst case for utf8 to
        // avoid reading the string twice. Add sizeof(unsigned) to hold the
        // string length in utf8.
        unsigned vectorLen = v.size() + sizeof(unsigned);
        unsigned length = (strLen << 2) + vectorLen;
        // Grow the vector. This will change the value of v.size() but we
        // remember the original size above.
        v.grow(length);
        // Grab the position to write to.
        char* data = v.begin() + vectorLen;
        // Write the actual string
        int l = SkUTF16_ToUTF8(str.characters(), strLen, data);
        LOGV("Writing string       %d %.*s", l, l, data);
        // Go back and write the utf8 length. Subtract sizeof(unsigned) from
        // data to get the position to write the length.
        memcpy(data - sizeof(unsigned), (char*)&l, sizeof(unsigned));
        // Shrink the internal state of the vector so we match what was
        // actually written.
        v.shrink(vectorLen + l);
    } else
        v.append((char*)&strLen, sizeof(unsigned));
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:27,代码来源:WebHistory.cpp

示例6: drawFindOnPage

void GLExtras::drawFindOnPage(SkRect& viewport)
{
    WTF::Vector<MatchInfo>* matches = m_findOnPage->matches();
    XLOG("drawFindOnPage, matches: %p", matches);
    if (!matches || !m_findOnPage->isCurrentLocationValid())
        return;
    int count = matches->size();
    int current = m_findOnPage->currentMatchIndex();
    XLOG("match count: %d", count);
    if (count < MAX_NUMBER_OF_MATCHES_TO_DRAW)
        for (int i = 0; i < count; i++) {
            MatchInfo& info = matches->at(i);
            const SkRegion& region = info.getLocation();
            SkIRect rect = region.getBounds();
            if (rect.intersect(viewport.fLeft, viewport.fTop,
                               viewport.fRight, viewport.fBottom))
                drawRegion(region, i == current, false, true);
#ifdef DEBUG
            else
                XLOG("Quick rejecting [%dx%d, %d, %d", rect.fLeft, rect.fTop,
                     rect.width(), rect.height());
#endif // DEBUG
        }
    else {
        MatchInfo& info = matches->at(current);
        drawRegion(info.getLocation(), true, false, true);
    }
}
开发者ID:ACSOP,项目名称:android_external_webkit,代码行数:28,代码来源:GLExtras.cpp

示例7: dirtyTexturesVector

void TilesManager::dirtyTexturesVector(WTF::Vector<TileTexture*>& textures)
{
    for (unsigned int i = 0; i < textures.size(); i++) {
        Tile* currentOwner = static_cast<Tile*>(textures[i]->owner());
        if (currentOwner)
            currentOwner->markAsDirty();
    }
}
开发者ID:3filiatd,项目名称:google_cache_invalidation_repo,代码行数:8,代码来源:TilesManager.cpp

示例8: updateGeometry

void PepperPluginImpl::updateGeometry(const WebCore::IntRect& window_rect, const WebCore::IntRect& clip_rect, const WTF::Vector<WebCore::IntRect>& cut_outs_rects, bool is_visible){
  plugin_rect_ = window_rect;
  if (!instance_->FlashIsFullscreenOrPending()) {
    std::vector<IntRect> cut_outs;
    for (size_t i = 0; i < cut_outs_rects.size(); ++i)
      cut_outs.push_back(cut_outs_rects[i]);
    instance_->ViewChanged(plugin_rect_, clip_rect, cut_outs);
  }
}
开发者ID:,项目名称:,代码行数:9,代码来源:

示例9: discardTexturesVector

void TilesManager::discardTexturesVector(unsigned long long sparedDrawCount,
                                         WTF::Vector<TileTexture*>& textures,
                                         bool deallocateGLTextures)
{
    const unsigned int max = textures.size();
    int dealloc = 0;
    WTF::Vector<int> discardedIndex;
    for (unsigned int i = 0; i < max; i++) {
        TextureOwner* owner = textures[i]->owner();
        if (!owner || owner->drawCount() < sparedDrawCount) {
            if (deallocateGLTextures) {
                // deallocate textures' gl memory
                textures[i]->discardGLTexture();
                discardedIndex.append(i);
            } else if (owner) {
                // simply detach textures from owner
                static_cast<Tile*>(owner)->discardTextures();
            }
            dealloc++;
        }
    }

    bool base = textures == m_textures;
    // Clean up the vector of TileTextures and reset the max texture count.
    if (discardedIndex.size()) {
        android::Mutex::Autolock lock(m_texturesLock);
        for (int i = discardedIndex.size() - 1; i >= 0; i--)
            textures.remove(discardedIndex[i]);

        int remainedTextureNumber = textures.size();
        int* countPtr = base ? &m_currentTextureCount : &m_currentLayerTextureCount;
        if (remainedTextureNumber < *countPtr) {
            ALOGV("reset currentTextureCount for %s tiles from %d to %d",
                  base ? "base" : "layer", *countPtr, remainedTextureNumber);
            *countPtr = remainedTextureNumber;
        }

    }

    ALOGV("Discarded %d %s textures (out of %d %s tiles)",
          dealloc, (deallocateGLTextures ? "gl" : ""),
          max, base ? "base" : "layer");
}
开发者ID:3filiatd,项目名称:google_cache_invalidation_repo,代码行数:43,代码来源:TilesManager.cpp

示例10: OnSelfOrChildStateChange

void MaskNode::OnSelfOrChildStateChange() {
	m_bChildNeedDraw = true;
	m_bBoundingDirty = true; // 不需要调用SetBoundingDirty(),因为不需要通知父节点

	WTF::Vector<UINode*>* owners = m_pManager->GetEffectsResOwnerNodes(this);
	if (!owners)
		return;

	// 子节点绘图消息被转发到拥有者节点上
	for (size_t i = 0; i < owners->size(); ++i)
		owners->at(i)->SetNeedLayout();
}
开发者ID:henryrao,项目名称:kdguigl,代码行数:12,代码来源:MaskNode.cpp

示例11: applyAntiAliasedClipPaths

    void applyAntiAliasedClipPaths(WTF::Vector<SkPath>& paths)
    {
        // Anti-aliased clipping:
        //
        // Refer to PlatformContextSkia.cpp's applyAntiAliasedClipPaths() for more details

        if (m_platformGfxCtx && m_platformGfxCtx->mCanvas)
            m_platformGfxCtx->mCanvas->restore();

        SkPaint paint;
        paint.setXfermodeMode(SkXfermode::kClear_Mode);
        paint.setAntiAlias(true);
        paint.setStyle(SkPaint::kFill_Style);

        if (m_platformGfxCtx && m_platformGfxCtx->mCanvas)  {
            for (size_t i = paths.size() - 1; i < paths.size(); --i) {
                paths[i].setFillType(SkPath::kInverseWinding_FillType);
                m_platformGfxCtx->mCanvas->drawPath(paths[i], paint);
            }
            m_platformGfxCtx->mCanvas->restore();
        } else
            ASSERT(0);
    }
开发者ID:cpascal7,项目名称:Xperia-U,代码行数:23,代码来源:GraphicsContextAndroid.cpp

示例12: Flatten

jbyteArray WebHistory::Flatten(JNIEnv* env, WTF::Vector<char>& v, WebCore::HistoryItem* item)
{
    if (!item)
        return NULL;

    // Reserve a vector of chars with an initial size of HISTORY_MIN_SIZE.
    v.reserveCapacity(HISTORY_MIN_SIZE);

    // Write the top-level history item and then write all the children
    // recursively.
    LOG_ASSERT(item->bridge(), "Why don't we have a bridge object here?");
    write_item(v, item);
    write_children_recursive(v, item);

    // Try to create a new java byte array.
    jbyteArray b = env->NewByteArray(v.size());
    if (!b)
        return NULL;

    // Write our flattened data to the java array.
    env->SetByteArrayRegion(b, 0, v.size(), (const jbyte*)v.data());
    return b;
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:23,代码来源:WebHistory.cpp

示例13: applyAntiAliasedClipPaths

void PlatformContextSkia::applyAntiAliasedClipPaths(WTF::Vector<SkPath>& paths)
{
    // Anti-aliased clipping:
    //
    // Skia's clipping is 1-bit only. Consider what would happen if it were 8-bit:
    // We have a square canvas, filled with white and we declare a circular
    // clipping path. Then we fill twice with a black rectangle. The fractional
    // pixels would first get the correct color (white * alpha + black * (1 -
    // alpha)), but the second fill would apply the alpha to the already
    // modified color and the result would be too dark.
    //
    // This, anti-aliased clipping needs to be performed after the drawing has
    // been done. In order to do this, we create a new layer of the canvas in
    // clipPathAntiAliased and store the clipping path. All drawing is done to
    // the layer's bitmap while it's in effect. When WebKit calls restore() to
    // undo the clipping, this function is called.
    //
    // Here, we walk the list of clipping paths backwards and, for each, we
    // clear outside of the clipping path. We only need a single extra layer
    // for any number of clipping paths.
    //
    // When we call restore on the SkCanvas, the layer's bitmap is composed
    // into the layer below and we end up with correct, anti-aliased clipping.

    SkPaint paint;
    paint.setXfermodeMode(SkXfermode::kClear_Mode);
    paint.setAntiAlias(true);
    paint.setStyle(SkPaint::kFill_Style);

    for (size_t i = paths.size() - 1; i < paths.size(); --i) {
        paths[i].setFillType(SkPath::kInverseWinding_FillType);
        m_canvas->drawPath(paths[i], paint);
    }

    m_canvas->restore();
}
开发者ID:abdollatiif,项目名称:android-manet-olsrd,代码行数:36,代码来源:PlatformContextSkia.cpp

示例14: deallocateTexturesVector

void TilesManager::deallocateTexturesVector(unsigned long long sparedDrawCount,
                                            WTF::Vector<BaseTileTexture*>& textures)
{
    const unsigned int max = textures.size();
    int dealloc = 0;
    for (unsigned int i = 0; i < max; i++) {
        TextureOwner* owner = textures[i]->owner();
        if (!owner || owner->drawCount() < sparedDrawCount) {
            textures[i]->discardGLTexture();
            dealloc++;
        }
    }
    XLOG("Deallocated %d gl textures (out of %d base tiles and %d layer tiles)",
         dealloc, max, maxLayer);
}
开发者ID:AwaisKing,项目名称:mt6577_aosp_source,代码行数:15,代码来源:TilesManager.cpp

示例15: ReverseBidi

// ReverseBidi is a trimmed-down version of GraphicsContext::drawBidiText()
void ReverseBidi(UChar* chars, int len) {
    using namespace WTF::Unicode;
    WTF::Vector<UChar> result;
    result.reserveCapacity(len);
    TextRun run(chars, len);
    BidiResolver<TextRunIterator, BidiCharacterRun> bidiResolver;
    BidiRunList<BidiCharacterRun>& bidiRuns = bidiResolver.runs();
    bidiResolver.setStatus(BidiStatus(LeftToRight, LeftToRight, LeftToRight,
        BidiContext::create(0, LeftToRight, false)));
    bidiResolver.setPosition(TextRunIterator(&run, 0));
    bidiResolver.createBidiRunsForLine(TextRunIterator(&run, len));
    if (!bidiRuns.runCount())
        return;
    BidiCharacterRun* bidiRun = bidiRuns.firstRun();
    while (bidiRun) {
        int bidiStart = bidiRun->start();
        int bidiStop = bidiRun->stop();
        int size = result.size();
        int bidiCount = bidiStop - bidiStart;
        result.append(chars + bidiStart, bidiCount);
        if (bidiRun->level() % 2) {
            UChar* start = &result[size];
            UChar* end = start + bidiCount;
            // reverse the order of any RTL substrings
            while (start < end) {
                UChar temp = *start;
                *start++ = *--end;
                *end = temp;
            }
            start = &result[size];
            end = start + bidiCount - 1;
            // if the RTL substring had a surrogate pair, restore its order
            while (start < end) {
                UChar trail = *start++;
                if (!U16_IS_SURROGATE(trail))
                    continue;
                start[-1] = *start; // lead
                *start++ = trail;
            }
        }
        bidiRun = bidiRun->next();
    }
    bidiRuns.deleteRuns();
    memcpy(chars, &result[0], len * sizeof(UChar));
}
开发者ID:0omega,项目名称:platform_external_webkit,代码行数:46,代码来源:SelectText.cpp


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