Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
GrFixedClip Class Referencefinal

#include <GrFixedClip.h>

Inheritance diagram for GrFixedClip:
GrHardClip GrClip

Public Member Functions

 GrFixedClip (const SkISize &rtDims)
 
 GrFixedClip (const SkISize &rtDims, const SkIRect &scissorRect)
 
const GrScissorStatescissorState () const
 
bool scissorEnabled () const
 
const SkIRectscissorRect () const
 
void disableScissor ()
 
bool setScissor (const SkIRect &irect)
 
bool intersect (const SkIRect &irect)
 
const GrWindowRectsStatewindowRectsState () const
 
bool hasWindowRectangles () const
 
void disableWindowRectangles ()
 
void setWindowRectangles (const GrWindowRectangles &windows, GrWindowRectsState::Mode mode)
 
SkIRect getConservativeBounds () const final
 
Effect apply (GrAppliedHardClip *, SkIRect *) const final
 
PreClipResult preApply (const SkRect &drawBounds, GrAA aa) const final
 
virtual Effect apply (GrAppliedHardClip *out, SkIRect *bounds) const =0
 
- Public Member Functions inherited from GrClip
virtual ~GrClip ()
 
virtual SkIRect getConservativeBounds () const =0
 
virtual Effect apply (GrRecordingContext *, skgpu::ganesh::SurfaceDrawContext *, GrDrawOp *, GrAAType, GrAppliedClip *, SkRect *bounds) const =0
 
virtual PreClipResult preApply (const SkRect &drawBounds, GrAA aa) const
 

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 scissor and window rectangles.

Definition at line 18 of file GrFixedClip.h.

Constructor & Destructor Documentation

◆ GrFixedClip() [1/2]

GrFixedClip::GrFixedClip ( const SkISize rtDims)
inlineexplicit

Definition at line 20 of file GrFixedClip.h.

20: fScissorState(rtDims) {}

◆ GrFixedClip() [2/2]

GrFixedClip::GrFixedClip ( const SkISize rtDims,
const SkIRect scissorRect 
)
inline

Definition at line 21 of file GrFixedClip.h.

22 : GrFixedClip(rtDims) {
23 SkAssertResult(fScissorState.set(scissorRect));
24 }
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
const SkIRect & scissorRect() const
Definition: GrFixedClip.h:29
GrFixedClip(const SkISize &rtDims)
Definition: GrFixedClip.h:20
bool set(const SkIRect &rect)

Member Function Documentation

◆ apply()

GrClip::Effect GrFixedClip::apply ( GrAppliedHardClip out,
SkIRect bounds 
) const
finalvirtual

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 34 of file GrFixedClip.cpp.

34 {
35 if (!SkIRect::Intersects(fScissorState.rect(), *bounds)) {
37 }
38
40 if (fScissorState.enabled() && !fScissorState.rect().contains(*bounds)) {
41 SkAssertResult(bounds->intersect(fScissorState.rect()));
42 out->setScissor(*bounds);
43 effect = Effect::kClipped;
44 }
45
46 if (fWindowRectsState.enabled()) {
47 out->addWindowRectangles(fWindowRectsState);
48 // We could iterate each window rectangle to check for intersection, but be conservative
49 // and report that it's clipped
50 effect = Effect::kClipped;
51 }
52
53 return effect;
54}
bool enabled() const
const SkIRect & rect() const
Optional< SkRect > bounds
Definition: SkRecords.h:189
static bool Intersects(const SkIRect &a, const SkIRect &b)
Definition: SkRect.h:535
bool contains(int32_t x, int32_t y) const
Definition: SkRect.h:463

◆ disableScissor()

void GrFixedClip::disableScissor ( )
inline

Definition at line 31 of file GrFixedClip.h.

31{ fScissorState.setDisabled(); }

◆ disableWindowRectangles()

void GrFixedClip::disableWindowRectangles ( )
inline

Definition at line 43 of file GrFixedClip.h.

43{ fWindowRectsState.setDisabled(); }

◆ getConservativeBounds()

SkIRect GrFixedClip::getConservativeBounds ( ) const
finalvirtual

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 12 of file GrFixedClip.cpp.

12 {
13 return fScissorState.rect();
14}

◆ hasWindowRectangles()

bool GrFixedClip::hasWindowRectangles ( ) const
inline

Definition at line 41 of file GrFixedClip.h.

41{ return fWindowRectsState.enabled(); }

◆ intersect()

bool GrFixedClip::intersect ( const SkIRect irect)
inline

Definition at line 36 of file GrFixedClip.h.

36 {
37 return fScissorState.intersect(irect);
38 }
bool intersect(const SkIRect &rect)

◆ preApply()

GrClip::PreClipResult GrFixedClip::preApply ( const SkRect drawBounds,
GrAA  aa 
) const
finalvirtual

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 16 of file GrFixedClip.cpp.

16 {
17 SkIRect pixelBounds = GetPixelIBounds(drawBounds, aa);
18 if (!SkIRect::Intersects(fScissorState.rect(), pixelBounds)) {
20 }
21
22 if (fWindowRectsState.enabled()) {
23 return Effect::kClipped;
24 }
25
26 if (!fScissorState.enabled() || fScissorState.rect().contains(pixelBounds)) {
27 // Either no scissor or the scissor doesn't clip the draw
28 return Effect::kUnclipped;
29 }
30 // Report the scissor as a degenerate round rect
31 return {SkRect::Make(fScissorState.rect()), GrAA::kNo};
32}
static SkIRect GetPixelIBounds(const SkRect &bounds, GrAA aa, BoundsType mode=BoundsType::kExterior)
Definition: GrClip.h:173
Definition: SkRect.h:32
static SkRect Make(const SkISize &size)
Definition: SkRect.h:669

◆ scissorEnabled()

bool GrFixedClip::scissorEnabled ( ) const
inline

Definition at line 27 of file GrFixedClip.h.

27{ return fScissorState.enabled(); }

◆ scissorRect()

const SkIRect & GrFixedClip::scissorRect ( ) const
inline

Definition at line 29 of file GrFixedClip.h.

29{ return fScissorState.rect(); }

◆ scissorState()

const GrScissorState & GrFixedClip::scissorState ( ) const
inline

Definition at line 26 of file GrFixedClip.h.

26{ return fScissorState; }

◆ setScissor()

bool GrFixedClip::setScissor ( const SkIRect irect)
inline

Definition at line 33 of file GrFixedClip.h.

33 {
34 return fScissorState.set(irect);
35 }

◆ setWindowRectangles()

void GrFixedClip::setWindowRectangles ( const GrWindowRectangles windows,
GrWindowRectsState::Mode  mode 
)
inline

Definition at line 45 of file GrFixedClip.h.

45 {
46 fWindowRectsState.set(windows, mode);
47 }
void set(const GrWindowRectangles &windows, Mode mode)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
Definition: switches.h:228

◆ windowRectsState()

const GrWindowRectsState & GrFixedClip::windowRectsState ( ) const
inline

Definition at line 40 of file GrFixedClip.h.

40{ return fWindowRectsState; }

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