本文整理汇总了C++中SkTArray类的典型用法代码示例。如果您正苦于以下问题:C++ SkTArray类的具体用法?C++ SkTArray怎么用?C++ SkTArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SkTArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handle_cmd
static void handle_cmd(struct android_app* app, int32_t cmd) {
struct VisualBenchState* state = (struct VisualBenchState*)app->userData;
switch (cmd) {
case APP_CMD_INIT_WINDOW:
// The window is being shown, get it ready.
if (state->fApp->window != nullptr && kInit_State == state->fState) {
// drain any events that occurred before |window| was assigned.
while (SkEvent::ProcessEvent());
// Start normal Skia sequence
application_init();
SkTArray<const char*> args;
args.push_back("VisualBench");
for (int i = 0; i < state->fFlags.count(); i++) {
SkDebugf(state->fFlags[i].c_str());
args.push_back(state->fFlags[i].c_str());
}
state->fWindow = create_sk_window((void*)state->fApp->window,
args.count(),
const_cast<char**>(args.begin()));
state->fWindow->forceInvalAll();
state->fState = kAnimate_State;
}
break;
case APP_CMD_TERM_WINDOW:
state->fState = kDestroyRequested_State;
break;
}
}
示例2: SkDebugf
void SkDiffContext::diffPatterns(const char baselinePattern[], const char testPattern[]) {
// Get the files in the baseline and test patterns. Because they are in sorted order, it's easy
// to find corresponding images by matching entry indices.
SkTArray<SkString> baselineEntries;
if (!glob_files(baselinePattern, &baselineEntries)) {
SkDebugf("Unable to get pattern \"%s\"\n", baselinePattern);
return;
}
SkTArray<SkString> testEntries;
if (!glob_files(testPattern, &testEntries)) {
SkDebugf("Unable to get pattern \"%s\"\n", testPattern);
return;
}
if (baselineEntries.count() != testEntries.count()) {
SkDebugf("Baseline and test patterns do not yield corresponding number of files\n");
return;
}
for (int entryIndex = 0; entryIndex < baselineEntries.count(); entryIndex++) {
const char* baselineFilename = baselineEntries[entryIndex].c_str();
const char* testFilename = testEntries [entryIndex].c_str();
this->addDiff(baselineFilename, testFilename);
}
}
示例3: handle
int handle(Request* request, MHD_Connection* connection,
const char* url, const char* method,
const char* upload_data, size_t* upload_data_size) override {
SkTArray<SkString> commands;
SkStrSplit(url, "/", &commands);
if (!request->fPicture.get() || commands.count() > 3) {
return MHD_NO;
}
// /cmd or /cmd/N or /cmd/N/[0|1]
if (commands.count() == 1 && 0 == strcmp(method, MHD_HTTP_METHOD_GET)) {
int n = request->fDebugCanvas->getSize() - 1;
return SendJSON(connection, request->fDebugCanvas, n);
}
// /cmd/N, for now only delete supported
if (commands.count() == 2 && 0 == strcmp(method, MHD_HTTP_METHOD_DELETE)) {
int n;
sscanf(commands[1].c_str(), "%d", &n);
request->fDebugCanvas->deleteDrawCommandAt(n);
return MHD_YES;
}
// /cmd/N/[0|1]
if (commands.count() == 3 && 0 == strcmp(method, MHD_HTTP_METHOD_POST)) {
int n, toggle;
sscanf(commands[1].c_str(), "%d", &n);
sscanf(commands[2].c_str(), "%d", &toggle);
request->fDebugCanvas->toggleCommand(n, toggle);
return MHD_YES;
}
return MHD_NO;
}
示例4: buildNameToFamilyMap
void buildNameToFamilyMap(SkTDArray<FontFamily*> families, const bool isolated) {
for (int i = 0; i < families.count(); i++) {
FontFamily& family = *families[i];
SkTArray<NameToFamily, true>* nameToFamily = &fNameToFamilyMap;
if (family.fIsFallbackFont) {
nameToFamily = &fFallbackNameToFamilyMap;
if (0 == family.fNames.count()) {
SkString& fallbackName = family.fNames.push_back();
fallbackName.printf("%.2x##fallback", i);
}
}
sk_sp<SkFontStyleSet_Android> newSet =
sk_make_sp<SkFontStyleSet_Android>(family, fScanner, isolated);
if (0 == newSet->count()) {
continue;
}
for (const SkString& name : family.fNames) {
nameToFamily->emplace_back(NameToFamily{name, newSet.get()});
}
fStyleSets.emplace_back(std::move(newSet));
}
}
示例5: writeSamplers
void GrVkPipelineState::writeSamplers(GrVkGpu* gpu,
const SkTArray<const GrTextureAccess*>& textureBindings,
bool allowSRGBInputs) {
SkASSERT(fNumSamplers == textureBindings.count());
for (int i = 0; i < textureBindings.count(); ++i) {
const GrTextureParams& params = textureBindings[i]->getParams();
GrVkTexture* texture = static_cast<GrVkTexture*>(textureBindings[i]->getTexture());
if (GrTextureParams::kMipMap_FilterMode == params.filterMode()) {
if (texture->texturePriv().mipMapsAreDirty()) {
gpu->generateMipmap(texture);
texture->texturePriv().dirtyMipMaps(false);
}
}
fSamplers.push(gpu->resourceProvider().findOrCreateCompatibleSampler(params,
texture->texturePriv().maxMipMapLevel()));
const GrVkResource* textureResource = texture->resource();
textureResource->ref();
fTextures.push(textureResource);
const GrVkImageView* textureView = texture->textureView(allowSRGBInputs);
textureView->ref();
fTextureViews.push(textureView);
// Change texture layout so it can be read in shader
texture->setImageLayout(gpu,
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
VK_ACCESS_SHADER_READ_BIT,
VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT,
false);
VkDescriptorImageInfo imageInfo;
memset(&imageInfo, 0, sizeof(VkDescriptorImageInfo));
imageInfo.sampler = fSamplers[i]->sampler();
imageInfo.imageView = textureView->imageView();
imageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
VkWriteDescriptorSet writeInfo;
memset(&writeInfo, 0, sizeof(VkWriteDescriptorSet));
writeInfo.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
writeInfo.pNext = nullptr;
writeInfo.dstSet = fDescriptorSets[GrVkUniformHandler::kSamplerDescSet];
writeInfo.dstBinding = i;
writeInfo.dstArrayElement = 0;
writeInfo.descriptorCount = 1;
writeInfo.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
writeInfo.pImageInfo = &imageInfo;
writeInfo.pBufferInfo = nullptr;
writeInfo.pTexelBufferView = nullptr;
GR_VK_CALL(gpu->vkInterface(), UpdateDescriptorSets(gpu->device(),
1,
&writeInfo,
0,
nullptr));
}
}
示例6: checkMessages
void SkResourceCache::checkMessages() {
SkTArray<PurgeSharedIDMessage> msgs;
fPurgeSharedIDInbox.poll(&msgs);
for (int i = 0; i < msgs.count(); ++i) {
this->purgeSharedID(msgs[i].fSharedID);
}
}
示例7: tool_main
int tool_main(int argc, char** argv) {
SetupCrashHandler();
SkAutoGraphics ag;
SkCommandLineFlags::Parse(argc, argv);
if (FLAGS_dryRun) {
FLAGS_verbose = true;
}
#if SK_ENABLE_INST_COUNT
gPrintInstCount = FLAGS_leaks;
#endif
SkTArray<SkString> configs;
for (int i = 0; i < FLAGS_config.count(); i++) {
SkStrSplit(FLAGS_config[i], ", ", &configs);
}
SkTDArray<GMRegistry::Factory> gms;
SkAutoTDelete<DM::Expectations> expectations(SkNEW(DM::NoExpectations));
if (FLAGS_gms) {
append_matching_factories<GM>(GMRegistry::Head(), &gms);
if (FLAGS_expectations.count() > 0) {
const char* path = FLAGS_expectations[0];
if (sk_isdir(path)) {
expectations.reset(SkNEW_ARGS(DM::WriteTask::Expectations, (path)));
} else {
expectations.reset(SkNEW_ARGS(DM::JsonExpectations, (path)));
}
}
}
SkTDArray<BenchRegistry::Factory> benches;
if (FLAGS_benches) {
append_matching_factories<Benchmark>(BenchRegistry::Head(), &benches);
}
SkTDArray<TestRegistry::Factory> tests;
if (FLAGS_tests) {
append_matching_factories<Test>(TestRegistry::Head(), &tests);
}
SkDebugf("(%d GMs, %d benches) x %d configs, %d tests\n",
gms.count(), benches.count(), configs.count(), tests.count());
DM::Reporter reporter;
DM::TaskRunner tasks(FLAGS_threads, FLAGS_gpuThreads);
kick_off_gms(gms, configs, *expectations, &reporter, &tasks);
kick_off_benches(benches, configs, &reporter, &tasks);
kick_off_tests(tests, &reporter, &tasks);
kick_off_skps(&reporter, &tasks);
tasks.wait();
SkDebugf("\n");
SkTArray<SkString> failures;
reporter.getFailures(&failures);
report_failures(failures);
return failures.count() > 0;
}
示例8: generate_page_tree
// return root node.
static sk_sp<SkPDFDict> generate_page_tree(SkTArray<sk_sp<SkPDFDict>>* pages) {
// PDF wants a tree describing all the pages in the document. We arbitrary
// choose 8 (kNodeSize) as the number of allowed children. The internal
// nodes have type "Pages" with an array of children, a parent pointer, and
// the number of leaves below the node as "Count." The leaves are passed
// into the method, have type "Page" and need a parent pointer. This method
// builds the tree bottom up, skipping internal nodes that would have only
// one child.
static const int kNodeSize = 8;
// curNodes takes a reference to its items, which it passes to pageTree.
int totalPageCount = pages->count();
SkTArray<sk_sp<SkPDFDict>> curNodes;
curNodes.swap(pages);
// nextRoundNodes passes its references to nodes on to curNodes.
int treeCapacity = kNodeSize;
do {
SkTArray<sk_sp<SkPDFDict>> nextRoundNodes;
for (int i = 0; i < curNodes.count(); ) {
if (i > 0 && i + 1 == curNodes.count()) {
SkASSERT(curNodes[i]);
nextRoundNodes.emplace_back(std::move(curNodes[i]));
break;
}
auto newNode = sk_make_sp<SkPDFDict>("Pages");
auto kids = sk_make_sp<SkPDFArray>();
kids->reserve(kNodeSize);
int count = 0;
for (; i < curNodes.count() && count < kNodeSize; i++, count++) {
SkASSERT(curNodes[i]);
curNodes[i]->insertObjRef("Parent", newNode);
kids->appendObjRef(std::move(curNodes[i]));
}
// treeCapacity is the number of leaf nodes possible for the
// current set of subtrees being generated. (i.e. 8, 64, 512, ...).
// It is hard to count the number of leaf nodes in the current
// subtree. However, by construction, we know that unless it's the
// last subtree for the current depth, the leaf count will be
// treeCapacity, otherwise it's what ever is left over after
// consuming treeCapacity chunks.
int pageCount = treeCapacity;
if (i == curNodes.count()) {
pageCount = ((totalPageCount - 1) % treeCapacity) + 1;
}
newNode->insertInt("Count", pageCount);
newNode->insertObject("Kids", std::move(kids));
nextRoundNodes.emplace_back(std::move(newNode));
}
SkDEBUGCODE( for (const auto& n : curNodes) { SkASSERT(!n); } );
curNodes.swap(&nextRoundNodes);
nextRoundNodes.reset();
treeCapacity *= kNodeSize;
} while (curNodes.count() > 1);
示例9:
// TODO(chudy): Free command string memory.
SkTArray<SkString>* SkDebugCanvas::getDrawCommandsAsStrings() const {
SkTArray<SkString>* commandString = new SkTArray<SkString>(fCommandVector.count());
if (!fCommandVector.isEmpty()) {
for (int i = 0; i < fCommandVector.count(); i ++) {
commandString->push_back() = fCommandVector[i]->toString();
}
}
return commandString;
}
示例10: writeSamplers
void GrVkProgram::writeSamplers(const GrVkGpu* gpu,
const SkTArray<const GrTextureAccess*>& textureBindings) {
SkASSERT(fNumSamplers == textureBindings.count());
for (int i = 0; i < textureBindings.count(); ++i) {
fSamplers.push(GrVkSampler::Create(gpu, *textureBindings[i]));
GrVkTexture* texture = static_cast<GrVkTexture*>(textureBindings[i]->getTexture());
const GrVkImage::Resource* textureResource = texture->resource();
textureResource->ref();
fTextures.push(textureResource);
const GrVkImageView* textureView = texture->textureView();
textureView->ref();
fTextureViews.push(textureView);
// Change texture layout so it can be read in shader
VkImageLayout layout = texture->currentLayout();
VkPipelineStageFlags srcStageMask = GrVkMemory::LayoutToPipelineStageFlags(layout);
VkPipelineStageFlags dstStageMask = VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT;
VkAccessFlags srcAccessMask = GrVkMemory::LayoutToSrcAccessMask(layout);
VkAccessFlags dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
texture->setImageLayout(gpu,
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
srcAccessMask,
dstAccessMask,
srcStageMask,
dstStageMask,
false);
VkDescriptorImageInfo imageInfo;
memset(&imageInfo, 0, sizeof(VkDescriptorImageInfo));
imageInfo.sampler = fSamplers[i]->sampler();
imageInfo.imageView = texture->textureView()->imageView();
imageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
VkWriteDescriptorSet writeInfo;
memset(&writeInfo, 0, sizeof(VkWriteDescriptorSet));
writeInfo.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
writeInfo.pNext = nullptr;
writeInfo.dstSet = fDescriptorSets[GrVkUniformHandler::kSamplerDescSet];
writeInfo.dstBinding = i;
writeInfo.dstArrayElement = 0;
writeInfo.descriptorCount = 1;
writeInfo.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
writeInfo.pImageInfo = &imageInfo;
writeInfo.pBufferInfo = nullptr;
writeInfo.pTexelBufferView = nullptr;
GR_VK_CALL(gpu->vkInterface(), UpdateDescriptorSets(gpu->device(),
1,
&writeInfo,
0,
nullptr));
}
}
示例11: parse_command_line_config_gpu
SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag,
const SkTArray<SkString>& vias,
const SkString& options) {
// Defaults for GPU backend.
bool seenAPI = false;
SkCommandLineConfigGpu::ContextType contextType = GrContextFactory::kNativeGL_ContextType;
bool seenUseNVPR = false;
bool useNVPR = false;
bool seenUseInstanced = false;
bool useInstanced = false;
bool seenUseDIText =false;
bool useDIText = false;
bool seenSamples = false;
int samples = 0;
bool seenColor = false;
SkColorType colorType = kN32_SkColorType;
sk_sp<SkColorSpace> colorSpace = nullptr;
SkTArray<SkString> optionParts;
SkStrSplit(options.c_str(), ",", kStrict_SkStrSplitMode, &optionParts);
for (int i = 0; i < optionParts.count(); ++i) {
SkTArray<SkString> keyValueParts;
SkStrSplit(optionParts[i].c_str(), "=", kStrict_SkStrSplitMode, &keyValueParts);
if (keyValueParts.count() != 2) {
return nullptr;
}
const SkString& key = keyValueParts[0];
const SkString& value = keyValueParts[1];
bool valueOk = false;
if (key.equals("api") && !seenAPI) {
valueOk = parse_option_gpu_api(value, &contextType);
seenAPI = true;
} else if (key.equals("nvpr") && !seenUseNVPR) {
valueOk = parse_option_bool(value, &useNVPR);
seenUseNVPR = true;
} else if (key.equals("inst") && !seenUseInstanced) {
valueOk = parse_option_bool(value, &useInstanced);
seenUseInstanced = true;
} else if (key.equals("dit") && !seenUseDIText) {
valueOk = parse_option_bool(value, &useDIText);
seenUseDIText = true;
} else if (key.equals("samples") && !seenSamples) {
valueOk = parse_option_int(value, &samples);
seenSamples = true;
} else if (key.equals("color") && !seenColor) {
valueOk = parse_option_gpu_color(value, &colorType, &colorSpace);
seenColor = true;
}
if (!valueOk) {
return nullptr;
}
}
return new SkCommandLineConfigGpu(tag, vias, contextType, useNVPR, useInstanced, useDIText,
samples, colorType, colorSpace);
}
示例12: split_suffixes
// Splits off the last N suffixes of name (splitting on _) and appends them to out.
// Returns the total number of characters consumed.
static int split_suffixes(int N, const char* name, SkTArray<SkString>* out) {
SkTArray<SkString> split;
SkStrSplit(name, "_", &split);
int consumed = 0;
for (int i = 0; i < N; i++) {
// We're splitting off suffixes from the back to front.
out->push_back(split[split.count()-i-1]);
consumed += out->back().size() + 1; // Add one for the _.
}
return consumed;
}
示例13: PrintLineByLine
// Prints shaders one line at the time. This ensures they don't get truncated by the adb log.
void PrintLineByLine(const char* header, const SkSL::String& text) {
if (header) {
SkDebugf("%s\n", header);
}
SkSL::String pretty = PrettyPrint(text);
SkTArray<SkString> lines;
SkStrSplit(pretty.c_str(), "\n", kStrict_SkStrSplitMode, &lines);
for (int i = 0; i < lines.count(); ++i) {
SkDebugf("%4i\t%s\n", i + 1, lines[i].c_str());
}
}
示例14: report_failures
static void report_failures(const SkTArray<SkString>& failures) {
if (failures.count() == 0) {
return;
}
SkDebugf("Failures:\n");
for (int i = 0; i < failures.count(); i++) {
SkDebugf(" %s\n", failures[i].c_str());
}
SkDebugf("%d failures.\n", failures.count());
}
示例15: find_or_append
static int find_or_append(SkTArray<sk_sp<T>>& array, T* obj) {
for (int i = 0; i < array.count(); i++) {
if (equals(array[i].get(), obj)) {
return i;
}
}
array.push_back(sk_ref_sp(obj));
return array.count() - 1;
}