2 * Copyright 2015 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
11 DEF_SIMPLE_GM(PlusMergesAA, canvas, 256, 256) {
13 p.setColor(SK_ColorRED);
14 p.setAntiAlias(true); // <-- crucial to the test that we use AA
16 // Draw a two red squares.
17 canvas->drawRect(SkRect::MakeWH(100, 100), p);
18 canvas->drawRect(SkRect::MakeXYWH(150, 0, 100, 100), p);
20 p.setColor(0xf000ff00);
22 // We'll draw a green square on top of each using two triangles.
24 upperLeft.lineTo(100, 0);
25 upperLeft.lineTo(0, 100);
26 upperLeft.lineTo(0, 0);
29 bottomRight.moveTo(100, 0);
30 bottomRight.lineTo(100, 100);
31 bottomRight.lineTo(0, 100);
32 bottomRight.lineTo(100, 0);
34 // The left square is drawn simply with SrcOver. It will show a red seam.
35 canvas->drawPath(upperLeft, p);
36 canvas->drawPath(bottomRight, p);
38 // Using Plus on the right should merge the AA of seam together completely covering the red.
39 canvas->saveLayer(nullptr, nullptr);
40 p.setBlendMode(SkBlendMode::kPlus);
41 canvas->translate(150, 0);
42 canvas->drawPath(upperLeft, p);
43 canvas->drawPath(bottomRight, p);