本文整理汇总了C++中SkToU32函数的典型用法代码示例。如果您正苦于以下问题:C++ SkToU32函数的具体用法?C++ SkToU32怎么用?C++ SkToU32使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SkToU32函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: b
void GrVkPipelineState::BuildStateKey(const GrPipeline& pipeline, GrPrimitiveType primitiveType,
SkTArray<uint8_t, true>* key) {
// Save room for the key length and key header
key->reset();
key->push_back_n(kData_StateKeyOffset);
GrProcessorKeyBuilder b(key);
GrVkRenderTarget* vkRT = (GrVkRenderTarget*)pipeline.getRenderTarget();
vkRT->simpleRenderPass()->genKey(&b);
pipeline.getStencil().genKey(&b);
SkASSERT(sizeof(GrPipelineBuilder::DrawFace) <= sizeof(uint32_t));
b.add32(pipeline.getDrawFace());
b.add32(get_blend_info_key(pipeline));
b.add32(primitiveType);
// Set key length
int keyLength = key->count();
SkASSERT(0 == (keyLength % 4));
*reinterpret_cast<uint32_t*>(key->begin()) = SkToU32(keyLength);
}
示例2: read_string
static void read_string(SkStream* stream, SkString* string) {
const uint32_t length = SkToU32(stream->readPackedUInt());
if (length > 0) {
string->resize(length);
stream->read(string->writable_str(), length);
}
}
示例3: SkASSERT
int SkPipeDeduper::findOrDefineFactory(SkFlattenable* flattenable) {
if (!flattenable) {
return 0;
}
int index = fFactories.find(flattenable->getFactory());
SkASSERT(index >= 0);
if (index) {
if (show_deduper_traffic) {
SkDebugf(" reuseFactory(%d)\n", index - 1);
}
return index;
}
index = fFactories.add(flattenable->getFactory());
ASSERT_FITS_IN(index, kIndex_DefineFactoryExtraBits);
const char* name = flattenable->getTypeName();
size_t len = strlen(name);
ASSERT_FITS_IN(len, kNameLength_DefineFactoryExtraBits);
unsigned extra = (index << kNameLength_DefineFactoryExtraBits) | len;
size_t prevWritten = fStream->bytesWritten();
fStream->write32(pack_verb(SkPipeVerb::kDefineFactory, extra));
write_pad(fStream, name, len + 1);
if (false) {
SkDebugf(" defineFactory(%d) %d %s\n",
index - 1, SkToU32(fStream->bytesWritten() - prevWritten), name);
}
return index;
}
示例4: write_encoded_bitmap
static void write_encoded_bitmap(SkWriteBuffer* buffer, SkData* data,
const SkIPoint& origin) {
buffer->writeUInt(SkToU32(data->size()));
buffer->getWriter32()->writePad(data->data(), data->size());
buffer->write32(origin.fX);
buffer->write32(origin.fY);
}
示例5: stream_peek_test
// Asserts that asset == expected and is peekable.
static void stream_peek_test(skiatest::Reporter* rep,
SkStreamAsset* asset,
const SkData* expected) {
if (asset->getLength() != expected->size()) {
ERRORF(rep, "Unexpected length.");
return;
}
SkRandom rand;
uint8_t buffer[4096];
const uint8_t* expect = expected->bytes();
for (size_t i = 0; i < asset->getLength(); ++i) {
uint32_t maxSize =
SkToU32(SkTMin(sizeof(buffer), asset->getLength() - i));
size_t size = rand.nextRangeU(1, maxSize);
SkASSERT(size >= 1);
SkASSERT(size <= sizeof(buffer));
SkASSERT(size + i <= asset->getLength());
if (asset->peek(buffer, size) < size) {
ERRORF(rep, "Peek Failed!");
return;
}
if (0 != memcmp(buffer, &expect[i], size)) {
ERRORF(rep, "Peek returned wrong bytes!");
return;
}
uint8_t value;
REPORTER_ASSERT(rep, 1 == asset->read(&value, 1));
if (value != expect[i]) {
ERRORF(rep, "Read Failed!");
return;
}
}
}
示例6: SkToU32
size_t SkPictureRecord::recordRestoreOffsetPlaceholder(SkClipOp op) {
if (fRestoreOffsetStack.isEmpty()) {
return -1;
}
// The RestoreOffset field is initially filled with a placeholder
// value that points to the offset of the previous RestoreOffset
// in the current stack level, thus forming a linked list so that
// the restore offsets can be filled in when the corresponding
// restore command is recorded.
int32_t prevOffset = fRestoreOffsetStack.top();
if (clipOpExpands(op)) {
// Run back through any previous clip ops, and mark their offset to
// be 0, disabling their ability to trigger a jump-to-restore, otherwise
// they could hide this clips ability to expand the clip (i.e. go from
// empty to non-empty).
this->fillRestoreOffsetPlaceholdersForCurrentStackLevel(0);
// Reset the pointer back to the previous clip so that subsequent
// restores don't overwrite the offsets we just cleared.
prevOffset = 0;
}
size_t offset = fWriter.bytesWritten();
this->addInt(prevOffset);
fRestoreOffsetStack.top() = SkToU32(offset);
return offset;
}
示例7: writer
void SkPipeCanvas::onDrawPoints(PointMode mode, size_t count, const SkPoint pts[],
const SkPaint& paint) {
SkPipeWriter writer(this);
writer.write32(pack_verb(SkPipeVerb::kDrawPoints, mode));
writer.write32(SkToU32(count));
writer.write(pts, count * sizeof(SkPoint));
write_paint(writer, paint, kGeometry_PaintUsage | kRespectsStroke_PaintUsage);
}
示例8: writeStream
size_t SkBinaryWriteBuffer::writeStream(SkStream* stream, size_t length) {
fWriter.write32(SkToU32(length));
size_t bytesWritten = fWriter.readFromStream(stream, length);
if (bytesWritten < length) {
fWriter.reservePad(length - bytesWritten);
}
return bytesWritten;
}
示例9: SkToU32
void SkPictureStateTree::appendNode(size_t offset) {
Node* n = static_cast<Node*>(fAlloc.allocThrow(sizeof(Node)));
n->fOffset = SkToU32(offset);
n->fFlags = 0;
n->fParent = fCurrentState.fNode;
n->fLevel = fCurrentState.fNode->fLevel + 1;
n->fMatrix = fCurrentState.fMatrix;
fCurrentState.fNode = n;
}
示例10: write_int32_to_buffer
/*static*/ bool SkBitmapHasher::ComputeDigestInternal(const SkBitmap& bitmap, uint64_t *result) {
SkMD5 out;
// start with the x/y dimensions
write_int32_to_buffer(SkToU32(bitmap.width()), &out);
write_int32_to_buffer(SkToU32(bitmap.height()), &out);
// add all the pixel data
SkAutoTDelete<SkImageEncoder> enc(CreateARGBImageEncoder());
if (!enc->encodeStream(&out, bitmap, SkImageEncoder::kDefaultQuality)) {
return false;
}
SkMD5::Digest digest;
out.finish(digest);
*result = first_8_bytes_as_uint64(digest.data);
return true;
}
示例11: SkASSERT
void GrGLProgramDesc::finalize() {
int keyLength = fKey.count();
SkASSERT(0 == (keyLength % 4));
*this->atOffset<uint32_t, kLengthOffset>() = SkToU32(keyLength);
uint32_t* checksum = this->atOffset<uint32_t, kChecksumOffset>();
*checksum = 0;
*checksum = SkChecksum::Compute(reinterpret_cast<uint32_t*>(fKey.begin()), keyLength);
}
示例12: strlen
void SkPipeCanvas::onDrawAnnotation(const SkRect& rect, const char key[], SkData* data) {
const size_t len = strlen(key) + 1; // must write the trailing 0
bool compact = fits_in(len, 23);
uint32_t extra = compact ? (unsigned)len : 0;
extra <<= 1; // make room for has_data_sentinel
if (data) {
extra |= 1;
}
fStream->write32(pack_verb(SkPipeVerb::kDrawAnnotation, extra));
fStream->write(&rect, sizeof(SkRect));
if (!compact) {
fStream->write32(SkToU32(len));
}
write_pad(fStream, key, len);
if (data) {
fStream->write32(SkToU32(data->size()));
write_pad(fStream, data->data(), data->size());
}
}
示例13: NOTIFY_SETUP
void SkGPipeCanvas::onDrawPoints(PointMode mode, size_t count,
const SkPoint pts[], const SkPaint& paint) {
if (count) {
NOTIFY_SETUP(this);
this->writePaint(paint);
if (this->needOpBytes(4 + count * sizeof(SkPoint))) {
this->writeOp(kDrawPoints_DrawOp, mode, 0);
fWriter.write32(SkToU32(count));
fWriter.write(pts, count * sizeof(SkPoint));
}
}
}
示例14: writeTypeface
static size_t writeTypeface(SkWriter32* writer, SkTypeface* typeface) {
SkASSERT(typeface);
SkDynamicMemoryWStream stream;
typeface->serialize(&stream);
size_t size = stream.getOffset();
if (writer) {
writer->write32(SkToU32(size));
SkAutoDataUnref data(stream.copyToData());
writer->writePad(data->data(), size);
}
return 4 + SkAlign4(size);
}
示例15: sizeof
/*static*/ bool SkBitmapHasher::ComputeDigestInternal(const SkBitmap& bitmap,
SkHashDigest *result) {
size_t pixelBufferSize = bitmap.width() * bitmap.height() * 4;
size_t totalBufferSize = pixelBufferSize + 2 * sizeof(uint32_t);
SkAutoMalloc bufferManager(totalBufferSize);
char *bufferStart = static_cast<char *>(bufferManager.get());
SkMemoryWStream out(bufferStart, totalBufferSize);
// start with the x/y dimensions
write_int_to_buffer(SkToU32(bitmap.width()), &out);
write_int_to_buffer(SkToU32(bitmap.height()), &out);
// add all the pixel data
SkAutoTDelete<SkImageEncoder> enc(CreateARGBImageEncoder());
if (!enc->encodeStream(&out, bitmap, SkImageEncoder::kDefaultQuality)) {
return false;
}
*result = SkCityHash::Compute64(bufferStart, totalBufferSize);
return true;
}