Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
GrNativeRect Struct Reference

#include <GrNativeRect.h>

Public Member Functions

const intasInts () const
 
intasInts ()
 
SkIRect asSkIRect () const
 
void setRelativeTo (GrSurfaceOrigin org, int rtHeight, const SkIRect &devRect)
 
void setRelativeTo (GrSurfaceOrigin origin, int surfaceHeight, int leftOffset, int topOffset, int width, int height)
 
bool contains (int width, int height) const
 
void invalidate ()
 
bool isInvalid () const
 
bool operator== (const GrNativeRect &that) const
 
bool operator!= (const GrNativeRect &that) const
 

Static Public Member Functions

static GrNativeRect MakeRelativeTo (GrSurfaceOrigin origin, int rtHeight, SkIRect devRect)
 
static SkIRect MakeIRectRelativeTo (GrSurfaceOrigin origin, int rtHeight, SkIRect devRect)
 

Public Attributes

int fX
 
int fY
 
int fWidth
 
int fHeight
 

Detailed Description

Helper struct for dealing with bottom-up surface origins (bottom-up instead of top-down).

Definition at line 19 of file GrNativeRect.h.

Member Function Documentation

◆ asInts() [1/2]

int * GrNativeRect::asInts ( )
inline

Definition at line 47 of file GrNativeRect.h.

47{ return &fX; }

◆ asInts() [2/2]

const int * GrNativeRect::asInts ( ) const
inline

cast-safe way to treat the rect as an array of (4) ints.

Definition at line 38 of file GrNativeRect.h.

38 {
39 return &fX;
40
41 static_assert(0 == offsetof(GrNativeRect, fX));
42 static_assert(4 == offsetof(GrNativeRect, fY));
43 static_assert(8 == offsetof(GrNativeRect, fWidth));
44 static_assert(12 == offsetof(GrNativeRect, fHeight));
45 static_assert(16 == sizeof(GrNativeRect)); // For an array of GrNativeRect.
46 }

◆ asSkIRect()

SkIRect GrNativeRect::asSkIRect ( ) const
inline

Definition at line 49 of file GrNativeRect.h.

49{ return SkIRect::MakeXYWH(fX, fY, fWidth, fHeight); }
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
Definition: SkRect.h:104

◆ contains()

bool GrNativeRect::contains ( int  width,
int  height 
) const
inline

Definition at line 77 of file GrNativeRect.h.

77 {
78 return fX <= 0 &&
79 fY <= 0 &&
80 fX + fWidth >= width &&
81 fY + fHeight >= height;
82 }
int32_t height
int32_t width

◆ invalidate()

void GrNativeRect::invalidate ( )
inline

Definition at line 84 of file GrNativeRect.h.

84{fX = fWidth = fY = fHeight = -1;}

◆ isInvalid()

bool GrNativeRect::isInvalid ( ) const
inline

Definition at line 85 of file GrNativeRect.h.

85 { return fX == -1 && fWidth == -1 && fY == -1
86 && fHeight == -1; }

◆ MakeIRectRelativeTo()

static SkIRect GrNativeRect::MakeIRectRelativeTo ( GrSurfaceOrigin  origin,
int  rtHeight,
SkIRect  devRect 
)
inlinestatic

Definition at line 31 of file GrNativeRect.h.

31 {
32 return MakeRelativeTo(origin, rtHeight, devRect).asSkIRect();
33 }
SkIRect asSkIRect() const
Definition: GrNativeRect.h:49
static GrNativeRect MakeRelativeTo(GrSurfaceOrigin origin, int rtHeight, SkIRect devRect)
Definition: GrNativeRect.h:25

◆ MakeRelativeTo()

static GrNativeRect GrNativeRect::MakeRelativeTo ( GrSurfaceOrigin  origin,
int  rtHeight,
SkIRect  devRect 
)
inlinestatic

Definition at line 25 of file GrNativeRect.h.

25 {
26 GrNativeRect nativeRect;
27 nativeRect.setRelativeTo(origin, rtHeight, devRect);
28 return nativeRect;
29 }
void setRelativeTo(GrSurfaceOrigin org, int rtHeight, const SkIRect &devRect)
Definition: GrNativeRect.h:57

◆ operator!=()

bool GrNativeRect::operator!= ( const GrNativeRect that) const
inline

Definition at line 92 of file GrNativeRect.h.

92{return !(*this == that);}

◆ operator==()

bool GrNativeRect::operator== ( const GrNativeRect that) const
inline

Definition at line 88 of file GrNativeRect.h.

88 {
89 return 0 == memcmp(this, &that, sizeof(GrNativeRect));
90 }

◆ setRelativeTo() [1/2]

void GrNativeRect::setRelativeTo ( GrSurfaceOrigin  org,
int  rtHeight,
const SkIRect devRect 
)
inline

Definition at line 57 of file GrNativeRect.h.

57 {
58 this->setRelativeTo(org, rtHeight, devRect.x(), devRect.y(), devRect.width(),
59 devRect.height());
60 }
constexpr int32_t x() const
Definition: SkRect.h:141
constexpr int32_t y() const
Definition: SkRect.h:148
constexpr int32_t height() const
Definition: SkRect.h:165
constexpr int32_t width() const
Definition: SkRect.h:158

◆ setRelativeTo() [2/2]

void GrNativeRect::setRelativeTo ( GrSurfaceOrigin  origin,
int  surfaceHeight,
int  leftOffset,
int  topOffset,
int  width,
int  height 
)
inline

Definition at line 62 of file GrNativeRect.h.

63 {
64 fX = leftOffset;
65 fWidth = width;
66 if (kBottomLeft_GrSurfaceOrigin == origin) {
67 fY = surfaceHeight - topOffset - height;
68 } else {
69 fY = topOffset;
70 }
72
73 SkASSERT(fWidth >= 0);
74 SkASSERT(fHeight >= 0);
75 }
@ kBottomLeft_GrSurfaceOrigin
Definition: GrTypes.h:149
#define SkASSERT(cond)
Definition: SkAssert.h:116

Member Data Documentation

◆ fHeight

int GrNativeRect::fHeight

Definition at line 23 of file GrNativeRect.h.

◆ fWidth

int GrNativeRect::fWidth

Definition at line 22 of file GrNativeRect.h.

◆ fX

int GrNativeRect::fX

Definition at line 20 of file GrNativeRect.h.

◆ fY

int GrNativeRect::fY

Definition at line 21 of file GrNativeRect.h.


The documentation for this struct was generated from the following file: