Lines Matching refs:clip
15 static bool quick_reject(const SkRect& bounds, const SkRect& clip) {
16 return bounds.fTop >= clip.fBottom || bounds.fBottom <= clip.fTop;
48 bool SkEdgeClipper::clipLine(SkPoint p0, SkPoint p1, const SkRect& clip) {
54 int lineCount = SkLineClipper::ClipLine(pts, clip, lines, fCanCullToTheRight);
94 // Modify pts[] in place so that it is clipped in Y to the clip rect
95 static void chop_quad_in_Y(SkPoint pts[3], const SkRect& clip) {
100 if (pts[0].fY < clip.fTop) {
101 if (chopMonoQuadAtY(pts, clip.fTop, &t)) {
105 tmp[2].fY = clip.fTop;
106 clamp_ge(tmp[3].fY, clip.fTop);
114 if (pts[i].fY < clip.fTop) {
115 pts[i].fY = clip.fTop;
122 if (pts[2].fY > clip.fBottom) {
123 if (chopMonoQuadAtY(pts, clip.fBottom, &t)) {
126 clamp_le(tmp[1].fY, clip.fBottom);
127 tmp[2].fY = clip.fBottom;
135 if (pts[i].fY > clip.fBottom) {
136 pts[i].fY = clip.fBottom;
144 void SkEdgeClipper::clipMonoQuad(const SkPoint srcPts[3], const SkRect& clip) {
149 if (pts[2].fY <= clip.fTop || pts[0].fY >= clip.fBottom) {
153 // Now chop so that pts is contained within clip in Y
154 chop_quad_in_Y(pts, clip);
166 if (pts[2].fX <= clip.fLeft) { // wholly to the left
167 this->appendVLine(clip.fLeft, pts[0].fY, pts[2].fY, reverse);
170 if (pts[0].fX >= clip.fRight) { // wholly to the right
172 this->appendVLine(clip.fRight, pts[0].fY, pts[2].fY, reverse);
181 if (pts[0].fX < clip.fLeft) {
182 if (chopMonoQuadAtX(pts, clip.fLeft, &t)) {
184 this->appendVLine(clip.fLeft, tmp[0].fY, tmp[2].fY, reverse);
186 tmp[2].fX = clip.fLeft;
187 clamp_ge(tmp[3].fX, clip.fLeft);
194 this->appendVLine(clip.fLeft, pts[0].fY, pts[2].fY, reverse);
200 if (pts[2].fX > clip.fRight) {
201 if (chopMonoQuadAtX(pts, clip.fRight, &t)) {
204 clamp_le(tmp[1].fX, clip.fRight);
205 tmp[2].fX = clip.fRight;
208 this->appendVLine(clip.fRight, tmp[2].fY, tmp[4].fY, reverse);
212 pts[1].fX = std::min(pts[1].fX, clip.fRight);
213 pts[2].fX = std::min(pts[2].fX, clip.fRight);
216 } else { // wholly inside the clip
221 bool SkEdgeClipper::clipQuad(const SkPoint srcPts[3], const SkRect& clip) {
228 if (!quick_reject(bounds, clip)) {
235 this->clipMonoQuad(&monoX[x * 2], clip);
282 // Modify pts[] in place so that it is clipped in Y to the clip rect
283 static void chop_cubic_in_Y(SkPoint pts[4], const SkRect& clip) {
286 if (pts[0].fY < clip.fTop) {
288 chop_mono_cubic_at_y(pts, clip.fTop, tmp);
292 * we computed resulted in the lower cubic still being partly above the clip.
300 if (tmp[3].fY < clip.fTop && tmp[4].fY < clip.fTop && tmp[5].fY < clip.fTop) {
303 chop_mono_cubic_at_y(tmp2, clip.fTop, tmp);
306 // tmp[3, 4].fY should all be to the below clip.fTop.
308 tmp[3].fY = clip.fTop;
309 clamp_ge(tmp[4].fY, clip.fTop);
317 if (pts[3].fY > clip.fBottom) {
319 chop_mono_cubic_at_y(pts, clip.fBottom, tmp);
320 tmp[3].fY = clip.fBottom;
321 clamp_le(tmp[2].fY, clip.fBottom);
337 void SkEdgeClipper::clipMonoCubic(const SkPoint src[4], const SkRect& clip) {
342 if (pts[3].fY <= clip.fTop || pts[0].fY >= clip.fBottom) {
346 // Now chop so that pts is contained within clip in Y
347 chop_cubic_in_Y(pts, clip);
358 if (pts[3].fX <= clip.fLeft) { // wholly to the left
359 this->appendVLine(clip.fLeft, pts[0].fY, pts[3].fY, reverse);
362 if (pts[0].fX >= clip.fRight) { // wholly to the right
364 this->appendVLine(clip.fRight, pts[0].fY, pts[3].fY, reverse);
370 if (pts[0].fX < clip.fLeft) {
372 chop_mono_cubic_at_x(pts, clip.fLeft, tmp);
373 this->appendVLine(clip.fLeft, tmp[0].fY, tmp[3].fY, reverse);
375 // tmp[3, 4].fX should all be to the right of clip.fLeft.
378 tmp[3].fX = clip.fLeft;
379 clamp_ge(tmp[4].fX, clip.fLeft);
387 if (pts[3].fX > clip.fRight) {
389 chop_mono_cubic_at_x(pts, clip.fRight, tmp);
390 tmp[3].fX = clip.fRight;
391 clamp_le(tmp[2].fX, clip.fRight);
394 this->appendVLine(clip.fRight, tmp[3].fY, tmp[6].fY, reverse);
395 } else { // wholly inside the clip
417 bool SkEdgeClipper::clipCubic(const SkPoint srcPts[4], const SkRect& clip) {
423 if (bounds.fBottom > clip.fTop && bounds.fTop < clip.fBottom) {
425 // can't safely clip the cubic, so we give up and draw a line (which we can safely clip)
431 return this->clipLine(srcPts[0], srcPts[3], clip);
439 this->clipMonoCubic(&monoX[x * 3], clip);
563 void SkEdgeClipper::ClipPath(const SkPath& path, const SkRect& clip, bool canCullToTheRight,
576 if (clipper.clipLine(e.fPts[0], e.fPts[1], clip)) {
581 if (clipper.clipQuad(e.fPts, clip)) {
588 if (clipper.clipQuad(quadPts, clip)) {
595 if (clipper.clipCubic(e.fPts, clip)) {