Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
GrOvalOpFactory Class Reference

#include <GrOvalOpFactory.h>

Static Public Member Functions

static GrOp::Owner MakeCircleOp (GrRecordingContext *, GrPaint &&, const SkMatrix &, const SkRect &oval, const GrStyle &style, const GrShaderCaps *)
 
static GrOp::Owner MakeOvalOp (GrRecordingContext *, GrPaint &&, const SkMatrix &, const SkRect &oval, const GrStyle &style, const GrShaderCaps *)
 
static GrOp::Owner MakeCircularRRectOp (GrRecordingContext *, GrPaint &&, const SkMatrix &, const SkRRect &, const SkStrokeRec &, const GrShaderCaps *)
 
static GrOp::Owner MakeRRectOp (GrRecordingContext *, GrPaint &&, const SkMatrix &, const SkRRect &, const SkStrokeRec &, const GrShaderCaps *)
 
static GrOp::Owner MakeArcOp (GrRecordingContext *, GrPaint &&, const SkMatrix &, const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter, const GrStyle &, const GrShaderCaps *)
 

Detailed Description

Definition at line 30 of file GrOvalOpFactory.h.

Member Function Documentation

◆ MakeArcOp()

GrOp::Owner GrOvalOpFactory::MakeArcOp ( GrRecordingContext context,
GrPaint &&  paint,
const SkMatrix viewMatrix,
const SkRect oval,
SkScalar  startAngle,
SkScalar  sweepAngle,
bool  useCenter,
const GrStyle style,
const GrShaderCaps shaderCaps 
)
static

Definition at line 3389 of file GrOvalOpFactory.cpp.

3395 {
3396 SkASSERT(!oval.isEmpty());
3397 SkASSERT(sweepAngle);
3399 if (SkScalarAbs(sweepAngle) >= 360.f) {
3400 return nullptr;
3401 }
3402 if (!SkScalarNearlyEqual(width, oval.height()) || !circle_stays_circle(viewMatrix)) {
3403 return nullptr;
3404 }
3406 CircleOp::ArcParams arcParams = {SkDegreesToRadians(startAngle), SkDegreesToRadians(sweepAngle),
3407 useCenter};
3408 return CircleOp::Make(context, std::move(paint), viewMatrix,
3409 center, width / 2.f, style, &arcParams);
3410}
#define SkASSERT(cond)
Definition SkAssert.h:116
#define SkDegreesToRadians(degrees)
Definition SkScalar.h:77
static bool SkScalarNearlyEqual(SkScalar x, SkScalar y, SkScalar tolerance=SK_ScalarNearlyZero)
Definition SkScalar.h:107
#define SkScalarAbs(x)
Definition SkScalar.h:39
static SkScalar center(float pos0, float pos1)
static GrOp::Owner Make(GrRecordingContext *context, GrPaint &&paint, const SkMatrix &viewMatrix, SkPoint center, SkScalar radius, const GrStyle &style, const ArcParams *arcParams=nullptr)
const Paint & paint
float SkScalar
Definition extension.cpp:12
SkRect oval
Definition SkRecords.h:249
int32_t width
constexpr float centerX() const
Definition SkRect.h:776
constexpr float height() const
Definition SkRect.h:769
constexpr float centerY() const
Definition SkRect.h:785
constexpr float width() const
Definition SkRect.h:762
bool isEmpty() const
Definition SkRect.h:693

◆ MakeCircleOp()

GrOp::Owner GrOvalOpFactory::MakeCircleOp ( GrRecordingContext context,
GrPaint &&  paint,
const SkMatrix viewMatrix,
const SkRect oval,
const GrStyle style,
const GrShaderCaps shaderCaps 
)
static

Definition at line 3314 of file GrOvalOpFactory.cpp.

