xref: /aosp_15_r20/external/skia/gm/crbug_1174186.cpp (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2021 Google LLC
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 
8 #include "gm/gm.h"
9 #include "include/core/SkCanvas.h"
10 #include "include/core/SkMatrix.h"
11 #include "include/core/SkRect.h"
12 #include "src/base/SkFloatBits.h"
13 
14 // Outsetting of very thin, nearly line, quads for AA would go haywire and draw far outside of the
15 // quad. Artifacts seemed to occur more when coord values are large, hence the large GM size. At the
16 // time of GM creation this was fixed by dropping AA, which makes these quads practically never draw
17 // as it's very unlikely a pixel center would fall inside the geometry.
18 DEF_SIMPLE_GM(crbug_1174186, canvas, 1200, 1200) {
19     auto m = SkMatrix::MakeAll(
20             SkBits2Float(0x24480629), SkBits2Float(0xbf3555c2), SkBits2Float(0x4377d67b),
21             SkBits2Float(0x23a61d51), SkBits2Float(0x3f34b400), SkBits2Float(0x4453f572),
22             SkBits2Float(0x00000000), SkBits2Float(0x00000000), SkBits2Float(0x3f800000));
23 
24     SkPoint pts[] = {{SkBits2Float(0x3f7ffff2), SkBits2Float(0x43483d60)},
25                      {SkBits2Float(0x00000000), SkBits2Float(0x43483d60)},
26                      {SkBits2Float(0x00000000), SkBits2Float(0x4311a628)},
27                      {SkBits2Float(0x3f800000), SkBits2Float(0x43130f8c)}};
28     SkColor color = SK_ColorGREEN;
29     canvas->translate(-500, 0);
30     for (int i = 0; i < 10; ++i) {
31         for (int flags = 0; flags < static_cast<int>(SkCanvas::kAll_QuadAAFlags); ++flags) {
32             SkCanvas::QuadAAFlags aaFlags = static_cast<SkCanvas::QuadAAFlags>(flags);
33             canvas->save();
34             canvas->concat(m);
35             canvas->experimental_DrawEdgeAAQuad(SkRect::MakeWH(1000, 1000), pts, aaFlags, color,
36                                                 SkBlendMode::kSrcOver);
37             canvas->restore();
38             canvas->translate(5.1f, 0);
39             SkColor rgb = color & 0x00FFFFFF;
40             color = 0xFF000000 | (rgb << 4) | (rgb >> 20);
41         }
42     }
43 }
44