skia2/gm/plus.cpp
Mike Reed 3ed485f424 Revert[5] "replace SkXfermode obj with SkBlendMode enum in paints"
This reverts commit I0fa5c58af428f3da8565465d1219a34ef8417d9a.

Reason for revert: failing to deserialize some of the 100K

Original change's description:
> Revert[4] "replace SkXfermode obj with SkBlendMode enum in paints"
> 
> This reverts commit 2cbcd12281.
> 
> BUG=skia:
> 
> GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2924
> 
> Change-Id: I0fa5c58af428f3da8565465d1219a34ef8417d9a
> Reviewed-on: https://skia-review.googlesource.com/2924
> Reviewed-by: Mike Reed <reed@google.com>
> Commit-Queue: Mike Reed <reed@google.com>
> 

TBR=reed@google.com,reviews@skia.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Change-Id: I1805a57eef5ebcac203da5989c8539345ecf806f
Reviewed-on: https://skia-review.googlesource.com/2962
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2016-10-04 21:35:56 +00:00

46 lines
1.3 KiB
C++

/*
* 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"
#include "SkPath.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();
}