3319 {
3322 circle_stays_circle(viewMatrix));
3323
3324 auto r = width / 2.f;
3326 if (style.hasNonDashPathEffect()) {
3327 return nullptr;
3328 } else if (style.isDashed()) {
3329 if (style.strokeRec().getCap() != SkPaint::kButt_Cap ||
3330 style.dashIntervalCnt() != 2 || style.strokeRec().getWidth() >= width) {
3331 return nullptr;
3332 }
3333 auto onInterval = style.dashIntervals()[0];
3334 auto offInterval = style.dashIntervals()[1];
3335 if (offInterval == 0) {
3336 GrStyle strokeStyle(style.strokeRec(), nullptr);
3337 return MakeOvalOp(context, std::move(paint), viewMatrix, oval,
3338 strokeStyle, shaderCaps);
3339 } else if (onInterval == 0) {
3340 // There is nothing to draw but we have no way to indicate that here.
3341 return nullptr;
3342 }
3343 auto angularOnInterval = onInterval / r;
3344 auto angularOffInterval = offInterval / r;
3345 auto phaseAngle = style.dashPhase() / r;
3346 // Currently this function doesn't accept ovals with different start angles, though
3347 // it could.
3348 static const SkScalar kStartAngle = 0.f;
3349 return ButtCapDashedCircleOp::Make(context, std::move(paint), viewMatrix, center, r,
3350 style.strokeRec().getWidth(), kStartAngle,
3351 angularOnInterval, angularOffInterval, phaseAngle);
3352 }
3353 return CircleOp::Make(context, std::move(paint), viewMatrix, center, r, style);
3354}
#define SK_ScalarNearlyZero
Definition SkScalar.h:99
static DEFINE_OP_CLASS_ID GrOp::Owner Make(GrRecordingContext *context, GrPaint &&paint, const SkMatrix &viewMatrix, SkPoint center, SkScalar radius, SkScalar strokeWidth, SkScalar startAngle, SkScalar onAngle, SkScalar offAngle, SkScalar phaseAngle)
static GrOp::Owner MakeOvalOp(GrRecordingContext *, GrPaint &&, const SkMatrix &, const SkRect &oval, const GrStyle &style, const GrShaderCaps *)
bool isDashed() const
Definition GrStyle.h:126
const SkScalar * dashIntervals() const
Definition GrStyle.h:135
bool hasNonDashPathEffect() const
Definition GrStyle.h:124
int dashIntervalCnt() const
Definition GrStyle.h:131
SkScalar dashPhase() const
Definition GrStyle.h:127
const SkStrokeRec & strokeRec() const
Definition GrStyle.h:140
@ kButt_Cap
no stroke extension
Definition SkPaint.h:334
SkScalar getWidth() const
Definition SkStrokeRec.h:42
SkPaint::Cap getCap() const
Definition SkStrokeRec.h:44

◆ MakeCircularRRectOp()

GrOp::Owner GrOvalOpFactory::MakeCircularRRectOp ( GrRecordingContext context,
GrPaint &&  paint,
const SkMatrix viewMatrix,
const SkRRect rrect,
const SkStrokeRec stroke,
const GrShaderCaps shaderCaps 
)
static

Definition at line 3173 of file GrOvalOpFactory.cpp.

