本文整理汇总了C++中SkString::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ SkString::isEmpty方法的具体用法?C++ SkString::isEmpty怎么用?C++ SkString::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkString
的用法示例。
在下文中一共展示了SkString::isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create_diff_images
/// If outputDir.isEmpty(), don't write out diff files.
static void create_diff_images (DiffMetricProc dmp,
const int colorThreshold,
const SkString& baseFile,
const SkString& comparisonFile,
const SkString& outputDir,
const SkString& outputFilename,
DiffRecord* drp) {
SkASSERT(!baseFile.isEmpty());
SkASSERT(!comparisonFile.isEmpty());
drp->fBase.fFilename = baseFile;
drp->fBase.fFullPath = baseFile;
drp->fBase.fStatus = DiffResource::kSpecified_Status;
drp->fComparison.fFilename = comparisonFile;
drp->fComparison.fFullPath = comparisonFile;
drp->fComparison.fStatus = DiffResource::kSpecified_Status;
SkAutoDataUnref baseFileBits(read_file(drp->fBase.fFullPath.c_str()));
if (baseFileBits) {
drp->fBase.fStatus = DiffResource::kRead_Status;
}
SkAutoDataUnref comparisonFileBits(read_file(drp->fComparison.fFullPath.c_str()));
if (comparisonFileBits) {
drp->fComparison.fStatus = DiffResource::kRead_Status;
}
if (nullptr == baseFileBits || nullptr == comparisonFileBits) {
if (nullptr == baseFileBits) {
drp->fBase.fStatus = DiffResource::kCouldNotRead_Status;
}
if (nullptr == comparisonFileBits) {
drp->fComparison.fStatus = DiffResource::kCouldNotRead_Status;
}
drp->fResult = DiffRecord::kCouldNotCompare_Result;
return;
}
if (are_buffers_equal(baseFileBits, comparisonFileBits)) {
drp->fResult = DiffRecord::kEqualBits_Result;
return;
}
get_bitmap(baseFileBits, drp->fBase, SkImageDecoder::kDecodePixels_Mode);
get_bitmap(comparisonFileBits, drp->fComparison, SkImageDecoder::kDecodePixels_Mode);
if (DiffResource::kDecoded_Status != drp->fBase.fStatus ||
DiffResource::kDecoded_Status != drp->fComparison.fStatus)
{
drp->fResult = DiffRecord::kCouldNotCompare_Result;
return;
}
create_and_write_diff_image(drp, dmp, colorThreshold, outputDir, outputFilename);
//TODO: copy fBase.fFilename and fComparison.fFilename to outputDir
// svn and git often present tmp files to diff tools which are promptly deleted
//TODO: serialize drp to outputDir
// write a tool to deserialize them and call print_diff_page
SkASSERT(DiffRecord::kUnknown_Result != drp->fResult);
}
示例2: tface
void SkSVGDevice::AutoElement::addTextAttributes(const SkPaint& paint) {
this->addAttribute("font-size", paint.getTextSize());
if (const char* textAlign = svg_text_align(paint.getTextAlign())) {
this->addAttribute("text-anchor", textAlign);
}
SkString familyName;
SkTHashSet<SkString> familySet;
SkAutoTUnref<const SkTypeface> tface(paint.getTypeface() ?
SkRef(paint.getTypeface()) : SkTypeface::RefDefault());
SkASSERT(tface);
SkTypeface::Style style = tface->style();
if (style & SkTypeface::kItalic) {
this->addAttribute("font-style", "italic");
}
if (style & SkTypeface::kBold) {
this->addAttribute("font-weight", "bold");
}
SkAutoTUnref<SkTypeface::LocalizedStrings> familyNameIter(tface->createFamilyNameIterator());
SkTypeface::LocalizedString familyString;
while (familyNameIter->next(&familyString)) {
if (familySet.contains(familyString.fString)) {
continue;
}
familySet.add(familyString.fString);
familyName.appendf((familyName.isEmpty() ? "%s" : ", %s"), familyString.fString.c_str());
}
if (!familyName.isEmpty()) {
this->addAttribute("font-family", familyName);
}
}
示例3: SkASSERT
DEF_GPUTEST_FOR_ALL_CONTEXTS(GrDrawTargetPrint, reporter, ctxInfo) {
// This used to assert.
SkString result = ctxInfo.fGrContext->caps()->dump();
SkASSERT(!result.isEmpty());
SkString shaderResult = ctxInfo.fGrContext->caps()->shaderCaps()->dump();
SkASSERT(!shaderResult.isEmpty());
}
示例4: run_test
static void run_test(skiatest::Test* test) {
struct : public skiatest::Reporter {
void reportFailed(const skiatest::Failure& failure) override {
fail(failure.toString());
JsonWriter::AddTestFailure(failure);
}
bool allowExtendedTest() const override {
return FLAGS_pathOpsExtended;
}
bool verbose() const override { return FLAGS_veryVerbose; }
} reporter;
SkString note;
SkString whyBlacklisted = is_blacklisted("_", "tests", "_", test->name);
if (!whyBlacklisted.isEmpty()) {
note.appendf(" (--blacklist %s)", whyBlacklisted.c_str());
}
WallTimer timer;
timer.start();
if (!FLAGS_dryRun && whyBlacklisted.isEmpty()) {
start("unit", "test", "", test->name);
GrContextFactory factory;
if (FLAGS_pre_log) {
SkDebugf("\nRunning test %s", test->name);
}
test->proc(&reporter, &factory);
}
timer.end();
done(timer.fWall, "unit", "test", "", test->name, note, "");
}
示例5: write_string
static void write_string(SkWStream* stream, const SkString& string, uint32_t id) {
if (!string.isEmpty()) {
stream->writePackedUInt(id);
stream->writePackedUInt(string.size());
stream->write(string.c_str(), string.size());
}
}
示例6: getFamilyNameForCharacter
static AtomicString getFamilyNameForCharacter(UChar32 c, UScriptCode script)
{
// This is a hack to use the preferred font for CJK scripts.
// FIXME: Use new Skia API once Android system supports per-family and per-script fallback fonts.
const char* locale;
switch (script) {
case USCRIPT_SIMPLIFIED_HAN:
locale = "zh-CN";
break;
case USCRIPT_TRADITIONAL_HAN:
locale = "zh-TW";
break;
case USCRIPT_KATAKANA_OR_HIRAGANA:
locale = "ja";
break;
case USCRIPT_HANGUL:
locale = "ko";
break;
default:
locale = 0;
break;
}
SkString skiaFamilyName;
if (!SkGetFallbackFamilyNameForChar(c, locale, &skiaFamilyName) || skiaFamilyName.isEmpty())
return emptyAtom;
return skiaFamilyName.c_str();
}
示例7: test_abortWithFile
static void test_abortWithFile(skiatest::Reporter* reporter) {
SkString tmpDir = skiatest::GetTmpDir();
if (tmpDir.isEmpty()) {
return; // TODO(edisonn): unfortunatelly this pattern is used in other
// tests, but if GetTmpDir() starts returning and empty dir
// allways, then all these tests will be disabled.
}
SkString path = SkOSPath::Join(tmpDir.c_str(), "aborted.pdf");
// Make sure doc's destructor is called to flush.
{
SkAutoTUnref<SkDocument> doc(SkDocument::CreatePDF(path.c_str()));
SkCanvas* canvas = doc->beginPage(100, 100);
canvas->drawColor(SK_ColorRED);
doc->endPage();
doc->abort();
}
FILE* file = fopen(path.c_str(), "r");
// The created file should be empty.
char buffer[100];
REPORTER_ASSERT(reporter, fread(buffer, 1, 1, file) == 0);
fclose(file);
}
示例8: test_files
static void test_files(skiatest::Reporter* reporter) {
SkString tmpDir = skiatest::Test::GetTmpDir();
if (tmpDir.isEmpty()) {
return;
}
SkString path = SkOSPath::SkPathJoin(tmpDir.c_str(), "data_test");
const char s[] = "abcdefghijklmnopqrstuvwxyz";
{
SkFILEWStream writer(path.c_str());
if (!writer.isValid()) {
ERRORF(reporter, "Failed to create tmp file %s\n", path.c_str());
return;
}
writer.write(s, 26);
}
SkFILE* file = sk_fopen(path.c_str(), kRead_SkFILE_Flag);
SkAutoTUnref<SkData> r1(SkData::NewFromFILE(file));
REPORTER_ASSERT(reporter, r1.get() != NULL);
REPORTER_ASSERT(reporter, r1->size() == 26);
REPORTER_ASSERT(reporter, strncmp(static_cast<const char*>(r1->data()), s, 26) == 0);
int fd = sk_fileno(file);
SkAutoTUnref<SkData> r2(SkData::NewFromFD(fd));
REPORTER_ASSERT(reporter, r2.get() != NULL);
REPORTER_ASSERT(reporter, r2->size() == 26);
REPORTER_ASSERT(reporter, strncmp(static_cast<const char*>(r2->data()), s, 26) == 0);
}
示例9: face
static sk_sp<SkTypeface_AndroidSystem> find_family_style_character(
const SkTArray<NameToFamily, true>& fallbackNameToFamilyMap,
const SkFontStyle& style, bool elegant,
const SkString& langTag, SkUnichar character)
{
for (int i = 0; i < fallbackNameToFamilyMap.count(); ++i) {
SkFontStyleSet_Android* family = fallbackNameToFamilyMap[i].styleSet;
sk_sp<SkTypeface_AndroidSystem> face(family->matchStyle(style));
if (!langTag.isEmpty() && !face->fLang.getTag().startsWith(langTag.c_str())) {
continue;
}
if (SkToBool(face->fVariantStyle & kElegant_FontVariant) != elegant) {
continue;
}
SkPaint paint;
paint.setTypeface(face);
paint.setTextEncoding(SkPaint::kUTF32_TextEncoding);
uint16_t glyphID;
paint.textToGlyphs(&character, sizeof(character), &glyphID);
if (glyphID != 0) {
return face;
}
}
return nullptr;
}
示例10: test_file
static void test_file(skiatest::Reporter* reporter) {
SkString tmpDir = skiatest::GetTmpDir();
if (tmpDir.isEmpty()) {
return; // TODO(edisonn): unfortunatelly this pattern is used in other
// tests, but if GetTmpDir() starts returning and empty dir
// allways, then all these tests will be disabled.
}
SkString path = SkOSPath::Join(tmpDir.c_str(), "file.pdf");
SkAutoTUnref<SkDocument> doc(SkDocument::CreatePDF(path.c_str()));
SkCanvas* canvas = doc->beginPage(100, 100);
canvas->drawColor(SK_ColorRED);
doc->endPage();
doc->close();
FILE* file = fopen(path.c_str(), "r");
REPORTER_ASSERT(reporter, file != nullptr);
char header[100];
REPORTER_ASSERT(reporter, fread(header, 4, 1, file) != 0);
REPORTER_ASSERT(reporter, strncmp(header, "%PDF", 4) == 0);
fclose(file);
}
示例11: main
int main(int argc, char *argv[]) {
QApplication a(argc, argv);
QStringList argList = a.arguments();
if (argList.count() <= 0) {
return -1; // should at least have command name
}
SkString input;
QStringList::const_iterator iter = argList.begin();
SkString commandName(iter->toAscii().data());
++iter; // skip the command name
for ( ; iter != argList.end(); ++iter) {
if (0 == iter->compare("--help") || 0 == iter->compare("-h")) {
usage(commandName.c_str());
return -1;
} else if (input.isEmpty()) {
input = SkString(iter->toAscii().data());
} else {
usage(commandName.c_str());
return -1;
}
}
SkDebuggerGUI w;
if (!input.isEmpty()) {
if (SkStrEndsWith(input.c_str(), ".skp")) {
w.openFile(input.c_str());
} else {
w.setupDirectoryWidget(input.c_str());
}
}
w.show();
return a.exec();
}
示例12: parse_option_int
static bool parse_option_int(const SkString& value, int* outInt) {
if (value.isEmpty()) {
return false;
}
char* endptr = nullptr;
long intValue = strtol(value.c_str(), &endptr, 10);
if (*endptr != '\0') {
return false;
}
*outInt = static_cast<int>(intValue);
return true;
}
示例13: create_and_write_diff_image
void create_and_write_diff_image(DiffRecord* drp,
DiffMetricProc dmp,
const int colorThreshold,
const SkString& outputDir,
const SkString& filename) {
const int w = drp->fBase.fBitmap.width();
const int h = drp->fBase.fBitmap.height();
if (w != drp->fComparison.fBitmap.width() || h != drp->fComparison.fBitmap.height()) {
drp->fResult = DiffRecord::kDifferentSizes_Result;
} else {
drp->fDifference.fBitmap.setConfig(SkBitmap::kARGB_8888_Config, w, h);
drp->fDifference.fBitmap.allocPixels();
drp->fWhite.fBitmap.setConfig(SkBitmap::kARGB_8888_Config, w, h);
drp->fWhite.fBitmap.allocPixels();
SkASSERT(DiffRecord::kUnknown_Result == drp->fResult);
compute_diff(drp, dmp, colorThreshold);
SkASSERT(DiffRecord::kUnknown_Result != drp->fResult);
}
if (outputDir.isEmpty()) {
drp->fDifference.fStatus = DiffResource::kUnspecified_Status;
drp->fWhite.fStatus = DiffResource::kUnspecified_Status;
} else {
drp->fDifference.fFilename = filename_to_diff_filename(filename);
drp->fDifference.fFullPath = outputDir;
drp->fDifference.fFullPath.append(drp->fDifference.fFilename);
drp->fDifference.fStatus = DiffResource::kSpecified_Status;
drp->fWhite.fFilename = filename_to_white_filename(filename);
drp->fWhite.fFullPath = outputDir;
drp->fWhite.fFullPath.append(drp->fWhite.fFilename);
drp->fWhite.fStatus = DiffResource::kSpecified_Status;
if (DiffRecord::kDifferentPixels_Result == drp->fResult) {
if (write_bitmap(drp->fDifference.fFullPath, drp->fDifference.fBitmap)) {
drp->fDifference.fStatus = DiffResource::kExists_Status;
} else {
drp->fDifference.fStatus = DiffResource::kDoesNotExist_Status;
}
if (write_bitmap(drp->fWhite.fFullPath, drp->fWhite.fBitmap)) {
drp->fWhite.fStatus = DiffResource::kExists_Status;
} else {
drp->fWhite.fStatus = DiffResource::kDoesNotExist_Status;
}
}
}
}
示例14: get_file_list_subdir
/// Internal (potentially recursive) implementation of get_file_list.
static void get_file_list_subdir(const SkString& rootDir, const SkString& subDir,
const StringArray& matchSubstrings,
const StringArray& nomatchSubstrings,
bool recurseIntoSubdirs, FileArray *files) {
bool isSubDirEmpty = subDir.isEmpty();
SkString dir(rootDir);
if (!isSubDirEmpty) {
dir.append(PATH_DIV_STR);
dir.append(subDir);
}
// Iterate over files (not directories) within dir.
SkOSFile::Iter fileIterator(dir.c_str());
SkString fileName;
while (fileIterator.next(&fileName, false)) {
if (fileName.startsWith(".")) {
continue;
}
SkString pathRelativeToRootDir(subDir);
if (!isSubDirEmpty) {
pathRelativeToRootDir.append(PATH_DIV_STR);
}
pathRelativeToRootDir.append(fileName);
if (string_contains_any_of(pathRelativeToRootDir, matchSubstrings) &&
!string_contains_any_of(pathRelativeToRootDir, nomatchSubstrings)) {
files->push(new SkString(pathRelativeToRootDir));
}
}
// Recurse into any non-ignored subdirectories.
if (recurseIntoSubdirs) {
SkOSFile::Iter dirIterator(dir.c_str());
SkString dirName;
while (dirIterator.next(&dirName, true)) {
if (dirName.startsWith(".")) {
continue;
}
SkString pathRelativeToRootDir(subDir);
if (!isSubDirEmpty) {
pathRelativeToRootDir.append(PATH_DIV_STR);
}
pathRelativeToRootDir.append(dirName);
if (!string_contains_any_of(pathRelativeToRootDir, nomatchSubstrings)) {
get_file_list_subdir(rootDir, pathRelativeToRootDir,
matchSubstrings, nomatchSubstrings, recurseIntoSubdirs,
files);
}
}
}
}
示例15: CreateTypefaceFromStream
SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) {
if (NULL == stream || stream->getLength() <= 0) {
return NULL;
}
bool isFixedWidth;
SkString name;
SkTypeface::Style style;
find_name_and_attributes(stream, &name, &style, &isFixedWidth);
if (!name.isEmpty()) {
return SkNEW_ARGS(StreamTypeface, (style, false, NULL, stream, isFixedWidth));
} else {
return NULL;
}
}