| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 | 7 |
| 8 #include "gm.h" | 8 #include "gm.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkPath.h" | 10 #include "SkPath.h" |
| 11 #include "SkPathOps.h" | 11 #include "SkPathOps.h" |
| 12 #include "SkRect.h" | 12 #include "SkRect.h" |
| 13 | 13 |
| 14 namespace skiagm { | 14 namespace skiagm { |
| 15 | 15 |
| 16 class PathOpsInverseGM : public GM { | 16 class PathOpsInverseGM : public GM { |
| 17 public: | 17 public: |
| 18 PathOpsInverseGM() { | 18 PathOpsInverseGM() { |
| 19 } | 19 } |
| 20 | 20 |
| 21 protected: | 21 protected: |
| 22 void onOnceBeforeDraw() override { | 22 void onOnceBeforeDraw() override { |
| 23 const unsigned oneColor = 0xFF8080FF; | 23 const unsigned oneColor = sk_tool_utils::color_to_565(0xFF8080FF); |
| 24 const unsigned twoColor = 0x807F1f1f; | 24 const unsigned twoColor = 0x807F1f1f; |
| 25 SkColor blendColor = blend(oneColor, twoColor); | 25 SkColor blendColor = blend(oneColor, twoColor); |
| 26 makePaint(&fOnePaint, oneColor); | 26 makePaint(&fOnePaint, oneColor); |
| 27 makePaint(&fTwoPaint, twoColor); | 27 makePaint(&fTwoPaint, twoColor); |
| 28 makePaint(&fOpPaint[kDifference_SkPathOp], oneColor); | 28 makePaint(&fOpPaint[kDifference_SkPathOp], oneColor); |
| 29 makePaint(&fOpPaint[kIntersect_SkPathOp], blendColor); | 29 makePaint(&fOpPaint[kIntersect_SkPathOp], blendColor); |
| 30 makePaint(&fOpPaint[kUnion_SkPathOp], 0xFFc0FFc0); | 30 makePaint(&fOpPaint[kUnion_SkPathOp], sk_tool_utils::color_to_565(0xFFc0
FFc0)); |
| 31 makePaint(&fOpPaint[kReverseDifference_SkPathOp], twoColor); | 31 makePaint(&fOpPaint[kReverseDifference_SkPathOp], twoColor); |
| 32 makePaint(&fOpPaint[kXOR_SkPathOp], 0xFFa0FFe0); | 32 makePaint(&fOpPaint[kXOR_SkPathOp], sk_tool_utils::color_to_565(0xFFa0FF
e0)); |
| 33 makePaint(&fOutlinePaint, 0xFF000000); | 33 makePaint(&fOutlinePaint, 0xFF000000); |
| 34 fOutlinePaint.setStyle(SkPaint::kStroke_Style); | 34 fOutlinePaint.setStyle(SkPaint::kStroke_Style); |
| 35 } | 35 } |
| 36 | 36 |
| 37 SkColor blend(SkColor one, SkColor two) { | 37 SkColor blend(SkColor one, SkColor two) { |
| 38 SkBitmap temp; | 38 SkBitmap temp; |
| 39 temp.allocN32Pixels(1, 1); | 39 temp.allocN32Pixels(1, 1); |
| 40 SkCanvas canvas(temp); | 40 SkCanvas canvas(temp); |
| 41 canvas.drawColor(one); | 41 canvas.drawColor(one); |
| 42 canvas.drawColor(two); | 42 canvas.drawColor(two); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 SkPaint fOpPaint[kReverseDifference_SkPathOp - kDifference_SkPathOp + 1]; | 105 SkPaint fOpPaint[kReverseDifference_SkPathOp - kDifference_SkPathOp + 1]; |
| 106 typedef GM INHERITED; | 106 typedef GM INHERITED; |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 ////////////////////////////////////////////////////////////////////////////// | 109 ////////////////////////////////////////////////////////////////////////////// |
| 110 | 110 |
| 111 static GM* MyFactory(void*) { return new PathOpsInverseGM; } | 111 static GM* MyFactory(void*) { return new PathOpsInverseGM; } |
| 112 static GMRegistry reg(MyFactory); | 112 static GMRegistry reg(MyFactory); |
| 113 | 113 |
| 114 } | 114 } |
| OLD | NEW |