3178 {
3179 SkASSERT(viewMatrix.rectStaysRect());
3180 SkASSERT(viewMatrix.isSimilarity());
3182 SkASSERT(!rrect.isOval());
3184
3185 // RRect ops only handle simple, but not too simple, rrects.
3186 // Do any matrix crunching before we reset the draw state for device coords.
3187 const SkRect& rrectBounds = rrect.getBounds();
3188 SkRect bounds;
3189 viewMatrix.mapRect(&bounds, rrectBounds);
3190
3191 SkScalar radius = SkRRectPriv::GetSimpleRadii(rrect).fX;
3192 SkScalar scaledRadius = SkScalarAbs(radius * (viewMatrix[SkMatrix::kMScaleX] +
3193 viewMatrix[SkMatrix::kMSkewY]));
3194
3195 // Do mapping of stroke. Use -1 to indicate fill-only draws.
3196 SkScalar scaledStroke = -1;
3197 SkScalar strokeWidth = stroke.getWidth();
3198 SkStrokeRec::Style style = stroke.getStyle();
3199
3200 bool isStrokeOnly =
3202 bool hasStroke = isStrokeOnly || SkStrokeRec::kStrokeAndFill_Style == style;
3203
3204 if (hasStroke) {
3205 if (SkStrokeRec::kHairline_Style == style) {
3206 scaledStroke = SK_Scalar1;
3207 } else {
3208 scaledStroke = SkScalarAbs(strokeWidth * (viewMatrix[SkMatrix::kMScaleX] +
3209 viewMatrix[SkMatrix::kMSkewY]));
3210 }
3211 }
3212
3213 // The way the effect interpolates the offset-to-ellipse/circle-center attribute only works on
3214 // the interior of the rrect if the radii are >= 0.5. Otherwise, the inner rect of the nine-
3215 // patch will have fractional coverage. This only matters when the interior is actually filled.
3216 // We could consider falling back to rect rendering here, since a tiny radius is
3217 // indistinguishable from a square corner.
3218 if (!isStrokeOnly && SK_ScalarHalf > scaledRadius) {
3219 return nullptr;
3220 }
3221
3222 return CircularRRectOp::Make(context, std::move(paint), viewMatrix, bounds, scaledRadius,
3223 scaledStroke, isStrokeOnly);
3224}
static const int strokeWidth
Definition BlurTest.cpp:60
#define SK_Scalar1
Definition SkScalar.h:18
#define SK_ScalarHalf
Definition SkScalar.h:19
static DEFINE_OP_CLASS_ID GrOp::Owner Make(GrRecordingContext *context, GrPaint &&paint, const SkMatrix &viewMatrix, const SkRect &devRect, float devRadius, float devStrokeWidth, bool strokeOnly)
static constexpr int kMScaleX
horizontal scale factor
Definition SkMatrix.h:353
bool rectStaysRect() const
Definition SkMatrix.h:271
static constexpr int kMSkewY
vertical skew factor
Definition SkMatrix.h:356
bool isSimilarity(SkScalar tol=SK_ScalarNearlyZero) const
Definition SkMatrix.cpp:180
bool mapRect(SkRect *dst, const SkRect &src, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
static SkVector GetSimpleRadii(const SkRRect &rr)
Definition SkRRectPriv.h:22
bool isOval() const
Definition SkRRect.h:85
const SkRect & getBounds() const
Definition SkRRect.h:279
bool isSimple() const
Definition SkRRect.h:86
Style getStyle() const
@ kStrokeAndFill_Style
Definition SkStrokeRec.h:36
Optional< SkRect > bounds
Definition SkRecords.h:189
SkRRect rrect
Definition SkRecords.h:232
float fX
x-axis value

◆ MakeOvalOp()

GrOp::Owner GrOvalOpFactory::MakeOvalOp ( GrRecordingContext context,
GrPaint &&  paint,
const SkMatrix viewMatrix,
const SkRect oval,
const GrStyle style,
const GrShaderCaps shaderCaps 
)
static

Definition at line 3356 of file GrOvalOpFactory.cpp.

3361 {
3362 if (style.pathEffect()) {
3363 return nullptr;
3364 }
3365
3366 // prefer the device space ellipse op for batchability
3367 if (viewMatrix.rectStaysRect()) {
3368 return EllipseOp::Make(context, std::move(paint), viewMatrix, oval, style.strokeRec());
3369 }
3370
3371 // Otherwise, if we have shader derivative support, render as device-independent
3372 if (shaderCaps->fShaderDerivativeSupport) {
3373 SkScalar a = viewMatrix[SkMatrix::kMScaleX];
3374 SkScalar b = viewMatrix[SkMatrix::kMSkewX];
3375 SkScalar c = viewMatrix[SkMatrix::kMSkewY];
3376 SkScalar d = viewMatrix[SkMatrix::kMScaleY];
3377 // Check for near-degenerate matrix
3378 if (a*a + c*c > SK_ScalarNearlyZero && b*b + d*d > SK_ScalarNearlyZero) {
3379 return DIEllipseOp::Make(context, std::move(paint), viewMatrix, oval,
3380 style.strokeRec());
3381 }
3382 }
3383
3384 return nullptr;
3385}
static DEFINE_OP_CLASS_ID GrOp::Owner Make(GrRecordingContext *context, GrPaint &&paint, const SkMatrix &viewMatrix, const SkRect &ellipse, const SkStrokeRec &stroke)
static DEFINE_OP_CLASS_ID GrOp::Owner Make(GrRecordingContext *context, GrPaint &&paint, const SkMatrix &viewMatrix, const SkRect &ellipse, const SkStrokeRec &stroke)
SkPathEffect * pathEffect() const
Definition GrStyle.h:119
static constexpr int kMScaleY
vertical scale factor
Definition SkMatrix.h:357
static constexpr int kMSkewX
horizontal skew factor
Definition SkMatrix.h:354
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition main.cc:19
static bool b
struct MyStruct a[10]
bool fShaderDerivativeSupport
Definition SkSLUtil.h:85

◆ MakeRRectOp()

GrOp::Owner GrOvalOpFactory::MakeRRectOp ( GrRecordingContext context,
GrPaint &&  paint,
const SkMatrix viewMatrix,
const SkRRect rrect,
const SkStrokeRec stroke,
const GrShaderCaps shaderCaps 
)
static

Definition at line 3294 of file GrOvalOpFactory.cpp.

3299 {
3300 if (rrect.isOval()) {
3301 return MakeOvalOp(context, std::move(paint), viewMatrix, rrect.getBounds(),
3302 GrStyle(stroke, nullptr), shaderCaps);
3303 }
3304
3305 if (!viewMatrix.rectStaysRect() || !rrect.isSimple()) {
3306 return nullptr;
3307 }
3308
3309 return make_rrect_op(context, std::move(paint), viewMatrix, rrect, stroke);
3310}
GrOp::Owner make_rrect_op(GrRecordingContext *context, GrPaint &&paint, const SkMatrix &viewMatrix, const SkRRect &rrect, const SkStrokeRec &stroke)

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