aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode/SampleAAClip.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-10-27 16:58:46 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-10-27 16:58:46 +0000
commitc90419199525141a5b98091f856e359bf9daf5b1 (patch)
tree42400cdc0ccebad3de093b6312ace430fde9e31c /samplecode/SampleAAClip.cpp
parent83a444602ec580a0040713eed588c245b4ae0ee9 (diff)
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
Diffstat (limited to 'samplecode/SampleAAClip.cpp')
-rw-r--r--samplecode/SampleAAClip.cpp29
1 files changed, 29 insertions, 0 deletions
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: