blob: abfcb540e56d1c4c31ad9079a53d5c623f43fc3e [file] [log] [blame]
Brian Salomon09181ef2018-11-14 13:39:51 -05001/*
2 * Copyright 2018 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#include "gm/gm.h"
Ben Wagner7fde8e12019-05-01 17:28:53 -04009#include "include/core/SkBlendMode.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050010#include "include/core/SkCanvas.h"
11#include "include/core/SkPaint.h"
Ben Wagner7fde8e12019-05-01 17:28:53 -040012#include "include/core/SkRect.h"
Brian Salomon09181ef2018-11-14 13:39:51 -050013
14// The root cause of this bug was that when dual source blending was not supported and we made a
15// copy of the destination to perform blending we would clip the copy bounds to the current clip.
16// However, it is possible for anti-aliased that are fully contained by the clip in a geometric
17// sense to actually draw outside the clip in pixel space because we don't consider aa bloat when
18// determining if the draw is contained by the clip.
19DEF_SIMPLE_GM(crbug_892988, canvas, 256, 256) {
20 SkPaint paint1;
21 paint1.setStyle(SkPaint::kStroke_Style);
22 paint1.setStrokeWidth(1.f);
23 paint1.setAntiAlias(true);
24 canvas->drawRect(SkRect::MakeLTRB(11.5, 0.5, 245.5, 245.5), paint1);
25 canvas->clipRect(SkRect::MakeLTRB(12, 1, 244, 244), true);
26 SkPaint paint2;
27 // Use src mode with a non-opaque color to produce a blend that can't be handled with
28 // simple blend coefficients.
29 paint2.setColor(0xF0FFFFFF);
30 paint2.setBlendMode(SkBlendMode::kSrc);
31 paint2.setAntiAlias(true);
32 canvas->drawRect(SkRect::MakeLTRB(12, 1, 244, 244), paint2);
33}