本文整理汇总了C++中SkMemoryStream::setMemoryOwned方法的典型用法代码示例。如果您正苦于以下问题:C++ SkMemoryStream::setMemoryOwned方法的具体用法?C++ SkMemoryStream::setMemoryOwned怎么用?C++ SkMemoryStream::setMemoryOwned使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkMemoryStream
的用法示例。
在下文中一共展示了SkMemoryStream::setMemoryOwned方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: content
SkStream* SkPDFDevice::content() const {
size_t offset = fContent.getOffset();
char* data = (char*)sk_malloc_throw(offset + fGraphicStackIndex * 2);
fContent.copyTo(data);
for (int i = 0; i < fGraphicStackIndex; i++) {
data[offset++] = 'Q';
data[offset++] = '\n';
}
SkMemoryStream* result = new SkMemoryStream;
result->setMemoryOwned(data, offset);
return result;
}
示例2: buildSkMemoryStream
static SkMemoryStream* buildSkMemoryStream(SkStream *stream) {
size_t bufferSize = 4096;
size_t streamLen = 0;
size_t len;
char* data = (char*)sk_malloc_throw(bufferSize);
while ((len = stream->read(data + streamLen,
bufferSize - streamLen)) != 0) {
streamLen += len;
if (streamLen == bufferSize) {
bufferSize *= 2;
data = (char*)sk_realloc_throw(data, bufferSize);
}
}
data = (char*)sk_realloc_throw(data, streamLen);
SkMemoryStream* streamMem = new SkMemoryStream();
streamMem->setMemoryOwned(data, streamLen);
return streamMem;
}