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


C++ AutoTArray::Length方法代码示例

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


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

示例1: PodZero

static void
CopyChunkToBlock(AudioChunk& aInput, AudioBlock *aBlock,
                 uint32_t aOffsetInBlock)
{
  uint32_t blockChannels = aBlock->ChannelCount();
  AutoTArray<const T*,2> channels;
  if (aInput.IsNull()) {
    channels.SetLength(blockChannels);
    PodZero(channels.Elements(), blockChannels);
  } else {
    const nsTArray<const T*>& inputChannels = aInput.ChannelData<T>();
    channels.SetLength(inputChannels.Length());
    PodCopy(channels.Elements(), inputChannels.Elements(), channels.Length());
    if (channels.Length() != blockChannels) {
      // We only need to upmix here because aBlock's channel count has been
      // chosen to be a superset of the channel count of every chunk.
      AudioChannelsUpMix(&channels, blockChannels, static_cast<T*>(nullptr));
    }
  }

  for (uint32_t c = 0; c < blockChannels; ++c) {
    float* outputData = aBlock->ChannelFloatsForWrite(c) + aOffsetInBlock;
    if (channels[c]) {
      ConvertAudioSamplesWithScale(channels[c], outputData, aInput.GetDuration(), aInput.mVolume);
    } else {
      PodZero(outputData, aInput.GetDuration());
    }
  }
}
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:29,代码来源:AudioNodeExternalInputStream.cpp

示例2: calculateNormalizationScale

Reverb::Reverb(ThreadSharedFloatArrayBufferList* impulseResponse, size_t impulseResponseBufferLength, size_t maxFFTSize, bool useBackgroundThreads, bool normalize, float sampleRate)
{
    float scale = 1;

    AutoTArray<const float*,4> irChannels;
    for (size_t i = 0; i < impulseResponse->GetChannels(); ++i) {
        irChannels.AppendElement(impulseResponse->GetData(i));
    }
    AutoTArray<float,1024> tempBuf;

    if (normalize) {
        scale = calculateNormalizationScale(impulseResponse, impulseResponseBufferLength, sampleRate);

        if (scale) {
            tempBuf.SetLength(irChannels.Length()*impulseResponseBufferLength);
            for (uint32_t i = 0; i < irChannels.Length(); ++i) {
                float* buf = &tempBuf[i*impulseResponseBufferLength];
                AudioBufferCopyWithScale(irChannels[i], scale, buf,
                                         impulseResponseBufferLength);
                irChannels[i] = buf;
            }
        }
    }

    initialize(irChannels, impulseResponseBufferLength,
               maxFFTSize, useBackgroundThreads);
}
开发者ID:bgrins,项目名称:gecko-dev,代码行数:27,代码来源:Reverb.cpp

示例3: Serialize

int32_t
nsTreeContentView::EnsureSubtree(int32_t aIndex)
{
  Row* row = mRows[aIndex];

  nsIContent* child;
  child = nsTreeUtils::GetImmediateChild(row->mContent, nsGkAtoms::treechildren);
  if (!child || !child->IsXULElement()) {
    return 0;
  }

  AutoTArray<nsAutoPtr<Row>, 8> rows;
  int32_t index = 0;
  Serialize(child, aIndex, &index, rows);
  // We can't use InsertElementsAt since the destination can't steal
  // ownership from its const source argument.
  for (nsTArray<Row>::index_type i = 0; i < rows.Length(); i++) {
    nsAutoPtr<Row>* newRow = mRows.InsertElementAt(aIndex + i + 1);
    *newRow = rows[i];
  }
  int32_t count = rows.Length();

  row->mSubtreeSize += count;
  UpdateSubtreeSizes(row->mParentIndex, count);

  // Update parent indexes, but skip newly added rows.
  // They already have correct values.
  UpdateParentIndexes(aIndex, count + 1, count);

  return count;
}
开发者ID:cbradley857,项目名称:gecko-dev,代码行数:31,代码来源:nsTreeContentView.cpp

示例4: SerializeItem

int32_t
nsTreeContentView::InsertRow(int32_t aParentIndex, int32_t aIndex, nsIContent* aContent)
{
  AutoTArray<nsAutoPtr<Row>, 8> rows;
  if (aContent->IsXULElement(nsGkAtoms::treeitem)) {
    SerializeItem(aContent, aParentIndex, &aIndex, rows);
  } else if (aContent->IsXULElement(nsGkAtoms::treeseparator)) {
    SerializeSeparator(aContent, aParentIndex, &aIndex, rows);
  }

  // We can't use InsertElementsAt since the destination can't steal
  // ownership from its const source argument.
  for (nsTArray<Row>::index_type i = 0; i < rows.Length(); i++) {
    nsAutoPtr<Row>* newRow = mRows.InsertElementAt(aParentIndex + aIndex + i + 1);
    *newRow = rows[i];
  }
  int32_t count = rows.Length();

  UpdateSubtreeSizes(aParentIndex, count);

  // Update parent indexes, but skip added rows.
  // They already have correct values.
  UpdateParentIndexes(aParentIndex + aIndex, count + 1, count);

  return count;
}
开发者ID:cbradley857,项目名称:gecko-dev,代码行数:26,代码来源:nsTreeContentView.cpp

