Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
skgpu::ganesh::StencilClip Class Referencefinal

#include <StencilClip.h>

Inheritance diagram for skgpu::ganesh::StencilClip:
GrHardClip GrClip

Public Member Functions

 StencilClip (const SkISize &rtDims, uint32_t stencilStackID=SK_InvalidGenID)
 
 StencilClip (const SkISize &rtDims, const SkIRect &scissorRect, uint32_t stencilStackID=SK_InvalidGenID)
 
const GrFixedClipfixedClip () const
 
GrFixedClipfixedClip ()
 
uint32_t stencilStackID () const
 
bool hasStencilClip () const
 
void setStencilClip (uint32_t stencilStackID)
 
SkIRect getConservativeBounds () const final
 
Effect apply (GrAppliedHardClip *out, SkIRect *bounds) const final
 
PreClipResult preApply (const SkRect &drawBounds, GrAA aa) const final
 
- Public Member Functions inherited from GrClip
virtual ~GrClip ()
 

Additional Inherited Members

- Public Types inherited from GrClip
enum class  Effect { kClipped , kUnclipped , kClippedOut }
 
enum class  BoundsType { kExterior , kInterior }
 
- Static Public Member Functions inherited from GrClip
static bool IsInsideClip (const SkIRect &innerClipBounds, const SkRect &drawBounds, GrAA aa)
 
static bool IsOutsideClip (const SkIRect &outerClipBounds, const SkRect &drawBounds, GrAA aa)
 
static SkIRect GetPixelIBounds (const SkRect &bounds, GrAA aa, BoundsType mode=BoundsType::kExterior)
 
static bool IsPixelAligned (const SkRect &rect)
 
- Static Public Attributes inherited from GrClip
static constexpr SkScalar kBoundsTolerance = 1e-3f
 
static constexpr SkScalar kHalfPixelRoundingTolerance = 5e-2f
 

Detailed Description

Implements GrHardClip with the currently-existing stencil buffer contents and GrFixedClip.

Definition at line 19 of file StencilClip.h.

Constructor & Destructor Documentation

◆ StencilClip() [1/2]

skgpu::ganesh::StencilClip::StencilClip ( const SkISize rtDims,
uint32_t  stencilStackID = SK_InvalidGenID 
)
inlineexplicit

Definition at line 21 of file StencilClip.h.

22 : fFixedClip(rtDims)
23 , fStencilStackID(stencilStackID) {}
uint32_t stencilStackID() const
Definition StencilClip.h:34

◆ StencilClip() [2/2]

skgpu::ganesh::StencilClip::StencilClip ( const SkISize rtDims,
const SkIRect scissorRect,
uint32_t  stencilStackID = SK_InvalidGenID 
)
inline

Definition at line 25 of file StencilClip.h.

28 : fFixedClip(rtDims, scissorRect)
29 , fStencilStackID(stencilStackID) {}

Member Function Documentation

◆ apply()

Effect skgpu::ganesh::StencilClip::apply ( GrAppliedHardClip out,
SkIRect bounds 
) const
inlinefinalvirtual

Sets the appropriate hardware state modifications on GrAppliedHardClip that will implement the clip. On input 'bounds' is a conservative bounds of the draw that is to be clipped. After return 'bounds' has been intersected with a conservative bounds of the clip.

Implements GrHardClip.

Definition at line 42 of file StencilClip.h.

42 {
43 Effect effect = fFixedClip.apply(out, bounds);
44 if (effect == Effect::kClippedOut) {
45 // Stencil won't bring back coverage
47 }
48 if (this->hasStencilClip()) {
49 out->addStencilClip(fStencilStackID);
50 effect = Effect::kClipped;
51 }
52 return effect;
53 }
void addStencilClip(uint32_t stencilStackID)
Effect apply(GrAppliedHardClip *, SkIRect *) const final

◆ fixedClip() [1/2]

GrFixedClip & skgpu::ganesh::StencilClip::fixedClip ( )
inline

Definition at line 32 of file StencilClip.h.

32{ return fFixedClip; }

◆ fixedClip() [2/2]

const GrFixedClip & skgpu::ganesh::StencilClip::fixedClip ( ) const
inline

Definition at line 31 of file StencilClip.h.

31{ return fFixedClip; }

◆ getConservativeBounds()

SkIRect skgpu::ganesh::StencilClip::getConservativeBounds ( ) const
inlinefinalvirtual

Compute a conservative pixel bounds restricted to the given render target dimensions. The returned bounds represent the limits of pixels that can be drawn; anything outside of the bounds will be entirely clipped out.

Implements GrClip.

Definition at line 38 of file StencilClip.h.

38 {
39 return fFixedClip.getConservativeBounds();
40 }
SkIRect getConservativeBounds() const final

◆ hasStencilClip()

bool skgpu::ganesh::StencilClip::hasStencilClip ( ) const
inline

Definition at line 35 of file StencilClip.h.

35{ return SK_InvalidGenID != fStencilStackID; }
static constexpr uint32_t SK_InvalidGenID
Definition SkTypes.h:192

◆ preApply()

PreClipResult skgpu::ganesh::StencilClip::preApply ( const SkRect drawBounds,
GrAA  aa 
) const
inlinefinalvirtual

Perform preliminary, conservative analysis on the draw bounds as if it were provided to apply(). The results of this are returned the PreClipResults struct, where 'result.fEffect' corresponds to what 'apply' would return. If this value is kUnclipped or kNoDraw, then it can be assumed that apply() would also always result in the same Effect.

If kClipped is returned, apply() may further refine the effect to kUnclipped or kNoDraw, with one exception. When 'result.fIsRRect' is true, preApply() reports the single round rect and anti-aliased state that would act as an intersection on the draw geometry. If no further action is taken to modify the draw, apply() will represent this round rect in the applied clip.

When set, 'result.fRRect' will intersect with the render target bounds but may extend beyond it. If the render target bounds are the only clip effect on the draw, this is reported as kUnclipped and not as a degenerate rrect that matches the bounds.

Reimplemented from GrClip.

Definition at line 55 of file StencilClip.h.

55 {
56 if (this->hasStencilClip()) {
57 return this->INHERITED::preApply(drawBounds, aa);
58 } else {
59 return fFixedClip.preApply(drawBounds, aa);
60 }
61 }
virtual PreClipResult preApply(const SkRect &drawBounds, GrAA aa) const
Definition GrClip.h:97
PreClipResult preApply(const SkRect &drawBounds, GrAA aa) const final

◆ setStencilClip()

void skgpu::ganesh::StencilClip::setStencilClip ( uint32_t  stencilStackID)
inline

Definition at line 36 of file StencilClip.h.

36{ fStencilStackID = stencilStackID; }

◆ stencilStackID()

uint32_t skgpu::ganesh::StencilClip::stencilStackID ( ) const
inline

Definition at line 34 of file StencilClip.h.

34{ return fStencilStackID; }

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