Flutter Engine
The Flutter Engine
|
#include <GrClip.h>
Classes | |
struct | PreClipResult |
Public Types | |
enum class | Effect { kClipped , kUnclipped , kClippedOut } |
enum class | BoundsType { kExterior , kInterior } |
Public Member Functions | |
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 |
Static Public Member Functions | |
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 | |
static constexpr SkScalar | kBoundsTolerance = 1e-3f |
static constexpr SkScalar | kHalfPixelRoundingTolerance = 5e-2f |
GrClip is an abstract base class for applying a clip. It constructs a clip mask if necessary, and fills out a GrAppliedClip instructing the caller on how to set up the draw state.
|
strong |
Definition at line 144 of file GrClip.h.
|
strong |
Enumerator | |
---|---|
kClipped | |
kUnclipped | |
kClippedOut |
Definition at line 31 of file GrClip.h.
|
pure virtual |
This computes a GrAppliedClip from the clip which in turn can be used to build a GrPipeline. To determine the appropriate clipping implementation the GrClip subclass must know whether the draw will enable HW AA or uses the stencil buffer. On input 'bounds' is a conservative bounds of the draw that is to be clipped. If kClipped or kUnclipped is returned, the 'bounds' will have been updated to be contained within the clip bounds (or the device's, for wide-open clips). If kNoDraw is returned, 'bounds' and the applied clip are in an undetermined state and should be ignored (and the draw should be skipped).
Implemented in skgpu::ganesh::ClipStack.
|
pure virtual |
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.
Implemented in GrFixedClip, skgpu::ganesh::StencilClip, and skgpu::ganesh::ClipStack.
|
inlinestatic |
Convert the analytic bounds of a shape into an integer pixel bounds, where the given aa type is used when the shape is rendered. The bounds mode can be used to query exterior or interior pixel boundaries. Interior bounds only make sense when its know that the analytic bounds are filled completely.
NOTE: When using kExterior_Bounds, some coverage-AA rendering methods may still touch a pixel center outside of these bounds but will evaluate to 0 coverage. This is visually acceptable, but an additional outset of 1px should be used for dst proxy access.
Definition at line 173 of file GrClip.h.
|
inlinestatic |
Returns true if the given draw bounds count as entirely inside the clip.
innerClipBounds | device-space rect fully contained by the clip |
drawBounds | device-space bounds of the query region. |
Definition at line 128 of file GrClip.h.
|
inlinestatic |
Returns true if the given draw bounds count as entirely outside the clip.
outerClipBounds | device-space rect that contains the clip |
drawBounds | device-space bounds of the query region. |
aa | whether or not the draw will use anti-aliasing |
|
inlinestatic |
|
inlinevirtual |
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 in GrFixedClip, skgpu::ganesh::StencilClip, and skgpu::ganesh::ClipStack.
Definition at line 97 of file GrClip.h.
|
staticconstexpr |
This is the maximum distance that a draw may extend beyond a clip's boundary and still count count as "on the other side". We leave some slack because floating point rounding error is likely to blame. The rationale for 1e-3 is that in the coverage case (and barring unexpected rounding), as long as coverage stays within 0.5 * 1/256 of its intended value it shouldn't have any effect on the final pixel values.
|
staticconstexpr |
This is the slack around a half-pixel vertex coordinate where we don't trust the GPU's rasterizer to round consistently. The rounding method is not defined in GPU specs, and rasterizer precision frequently introduces errors where a fraction < 1/2 still rounds up.
For non-AA bounds edges, an edge value between 0.45 and 0.55 will round in or round out depending on what side its on. Outside of this range, the non-AA edge will snap using round()