本文整理汇总了C++中SkString::writable_str方法的典型用法代码示例。如果您正苦于以下问题:C++ SkString::writable_str方法的具体用法?C++ SkString::writable_str怎么用?C++ SkString::writable_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkString
的用法示例。
在下文中一共展示了SkString::writable_str方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SkStringFromUTF16
SkString SkStringFromUTF16(const uint16_t* src, size_t count) {
SkString ret;
const uint16_t* stop = src + count;
if (count > 0) {
SkASSERT(src);
size_t n = 0;
const uint16_t* end = src + count;
for (const uint16_t* ptr = src; ptr < end;) {
const uint16_t* last = ptr;
SkUnichar u = SkUTF::NextUTF16(&ptr, stop);
size_t s = SkUTF::ToUTF8(u);
if (n > UINT32_MAX - s) {
end = last; // truncate input string
break;
}
n += s;
}
ret = SkString(n);
char* out = ret.writable_str();
for (const uint16_t* ptr = src; ptr < end;) {
out += SkUTF::ToUTF8(SkUTF::NextUTF16(&ptr, stop), out);
}
SkASSERT(out == ret.writable_str() + n);
}
return ret;
}
示例2: Deserialize
SkTypeface* SkFontHost::Deserialize(SkStream* stream) {
load_system_fonts();
int style = stream->readU8();
int len = stream->readPackedUInt();
if (len > 0) {
SkString str;
str.resize(len);
stream->read(str.writable_str(), len);
const FontInitRec* rec = gSystemFonts;
for (size_t i = 0; i < SK_ARRAY_COUNT(gSystemFonts); i++) {
if (strcmp(rec[i].fFileName, str.c_str()) == 0) {
// backup until we hit the fNames
for (int j = i; j >= 0; --j) {
if (rec[j].fNames != NULL) {
return SkFontHost::CreateTypeface(NULL,
rec[j].fNames[0], (SkTypeface::Style)style);
}
}
}
}
}
return NULL;
}
示例3: loadKernelStream
bool SkCLImageDiffer::loadKernelStream(SkStream* stream, const char name[], cl_kernel* kernel) {
// Read the kernel source into memory
SkString sourceString;
sourceString.resize(stream->getLength());
size_t bytesRead = stream->read(sourceString.writable_str(), sourceString.size());
if (bytesRead != sourceString.size()) {
SkDebugf("Failed to read kernel source file");
return false;
}
return loadKernelSource(sourceString.c_str(), name, kernel);
}
示例4: addAttributeLen
void SkXMLWriter::addAttributeLen(const char name[], const char value[], size_t length) {
SkString valueStr;
if (fDoEscapeMarkup) {
size_t extra = escape_markup(nullptr, value, length);
if (extra) {
valueStr.resize(length + extra);
(void)escape_markup(valueStr.writable_str(), value, length);
value = valueStr.c_str();
length += extra;
}
}
this->onAddAttributeLen(name, value, length);
}