Flutter Engine
The Flutter Engine
crbug_1177833.cpp
Go to the documentation of this file.
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"
11#include "include/core/SkRect.h"
13
14// Bad quads dumped from SkiaRenderer in crbug.com/1178833. These should all draw as really thin
15// lines.
16DEF_SIMPLE_GM(crbug_1177833, canvas, 400, 400) {
17 canvas->clear(SK_ColorBLACK);
18 canvas->translate(-700, -700);
19 // This quad had two issues. The inset collapsed the inner 2D projected quad to a point but
20 // didn't enable enough degrees of freedom to adjust the 4 3D points to project to that point.
21 // Also, the outset produced a 2D projected point far away from the original quad but the
22 // shader was not checking the geometric subset and so pixels far away from the projection of
23 // the quad would have positive coverage.
24 {
25 canvas->save();
26 canvas->concat(SkMatrix::MakeAll(SkBits2Float(0xbf79250e), SkBits2Float(0x3e9da860), SkBits2Float(0x44914c8a),
27 SkBits2Float(0xbf982962), SkBits2Float(0xbf280002), SkBits2Float(0x44c3116e),
28 SkBits2Float(0xba9bfe62), SkBits2Float(0x39d10455), SkBits2Float(0x3fc9b377)));
29 SkRect rect = {SkBits2Float(0x00000000),
30 SkBits2Float(0x00000000),
31 SkBits2Float(0x40a00000),
32 SkBits2Float(0x43560000)};
33 SkPoint clip[4] = {{SkBits2Float(0x409fff57), SkBits2Float(0x40c86a18)},
34 {SkBits2Float(0x409fff57), SkBits2Float(0x4314dc8c)},
35 {SkBits2Float(0x407f6b0d), SkBits2Float(0x43157fff)},
36 {SkBits2Float(0x4040859c), SkBits2Float(0x43140374)}};
37 SkCanvas::QuadAAFlags aaFlags = static_cast<SkCanvas::QuadAAFlags>(0x00000002);
38 SkColor4f color = {SkBits2Float(0x3f6eeef0),
39 SkBits2Float(0x3f6eeef0),
40 SkBits2Float(0x3f6eeef0),
41 SkBits2Float(0x3f800000)};
42 SkBlendMode mode = static_cast<SkBlendMode>(0x00000003);
43 canvas->experimental_DrawEdgeAAQuad(rect, clip, aaFlags, color, mode);
44 canvas->restore();
45 }
46 // This quad also exposed the inset collapse to a point without enough degrees of freedom issue.
47 canvas->save();
48 canvas->translate(-300, 0);
49 {
50 canvas->save();
51 canvas->concat(SkMatrix::MakeAll(SkBits2Float(0x3f54dd8a), SkBits2Float(0xbf9096a4), SkBits2Float(0x447eae34),
52 SkBits2Float(0x3f3f6905), SkBits2Float(0xbe5208ba), SkBits2Float(0x4418118b),
53 SkBits2Float(0x3aa134a1), SkBits2Float(0xb93ef249), SkBits2Float(0x3f580bd4)));
54 SkRect rect = {SkBits2Float(0x00000000),
55 SkBits2Float(0x00000000),
56 SkBits2Float(0x40a00000),
57 SkBits2Float(0x43560000)};
58 SkPoint clip[4] = {{SkBits2Float(0x40a0000e), SkBits2Float(0x40c86b5a)},
59 {SkBits2Float(0x40a0001e), SkBits2Float(0x4314dd5f)},
60 {SkBits2Float(0x407f76eb), SkBits2Float(0x431580c2)},
61 {SkBits2Float(0x404092e7), SkBits2Float(0x43140445)}};
62 SkCanvas::QuadAAFlags aaFlags = static_cast<SkCanvas::QuadAAFlags>(0x00000002);
63 SkColor4f color = {SkBits2Float(0x3f6eeef0),
64 SkBits2Float(0x3f6eeef0),
65 SkBits2Float(0x3f6eeef0),
66 SkBits2Float(0x3f800000)};
67 SkBlendMode mode = static_cast<SkBlendMode>(0x00000003);
68 canvas->experimental_DrawEdgeAAQuad(rect, clip, aaFlags, color, mode);
69 canvas->restore();
70 }
71 canvas->restore();
72 // This quad exposed a similar issue to the point issue above, but when collapsing to a
73 // triangle. When a 2D quad edge collapsed from insetting we'd replace it with a point off of
74 // its adjacent edges. We need to ensure the code that moves the 3D point that projects to
75 // the 2D point has 2 degrees of freedom so it can find the correct 3D point.
76 {
77 canvas->save();
78 canvas->concat(SkMatrix::MakeAll(SkBits2Float(0x3f54b255), SkBits2Float(0x3eb5a94d), SkBits2Float(0x443d7419),
79 SkBits2Float(0x3f885d66), SkBits2Float(0x3f5a6b9c), SkBits2Float(0x443c7334),
80 SkBits2Float(0x3aa95ea5), SkBits2Float(0xb8a1391e), SkBits2Float(0x3f84dde5)));
81 SkRect rect = {SkBits2Float(0x00000000),
82 SkBits2Float(0x00000000),
83 SkBits2Float(0x40a00000),
84 SkBits2Float(0x43100000)};
85 SkPoint clip[4] = {{SkBits2Float(0x405a654c), SkBits2Float(0x42e8c790)},
86 {SkBits2Float(0x3728c61b), SkBits2Float(0x42e7df31)},
87 {SkBits2Float(0xb678ecc5), SkBits2Float(0x412db4e0)},
88 {SkBits2Float(0x4024b2ad), SkBits2Float(0x413ab3ed)}};
89 SkCanvas::QuadAAFlags aaFlags = static_cast<SkCanvas::QuadAAFlags>(0x00000004);
90 SkColor4f color = {SkBits2Float(0x3f800000),
91 SkBits2Float(0x3f800000),
92 SkBits2Float(0x3f800000),
93 SkBits2Float(0x3f800000)};
94 SkBlendMode mode = static_cast<SkBlendMode>(0x00000003);
95 canvas->experimental_DrawEdgeAAQuad(rect, clip, aaFlags, color, mode);
96 canvas->restore();
97 }
98}
99
SkBlendMode
Definition: SkBlendMode.h:38
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
static float SkBits2Float(uint32_t bits)
Definition: SkFloatBits.h:48
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
static SkMatrix MakeAll(SkScalar scaleX, SkScalar skewX, SkScalar transX, SkScalar skewY, SkScalar scaleY, SkScalar transY, SkScalar pers0, SkScalar pers1, SkScalar pers2)
Definition: SkMatrix.h:179
DEF_SIMPLE_GM(crbug_1177833, canvas, 400, 400)
DlColor color
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
Definition: switches.h:228