diff options
author | mtklein <mtklein@chromium.org> | 2015-05-21 10:33:09 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-21 10:33:09 -0700 |
commit | 7005a57c545811b13ed141bac3ef12cb4a94f329 (patch) | |
tree | 9cf0eb844738a35f3ef7c0ae689e1e910f3e3c77 /gm/plus.cpp | |
parent | 0edea2c8e76a9f5340a7a4960193757c4a5fb227 (diff) |
Add PlusMergesAA GM
C.f. https://crrev.com/1156453002/
BUG=skia:
Review URL: https://codereview.chromium.org/1149103003
Diffstat (limited to 'gm/plus.cpp')
-rw-r--r-- | gm/plus.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/gm/plus.cpp b/gm/plus.cpp new file mode 100644 index 0000000000..ba2a1a0a39 --- /dev/null +++ b/gm/plus.cpp @@ -0,0 +1,44 @@ +/* + * Copyright 2015 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "gm.h" + +DEF_SIMPLE_GM(PlusMergesAA, canvas, 256, 256) { + SkPaint p; + p.setColor(SK_ColorRED); + p.setAntiAlias(true); // <-- crucial to the test that we use AA + + // Draw a two red squares. + canvas->drawRect(SkRect::MakeWH(100, 100), p); + canvas->drawRect(SkRect::MakeXYWH(150, 0, 100, 100), p); + + p.setColor(0xf000ff00); + + // We'll draw a green square on top of each using two triangles. + SkPath upperLeft; + upperLeft.lineTo(100, 0); + upperLeft.lineTo(0, 100); + upperLeft.lineTo(0, 0); + + SkPath bottomRight; + bottomRight.moveTo(100, 0); + bottomRight.lineTo(100, 100); + bottomRight.lineTo(0, 100); + bottomRight.lineTo(100, 0); + + // The left square is drawn simply with SrcOver. It will show a red seam. + canvas->drawPath(upperLeft, p); + canvas->drawPath(bottomRight, p); + + // Using Plus on the right should merge the AA of seam together completely covering the red. + canvas->saveLayer(nullptr, nullptr); + p.setXfermodeMode(SkXfermode::kPlus_Mode); + canvas->translate(150, 0); + canvas->drawPath(upperLeft, p); + canvas->drawPath(bottomRight, p); + canvas->restore(); +} |