Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Typedefs | Functions
GrQuad.cpp File Reference
#include "src/gpu/ganesh/geometry/GrQuad.h"
#include "include/core/SkMatrix.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"

Go to the source code of this file.

Typedefs

using V4f = skvx::Vec< 4, float >
 

Functions

static bool aa_affects_rect (GrQuadAAFlags edgeFlags, float ql, float qt, float qr, float qb)
 
static void map_rect_translate_scale (const SkRect &rect, const SkMatrix &m, V4f *xs, V4f *ys)
 
static void map_quad_general (const V4f &qx, const V4f &qy, const SkMatrix &m, V4f *xs, V4f *ys, V4f *ws)
 
static void map_rect_general (const SkRect &rect, const SkMatrix &matrix, V4f *xs, V4f *ys, V4f *ws)
 
static void rearrange_sk_to_gr_points (const SkPoint skQuadPts[4], V4f *xs, V4f *ys)
 
static GrQuad::Type quad_type_for_transformed_rect (const SkMatrix &matrix)
 
static GrQuad::Type quad_type_for_points (const SkPoint pts[4], const SkMatrix &matrix)
 

Typedef Documentation

◆ V4f

using V4f = skvx::Vec<4, float>

Definition at line 13 of file GrQuad.cpp.

Function Documentation

◆ aa_affects_rect()

static bool aa_affects_rect ( GrQuadAAFlags  edgeFlags,
float  ql,
float  qt,
float  qr,
float  qb 
)
static

Definition at line 15 of file GrQuad.cpp.

15 {
16 // Edge coordinates for non-AA edges do not need to be integers; any AA-enabled edge that is
17 // at an integer coordinate could be drawn non-AA and be visually identical to non-AA.
18 return ((edgeFlags & GrQuadAAFlags::kLeft) && !SkScalarIsInt(ql)) ||
19 ((edgeFlags & GrQuadAAFlags::kRight) && !SkScalarIsInt(qr)) ||
20 ((edgeFlags & GrQuadAAFlags::kTop) && !SkScalarIsInt(qt)) ||
21 ((edgeFlags & GrQuadAAFlags::kBottom) && !SkScalarIsInt(qb));
22}
static bool SkScalarIsInt(SkScalar x)
Definition SkScalar.h:80

◆ map_quad_general()

static void map_quad_general ( const V4f qx,
const V4f qy,
const SkMatrix m,
V4f xs,
V4f ys,
V4f ws 
)
static

Definition at line 43 of file GrQuad.cpp.

44 {
45 *xs = m.getScaleX() * qx + (m.getSkewX() * qy + m.getTranslateX());
46 *ys = m.getSkewY() * qx + (m.getScaleY() * qy + m.getTranslateY());
47 if (m.hasPerspective()) {
48 V4f w = m.getPerspX() * qx + (m.getPerspY() * qy + m.get(SkMatrix::kMPersp2));
49 if (ws) {
50 // Output the calculated w coordinates
51 *ws = w;
52 } else {
53 // Apply perspective division immediately
54 V4f iw = 1.f / w;
55 *xs *= iw;
56 *ys *= iw;
57 }
58 } else if (ws) {
59 *ws = 1.f;
60 }
61}
static constexpr int kMPersp2
perspective bias
Definition SkMatrix.h:361
SkScalar w

◆ map_rect_general()

static void map_rect_general ( const SkRect rect,
const SkMatrix matrix,
V4f xs,
V4f ys,
V4f ws 
)
static

Definition at line 63 of file GrQuad.cpp.

64 {
65 V4f rx{rect.fLeft, rect.fLeft, rect.fRight, rect.fRight};
66 V4f ry{rect.fTop, rect.fBottom, rect.fTop, rect.fBottom};
67 map_quad_general(rx, ry, matrix, xs, ys, ws);
68}
static void map_quad_general(const V4f &qx, const V4f &qy, const SkMatrix &m, V4f *xs, V4f *ys, V4f *ws)
Definition GrQuad.cpp:43
sk_sp< SkBlender > blender SkRect rect
Definition SkRecords.h:350

◆ map_rect_translate_scale()

static void map_rect_translate_scale ( const SkRect rect,
const SkMatrix m,
V4f xs,
V4f ys 
)
static

Definition at line 24 of file GrQuad.cpp.

25 {
26 SkMatrix::TypeMask tm = m.getType();
28
29 V4f r = V4f::Load(&rect);
30 if (tm > SkMatrix::kIdentity_Mask) {
31 const V4f t{m.getTranslateX(), m.getTranslateY(), m.getTranslateX(), m.getTranslateY()};
32 if (tm <= SkMatrix::kTranslate_Mask) {
33 r += t;
34 } else {
35 const V4f s{m.getScaleX(), m.getScaleY(), m.getScaleX(), m.getScaleY()};
36 r = r * s + t;
37 }
38 }
39 *xs = skvx::shuffle<0, 0, 2, 2>(r);
40 *ys = skvx::shuffle<1, 3, 1, 3>(r);
41}
#define SkASSERT(cond)
Definition SkAssert.h:116
@ kTranslate_Mask
translation SkMatrix
Definition SkMatrix.h:193
@ kScale_Mask
scale SkMatrix
Definition SkMatrix.h:194
@ kIdentity_Mask
identity SkMatrix; all bits clear
Definition SkMatrix.h:192
struct MyStruct s
static SKVX_ALWAYS_INLINE Vec Load(const void *ptr)
Definition SkVx.h:109

◆ quad_type_for_points()

static GrQuad::Type quad_type_for_points ( const SkPoint  pts[4],
const SkMatrix matrix 
)
static

Definition at line 92 of file GrQuad.cpp.

92 {
93 if (matrix.hasPerspective()) {
95 }
96 // If 'pts' was formed by SkRect::toQuad() and not transformed further, it is safe to use the
97 // quad type derived from 'matrix'. Otherwise don't waste any more time and assume kStandard
98 // (most general 2D quad).
99 if ((pts[0].fX == pts[3].fX && pts[1].fX == pts[2].fX) &&
100 (pts[0].fY == pts[1].fY && pts[2].fY == pts[3].fY)) {
101 return quad_type_for_transformed_rect(matrix);
102 } else {
104 }
105}
static GrQuad::Type quad_type_for_transformed_rect(const SkMatrix &matrix)
Definition GrQuad.cpp:78
unsigned useCenter Optional< SkMatrix > matrix
Definition SkRecords.h:258

◆ quad_type_for_transformed_rect()

static GrQuad::Type quad_type_for_transformed_rect ( const SkMatrix matrix)
static

Definition at line 78 of file GrQuad.cpp.

78 {
79 if (matrix.rectStaysRect()) {
81 } else if (matrix.preservesRightAngles()) {
83 } else if (matrix.hasPerspective()) {
85 } else {
87 }
88}

◆ rearrange_sk_to_gr_points()

static void rearrange_sk_to_gr_points ( const SkPoint  skQuadPts[4],
V4f xs,
V4f ys 
)
static

Definition at line 72 of file GrQuad.cpp.

72 {
73 *xs = V4f{skQuadPts[0].fX, skQuadPts[3].fX, skQuadPts[1].fX, skQuadPts[2].fX};
74 *ys = V4f{skQuadPts[0].fY, skQuadPts[3].fY, skQuadPts[1].fY, skQuadPts[2].fY};
75}
float fX
x-axis value
float fY
y-axis value