本文整理汇总了C++中SkString::reset方法的典型用法代码示例。如果您正苦于以下问题:C++ SkString::reset方法的具体用法?C++ SkString::reset怎么用?C++ SkString::reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkString
的用法示例。
在下文中一共展示了SkString::reset方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_get_basename
static void test_get_basename(skiatest::Reporter* reporter) {
SkString result;
SkString path("/path/basename");
sk_tools::get_basename(&result, path);
REPORTER_ASSERT(reporter, result.equals("basename"));
result.reset();
path.set("/path/dir/");
sk_tools::get_basename(&result, path);
REPORTER_ASSERT(reporter, result.equals("dir"));
result.reset();
path.set("path");
sk_tools::get_basename(&result, path);
REPORTER_ASSERT(reporter, result.equals("path"));
#if defined(SK_BUILD_FOR_WIN)
result.reset();
path.set("path\\winbasename");
sk_tools::get_basename(&result, path);
REPORTER_ASSERT(reporter, result.equals("winbasename"));
result.reset();
path.set("path\\windir\\");
sk_tools::get_basename(&result, path);
REPORTER_ASSERT(reporter, result.equals("windir"));
#endif
}
示例2: SkStringFromMacRoman
static void SkStringFromMacRoman(const uint8_t* macRoman, size_t length, SkString& utf8) {
utf8.reset();
for (size_t i = 0; i < length; ++i) {
utf8.appendUnichar(macRoman[i] < 0x80 ? macRoman[i]
: UnicodeFromMacRoman[macRoman[i] - 0x80]);
}
}
示例3: SkASSERT
static void SkStringFromUTF16BE(const uint16_t* utf16be, size_t length, SkString& utf8) {
SkASSERT(utf16be != NULL);
utf8.reset();
size_t numberOf16BitValues = length / 2;
const uint16_t* end = utf16be + numberOf16BitValues;
while (utf16be < end) {
utf8.appendUnichar(SkUTF16BE_NextUnichar(&utf16be));
}
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_skia_src,代码行数:10,代码来源:SkOTTable_name.cpp
示例4: onDrawContent
void onDrawContent(SkCanvas* canvas) override {
fCell.set(this->height() / 2, this->height() / 2);
SkScalar trans[2];
fTrans.timeToValues(fCurrTime, trans);
for (int y = 0; y < 2; ++y) {
for (int x = 0; x < 2; ++x) {
int index = y * 2 + x;
SkAutoCanvasRestore acr(canvas, true);
canvas->translate(fCell.width() * x, fCell.height() * y);
SkRect r = SkRect::MakeWH(fCell.width(), fCell.height());
r.inset(4, 4);
canvas->clipRect(r);
this->drawHere(canvas, SkFilterQuality(index), trans[0], trans[1]);
}
}
this->drawBorders(canvas);
const SkScalar textX = fCell.width() * 2 + 30;
SkPaint paint;
paint.setAntiAlias(true);
paint.setTextSize(36);
SkString str;
str.appendScalar(fScale);
canvas->drawText(str.c_str(), str.size(), textX, 100, paint);
str.reset(); str.appendScalar(fAngle);
canvas->drawText(str.c_str(), str.size(), textX, 150, paint);
str.reset(); str.appendScalar(trans[0]);
canvas->drawText(str.c_str(), str.size(), textX, 200, paint);
str.reset(); str.appendScalar(trans[1]);
canvas->drawText(str.c_str(), str.size(), textX, 250, paint);
}
示例5: translateMatrix
void SkSVGParser::translateMatrix(SkString& string, SkString* stringID) {
if (string.size() == 0)
return;
if (stringID->size() > 0) {
_startElement("add");
_addAttribute("use", stringID->c_str());
_endElement(); // add
return;
}
SkASSERT(strncmp(string.c_str(), "matrix", 6) == 0);
++gGeneratedMatrixID;
_startElement("matrix");
char idStr[24];
strcpy(idStr, "sk_matrix");
sprintf(idStr + strlen(idStr), "%d", gGeneratedMatrixID);
_addAttribute("id", idStr);
stringID->set(idStr);
const char* str = string.c_str();
SkASSERT(strncmp(str, "matrix(", 7) == 0);
str += 6;
const char* strEnd = strrchr(str, ')');
SkASSERT(strEnd != NULL);
SkString mat(str, strEnd - str);
ConvertToArray(mat);
const char* elems[6];
static const int order[] = {0, 3, 1, 4, 2, 5};
const int* orderPtr = order;
str = mat.c_str();
strEnd = str + mat.size();
while (str < strEnd) {
elems[*orderPtr++] = str;
while (str < strEnd && *str != ',' )
str++;
str++;
}
string.reset();
for (int index = 0; index < 6; index++) {
const char* end = strchr(elems[index], ',');
if (end == NULL)
end= strchr(elems[index], ']');
string.append(elems[index], end - elems[index] + 1);
}
string.remove(string.size() - 1, 1);
string.append(",0,0,1]");
_addAttribute("matrix", string);
_endElement(); // matrix
}
示例6: CreateTable
static void CreateTable() {
SkString comment;
size_t originalSize = 0;
int replacement = 0;
for (int index = 0; index < colorNamesSize; index++) {
SkNameRGB nameRGB = colorNames[index];
const char* name = nameRGB.name;
size_t len = strlen(name);
originalSize += len + 9;
bool first = true;
bool last = false;
do {
int compressed = 0;
const char* start = name;
for (int chIndex = 0; chIndex < 6; chIndex++) {
compressed <<= 5;
compressed |= *name ? *name++ - 'a' + 1 : 0 ;
}
replacement += sizeof(int);
compressed <<= 1;
compressed |= 1;
if (first) {
compressed |= 0x80000000;
first = false;
}
if (len <= 6) { // last
compressed &= ~1;
last = true;
}
len -= 6;
SkDebugf("0x%08x, ", compressed);
comment.append(start, name - start);
} while (last == false);
replacement += sizeof(int);
SkDebugf("0x%08x, ", nameRGB.rgb);
SkDebugf("// %s\n", comment.c_str());
comment.reset();
}
SkDebugf("// original = %d : replacement = %d\n", originalSize, replacement);
SkASSERT(0); // always stop after creating table
}
示例7: TestString
static void TestString(skiatest::Reporter* reporter) {
SkString a;
SkString b((size_t)0);
SkString c("");
SkString d(NULL, 0);
REPORTER_ASSERT(reporter, a.isEmpty());
REPORTER_ASSERT(reporter, a == b && a == c && a == d);
a.set("hello");
b.set("hellox", 5);
c.set(a);
d.resize(5);
memcpy(d.writable_str(), "helloz", 5);
REPORTER_ASSERT(reporter, !a.isEmpty());
REPORTER_ASSERT(reporter, a.size() == 5);
REPORTER_ASSERT(reporter, a == b && a == c && a == d);
REPORTER_ASSERT(reporter, a.equals("hello", 5));
REPORTER_ASSERT(reporter, a.equals("hello"));
REPORTER_ASSERT(reporter, !a.equals("help"));
SkString e(a);
SkString f("hello");
SkString g("helloz", 5);
REPORTER_ASSERT(reporter, a == e && a == f && a == g);
b.set("world");
c = b;
REPORTER_ASSERT(reporter, a != b && a != c && b == c);
a.append(" world");
e.append("worldz", 5);
e.insert(5, " ");
f.set("world");
f.prepend("hello ");
REPORTER_ASSERT(reporter, a.equals("hello world") && a == e && a == f);
a.reset();
b.resize(0);
REPORTER_ASSERT(reporter, a.isEmpty() && b.isEmpty() && a == b);
a.set("a");
a.set("ab");
a.set("abc");
a.set("abcd");
a.set("");
a.appendS64(72036854775808LL, 0);
REPORTER_ASSERT(reporter, a.equals("72036854775808"));
a.set("");
a.appendS64(-1844674407370LL, 0);
REPORTER_ASSERT(reporter, a.equals("-1844674407370"));
a.set("");
a.appendS64(73709551616LL, 15);
REPORTER_ASSERT(reporter, a.equals("000073709551616"));
a.set("");
a.appendS64(-429496729612LL, 15);
REPORTER_ASSERT(reporter, a.equals("-000429496729612"));
}
示例8: TestString
static void TestString(skiatest::Reporter* reporter) {
SkString a;
SkString b((size_t)0);
SkString c("");
SkString d(NULL, 0);
REPORTER_ASSERT(reporter, a.isEmpty());
REPORTER_ASSERT(reporter, a == b && a == c && a == d);
a.set("hello");
b.set("hellox", 5);
c.set(a);
d.resize(5);
memcpy(d.writable_str(), "helloz", 5);
REPORTER_ASSERT(reporter, !a.isEmpty());
REPORTER_ASSERT(reporter, a.size() == 5);
REPORTER_ASSERT(reporter, a == b && a == c && a == d);
REPORTER_ASSERT(reporter, a.equals("hello", 5));
REPORTER_ASSERT(reporter, a.equals("hello"));
REPORTER_ASSERT(reporter, !a.equals("help"));
SkString e(a);
SkString f("hello");
SkString g("helloz", 5);
REPORTER_ASSERT(reporter, a == e && a == f && a == g);
b.set("world");
c = b;
REPORTER_ASSERT(reporter, a != b && a != c && b == c);
a.append(" world");
e.append("worldz", 5);
e.insert(5, " ");
f.set("world");
f.prepend("hello ");
REPORTER_ASSERT(reporter, a.equals("hello world") && a == e && a == f);
a.reset();
b.resize(0);
REPORTER_ASSERT(reporter, a.isEmpty() && b.isEmpty() && a == b);
a.set("a");
a.set("ab");
a.set("abc");
a.set("abcd");
a.set("");
a.appendS64(72036854775808LL, 0);
REPORTER_ASSERT(reporter, a.equals("72036854775808"));
a.set("");
a.appendS64(-1844674407370LL, 0);
REPORTER_ASSERT(reporter, a.equals("-1844674407370"));
a.set("");
a.appendS64(73709551616LL, 15);
REPORTER_ASSERT(reporter, a.equals("000073709551616"));
a.set("");
a.appendS64(-429496729612LL, 15);
REPORTER_ASSERT(reporter, a.equals("-000429496729612"));
static const struct {
SkScalar fValue;
const char* fString;
} gRec[] = {
{ 0, "0" },
{ SK_Scalar1, "1" },
{ -SK_Scalar1, "-1" },
{ SK_Scalar1/2, "0.5" },
#ifdef SK_SCALAR_IS_FLOAT
{ 3.4028234e38f, "3.4028235e+38" },
{ -3.4028234e38f, "-3.4028235e+38" },
#endif
};
for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) {
a.reset();
a.appendScalar(gRec[i].fValue);
REPORTER_ASSERT(reporter, a.size() <= SkStrAppendScalar_MaxSize);
// SkDebugf(" received <%s> expected <%s>\n", a.c_str(), gRec[i].fString);
REPORTER_ASSERT(reporter, a.equals(gRec[i].fString));
}
}