bool SkRasterClip::op(const SkRasterClip& clip, SkRegion::Op op) { if (this->isBW() && clip.isBW()) { return fBW.op(clip.fBW, op); } else { SkAAClip tmp; const SkAAClip* other; if (this->isBW()) { this->convertToAA(); } if (clip.isBW()) { tmp.setRegion(clip.bwRgn()); other = &tmp; } else { other = &clip.aaRgn(); } return fAA.op(*other, op); } }
bool SkRasterClip::setPath(const SkPath& path, const SkRasterClip& clip, bool doAA) { if (clip.isBW()) { return this->setPath(path, clip.bwRgn(), doAA); } else { SkRegion tmp; tmp.setRect(clip.getBounds()); if (!this->setPath(path, clip, doAA)) { return false; } return this->op(clip, SkRegion::kIntersect_Op); } }
bool SkRasterClip::op(const SkRasterClip& clip, SkRegion::Op op) { AUTO_RASTERCLIP_VALIDATE(*this); clip.validate(); if (this->isBW() && clip.isBW()) { return fBW.op(clip.fBW, op); } else { SkAAClip tmp; const SkAAClip* other; if (this->isBW()) { this->convertToAA(); } if (clip.isBW()) { tmp.setRegion(clip.bwRgn()); other = &tmp; } else { other = &clip.aaRgn(); } return fAA.op(*other, op); } }
void SkScan::FillXRect(const SkXRect& xr, const SkRasterClip& clip, SkBlitter* blitter) { if (clip.isEmpty() || xr.isEmpty()) { return; } if (clip.isBW()) { FillXRect(xr, &clip.bwRgn(), blitter); return; } SkAAClipBlitterWrapper wrapper(clip, blitter); FillXRect(xr, &wrapper.getRgn(), wrapper.getBlitter()); }
void SkScan::FillTriangle(const SkPoint pts[], const SkRasterClip& clip, SkBlitter* blitter) { if (clip.isEmpty()) { return; } SkRect r; r.set(pts, 3); // If r is too large (larger than can easily fit in SkFixed) then we need perform geometric // clipping. This is a bit of work, so we just call the general FillPath() to handle it. // Use FixedMax/2 as the limit so we can subtract two edges and still store that in Fixed. const SkScalar limit = SK_MaxS16 >> 1; if (!SkRect::MakeLTRB(-limit, -limit, limit, limit).contains(r)) { SkPath path; path.addPoly(pts, 3, false); FillPath(path, clip, blitter); return; } SkIRect ir = conservative_round_to_int(r); if (ir.isEmpty() || !SkIRect::Intersects(ir, clip.getBounds())) { return; } SkAAClipBlitterWrapper wrap; const SkRegion* clipRgn; if (clip.isBW()) { clipRgn = &clip.bwRgn(); } else { wrap.init(clip, blitter); clipRgn = &wrap.getRgn(); blitter = wrap.getBlitter(); } SkScanClipper clipper(blitter, clipRgn, ir); blitter = clipper.getBlitter(); if (blitter) { sk_fill_triangle(pts, clipper.getClipRect(), blitter, ir); } }