Flutter Engine
The Flutter Engine
crbug_1162942.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2020 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// This tests a scenario where when the 2D projection of a perspective quad is inset we degenerate
15// the inset 2d geometry to a triangle because an inset vertex crosses the opposite edge. When we
16// project back to 3D and try to move the original verts along the original edges so that they
17// project to the 2D points. Whether an edge can be moved along depends on whether the adjacent edge
18// at the vertex is AA. However, in the degenerate triangle case the 2D point may not fall along
19// either of the edges. Thus, if we're constrained to moving along one edge and solve for X or Y the
20// other value may go wildly away from projecting to the 2D value. The current approach is to force
21// AA on at both edges that meet at a vertex whose inset point has been replaced by an off-edge
22// point if either is AA originally. This gives us an additional vector to move along so that we can
23// find a 3D point that projects to the 2D point in both X and Y.
24DEF_SIMPLE_GM(crbug_1162942, canvas, 620, 200) {
25 // Matrix and quad values taken from Chrome repro scenario.
27 SkBits2Float(0x3FCC7F75), SkBits2Float(0x3D5784FC), SkBits2Float(0x44C48C99),
28 SkBits2Float(0x3F699F7F), SkBits2Float(0x3E0A0D37), SkBits2Float(0x43908518),
29 SkBits2Float(0x3AA17423), SkBits2Float(0x3A6CCDC3), SkBits2Float(0x3F2EFEEC));
30 ctm.postTranslate(-1500.f, -325.f);
31
32 SkPoint pts[4] = {{SkBits2Float(0x3F39778B), SkBits2Float(0x43FF7FFC)},
33 {SkBits2Float(0x0), SkBits2Float(0x43FF7FFA)},
34 {SkBits2Float(0xB83B055E), SkBits2Float(0x42500003)},
35 {SkBits2Float(0x3F39776F), SkBits2Float(0x4250000D)}};
37 bounds.setBounds(pts, 4);
38
39 canvas->clear(SK_ColorWHITE);
40
48 };
49
51 for (auto aaFlags : flags) {
52 canvas->save();
53 canvas->concat(ctm);
54 canvas->experimental_DrawEdgeAAQuad(bounds, pts, aaFlags, color, SkBlendMode::kSrcOver);
55 SkColor rgb = color & 0x00FFFFFF;
56 color = 0xFF000000 | (rgb << 4) | (rgb >> 20);
57 canvas->restore();
58 canvas->translate(0, 25);
59 }
60}
61
@ kSrcOver
r = s + (1-sa)*d
uint32_t SkColor
Definition: SkColor.h:37
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
static float SkBits2Float(uint32_t bits)
Definition: SkFloatBits.h:48
@ kTop_QuadAAFlag
Definition: SkCanvas.h:1660
@ kRight_QuadAAFlag
Definition: SkCanvas.h:1661
@ kLeft_QuadAAFlag
Definition: SkCanvas.h:1659
@ kBottom_QuadAAFlag
Definition: SkCanvas.h:1662
SkMatrix & postTranslate(SkScalar dx, SkScalar dy)
Definition: SkMatrix.cpp:281
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_1162942, canvas, 620, 200)
DlColor color
FlutterSemanticsFlag flags
Optional< SkRect > bounds
Definition: SkRecords.h:189