From c90419199525141a5b98091f856e359bf9daf5b1 Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Thu, 27 Oct 2011 16:58:46 +0000 Subject: now we trim the aaclip after building it, to ensure that it has tight bounds around its (rle compressed) image. git-svn-id: http://skia.googlecode.com/svn/trunk@2542 2bbb7eff-a529-9590-31e7-b0007b416f81 --- samplecode/SampleAAClip.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'samplecode/SampleAAClip.cpp') diff --git a/samplecode/SampleAAClip.cpp b/samplecode/SampleAAClip.cpp index f2a025ded6..d2931fabf6 100644 --- a/samplecode/SampleAAClip.cpp +++ b/samplecode/SampleAAClip.cpp @@ -11,6 +11,34 @@ #include "SkCanvas.h" #include "SkAAClip.h" +static void testop(const SkIRect& r0, const SkIRect& r1, SkRegion::Op op, + const SkIRect& expectedR) { + SkAAClip c0, c1, c2; + c0.setRect(r0); + c1.setRect(r1); + c2.op(c0, c1, op); + + SkIRect r2 = c2.getBounds(); + SkASSERT(r2 == expectedR); +} + +static const struct { + SkIRect r0; + SkIRect r1; + SkRegion::Op op; + SkIRect expectedR; +} gRec[] = { + {{ 1, 2, 9, 3 }, { -3, 2, 5, 11 }, SkRegion::kDifference_Op, { 5, 2, 9, 3 }}, + {{ 1, 10, 5, 13 }, { 1, 2, 5, 11 }, SkRegion::kDifference_Op, { 1, 11, 5, 13 }}, + {{ 1, 10, 5, 13 }, { 1, 2, 5, 11 }, SkRegion::kReverseDifference_Op, { 1, 2, 5, 10 }}, +}; + +static void testop() { + for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { + testop(gRec[i].r0, gRec[i].r1, gRec[i].op, gRec[i].expectedR); + } +} + static void drawClip(SkCanvas* canvas, const SkAAClip& clip) { SkMask mask; SkBitmap bm; @@ -32,6 +60,7 @@ static void drawClip(SkCanvas* canvas, const SkAAClip& clip) { class AAClipView : public SampleView { public: AAClipView() { + testop(); } protected: -- cgit v1.2.3