Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
gm
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
"
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
// 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.
24
DEF_SIMPLE_GM
(crbug_1162942, canvas, 620, 200) {
25
// Matrix and quad values taken from Chrome repro scenario.
26
SkMatrix
ctm =
SkMatrix::MakeAll
(
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)}};
36
SkRect
bounds;
37
bounds.setBounds(pts, 4);
38
39
canvas->clear(
SK_ColorWHITE
);
40
41
SkCanvas::QuadAAFlags
flags
[] = {
42
(
SkCanvas::QuadAAFlags
) (
SkCanvas::kTop_QuadAAFlag
|
SkCanvas::kLeft_QuadAAFlag
),
43
(
SkCanvas::QuadAAFlags
) (
SkCanvas::kBottom_QuadAAFlag
|
SkCanvas::kRight_QuadAAFlag
),
44
(
SkCanvas::QuadAAFlags
) (
SkCanvas::kBottom_QuadAAFlag
),
45
(
SkCanvas::QuadAAFlags
) (
SkCanvas::kRight_QuadAAFlag
),
46
(
SkCanvas::QuadAAFlags
) (
SkCanvas::kRight_QuadAAFlag
|
SkCanvas::kLeft_QuadAAFlag
),
47
(
SkCanvas::QuadAAFlags
) (
SkCanvas::kTop_QuadAAFlag
|
SkCanvas::kBottom_QuadAAFlag
),
48
};
49
50
SkColor
color
=
SK_ColorGREEN
;
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
color
SkColor4f color
Definition
ImageShaderTest.cpp:28
SkBlendMode::kSrcOver
@ kSrcOver
r = s + (1-sa)*d
SkCanvas.h
SkColor
uint32_t SkColor
Definition
SkColor.h:37
SK_ColorGREEN
constexpr SkColor SK_ColorGREEN
Definition
SkColor.h:131
SK_ColorWHITE
constexpr SkColor SK_ColorWHITE
Definition
SkColor.h:122
SkFloatBits.h
SkBits2Float
static float SkBits2Float(uint32_t bits)
Definition
SkFloatBits.h:48
SkMatrix.h
SkRect.h
SkCanvas::QuadAAFlags
QuadAAFlags
Definition
SkCanvas.h:1658
SkCanvas::kTop_QuadAAFlag
@ kTop_QuadAAFlag
Definition
SkCanvas.h:1660
SkCanvas::kRight_QuadAAFlag
@ kRight_QuadAAFlag
Definition
SkCanvas.h:1661
SkCanvas::kLeft_QuadAAFlag
@ kLeft_QuadAAFlag
Definition
SkCanvas.h:1659
SkCanvas::kBottom_QuadAAFlag
@ kBottom_QuadAAFlag
Definition
SkCanvas.h:1662
SkMatrix
Definition
SkMatrix.h:54
SkMatrix::postTranslate
SkMatrix & postTranslate(SkScalar dx, SkScalar dy)
Definition
SkMatrix.cpp:281
SkMatrix::MakeAll
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
flags
FlutterSemanticsFlag flags
Definition
fl_accessible_node.cc:105
gm.h
DEF_SIMPLE_GM
#define DEF_SIMPLE_GM(NAME, CANVAS, W, H)
Definition
gm.h:50
SkPoint
Definition
SkPoint_impl.h:163
SkRect
Definition
extension.cpp:13
Generated on Fri Apr 26 2024 06:16:01 for Flutter Engine by
1.9.8