示例5: Serialize

int32_t
nsTreeContentView::EnsureSubtree(int32_t aIndex)
{
  Row* row = mRows[aIndex].get();

  nsIContent* child;
  child = nsTreeUtils::GetImmediateChild(row->mContent, nsGkAtoms::treechildren);
  if (!child || !child->IsXULElement()) {
    return 0;
  }

  AutoTArray<UniquePtr<Row>, 8> rows;
  int32_t index = 0;
  Serialize(child, aIndex, &index, rows);
  // Insert |rows| into |mRows| at position |aIndex|, by first creating empty
  // UniquePtr entries and then Move'ing |rows|'s entries into them. (Note
  // that we can't simply use InsertElementsAt with an array argument, since
  // the destination can't steal ownership from its const source argument.)
  UniquePtr<Row>* newRows = mRows.InsertElementsAt(aIndex + 1,
                                                   rows.Length());
  for (nsTArray<Row>::index_type i = 0; i < rows.Length(); i++) {
    newRows[i] = Move(rows[i]);
  }
  int32_t count = rows.Length();

  row->mSubtreeSize += count;
  UpdateSubtreeSizes(row->mParentIndex, count);

  // Update parent indexes, but skip newly added rows.
  // They already have correct values.
  UpdateParentIndexes(aIndex, count + 1, count);

  return count;
}
开发者ID:luke-chang,项目名称:gecko-1,代码行数:34,代码来源:nsTreeContentView.cpp

示例6: switch

/*static*/
void
AudioTrackEncoder::InterleaveTrackData(AudioChunk& aChunk,
                                       int32_t aDuration,
                                       uint32_t aOutputChannels,
                                       AudioDataValue* aOutput)
{
    switch(aChunk.mBufferFormat) {
    case AUDIO_FORMAT_S16: {
        AutoTArray<const int16_t*, 2> array;
        array.SetLength(aOutputChannels);
        for (uint32_t i = 0; i < array.Length(); i++) {
            array[i] = static_cast<const int16_t*>(aChunk.mChannelData[i]);
        }
        InterleaveTrackData(array, aDuration, aOutputChannels, aOutput, aChunk.mVolume);
        break;
    }
    case AUDIO_FORMAT_FLOAT32: {
        AutoTArray<const float*, 2> array;
        array.SetLength(aOutputChannels);
        for (uint32_t i = 0; i < array.Length(); i++) {
            array[i] = static_cast<const float*>(aChunk.mChannelData[i]);
        }
        InterleaveTrackData(array, aDuration, aOutputChannels, aOutput, aChunk.mVolume);
        break;
    }
    case AUDIO_FORMAT_SILENCE: {
        MOZ_ASSERT(false, "To implement.");
    }
    };
}
开发者ID:leplatrem,项目名称:gecko-dev,代码行数:31,代码来源:TrackEncoder.cpp

示例7: TableSelectedCells

void ProxyAccessible::TableSelectedCells(nsTArray<ProxyAccessible*>* aCellIDs) {
  AutoTArray<uint64_t, 30> cellIDs;
  Unused << mDoc->SendTableSelectedCells(mID, &cellIDs);
  aCellIDs->SetCapacity(cellIDs.Length());
  for (uint32_t i = 0; i < cellIDs.Length(); ++i) {
    aCellIDs->AppendElement(mDoc->GetAccessible(cellIDs[i]));
  }
}
开发者ID:jld,项目名称:gecko-dev,代码行数:8,代码来源:ProxyAccessible.cpp

示例8: SelectedItems

void ProxyAccessible::SelectedItems(
    nsTArray<ProxyAccessible*>* aSelectedItems) {
  AutoTArray<uint64_t, 10> itemIDs;
  Unused << mDoc->SendSelectedItems(mID, &itemIDs);
  aSelectedItems->SetCapacity(itemIDs.Length());
  for (size_t i = 0; i < itemIDs.Length(); ++i) {
    aSelectedItems->AppendElement(mDoc->GetAccessible(itemIDs[i]));
  }
}
开发者ID:jld,项目名称:gecko-dev,代码行数:9,代码来源:ProxyAccessible.cpp

示例9: lists

