Home | History | Annotate | Download | only in tests

Lines Matching full:stack

25     // Build up a clip stack with a path, an empty clip, and a rect.
124 static void assert_count(skiatest::Reporter* reporter, const SkClipStack& stack,
126 SkClipStack::B2TIter iter(stack);
137 SkClipStack stack;
148 stack.clipDevRect(gRects[i], SkRegion::kUnion_Op, false);
151 assert_count(reporter, stack, 4);
157 SkClipStack::B2TIter iter(stack);
172 SkClipStack::Iter iter(stack, SkClipStack::Iter::kTop_IterStart);
187 SkClipStack::Iter iter(stack, SkClipStack::Iter::kBottom_IterStart);
247 SkClipStack stack;
256 stack.save();
266 stack.clipDevRect(rectA, SkRegion::kIntersect_Op, false);
267 stack.clipDevRect(rectB, gOps[op], false);
269 stack.clipDevPath(clipA, SkRegion::kIntersect_Op, false);
270 stack.clipDevPath(clipB, gOps[op], false);
273 REPORTER_ASSERT(reporter, !stack.isWideOpen());
275 stack.getConservativeBounds(0, 0, 100, 100, &devClipBound,
289 stack.restore();
302 // Stack should initially be wide open
304 SkClipStack stack;
306 REPORTER_ASSERT(reporter, stack.isWideOpen());
311 SkClipStack stack;
321 stack.clipDevPath(clipA, SkRegion::kReplace_Op, false);
322 stack.clipDevPath(clipB, SkRegion::kUnion_Op, false);
324 REPORTER_ASSERT(reporter, stack.isWideOpen());
329 SkClipStack stack;
331 stack.clipDevRect(rectA, SkRegion::kUnion_Op, false);
333 REPORTER_ASSERT(reporter, stack.isWideOpen());
338 SkClipStack stack;
343 stack.clipDevRect(emptyRect, SkRegion::kDifference_Op, false);
345 REPORTER_ASSERT(reporter, stack.isWideOpen());
350 SkClipStack stack;
352 stack.save();
354 stack.clipDevRect(rectA, SkRegion::kReplace_Op, false);
356 REPORTER_ASSERT(reporter, !stack.isWideOpen());
358 stack.restore();
360 REPORTER_ASSERT(reporter, stack.isWideOpen());
364 static int count(const SkClipStack& stack) {
366 SkClipStack::Iter iter(stack, SkClipStack::Iter::kTop_IterStart);
385 SkClipStack stack;
386 stack.clipDevPath(path, SkRegion::kIntersect_Op, false);
390 stack.getBounds(&bounds, &boundsType);
404 // the stack depth. BW replacing BW.
406 SkClipStack stack;
407 REPORTER_ASSERT(reporter, 0 == count(stack));
408 stack.clipDevRect(rect, SkRegion::kReplace_Op, false);
409 REPORTER_ASSERT(reporter, 1 == count(stack));
410 stack.clipDevRect(rect, SkRegion::kReplace_Op, false);
411 REPORTER_ASSERT(reporter, 1 == count(stack));
415 // the stack depth. AA replacing AA.
417 SkClipStack stack;
418 REPORTER_ASSERT(reporter, 0 == count(stack));
419 stack.clipDevRect(rect, SkRegion::kReplace_Op, true);
420 REPORTER_ASSERT(reporter, 1 == count(stack));
421 stack.clipDevRect(rect, SkRegion::kReplace_Op, true);
422 REPORTER_ASSERT(reporter, 1 == count(stack));
426 // the stack depth. BW replacing AA replacing BW.
428 SkClipStack stack;
429 REPORTER_ASSERT(reporter, 0 == count(stack));
430 stack.clipDevRect(rect, SkRegion::kReplace_Op, false);
431 REPORTER_ASSERT(reporter, 1 == count(stack));
432 stack.clipDevRect(rect, SkRegion::kReplace_Op, true);
433 REPORTER_ASSERT(reporter, 1 == count(stack));
434 stack.clipDevRect(rect, SkRegion::kReplace_Op, false);
435 REPORTER_ASSERT(reporter, 1 == count(stack));
440 SkClipStack stack;
441 stack.clipDevRect(rect, SkRegion::kReplace_Op, false);
442 stack.clipDevRect(rect2, SkRegion::kIntersect_Op, false);
443 REPORTER_ASSERT(reporter, 1 == count(stack));
445 stack.save();
446 stack.clipDevRect(rect, SkRegion::kReplace_Op, false);
447 REPORTER_ASSERT(reporter, 2 == count(stack));
448 stack.getBounds(&bound, &type, &isIntersectionOfRects);
450 stack.restore();
451 REPORTER_ASSERT(reporter, 1 == count(stack));
453 stack.save();
454 stack.clipDevRect(rect, SkRegion::kReplace_Op, false);
455 stack.clipDevRect(rect, SkRegion::kReplace_Op, false);
456 REPORTER_ASSERT(reporter, 2 == count(stack));
457 stack.restore();
458 REPORTER_ASSERT(reporter, 1 == count(stack));
460 stack.save();
461 stack.clipDevRect(rect, SkRegion::kReplace_Op, false);
462 stack.clipDevRect(rect2, SkRegion::kIntersect_Op, false);
463 stack.clipDevRect(rect, SkRegion::kReplace_Op, false);
464 REPORTER_ASSERT(reporter, 2 == count(stack));
465 stack.restore();
466 REPORTER_ASSERT(reporter, 1 == count(stack));
476 // Replace operation doesn't grow the stack.
478 SkClipStack stack;
479 REPORTER_ASSERT(reporter, 0 == count(stack));
480 stack.clipDevPath(path, SkRegion::kReplace_Op, false);
481 REPORTER_ASSERT(reporter, 1 == count(stack));
482 stack.clipDevPath(path, SkRegion::kReplace_Op, false);
483 REPORTER_ASSERT(reporter, 1 == count(stack));
488 SkClipStack stack;
489 stack.clipDevRect(rect, SkRegion::kReplace_Op, true);
490 REPORTER_ASSERT(reporter, 1 == count(stack));
491 stack.clipDevPath(path, SkRegion::kReplace_Op, true);
492 REPORTER_ASSERT(reporter, 1 == count(stack));
512 SkClipStack stack;
514 stack.clipDevRect(overlapLeft, SkRegion::kReplace_Op, false);
516 stack.clipDevRect(overlapRight, SkRegion::kIntersect_Op, false);
518 REPORTER_ASSERT(reporter, 1 == count(stack));
520 stack.getBounds(&bound, &type, &isIntersectionOfRects);
527 SkClipStack stack;
529 stack.clipDevRect(overlapLeft, SkRegion::kReplace_Op, true);
531 stack.clipDevRect(overlapRight, SkRegion::kIntersect_Op, true);
533 REPORTER_ASSERT(reporter, 1 == count(stack));
535 stack.getBounds(&bound, &type, &isIntersectionOfRects);
542 SkClipStack stack;
544 stack.clipDevRect(overlapLeft, SkRegion::kReplace_Op, true);
546 stack.clipDevRect(overlapRight, SkRegion::kIntersect_Op, false);
548 REPORTER_ASSERT(reporter, 2 == count(stack));
550 stack.getBounds(&bound, &type, &isIntersectionOfRects);
557 SkClipStack stack;
559 stack.clipDevRect(nestedParent, SkRegion::kReplace_Op, true);
561 stack.clipDevRect(nestedChild, SkRegion::kIntersect_Op, false);
563 REPORTER_ASSERT(reporter, 1 == count(stack));
565 stack.getBounds(&bound, &type, &isIntersectionOfRects);
572 SkClipStack stack;
574 stack.clipDevRect(nestedParent, SkRegion::kReplace_Op, false);
576 stack.clipDevRect(nestedChild, SkRegion::kIntersect_Op, true);
578 REPORTER_ASSERT(reporter, 1 == count(stack));
580 stack.getBounds(&bound, &type, &isIntersectionOfRects);
587 SkClipStack stack;
589 stack.clipDevRect(nestedChild, SkRegion::kReplace_Op, false);
591 stack.clipDevRect(nestedParent, SkRegion::kIntersect_Op, true);
593 REPORTER_ASSERT(reporter, 2 == count(stack));
595 stack.getBounds(&bound, &type, &isIntersectionOfRects);
618 SkClipStack stack;
619 stack.clipDevRect(outsideRect, SkRegion::kDifference_Op, false);
621 REPORTER_ASSERT(reporter, false == stack.quickContains(testRect));
626 SkClipStack stack;
627 stack.clipDevRect(outsideRect, SkRegion::kReplace_Op, false);
628 REPORTER_ASSERT(reporter, true == stack.quickContains(testRect));
632 SkClipStack stack;
633 stack.clipDevRect(insideRect, SkRegion::kIntersect_Op, false);
634 stack.save(); // To prevent in-place substitution by replace OP
635 stack.clipDevRect(outsideRect, SkRegion::kReplace_Op, false);
636 REPORTER_ASSERT(reporter, true == stack.quickContains(testRect));
637 stack.restore();
641 SkClipStack stack;
642 stack.clipDevRect(outsideRect, SkRegion::kIntersect_Op, false);
643 stack.save(); // To prevent in-place substitution by replace OP
644 stack.clipDevRect(insideRect, SkRegion::kReplace_Op, false);
645 REPORTER_ASSERT(reporter, false == stack.quickContains(testRect));
646 stack.restore();
651 SkClipStack stack;
652 stack.clipDevRect(insideRect, SkRegion::kIntersect_Op, false);
654 stack.clipDevPath(outsideCircle, SkRegion::kIntersect_Op, false);
655 REPORTER_ASSERT(reporter, false == stack.quickContains(testRect));
660 SkClipStack stack;
661 stack.clipDevRect(outsideRect, SkRegion::kIntersect_Op, false);
662 REPORTER_ASSERT(reporter, true == stack.quickContains(testRect));
666 SkClipStack stack;
667 stack.clipDevRect(insideRect, SkRegion::kIntersect_Op, false);
668 REPORTER_ASSERT(reporter, false == stack.quickContains(testRect));
672 SkClipStack stack;
673 stack.clipDevRect(intersectingRect, SkRegion::kIntersect_Op, false);
674 REPORTER_ASSERT(reporter, false == stack.quickContains(testRect));
678 SkClipStack stack;
679 stack.clipDevRect(nonIntersectingRect, SkRegion::kIntersect_Op, false);
680 REPORTER_ASSERT(reporter, false == stack.quickContains(testRect));
685 SkClipStack stack;
686 stack.clipDevPath(outsideCircle, SkRegion::kIntersect_Op, false);
687 REPORTER_ASSERT(reporter, true == stack.quickContains(testRect));
691 SkClipStack stack;
692 stack.clipDevPath(insideCircle, SkRegion::kIntersect_Op, false);
693 REPORTER_ASSERT(reporter, false == stack.quickContains(testRect));
697 SkClipStack stack;
698 stack.clipDevPath(intersectingCircle, SkRegion::kIntersect_Op, false);
699 REPORTER_ASSERT(reporter, false == stack.quickContains(testRect));
703 SkClipStack stack;
704 stack.clipDevPath(nonIntersectingCircle, SkRegion::kIntersect_Op, false);
705 REPORTER_ASSERT(reporter, false == stack.quickContains(testRect));
710 SkClipStack stack;
714 stack.clipDevPath(path, SkRegion::kIntersect_Op, false);
715 REPORTER_ASSERT(reporter, false == stack.quickContains(testRect));
719 SkClipStack stack;
723 stack.clipDevPath(path, SkRegion::kIntersect_Op, false);
724 REPORTER_ASSERT(reporter, false == stack.quickContains(testRect));
728 SkClipStack stack;
732 stack.clipDevPath(path, SkRegion::kIntersect_Op, false);
733 REPORTER_ASSERT(reporter, false == stack.quickContains(testRect));
737 SkClipStack stack;
741 stack.clipDevPath(path, SkRegion::kIntersect_Op, false);
742 REPORTER_ASSERT(reporter, true == stack.quickContains(testRect));
747 SkClipStack stack;
750 stack.clipDevPath(path, SkRegion::kIntersect_Op, false);
751 REPORTER_ASSERT(reporter, false == stack.quickContains(testRect));
755 SkClipStack stack;
758 stack.clipDevPath(path, SkRegion::kIntersect_Op, false);
759 REPORTER_ASSERT(reporter, false == stack.quickContains(testRect));
763 SkClipStack stack;
766 stack.clipDevPath(path, SkRegion::kIntersect_Op, false);
767 REPORTER_ASSERT(reporter, false == stack.quickContains(testRect));
771 SkClipStack stack;
774 stack.clipDevPath(path, SkRegion::kIntersect_Op, false);
775 REPORTER_ASSERT(reporter, true == stack.quickContains(testRect));
782 // Functions that add a shape to the clip stack. The shape is computed from a rectangle.
783 // AA is always disabled since the clip stack reducer can cause changes in aa rasterization of the
784 // stack. A fractional edge repeated in different elements may be rasterized fewer times using the
785 // reduced stack.
789 SkClipStack* stack);
791 static void add_round_rect(const SkRect& rect, bool invert, SkRegion::Op op, SkClipStack* stack) {
799 stack->clipDevPath(path, op, false);
802 static void add_rect(const SkRect& rect, bool invert, SkRegion::Op op, SkClipStack* stack) {
807 stack->clipDevPath(path, op, false);
809 stack->clipDevRect(rect, op, false);
813 static void add_oval(const SkRect& rect, bool invert, SkRegion::Op op, SkClipStack* stack) {
819 stack->clipDevPath(path, op, false);
822 static void add_elem_to_stack(const SkClipStack::Element& element, SkClipStack* stack) {
825 stack->clipDevRect(element.getRect(), element.getOp(), element.isAA());
828 stack->clipDevPath(element.getPath(), element.getOp(), element.isAA());
832 stack->clipEmpty();
861 // This can assist with debugging the clip stack reduction code when the test below fails.
927 // Randomly generate a clip stack.
928 SkClipStack stack;
939 // saves can change the clip stack behavior when an element is added.
952 kElementFuncs[r.nextULessThan(SK_ARRAY_COUNT(kElementFuncs))](rect, invert, op, &stack);
954 stack.save();
964 // Get the reduced version of the stack.
970 GrReducedClip::ReduceClipStack(stack,
976 // Build a new clip stack based on the reduced clip elements
991 // convert both the original stack and reduced stack to SkRegions and see if they're equal
997 SkClipStack::Iter iter(stack, SkClipStack::Iter::kBottom_IterStart);
1016 SkClipStack stack;
1018 REPORTER_ASSERT(reporter, 0 == stack.getSaveCount());
1019 assert_count(reporter, stack, 0);
1028 stack.clipDevRect(gRects[i], SkRegion::kIntersect_Op);
1032 SkClipStack::B2TIter iter(stack);
1044 stack.reset();
1045 REPORTER_ASSERT(reporter, 0 == stack.getSaveCount());
1046 assert_count(reporter, stack, 0);