| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 #include "gm.h" | 7 #include "gm.h" |
| 8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
| 9 #include "SkPath.h" | 9 #include "SkPath.h" |
| 10 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 if (!fDoSimpleClipFirst) { | 45 if (!fDoSimpleClipFirst) { |
| 46 SkTSwap<SkPath*>(firstClip, secondClip); | 46 SkTSwap<SkPath*>(firstClip, secondClip); |
| 47 } | 47 } |
| 48 | 48 |
| 49 SkPaint paint; | 49 SkPaint paint; |
| 50 paint.setAntiAlias(true); | 50 paint.setAntiAlias(true); |
| 51 sk_tool_utils::set_portable_typeface(&paint); | 51 sk_tool_utils::set_portable_typeface(&paint); |
| 52 paint.setTextSize(SkIntToScalar(20)); | 52 paint.setTextSize(SkIntToScalar(20)); |
| 53 | 53 |
| 54 constexpr struct { | 54 constexpr struct { |
| 55 SkRegion::Op fOp; | 55 SkCanvas::ClipOp fOp; |
| 56 const char* fName; | 56 const char* fName; |
| 57 } gOps[] = { | 57 } gOps[] = { |
| 58 {SkRegion::kIntersect_Op, "I"}, | 58 {SkCanvas::kIntersect_Op, "I"}, |
| 59 {SkRegion::kDifference_Op, "D" }, | 59 {SkCanvas::kDifference_Op, "D" }, |
| 60 {SkRegion::kUnion_Op, "U"}, | 60 {SkCanvas::kUnion_Op, "U"}, |
| 61 {SkRegion::kXOR_Op, "X" }, | 61 {SkCanvas::kXOR_Op, "X" }, |
| 62 {SkRegion::kReverseDifference_Op, "R"} | 62 {SkCanvas::kReverseDifference_Op, "R"} |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 canvas->translate(SkIntToScalar(20), SkIntToScalar(20)); | 65 canvas->translate(SkIntToScalar(20), SkIntToScalar(20)); |
| 66 canvas->scale(3 * SK_Scalar1 / 4, 3 * SK_Scalar1 / 4); | 66 canvas->scale(3 * SK_Scalar1 / 4, 3 * SK_Scalar1 / 4); |
| 67 | 67 |
| 68 SkPaint pathPaint; | 68 SkPaint pathPaint; |
| 69 pathPaint.setAntiAlias(true); | 69 pathPaint.setAntiAlias(true); |
| 70 pathPaint.setColor(gPathColor); | 70 pathPaint.setColor(gPathColor); |
| 71 | 71 |
| 72 for (int invA = 0; invA < 2; ++invA) { | 72 for (int invA = 0; invA < 2; ++invA) { |
| 73 for (int aaBits = 0; aaBits < 4; ++aaBits) { | 73 for (int aaBits = 0; aaBits < 4; ++aaBits) { |
| 74 canvas->save(); | 74 canvas->save(); |
| 75 for (size_t op = 0; op < SK_ARRAY_COUNT(gOps); ++op) { | 75 for (size_t op = 0; op < SK_ARRAY_COUNT(gOps); ++op) { |
| 76 for (int invB = 0; invB < 2; ++invB) { | 76 for (int invB = 0; invB < 2; ++invB) { |
| 77 bool doAAA = SkToBool(aaBits & 1); | 77 bool doAAA = SkToBool(aaBits & 1); |
| 78 bool doAAB = SkToBool(aaBits & 2); | 78 bool doAAB = SkToBool(aaBits & 2); |
| 79 bool doInvA = SkToBool(invA); | 79 bool doInvA = SkToBool(invA); |
| 80 bool doInvB = SkToBool(invB); | 80 bool doInvB = SkToBool(invB); |
| 81 canvas->save(); | 81 canvas->save(); |
| 82 // set clip | 82 // set clip |
| 83 firstClip->setFillType(doInvA ? SkPath::kInverseEvenOdd_
FillType : | 83 firstClip->setFillType(doInvA ? SkPath::kInverseEvenOdd_
FillType : |
| 84 SkPath::kEvenOdd_FillType); | 84 SkPath::kEvenOdd_FillType); |
| 85 secondClip->setFillType(doInvB ? SkPath::kInverseEvenOdd
_FillType : | 85 secondClip->setFillType(doInvB ? SkPath::kInverseEvenOdd
_FillType : |
| 86 SkPath::kEvenOdd_FillType); | 86 SkPath::kEvenOdd_FillType); |
| 87 canvas->clipPath(*firstClip, SkRegion::kIntersect_Op, do
AAA); | 87 canvas->clipPath(*firstClip, SkCanvas::kIntersect_Op, do
AAA); |
| 88 canvas->clipPath(*secondClip, gOps[op].fOp, doAAB); | 88 canvas->clipPath(*secondClip, gOps[op].fOp, doAAB); |
| 89 | 89 |
| 90 // draw rect clipped | 90 // draw rect clipped |
| 91 SkRect r = { 0, 0, 100, 100 }; | 91 SkRect r = { 0, 0, 100, 100 }; |
| 92 canvas->drawRect(r, pathPaint); | 92 canvas->drawRect(r, pathPaint); |
| 93 canvas->restore(); | 93 canvas->restore(); |
| 94 | 94 |
| 95 | 95 |
| 96 SkScalar txtX = SkIntToScalar(10); | 96 SkScalar txtX = SkIntToScalar(10); |
| 97 paint.setColor(SK_ColorBLACK); | 97 paint.setColor(SK_ColorBLACK); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 123 typedef GM INHERITED; | 123 typedef GM INHERITED; |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 ////////////////////////////////////////////////////////////////////////////// | 126 ////////////////////////////////////////////////////////////////////////////// |
| 127 | 127 |
| 128 // Simple clip first | 128 // Simple clip first |
| 129 DEF_GM( return new ComplexClip3GM(true); ) | 129 DEF_GM( return new ComplexClip3GM(true); ) |
| 130 // Complex clip first | 130 // Complex clip first |
| 131 DEF_GM( return new ComplexClip3GM(false); ) | 131 DEF_GM( return new ComplexClip3GM(false); ) |
| 132 } | 132 } |
| OLD | NEW |