本文整理汇总了C++中KeyframeVector::reserveCapacity方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyframeVector::reserveCapacity方法的具体用法?C++ KeyframeVector::reserveCapacity怎么用?C++ KeyframeVector::reserveCapacity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyframeVector
的用法示例。
在下文中一共展示了KeyframeVector::reserveCapacity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: normalizedKeyframes
KeyframeEffectModelBase::KeyframeVector KeyframeEffectModelBase::normalizedKeyframes(const KeyframeVector& keyframes)
{
double lastOffset = 0;
KeyframeVector result;
result.reserveCapacity(keyframes.size());
for (size_t i = 0; i < keyframes.size(); ++i) {
double offset = keyframes[i]->offset();
if (!isNull(offset)) {
ASSERT(offset >= 0);
ASSERT(offset <= 1);
ASSERT(offset >= lastOffset);
lastOffset = offset;
}
result.append(keyframes[i]->clone());
}
if (result.isEmpty()) {
return result;
}
if (isNull(result.last()->offset()))
result.last()->setOffset(1);
if (result.size() > 1 && isNull(result[0]->offset()))
result[0]->setOffset(0);
size_t lastIndex = 0;
lastOffset = result[0]->offset();
for (size_t i = 1; i < result.size(); ++i) {
double offset = result[i]->offset();
if (!isNull(offset)) {
for (size_t j = 1; j < i - lastIndex; ++j)
result[lastIndex + j]->setOffset(lastOffset + (offset - lastOffset) * j / (i - lastIndex));
lastIndex = i;
lastOffset = offset;
}
}
return result;
}
示例2:
KeyframeEffectModelBase::KeyframeVector
KeyframeEffectModelBase::normalizedKeyframes(const KeyframeVector& keyframes) {
double lastOffset = 0;
KeyframeVector result;
result.reserveCapacity(keyframes.size());
for (const auto& keyframe : keyframes) {
double offset = keyframe->offset();
if (!isNull(offset)) {
DCHECK_GE(offset, 0);
DCHECK_LE(offset, 1);
DCHECK_GE(offset, lastOffset);
lastOffset = offset;
}
result.push_back(keyframe->clone());
}
if (result.isEmpty())
return result;
if (isNull(result.back()->offset()))
result.back()->setOffset(1);
if (result.size() > 1 && isNull(result[0]->offset()))
result.front()->setOffset(0);
size_t lastIndex = 0;
lastOffset = result.front()->offset();
for (size_t i = 1; i < result.size(); ++i) {
double offset = result[i]->offset();
if (!isNull(offset)) {
for (size_t j = 1; j < i - lastIndex; ++j)
result[lastIndex + j]->setOffset(
lastOffset + (offset - lastOffset) * j / (i - lastIndex));
lastIndex = i;
lastOffset = offset;
}
}
return result;
}
示例3: normalizedKeyframes
KeyframeEffectModelBase::KeyframeVector KeyframeEffectModelBase::normalizedKeyframes(const KeyframeVector& keyframes)
{
// keyframes [beginIndex, endIndex) will remain after removing all keyframes if they are not
// loosely sorted by offset, and after removing keyframes with positional offset outide [0, 1].
size_t beginIndex = 0;
size_t endIndex = keyframes.size();
// Becomes the most recent keyframe with an explicit offset.
size_t lastIndex = endIndex;
double lastOffset = std::numeric_limits<double>::quiet_NaN();
for (size_t i = 0; i < keyframes.size(); ++i) {
double offset = keyframes[i]->offset();
if (!isNull(offset)) {
if (lastIndex < i && offset < lastOffset) {
// The keyframes are not loosely sorted by offset. Exclude all.
endIndex = beginIndex;
break;
}
if (offset < 0) {
// Remove all keyframes up to and including this keyframe.
beginIndex = i + 1;
} else if (offset > 1) {
// Remove all keyframes from this keyframe onwards. Note we must complete our checking
// that the keyframes are loosely sorted by offset, so we can't exit the loop early.
endIndex = std::min(i, endIndex);
}
lastIndex = i;
lastOffset = offset;
}
}
KeyframeVector result;
if (beginIndex != endIndex) {
result.reserveCapacity(endIndex - beginIndex);
for (size_t i = beginIndex; i < endIndex; ++i) {
result.append(keyframes[i]->clone());
}
if (isNull(result[result.size() - 1]->offset()))
result[result.size() - 1]->setOffset(1);
if (result.size() > 1 && isNull(result[0]->offset()))
result[0]->setOffset(0);
lastIndex = 0;
lastOffset = result[0]->offset();
for (size_t i = 1; i < result.size(); ++i) {
double offset = result[i]->offset();
if (!isNull(offset)) {
if (lastIndex + 1 < i) {
for (size_t j = 1; j < i - lastIndex; ++j)
result[lastIndex + j]->setOffset(lastOffset + (offset - lastOffset) * j / (i - lastIndex));
}
lastIndex = i;
lastOffset = offset;
}
}
}
return result;
}