/* static */ void
nsFontFaceUtils::MarkDirtyForFontChange(nsIFrame* aSubtreeRoot,
                                        const gfxUserFontEntry* aFont)
{
  AutoTArray<nsIFrame*, 4> subtrees;
  subtrees.AppendElement(aSubtreeRoot);

  nsIPresShell* ps = aSubtreeRoot->PresContext()->PresShell();

  // check descendants, iterating over subtrees that may include
  // additional subtrees associated with placeholders
  do {
    nsIFrame* subtreeRoot = subtrees.ElementAt(subtrees.Length() - 1);
    subtrees.RemoveElementAt(subtrees.Length() - 1);

    // Check all descendants to see if they use the font
    AutoTArray<nsIFrame*, 32> stack;
    stack.AppendElement(subtreeRoot);

    do {
      nsIFrame* f = stack.ElementAt(stack.Length() - 1);
      stack.RemoveElementAt(stack.Length() - 1);

      // if this frame uses the font, mark its descendants dirty
      // and skip checking its children
      if (FrameUsesFont(f, aFont)) {
        ScheduleReflow(ps, f);
      } else {
        if (f->GetType() == nsGkAtoms::placeholderFrame) {
          nsIFrame* oof = nsPlaceholderFrame::GetRealFrameForPlaceholder(f);
          if (!nsLayoutUtils::IsProperAncestorFrame(subtreeRoot, oof)) {
            // We have another distinct subtree we need to mark.
            subtrees.AppendElement(oof);
          }
        }

        nsIFrame::ChildListIterator lists(f);
        for (; !lists.IsDone(); lists.Next()) {
          nsFrameList::Enumerator childFrames(lists.CurrentList());
          for (; !childFrames.AtEnd(); childFrames.Next()) {
            nsIFrame* kid = childFrames.get();
            stack.AppendElement(kid);
          }
        }
      }
    } while (!stack.IsEmpty());
  } while (!subtrees.IsEmpty());
}
开发者ID:MekliCZ,项目名称:positron,代码行数:48,代码来源:nsFontFaceUtils.cpp

示例10: Intl

NS_IMETHODIMP
xpcAccessibleTable::GetSelectedCells(nsIArray** aSelectedCells)
{
  NS_ENSURE_ARG_POINTER(aSelectedCells);
  *aSelectedCells = nullptr;

  if (!Intl())
    return NS_ERROR_FAILURE;

  nsresult rv = NS_OK;
  nsCOMPtr<nsIMutableArray> selCells =
    do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv, rv);

  AutoTArray<Accessible*, XPC_TABLE_DEFAULT_SIZE> cellsArray;
  Intl()->SelectedCells(&cellsArray);

  uint32_t totalCount = cellsArray.Length();
  for (uint32_t idx = 0; idx < totalCount; idx++) {
    Accessible* cell = cellsArray.ElementAt(idx);
    selCells->AppendElement(static_cast<nsIAccessible*>(ToXPC(cell)));
  }

  NS_ADDREF(*aSelectedCells = selCells);
  return NS_OK;
}
开发者ID:nils-ohlmeier,项目名称:gecko-dev,代码行数:26,代码来源:xpcAccessibleTable.cpp

示例11: IntlGeneric

NS_IMETHODIMP
xpcAccessible::GetAttributes(nsIPersistentProperties** aAttributes)
{
  NS_ENSURE_ARG_POINTER(aAttributes);
  *aAttributes = nullptr;

  if (IntlGeneric().IsNull()) {
    return NS_ERROR_FAILURE;
  }

  if (Accessible* acc = Intl()) {
    nsCOMPtr<nsIPersistentProperties> attributes = acc->Attributes();
    attributes.swap(*aAttributes);
    return NS_OK;
  }

  ProxyAccessible* proxy = IntlGeneric().AsProxy();
  AutoTArray<Attribute, 10> attrs;
  proxy->Attributes(&attrs);

  nsCOMPtr<nsIPersistentProperties> props =
    do_CreateInstance(NS_PERSISTENTPROPERTIES_CONTRACTID);
  uint32_t attrCount = attrs.Length();
  nsAutoString unused;
  for (uint32_t i = 0; i < attrCount; i++) {
    props->SetStringProperty(attrs[i].Name(), attrs[i].Value(), unused);
  }

  props.forget(aAttributes);
  return NS_OK;
}
开发者ID:SergiosLen,项目名称:browser-f,代码行数:31,代码来源:xpcAccessible.cpp

示例12: WritingMode

