Flutter Engine
The Flutter Engine
Functions
skgpu::ganesh::StrokeRectOp Namespace Reference

Functions

GrOp::Owner Make (GrRecordingContext *context, GrPaint &&paint, GrAAType aaType, const SkMatrix &viewMatrix, const SkRect &rect, const SkStrokeRec &stroke)
 
GrOp::Owner MakeNested (GrRecordingContext *context, GrPaint &&paint, const SkMatrix &viewMatrix, const SkRect rects[2])
 

Detailed Description

A set of factory functions for drawing stroked rectangles either coverage-antialiased, or non-antialiased. The non-antialiased ops can be used with MSAA. As with other GrDrawOp factories, the GrPaint is only consumed by these methods if a valid op is returned. If null is returned then the paint is unmodified and may still be used.

Function Documentation

◆ Make()

GrOp::Owner skgpu::ganesh::StrokeRectOp::Make ( GrRecordingContext context,
GrPaint &&  paint,
GrAAType  aaType,
const SkMatrix viewMatrix,
const SkRect rect,
const SkStrokeRec stroke 
)

Definition at line 944 of file StrokeRectOp.cpp.

949 {
950 SkASSERT(!context->priv().caps()->reducedShaderMode());
951 if (aaType == GrAAType::kCoverage) {
952 return AAStrokeRectOp::Make(context, std::move(paint), viewMatrix, rect, stroke);
953 } else {
954 return NonAAStrokeRectOp::Make(context, std::move(paint), viewMatrix, rect, stroke, aaType);
955 }
956}
#define SkASSERT(cond)
Definition: SkAssert.h:116
const GrCaps * caps() const
bool reducedShaderMode() const
Definition: GrCaps.h:190
GrRecordingContextPriv priv()
const Paint & paint
Definition: color_source.cc:38
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
GrOp::Owner Make(GrRecordingContext *context, GrPaint &&paint, GrAAType aaType, const SkMatrix &viewMatrix, const SkRect &rect, const SkStrokeRec &stroke)

◆ MakeNested()

GrOp::Owner skgpu::ganesh::StrokeRectOp::MakeNested ( GrRecordingContext context,
GrPaint &&  paint,
const SkMatrix viewMatrix,
const SkRect  rects[2] 
)

Definition at line 958 of file StrokeRectOp.cpp.

961 {
962 SkASSERT(viewMatrix.rectStaysRect());
963 SkASSERT(!rects[0].isEmpty() && !rects[1].isEmpty());
964
965 SkRect devOutside = viewMatrix.mapRect(rects[0]);
966 SkRect devInside = viewMatrix.mapRect(rects[1]);
967 float dx = devOutside.fRight - devInside.fRight;
968 float dy = devOutside.fBottom - devInside.fBottom;
969
970 // Clips our draw rects 1 full pixel outside the viewport. This avoids interpolation precision
971 // issues with very large coordinates.
972 const float m = context->priv().caps()->maxRenderTargetSize();
973 const SkRect visibilityBounds = SkRect::MakeWH(m, m).makeOutset(1, 1);
974
975 if (!devOutside.intersect(visibilityBounds.makeOutset(dx, dy))) {
976 return nullptr;
977 }
978
979 if (devInside.isEmpty() || !devInside.intersect(visibilityBounds)) {
980 if (devOutside.isEmpty()) {
981 return nullptr;
982 }
983 DrawQuad quad{GrQuad::MakeFromRect(rects[0], viewMatrix), GrQuad(rects[0]),
985 return ganesh::FillRectOp::Make(context, std::move(paint), GrAAType::kCoverage, &quad);
986 }
987
988 return AAStrokeRectOp::Make(context, std::move(paint), viewMatrix, devOutside,
989 devInside, SkVector{dx, dy} * .5f);
990}
int maxRenderTargetSize() const
Definition: GrCaps.h:223
Definition: GrQuad.h:30
static GrQuad MakeFromRect(const SkRect &, const SkMatrix &)
Definition: GrQuad.cpp:107
bool rectStaysRect() const
Definition: SkMatrix.h:271
bool mapRect(SkRect *dst, const SkRect &src, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
Definition: SkMatrix.cpp:1141
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition: SkRecords.h:208
SkScalar fBottom
larger y-axis bounds
Definition: extension.cpp:17
bool intersect(const SkRect &r)
Definition: SkRect.cpp:114
SkRect makeOutset(float dx, float dy) const
Definition: SkRect.h:1002
SkScalar fRight
larger x-axis bounds
Definition: extension.cpp:16
bool isEmpty() const
Definition: SkRect.h:693
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609