| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkParsePath.h" | 9 //#include "SkParsePath.h" |
| 10 #include "SkPath.h" | 10 #include "SkPath.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 clipB.lineTo(SkIntToScalar(40), SkIntToScalar(185)); | 79 clipB.lineTo(SkIntToScalar(40), SkIntToScalar(185)); |
| 80 clipB.lineTo(SkIntToScalar(155), SkIntToScalar(100)); | 80 clipB.lineTo(SkIntToScalar(155), SkIntToScalar(100)); |
| 81 clipB.close(); | 81 clipB.close(); |
| 82 | 82 |
| 83 SkPaint paint; | 83 SkPaint paint; |
| 84 paint.setAntiAlias(true); | 84 paint.setAntiAlias(true); |
| 85 sk_tool_utils::set_portable_typeface(&paint); | 85 sk_tool_utils::set_portable_typeface(&paint); |
| 86 paint.setTextSize(SkIntToScalar(20)); | 86 paint.setTextSize(SkIntToScalar(20)); |
| 87 | 87 |
| 88 constexpr struct { | 88 constexpr struct { |
| 89 SkRegion::Op fOp; | 89 SkCanvas::ClipOp fOp; |
| 90 const char* fName; | 90 const char* fName; |
| 91 } gOps[] = { //extra spaces in names for measureText | 91 } gOps[] = { //extra spaces in names for measureText |
| 92 {SkRegion::kIntersect_Op, "Isect "}, | 92 {SkCanvas::kIntersect_Op, "Isect "}, |
| 93 {SkRegion::kDifference_Op, "Diff " }, | 93 {SkCanvas::kDifference_Op, "Diff " }, |
| 94 {SkRegion::kUnion_Op, "Union "}, | 94 {SkCanvas::kUnion_Op, "Union "}, |
| 95 {SkRegion::kXOR_Op, "Xor " }, | 95 {SkCanvas::kXOR_Op, "Xor " }, |
| 96 {SkRegion::kReverseDifference_Op, "RDiff "} | 96 {SkCanvas::kReverseDifference_Op, "RDiff "} |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 canvas->translate(SkIntToScalar(20), SkIntToScalar(20)); | 99 canvas->translate(SkIntToScalar(20), SkIntToScalar(20)); |
| 100 canvas->scale(3 * SK_Scalar1 / 4, 3 * SK_Scalar1 / 4); | 100 canvas->scale(3 * SK_Scalar1 / 4, 3 * SK_Scalar1 / 4); |
| 101 | 101 |
| 102 if (fDoSaveLayer) { | 102 if (fDoSaveLayer) { |
| 103 // We want the layer to appear symmetric relative to actual | 103 // We want the layer to appear symmetric relative to actual |
| 104 // device boundaries so we need to "undo" the effect of the | 104 // device boundaries so we need to "undo" the effect of the |
| 105 // scale and translate | 105 // scale and translate |
| 106 SkRect bounds = SkRect::MakeLTRB( | 106 SkRect bounds = SkRect::MakeLTRB( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 123 this->drawHairlines(canvas, path, clipA, clipB); | 123 this->drawHairlines(canvas, path, clipA, clipB); |
| 124 | 124 |
| 125 bool doInvA = SkToBool(invBits & 1); | 125 bool doInvA = SkToBool(invBits & 1); |
| 126 bool doInvB = SkToBool(invBits & 2); | 126 bool doInvB = SkToBool(invBits & 2); |
| 127 canvas->save(); | 127 canvas->save(); |
| 128 // set clip | 128 // set clip |
| 129 clipA.setFillType(doInvA ? SkPath::kInverseEvenOdd_FillType
: | 129 clipA.setFillType(doInvA ? SkPath::kInverseEvenOdd_FillType
: |
| 130 SkPath::kEvenOdd_FillType); | 130 SkPath::kEvenOdd_FillType); |
| 131 clipB.setFillType(doInvB ? SkPath::kInverseEvenOdd_FillType
: | 131 clipB.setFillType(doInvB ? SkPath::kInverseEvenOdd_FillType
: |
| 132 SkPath::kEvenOdd_FillType); | 132 SkPath::kEvenOdd_FillType); |
| 133 canvas->clipPath(clipA, SkRegion::kIntersect_Op, fDoAAClip); | 133 canvas->clipPath(clipA, SkCanvas::kIntersect_Op, fDoAAClip); |
| 134 canvas->clipPath(clipB, gOps[op].fOp, fDoAAClip); | 134 canvas->clipPath(clipB, gOps[op].fOp, fDoAAClip); |
| 135 | 135 |
| 136 // In the inverse case we need to prevent the draw from cove
ring the whole | 136 // In the inverse case we need to prevent the draw from cove
ring the whole |
| 137 // canvas. | 137 // canvas. |
| 138 if (fInvertDraw) { | 138 if (fInvertDraw) { |
| 139 SkRect rectClip = clipA.getBounds(); | 139 SkRect rectClip = clipA.getBounds(); |
| 140 rectClip.join(path.getBounds()); | 140 rectClip.join(path.getBounds()); |
| 141 rectClip.join(path.getBounds()); | 141 rectClip.join(path.getBounds()); |
| 142 rectClip.outset(5, 5); | 142 rectClip.outset(5, 5); |
| 143 canvas->clipRect(rectClip); | 143 canvas->clipRect(rectClip); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 | 201 |
| 202 DEF_GM(return new ComplexClipGM(false, false, false);) | 202 DEF_GM(return new ComplexClipGM(false, false, false);) |
| 203 DEF_GM(return new ComplexClipGM(false, false, true);) | 203 DEF_GM(return new ComplexClipGM(false, false, true);) |
| 204 DEF_GM(return new ComplexClipGM(false, true, false);) | 204 DEF_GM(return new ComplexClipGM(false, true, false);) |
| 205 DEF_GM(return new ComplexClipGM(false, true, true);) | 205 DEF_GM(return new ComplexClipGM(false, true, true);) |
| 206 DEF_GM(return new ComplexClipGM(true, false, false);) | 206 DEF_GM(return new ComplexClipGM(true, false, false);) |
| 207 DEF_GM(return new ComplexClipGM(true, false, true);) | 207 DEF_GM(return new ComplexClipGM(true, false, true);) |
| 208 DEF_GM(return new ComplexClipGM(true, true, false);) | 208 DEF_GM(return new ComplexClipGM(true, true, false);) |
| 209 DEF_GM(return new ComplexClipGM(true, true, true);) | 209 DEF_GM(return new ComplexClipGM(true, true, true);) |
| 210 } | 210 } |
| OLD | NEW |