Lines Matching refs:canvas
96 SkCanvas canvas(10, 10); in DEF_TEST() local
100 irect = canvas.getDeviceClipBounds(); in DEF_TEST()
102 REPORTER_ASSERT(reporter, canvas.getDeviceClipBounds(&irect2)); in DEF_TEST()
106 rect = canvas.getLocalClipBounds(); in DEF_TEST()
108 REPORTER_ASSERT(reporter, canvas.getLocalClipBounds(&rect2)); in DEF_TEST()
111 canvas.clipRect(SkRect::MakeEmpty()); in DEF_TEST()
113 irect = canvas.getDeviceClipBounds(); in DEF_TEST()
115 REPORTER_ASSERT(reporter, !canvas.getDeviceClipBounds(&irect2)); in DEF_TEST()
118 rect = canvas.getLocalClipBounds(); in DEF_TEST()
120 REPORTER_ASSERT(reporter, !canvas.getLocalClipBounds(&rect2)); in DEF_TEST()
146 static void test_restriction(skiatest::Reporter* reporter, SkCanvas* canvas) { in test_restriction() argument
147 REPORTER_ASSERT(reporter, canvas->getDeviceClipBounds() == gBaseRestrictedR); in test_restriction()
150 canvas->androidFramework_setDeviceClipRestriction(restrictionR); in test_restriction()
151 REPORTER_ASSERT(reporter, canvas->getDeviceClipBounds() == restrictionR); in test_restriction()
154 canvas->clipRect(SkRect::Make(clipR), SkClipOp::kIntersect); in test_restriction()
155 REPORTER_ASSERT(reporter, canvas->getDeviceClipBounds() == clipR); in test_restriction()
170 canvas->save(); in test_restriction()
171 canvas->clipRect(expandR, op); in test_restriction()
172 REPORTER_ASSERT(reporter, gBaseRestrictedR.contains(canvas->getDeviceClipBounds())); in test_restriction()
173 canvas->restore(); in test_restriction()
188 [reporter](SkCanvas* canvas) { test_restriction(reporter, canvas); }); in DEF_TEST() argument
192 multi_canvas_driver(50, 50, [reporter](SkCanvas* canvas) { in DEF_TEST() argument
193 canvas->save(); in DEF_TEST()
194 canvas->clipRect({0, 0, 20, 40 }); in DEF_TEST()
195 REPORTER_ASSERT(reporter, !canvas->isClipEmpty()); in DEF_TEST()
196 canvas->clipRect({30, 0, 50, 40 }); in DEF_TEST()
197 REPORTER_ASSERT(reporter, canvas->isClipEmpty()); in DEF_TEST()
356 virtual void draw(SkCanvas* canvas, const TestData& d, \
358 FUNCTION (canvas, d, reporter, this); \
368 virtual void draw(SkCanvas* canvas, const TestData& d, \
370 FUNCTION (canvas, d, reporter, this); \
377 static void NAME##TestStep(SkCanvas* canvas, const TestData& d, \
379 canvas-> CALL ; \
384 static void NAME##TestStep(SkCanvas* canvas, const TestData& d, skiatest::Reporter*, \
386 REPORTER_ASSERT(reporter, canvas->CALL, testStep->assertMessage()); \
408 static void SaveMatrixClipStep(SkCanvas* canvas, const TestData& d, in SaveMatrixClipStep() argument
410 int saveCount = canvas->getSaveCount(); in SaveMatrixClipStep()
411 canvas->save(); in SaveMatrixClipStep()
412 canvas->translate(SkIntToScalar(1), SkIntToScalar(2)); in SaveMatrixClipStep()
413 canvas->clipRegion(d.fRegion); in SaveMatrixClipStep()
414 canvas->restore(); in SaveMatrixClipStep()
415 REPORTER_ASSERT(reporter, canvas->getSaveCount() == saveCount, testStep->assertMessage()); in SaveMatrixClipStep()
416 REPORTER_ASSERT(reporter, canvas->getTotalMatrix().isIdentity(), testStep->assertMessage()); in SaveMatrixClipStep()
422 static void SaveLayerStep(SkCanvas* canvas, const TestData& d, in SaveLayerStep() argument
424 int saveCount = canvas->getSaveCount(); in SaveLayerStep()
425 canvas->saveLayer(nullptr, nullptr); in SaveLayerStep()
426 canvas->restore(); in SaveLayerStep()
427 REPORTER_ASSERT(reporter, canvas->getSaveCount() == saveCount, testStep->assertMessage()); in SaveLayerStep()
431 static void BoundedSaveLayerStep(SkCanvas* canvas, const TestData& d, in BoundedSaveLayerStep() argument
433 int saveCount = canvas->getSaveCount(); in BoundedSaveLayerStep()
434 canvas->saveLayer(&d.fRect, nullptr); in BoundedSaveLayerStep()
435 canvas->restore(); in BoundedSaveLayerStep()
436 REPORTER_ASSERT(reporter, canvas->getSaveCount() == saveCount, testStep->assertMessage()); in BoundedSaveLayerStep()
440 static void PaintSaveLayerStep(SkCanvas* canvas, const TestData& d, in PaintSaveLayerStep() argument
442 int saveCount = canvas->getSaveCount(); in PaintSaveLayerStep()
443 canvas->saveLayer(nullptr, &d.fPaint); in PaintSaveLayerStep()
444 canvas->restore(); in PaintSaveLayerStep()
445 REPORTER_ASSERT(reporter, canvas->getSaveCount() == saveCount, testStep->assertMessage()); in PaintSaveLayerStep()
449 static void TwoClipOpsStep(SkCanvas* canvas, const TestData& d, in TwoClipOpsStep() argument
455 canvas->clipRect(d.fRect); in TwoClipOpsStep()
456 canvas->clipRegion(d.fRegion); in TwoClipOpsStep()
462 static void DrawNearlyZeroLengthPathTestStep(SkCanvas* canvas, const TestData& d, in DrawNearlyZeroLengthPathTestStep() argument
468 canvas->drawPath(d.fNearlyZeroLengthPath, paint); in DrawNearlyZeroLengthPathTestStep()
472 static void DrawVerticesShaderTestStep(SkCanvas* canvas, const TestData& d, in DrawVerticesShaderTestStep() argument
482 canvas->drawVertices(SkVertices::MakeCopy(SkVertices::kTriangleFan_VertexMode, 4, pts, pts, in DrawVerticesShaderTestStep()
489 static void DrawPictureTestStep(SkCanvas* canvas, const TestData& d, in DrawPictureTestStep() argument
498 canvas->drawPicture(recorder.finishRecordingAsPicture()); in DrawPictureTestStep()
502 static void SaveRestoreTestStep(SkCanvas* canvas, const TestData& d, in SaveRestoreTestStep() argument
504 int baseSaveCount = canvas->getSaveCount(); in SaveRestoreTestStep()
505 int n = canvas->save(); in SaveRestoreTestStep()
507 REPORTER_ASSERT(reporter, baseSaveCount + 1 == canvas->getSaveCount(), in SaveRestoreTestStep()
509 canvas->save(); in SaveRestoreTestStep()
510 canvas->save(); in SaveRestoreTestStep()
511 REPORTER_ASSERT(reporter, baseSaveCount + 3 == canvas->getSaveCount(), in SaveRestoreTestStep()
513 canvas->restoreToCount(baseSaveCount + 1); in SaveRestoreTestStep()
514 REPORTER_ASSERT(reporter, baseSaveCount + 1 == canvas->getSaveCount(), in SaveRestoreTestStep()
518 canvas->restoreToCount(0); in SaveRestoreTestStep()
519 REPORTER_ASSERT(reporter, 1 == canvas->getSaveCount(), testStep->assertMessage()); in SaveRestoreTestStep()
523 static void NestedSaveRestoreWithSolidPaintTestStep(SkCanvas* canvas, const TestData& d, in NestedSaveRestoreWithSolidPaintTestStep() argument
529 canvas->resetMatrix(); in NestedSaveRestoreWithSolidPaintTestStep()
530 canvas->rotate(SkIntToScalar(30)); in NestedSaveRestoreWithSolidPaintTestStep()
531 canvas->save(); in NestedSaveRestoreWithSolidPaintTestStep()
532 canvas->translate(SkIntToScalar(2), SkIntToScalar(1)); in NestedSaveRestoreWithSolidPaintTestStep()
533 canvas->save(); in NestedSaveRestoreWithSolidPaintTestStep()
534 canvas->scale(SkIntToScalar(3), SkIntToScalar(3)); in NestedSaveRestoreWithSolidPaintTestStep()
537 canvas->drawPaint(paint); in NestedSaveRestoreWithSolidPaintTestStep()
538 canvas->restore(); in NestedSaveRestoreWithSolidPaintTestStep()
539 canvas->restore(); in NestedSaveRestoreWithSolidPaintTestStep()
544 static void NestedSaveRestoreWithFlushTestStep(SkCanvas* canvas, const TestData& d, in NestedSaveRestoreWithFlushTestStep() argument
550 canvas->resetMatrix(); in NestedSaveRestoreWithFlushTestStep()
551 canvas->rotate(SkIntToScalar(30)); in NestedSaveRestoreWithFlushTestStep()
552 canvas->save(); in NestedSaveRestoreWithFlushTestStep()
553 canvas->translate(SkIntToScalar(2), SkIntToScalar(1)); in NestedSaveRestoreWithFlushTestStep()
554 canvas->save(); in NestedSaveRestoreWithFlushTestStep()
555 canvas->scale(SkIntToScalar(3), SkIntToScalar(3)); in NestedSaveRestoreWithFlushTestStep()
556 canvas->drawRect(d.fRect,d.fPaint); in NestedSaveRestoreWithFlushTestStep()
557 canvas->flush(); in NestedSaveRestoreWithFlushTestStep()
558 canvas->restore(); in NestedSaveRestoreWithFlushTestStep()
559 canvas->restore(); in NestedSaveRestoreWithFlushTestStep()
570 SkCanvas* canvas = doc->beginPage(SkIntToScalar(d.fWidth), in TestPdfDevice() local
572 REPORTER_ASSERT(reporter, canvas); in TestPdfDevice()
574 step->draw(canvas, d, reporter); in TestPdfDevice()
600 std::unique_ptr<SkCanvas> canvas = SkCanvas::MakeRasterDirect(info, baseAddr, minRowBytes); in test_newraster() local
601 REPORTER_ASSERT(reporter, canvas); in test_newraster()
604 const SkPMColor* addr = canvas->peekPixels(&pmap) ? pmap.addr32() : nullptr; in test_newraster()
629 canvas = SkCanvas::MakeRasterDirect(info, baseAddr, minRowBytes); in test_newraster()
630 REPORTER_ASSERT(reporter, nullptr == canvas); in test_newraster()
647 SkCanvas canvas(10, 10); in DEF_TEST() local
648 REPORTER_ASSERT(reporter, 1 == canvas.getSaveCount()); in DEF_TEST()
650 int n = canvas.save(); in DEF_TEST()
652 REPORTER_ASSERT(reporter, 2 == canvas.getSaveCount()); in DEF_TEST()
654 n = canvas.saveLayer(nullptr, nullptr); in DEF_TEST()
656 REPORTER_ASSERT(reporter, 3 == canvas.getSaveCount()); in DEF_TEST()
658 canvas.restore(); in DEF_TEST()
659 REPORTER_ASSERT(reporter, 2 == canvas.getSaveCount()); in DEF_TEST()
660 canvas.restore(); in DEF_TEST()
661 REPORTER_ASSERT(reporter, 1 == canvas.getSaveCount()); in DEF_TEST()
665 SkCanvas canvas(10, 10); in DEF_TEST() local
666 canvas.save(); in DEF_TEST()
668 canvas.clipPath(path); in DEF_TEST()
669 canvas.restore(); in DEF_TEST()
670 canvas.save(); in DEF_TEST()
672 canvas.clipPath(path); in DEF_TEST()
673 canvas.restore(); in DEF_TEST()
674 canvas.save(); in DEF_TEST()
676 canvas.clipPath(path); // should not assert here in DEF_TEST()
677 canvas.restore(); in DEF_TEST()
684 MockFilterCanvas(SkCanvas* canvas) : INHERITED(canvas) { } in MockFilterCanvas() argument
697 SkCanvas canvas(100, 100); in DEF_TEST() local
698 canvas.clipRect(SkRect::MakeXYWH(12.7f, 12.7f, 75, 75)); in DEF_TEST()
699 canvas.scale(0.5f, 0.75f); in DEF_TEST()
701 MockFilterCanvas filterCanvas(&canvas); in DEF_TEST()
702 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMatrix()); in DEF_TEST()
703 REPORTER_ASSERT(reporter, canvas.getLocalClipBounds() == filterCanvas.getLocalClipBounds()); in DEF_TEST()
707 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMatrix()); in DEF_TEST()
708 …REPORTER_ASSERT(reporter, filterCanvas.getLocalClipBounds().contains(canvas.getLocalClipBounds())); in DEF_TEST()
777 static void test_cliptype(SkCanvas* canvas, skiatest::Reporter* r) { in test_cliptype() argument
778 REPORTER_ASSERT(r, !canvas->isClipEmpty()); in test_cliptype()
779 REPORTER_ASSERT(r, canvas->isClipRect()); in test_cliptype()
781 canvas->save(); in test_cliptype()
782 canvas->clipRect({0, 0, 0, 0}); in test_cliptype()
783 REPORTER_ASSERT(r, canvas->isClipEmpty()); in test_cliptype()
784 REPORTER_ASSERT(r, !canvas->isClipRect()); in test_cliptype()
785 canvas->restore(); in test_cliptype()
787 canvas->save(); in test_cliptype()
788 canvas->clipRect({2, 2, 6, 6}); in test_cliptype()
789 REPORTER_ASSERT(r, !canvas->isClipEmpty()); in test_cliptype()
790 REPORTER_ASSERT(r, canvas->isClipRect()); in test_cliptype()
791 canvas->restore(); in test_cliptype()
793 canvas->save(); in test_cliptype()
794 canvas->clipRect({2, 2, 6, 6}, SkClipOp::kDifference); // punch a hole in the clip in test_cliptype()
795 REPORTER_ASSERT(r, !canvas->isClipEmpty()); in test_cliptype()
796 REPORTER_ASSERT(r, !canvas->isClipRect()); in test_cliptype()
797 canvas->restore(); in test_cliptype()
799 REPORTER_ASSERT(r, !canvas->isClipEmpty()); in test_cliptype()
800 REPORTER_ASSERT(r, canvas->isClipRect()); in test_cliptype()
825 SkCanvas canvas(bitmap, SkCanvas::ColorBehavior::kLegacy); in DEF_TEST() local
826 REPORTER_ASSERT(r, !canvas.imageInfo().colorSpace()); in DEF_TEST()
829 canvas.drawIRect(SkIRect::MakeWH(1, 1), p); in DEF_TEST()
866 SkCanvas canvas(10, 10); in DEF_TEST() local
870 canvas.saveLayer(nullptr, &p); in DEF_TEST()
871 REPORTER_ASSERT(r, canvas.getDeviceClipBounds().isEmpty()); in DEF_TEST()
872 canvas.restore(); in DEF_TEST()
891 SkCanvas canvas(bm); in DEF_TEST() local
892 canvas.drawRect({0, 0, 100, 90*1024}, paint); in DEF_TEST()
899 SkCanvas canvas(100, 100); in DEF_TEST() local
913 canvas.clipRect(clipRect); in DEF_TEST()
915 canvas.rotate(45); in DEF_TEST()
916 const SkMatrix preCTM = canvas.getTotalMatrix(); in DEF_TEST()
917 canvas.drawRect(blurredRect, p); in DEF_TEST()
918 const SkMatrix postCTM = canvas.getTotalMatrix(); in DEF_TEST()