Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
GrScissorState Class Reference

#include <GrScissorState.h>

Public Member Functions

 GrScissorState (const SkISize &rtDims)
 
void setDisabled ()
 
bool set (const SkIRect &rect)
 
bool intersect (const SkIRect &rect)
 
bool relaxTest (const SkISize &logicalDimensions)
 
bool operator== (const GrScissorState &other) const
 
bool operator!= (const GrScissorState &other) const
 
bool enabled () const
 
const SkIRectrect () const
 

Detailed Description

The scissor state is stored as the scissor rectangle and the backing store bounds of the render target that the scissor will apply to. If the render target is approximate fit and the padded content should not be modified, the clip should apply the render target context's logical bounds as part of the scissor (e.g. when stenciling). This puts the onus on the render target context to intentionally discard the scissor at its logical bounds when drawing into the padded content is acceptable (e.g. color-only updates).

Definition at line 21 of file GrScissorState.h.

Constructor & Destructor Documentation

◆ GrScissorState()

GrScissorState::GrScissorState ( const SkISize rtDims)
inlineexplicit

Definition at line 24 of file GrScissorState.h.

25 : fRTSize(rtDims)
26 , fRect(SkIRect::MakeSize(rtDims)) {}
static constexpr SkIRect MakeSize(const SkISize &size)
Definition: SkRect.h:66

Member Function Documentation

◆ enabled()

bool GrScissorState::enabled ( ) const
inline

Definition at line 63 of file GrScissorState.h.

63 {
64 SkASSERT(fRect.isEmpty() || SkIRect::MakeSize(fRTSize).contains(fRect));
65 // This is equivalent to a strict contains check on SkIRect::MakeSize(rtSize) w/o creating
66 // the render target bounding rectangle.
67 return fRect.fLeft > 0 || fRect.fTop > 0 ||
68 fRect.fRight < fRTSize.fWidth || fRect.fBottom < fRTSize.fHeight;
69 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
int32_t fBottom
larger y-axis bounds
Definition: SkRect.h:36
int32_t fTop
smaller y-axis bounds
Definition: SkRect.h:34
bool isEmpty() const
Definition: SkRect.h:202
int32_t fLeft
smaller x-axis bounds
Definition: SkRect.h:33
bool contains(int32_t x, int32_t y) const
Definition: SkRect.h:463
int32_t fRight
larger x-axis bounds
Definition: SkRect.h:35
int32_t fHeight
Definition: SkSize.h:18
int32_t fWidth
Definition: SkSize.h:17

◆ intersect()

bool GrScissorState::intersect ( const SkIRect rect)
inline

Definition at line 34 of file GrScissorState.h.

34 {
35 if (!fRect.intersect(rect)) {
36 fRect.setEmpty();
37 return false;
38 } else {
39 return true;
40 }
41 }
const SkIRect & rect() const
bool intersect(const SkIRect &r)
Definition: SkRect.h:513
void setEmpty()
Definition: SkRect.h:242

◆ operator!=()

bool GrScissorState::operator!= ( const GrScissorState other) const
inline

Definition at line 61 of file GrScissorState.h.

61{ return !(*this == other); }

◆ operator==()

bool GrScissorState::operator== ( const GrScissorState other) const
inline

Definition at line 58 of file GrScissorState.h.

58 {
59 return fRTSize == other.fRTSize && fRect == other.fRect;
60 }

◆ rect()

const SkIRect & GrScissorState::rect ( ) const
inline

Definition at line 73 of file GrScissorState.h.

73 {
74 SkASSERT(fRect.isEmpty() || SkIRect::MakeSize(fRTSize).contains(fRect));
75 return fRect;
76 }

◆ relaxTest()

bool GrScissorState::relaxTest ( const SkISize logicalDimensions)
inline

Definition at line 46 of file GrScissorState.h.

46 {
47 SkASSERT(logicalDimensions.fWidth <= fRTSize.fWidth &&
48 logicalDimensions.fHeight <= fRTSize.fHeight);
49 if (fRect.fLeft == 0 && fRect.fTop == 0 && fRect.fRight >= logicalDimensions.fWidth &&
50 fRect.fBottom >= logicalDimensions.fHeight) {
51 this->setDisabled();
52 return true;
53 } else {
54 return false;
55 }
56 }

◆ set()

bool GrScissorState::set ( const SkIRect rect)
inline

Definition at line 29 of file GrScissorState.h.

29 {
30 this->setDisabled();
31 return this->intersect(rect);
32 }
bool intersect(const SkIRect &rect)

◆ setDisabled()

void GrScissorState::setDisabled ( )
inline

Definition at line 28 of file GrScissorState.h.

28{ fRect = SkIRect::MakeSize(fRTSize); }

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