void SkPipeCanvas::onDrawRegion(const SkRegion& region, const SkPaint& paint) { size_t size = region.writeToMemory(nullptr); unsigned extra = 0; if (fits_in(size, 24)) { extra = SkToUInt(size); } SkPipeWriter writer(this); writer.write32(pack_verb(SkPipeVerb::kDrawRegion, extra)); if (0 == extra) { writer.write32(size); } SkAutoSMalloc<2048> storage(size); region.writeToMemory(storage.get()); write_pad(&writer, storage.get(), size); write_paint(writer, paint, kGeometry_PaintUsage); }
void SkGPipeCanvas::onClipRegion(const SkRegion& region, SkRegion::Op rgnOp) { NOTIFY_SETUP(this); if (this->needOpBytes(region.writeToMemory(nullptr))) { this->writeOp(kClipRegion_DrawOp, 0, rgnOp); fWriter.writeRegion(region); } this->INHERITED::onClipRegion(region, rgnOp); }
void SkPictureRecord::onDrawRegion(const SkRegion& region, const SkPaint& paint) { // op + paint index + region size_t regionBytes = region.writeToMemory(nullptr); size_t size = 2 * kUInt32Size + regionBytes; size_t initialOffset = this->addDraw(DRAW_REGION, &size); this->addPaint(paint); fWriter.writeRegion(region); this->validate(initialOffset, size); }
size_t SkPictureRecord::recordClipRegion(const SkRegion& region, SkClipOp op) { // op + clip params + region size_t size = 2 * kUInt32Size + region.writeToMemory(nullptr); // recordRestoreOffsetPlaceholder doesn't always write an offset if (!fRestoreOffsetStack.isEmpty()) { // + restore offset size += kUInt32Size; } size_t initialOffset = this->addDraw(CLIP_REGION, &size); this->addRegion(region); this->addInt(ClipParams_pack(op, false)); size_t offset = this->recordRestoreOffsetPlaceholder(op); this->validate(initialOffset, size); return offset; }