// The text that should be displayed for this counter.
void
nsCounterUseNode::GetText(nsString& aResult)
{
  aResult.Truncate();

  AutoTArray<nsCounterNode*, 8> stack;
  stack.AppendElement(static_cast<nsCounterNode*>(this));

  if (mAllCounters && mScopeStart) {
    for (nsCounterNode* n = mScopeStart; n->mScopePrev; n = n->mScopeStart) {
      stack.AppendElement(n->mScopePrev);
    }
  }

  WritingMode wm = mPseudoFrame ?
    mPseudoFrame->GetWritingMode() : WritingMode();
  for (uint32_t i = stack.Length() - 1;; --i) {
    nsCounterNode* n = stack[i];
    nsAutoString text;
    bool isTextRTL;
    mCounterStyle->GetCounterText(n->mValueAfter, wm, text, isTextRTL);
    aResult.Append(text);
    if (i == 0) {
      break;
    }
    aResult.Append(mSeparator);
  }
}
开发者ID:luke-chang,项目名称:gecko-1,代码行数:29,代码来源:nsCounterManager.cpp

示例13:

void
HTMLOptionsCollection::GetSupportedNames(nsTArray<nsString>& aNames)
{
  AutoTArray<nsIAtom*, 8> atoms;
  for (uint32_t i = 0; i < mElements.Length(); ++i) {
    HTMLOptionElement* content = mElements.ElementAt(i);
    if (content) {
      // Note: HasName means the names is exposed on the document,
      // which is false for options, so we don't check it here.
      const nsAttrValue* val = content->GetParsedAttr(nsGkAtoms::name);
      if (val && val->Type() == nsAttrValue::eAtom) {
        nsIAtom* name = val->GetAtomValue();
        if (!atoms.Contains(name)) {
          atoms.AppendElement(name);
        }
      }
      if (content->HasID()) {
        nsIAtom* id = content->GetID();
        if (!atoms.Contains(id)) {
          atoms.AppendElement(id);
        }
      }
    }
  }

  uint32_t atomsLen = atoms.Length();
  nsString* names = aNames.AppendElements(atomsLen);
  for (uint32_t i = 0; i < atomsLen; ++i) {
    atoms[i]->ToString(names[i]);
  }
}
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:31,代码来源:HTMLOptionsCollection.cpp

示例14: UpMixDownMixChunk

void
AudioNodeStream::AccumulateInputChunk(uint32_t aInputIndex,
                                      const AudioBlock& aChunk,
                                      AudioBlock* aBlock,
                                      DownmixBufferType* aDownmixBuffer)
{
  AutoTArray<const float*,GUESS_AUDIO_CHANNELS> channels;
  UpMixDownMixChunk(&aChunk, aBlock->ChannelCount(), channels, *aDownmixBuffer);

  for (uint32_t c = 0; c < channels.Length(); ++c) {
    const float* inputData = static_cast<const float*>(channels[c]);
    float* outputData = aBlock->ChannelFloatsForWrite(c);
    if (inputData) {
      if (aInputIndex == 0) {
        AudioBlockCopyChannelWithScale(inputData, aChunk.mVolume, outputData);
      } else {
        AudioBlockAddChannelWithScale(inputData, aChunk.mVolume, outputData);
      }
    } else {
      if (aInputIndex == 0) {
        PodZero(outputData, WEBAUDIO_BLOCK_SIZE);
      }
    }
  }
}
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:25,代码来源:AudioNodeStream.cpp

示例15: ceil

void
AudioStream::GetTimeStretched(AudioBufferWriter& aWriter)
{
  mMonitor.AssertCurrentThreadOwns();

  // We need to call the non-locking version, because we already have the lock.
  if (EnsureTimeStretcherInitializedUnlocked() != NS_OK) {
    return;
  }

  uint32_t toPopFrames =
    ceil(aWriter.Available() * mAudioClock.GetPlaybackRate());

  while (mTimeStretcher->numSamples() < aWriter.Available()) {
    UniquePtr<Chunk> c = mDataSource.PopFrames(toPopFrames);
    if (c->Frames() == 0) {
      break;
    }
    MOZ_ASSERT(c->Frames() <= toPopFrames);
    if (IsValidAudioFormat(c.get())) {
      mTimeStretcher->putSamples(c->Data(), c->Frames());
    } else {
      // Write silence if invalid format.
      AutoTArray<AudioDataValue, 1000> buf;
      buf.SetLength(mOutChannels * c->Frames());
      memset(buf.Elements(), 0, buf.Length() * sizeof(AudioDataValue));
      mTimeStretcher->putSamples(buf.Elements(), c->Frames());
    }
  }

  auto timeStretcher = mTimeStretcher;
  aWriter.Write([timeStretcher] (AudioDataValue* aPtr, uint32_t aFrames) {
    return timeStretcher->receiveSamples(aPtr, aFrames);
  }, aWriter.Available());
}
开发者ID:SJasoria,项目名称:gecko-dev,代码行数:35,代码来源:AudioStream.cpp


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