本文整理汇总了C++中SkTArray::reserve方法的典型用法代码示例。如果您正苦于以下问题:C++ SkTArray::reserve方法的具体用法?C++ SkTArray::reserve怎么用?C++ SkTArray::reserve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkTArray
的用法示例。
在下文中一共展示了SkTArray::reserve方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: name
std::unique_ptr<GrFragmentProcessor> GrFragmentProcessor::RunInSeries(
std::unique_ptr<GrFragmentProcessor>* series, int cnt) {
class SeriesFragmentProcessor : public GrFragmentProcessor {
public:
static std::unique_ptr<GrFragmentProcessor> Make(
std::unique_ptr<GrFragmentProcessor>* children, int cnt) {
return std::unique_ptr<GrFragmentProcessor>(new SeriesFragmentProcessor(children, cnt));
}
const char* name() const override { return "Series"; }
std::unique_ptr<GrFragmentProcessor> clone() const override {
SkSTArray<4, std::unique_ptr<GrFragmentProcessor>> children(this->numChildProcessors());
for (int i = 0; i < this->numChildProcessors(); ++i) {
if (!children.push_back(this->childProcessor(i).clone())) {
return nullptr;
}
}
return Make(children.begin(), this->numChildProcessors());
}
private:
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override {
class GLFP : public GrGLSLFragmentProcessor {
public:
void emitCode(EmitArgs& args) override {
// First guy's input might be nil.
SkString temp("out0");
this->emitChild(0, args.fInputColor, &temp, args);
SkString input = temp;
for (int i = 1; i < this->numChildProcessors() - 1; ++i) {
temp.printf("out%d", i);
this->emitChild(i, input.c_str(), &temp, args);
input = temp;
}
// Last guy writes to our output variable.
this->emitChild(this->numChildProcessors() - 1, input.c_str(), args);
}
};
return new GLFP;
}
SeriesFragmentProcessor(std::unique_ptr<GrFragmentProcessor>* children, int cnt)
: INHERITED(kSeriesFragmentProcessor_ClassID, OptFlags(children, cnt)) {
SkASSERT(cnt > 1);
for (int i = 0; i < cnt; ++i) {
this->registerChildProcessor(std::move(children[i]));
}
}
static OptimizationFlags OptFlags(std::unique_ptr<GrFragmentProcessor>* children, int cnt) {
OptimizationFlags flags = kAll_OptimizationFlags;
for (int i = 0; i < cnt && flags != kNone_OptimizationFlags; ++i) {
flags &= children[i]->optimizationFlags();
}
return flags;
}
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {}
bool onIsEqual(const GrFragmentProcessor&) const override { return true; }
GrColor4f constantOutputForConstantInput(GrColor4f color) const override {
int childCnt = this->numChildProcessors();
for (int i = 0; i < childCnt; ++i) {
color = ConstantOutputForConstantInput(this->childProcessor(i), color);
}
return color;
}
typedef GrFragmentProcessor INHERITED;
};
if (!cnt) {
return nullptr;
}
if (1 == cnt) {
return std::move(series[0]);
}
// Run the through the series, do the invariant output processing, and look for eliminations.
GrProcessorAnalysisColor inputColor;
inputColor.setToUnknown();
GrColorFragmentProcessorAnalysis info(inputColor, unique_ptr_address_as_pointer_address(series),
cnt);
SkTArray<std::unique_ptr<GrFragmentProcessor>> replacementSeries;
GrColor4f knownColor;
int leadingFPsToEliminate = info.initialProcessorsToEliminate(&knownColor);
if (leadingFPsToEliminate) {
std::unique_ptr<GrFragmentProcessor> colorFP(
GrConstColorProcessor::Make(knownColor, GrConstColorProcessor::InputMode::kIgnore));
if (leadingFPsToEliminate == cnt) {
return colorFP;
}
cnt = cnt - leadingFPsToEliminate + 1;
replacementSeries.reserve(cnt);
replacementSeries.emplace_back(std::move(colorFP));
for (int i = 0; i < cnt - 1; ++i) {
replacementSeries.emplace_back(std::move(series[leadingFPsToEliminate + i]));
}
series = replacementSeries.begin();
}
//.........这里部分代码省略.........