static uint32_t pack_paint_flags(unsigned flags, unsigned hint, unsigned align, unsigned filter, unsigned flatFlags) { ASSERT_FITS_IN(flags, kFlags_BPF); ASSERT_FITS_IN(hint, kHint_BPF); ASSERT_FITS_IN(align, kAlign_BPF); ASSERT_FITS_IN(filter, kFilter_BPF); ASSERT_FITS_IN(flatFlags, kFlatFlags_BPF); // left-align the fields of "known" size, and right-align the last (flatFlags) so it can easly // add more bits in the future. return (flags << 16) | (hint << 14) | (align << 12) | (filter << 10) | flatFlags; }
static uint32_t pack_paint_flags(unsigned flags, unsigned hint, unsigned align, unsigned filter, unsigned style, unsigned caps, unsigned joins, unsigned encoding) { SkASSERT(kFlags_BPF + kHint_BPF + kAlign_BPF + kFilter_BPF <= 32); ASSERT_FITS_IN(flags, kFlags_BPF); ASSERT_FITS_IN(filter, kFilter_BPF); ASSERT_FITS_IN(style, kStyle_BPF); ASSERT_FITS_IN(caps, kCaps_BPF); ASSERT_FITS_IN(joins, kJoins_BPF); ASSERT_FITS_IN(hint, kHint_BPF); ASSERT_FITS_IN(align, kAlign_BPF); ASSERT_FITS_IN(encoding, kEncoding_BPF); // left-align the fields of "known" size, and right-align the last (flatFlags) so it can easly // add more bits in the future. uint32_t packed = 0; int shift = 32; shift -= kFlags_BPF; packed |= (flags << shift); shift -= kFilter_BPF; packed |= (filter << shift); shift -= kStyle_BPF; packed |= (style << shift); // these are only needed for stroking (geometry or text) shift -= kCaps_BPF; packed |= (caps << shift); shift -= kJoins_BPF; packed |= (joins << shift); // these are only needed for text shift -= kHint_BPF; packed |= (hint << shift); shift -= kAlign_BPF; packed |= (align << shift); shift -= kEncoding_BPF; packed |= (encoding << shift); return packed; }
int SkPipeDeduper::findOrDefinePicture(SkPicture* picture) { int index = fPictures.find(picture->uniqueID()); SkASSERT(index >= 0); if (index) { if (show_deduper_traffic) { SkDebugf(" reusePicture(%d)\n", index - 1); } return index; } size_t prevWritten = fStream->bytesWritten(); unsigned extra = 0; // 0 means we're defining a new picture, non-zero means undef_index + 1 fStream->write32(pack_verb(SkPipeVerb::kDefinePicture, extra)); const SkRect cull = picture->cullRect(); fStream->write(&cull, sizeof(cull)); picture->playback(fPipeCanvas); // call fPictures.add *after* we're written the picture, so that any nested pictures will have // already been defined, and we get the "last" index value. index = fPictures.add(picture->uniqueID()); ASSERT_FITS_IN(index, kObjectDefinitionBits); fStream->write32(pack_verb(SkPipeVerb::kEndPicture, index)); SkDebugf(" definePicture(%d) %d\n", index - 1, SkToU32(fStream->bytesWritten() - prevWritten)); return index; }