Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | List of all members
ButtCapDashedCircleOp Class Referencefinal
Inheritance diagram for ButtCapDashedCircleOp:
GrMeshDrawOp GrDrawOp GrOp SkNoncopyable

Public Member Functions

 ButtCapDashedCircleOp (GrProcessorSet *processorSet, const SkPMColor4f &color, const SkMatrix &viewMatrix, SkPoint center, SkScalar radius, SkScalar strokeWidth, SkScalar startAngle, SkScalar onAngle, SkScalar offAngle, SkScalar phaseAngle)
 
const char * name () const override
 
void visitProxies (const GrVisitProxyFunc &func) const override
 
GrProcessorSet::Analysis finalize (const GrCaps &caps, const GrAppliedClip *clip, GrClampType clampType) override
 
FixedFunctionFlags fixedFunctionFlags () const override
 
- Public Member Functions inherited from GrDrawOp
 GrDrawOp (uint32_t classID)
 
virtual bool usesMSAA () const
 
virtual ClipResult clipToShape (skgpu::ganesh::SurfaceDrawContext *, SkClipOp, const SkMatrix &, const GrShape &, GrAA)
 
virtual bool usesStencil () const
 
- Public Member Functions inherited from GrOp
virtual ~GrOp ()=default
 
CombineResult combineIfPossible (GrOp *that, SkArenaAlloc *alloc, const GrCaps &caps)
 
const SkRectbounds () const
 
void setClippedBounds (const SkRect &clippedBounds)
 
bool hasAABloat () const
 
bool hasZeroArea () const
 
void operator delete (void *p)
 
template<typename T >
const Tcast () const
 
template<typename T >
Tcast ()
 
uint32_t classID () const
 
uint32_t uniqueID () const
 
void prePrepare (GrRecordingContext *context, const GrSurfaceProxyView &dstView, GrAppliedClip *clip, const GrDstProxyView &dstProxyView, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp)
 
void prepare (GrOpFlushState *state)
 
void execute (GrOpFlushState *state, const SkRect &chainBounds)
 
void chainConcat (GrOp::Owner)
 
bool isChainHead () const
 
bool isChainTail () const
 
GrOpnextInChain () const
 
GrOpprevInChain () const
 
GrOp::Owner cutChain ()
 
void setBounds (const SkRect &newBounds, HasAABloat aabloat, IsHairline zeroArea)
 
void setTransformedBounds (const SkRect &srcBounds, const SkMatrix &m, HasAABloat aabloat, IsHairline zeroArea)
 
void makeFullScreen (GrSurfaceProxy *proxy)
 

Static Public Member Functions

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 Public Member Functions inherited from GrMeshDrawOp
static bool CanUpgradeAAOnMerge (GrAAType aa1, GrAAType aa2)
 
- Static Public Member Functions inherited from GrOp
template<typename Op , typename... Args>
static Owner Make (GrRecordingContext *context, Args &&... args)
 
template<typename Op , typename... Args>
static Owner MakeWithProcessorSet (GrRecordingContext *context, const SkPMColor4f &color, GrPaint &&paint, Args &&... args)
 
template<typename Op , typename... Args>
static Owner MakeWithExtraMemory (GrRecordingContext *context, size_t extraSize, Args &&... args)
 
static uint32_t GenOpClassID ()
 

Private Member Functions

GrProgramInfoprogramInfo () override
 
void onCreateProgramInfo (const GrCaps *caps, SkArenaAlloc *arena, const GrSurfaceProxyView &writeView, bool usesMSAASurface, GrAppliedClip &&appliedClip, const GrDstProxyView &dstProxyView, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp) override
 
void onPrepareDraws (GrMeshDrawTarget *target) override
 
void onExecute (GrOpFlushState *flushState, const SkRect &chainBounds) override
 
CombineResult onCombineIfPossible (GrOp *t, SkArenaAlloc *, const GrCaps &caps) override
 

Additional Inherited Members

- Public Types inherited from GrDrawOp
enum class  ClipResult { kFail , kClippedGeometrically , kClippedInShader , kClippedOut }
 
- Public Types inherited from GrOp
enum class  CombineResult { kMerged , kMayChain , kCannotCombine }
 
enum class  HasAABloat : bool { kNo = false , kYes = true }
 
enum class  IsHairline : bool { kNo = false , kYes = true }
 
using Owner = std::unique_ptr< GrOp >
 
- Protected Types inherited from GrDrawOp
enum class  FixedFunctionFlags : uint32_t { kNone = 0x0 , kUsesHWAA = 0x1 , kUsesStencil = 0x2 }
 
- Protected Member Functions inherited from GrMeshDrawOp
 GrMeshDrawOp (uint32_t classID)
 
void createProgramInfo (const GrCaps *caps, SkArenaAlloc *arena, const GrSurfaceProxyView &writeView, bool usesMSAASurface, GrAppliedClip &&appliedClip, const GrDstProxyView &dstProxyView, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp)
 
void createProgramInfo (GrMeshDrawTarget *)
 
virtual void onPrePrepareDraws (GrRecordingContext *, const GrSurfaceProxyView &writeView, GrAppliedClip *, const GrDstProxyView &, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp)
 
- Protected Member Functions inherited from GrDrawOp
 GR_DECL_BITFIELD_CLASS_OPS_FRIENDS (FixedFunctionFlags)
 
- Static Protected Member Functions inherited from GrMeshDrawOp
static bool CombinedQuadCountWillOverflow (GrAAType aaType, bool willBeUpgradedToAA, int combinedQuadCount)
 

Detailed Description

Definition at line 1500 of file GrOvalOpFactory.cpp.

Constructor & Destructor Documentation

◆ ButtCapDashedCircleOp()

ButtCapDashedCircleOp::ButtCapDashedCircleOp ( GrProcessorSet processorSet,
const SkPMColor4f color,
const SkMatrix viewMatrix,
SkPoint  center,
SkScalar  radius,
SkScalar  strokeWidth,
SkScalar  startAngle,
SkScalar  onAngle,
SkScalar  offAngle,
SkScalar  phaseAngle 
)
inline

Definition at line 1524 of file GrOvalOpFactory.cpp.

1528 : GrMeshDrawOp(ClassID())
1529 , fHelper(processorSet, GrAAType::kCoverage) {
1530 SkASSERT(circle_stays_circle(viewMatrix));
1531 viewMatrix.mapPoints(&center, 1);
1532 radius = viewMatrix.mapRadius(radius);
1533 strokeWidth = viewMatrix.mapRadius(strokeWidth);
1534
1535 // Determine the angle where the circle starts in device space and whether its orientation
1536 // has been reversed.
1538 bool reflection;
1539 if (!startAngle) {
1540 start = {1, 0};
1541 } else {
1542 start.fY = SkScalarSin(startAngle);
1543 start.fX = SkScalarCos(startAngle);
1544 }
1545 viewMatrix.mapVectors(&start, 1);
1547 reflection = (viewMatrix.getScaleX() * viewMatrix.getScaleY() -
1548 viewMatrix.getSkewX() * viewMatrix.getSkewY()) < 0;
1549
1550 auto totalAngle = onAngle + offAngle;
1551 phaseAngle = SkScalarMod(phaseAngle + totalAngle / 2, totalAngle) - totalAngle / 2;
1552
1553 SkScalar halfWidth = 0;
1555 halfWidth = SK_ScalarHalf;
1556 } else {
1557 halfWidth = SkScalarHalf(strokeWidth);
1558 }
1559
1560 SkScalar outerRadius = radius + halfWidth;
1561 SkScalar innerRadius = radius - halfWidth;
1562
1563 // The radii are outset for two reasons. First, it allows the shader to simply perform
1564 // simpler computation because the computed alpha is zero, rather than 50%, at the radius.
1565 // Second, the outer radius is used to compute the verts of the bounding box that is
1566 // rendered and the outset ensures the box will cover all partially covered by the circle.
1567 outerRadius += SK_ScalarHalf;
1568 innerRadius -= SK_ScalarHalf;
1569 fViewMatrixIfUsingLocalCoords = viewMatrix;
1570
1571 SkRect devBounds = SkRect::MakeLTRB(center.fX - outerRadius, center.fY - outerRadius,
1572 center.fX + outerRadius, center.fY + outerRadius);
1573
1574 // We store whether there is a reflection as a negative total angle.
1575 if (reflection) {
1576 totalAngle = -totalAngle;
1577 }
1578 fCircles.push_back(Circle{
1579 color,
1580 outerRadius,
1581 innerRadius,
1582 onAngle,
1583 totalAngle,
1584 startAngle,
1585 phaseAngle,
1586 devBounds
1587 });
1588 // Use the original radius and stroke radius for the bounds so that it does not include the
1589 // AA bloat.
1590 radius += halfWidth;
1591 this->setBounds(
1592 {center.fX - radius, center.fY - radius, center.fX + radius, center.fY + radius},
1594 fVertCount = circle_type_to_vert_count(true);
1595 fIndexCount = circle_type_to_index_count(true);
1596 }
static const int strokeWidth
Definition BlurTest.cpp:60
static int circle_type_to_index_count(bool stroked)
static int circle_type_to_vert_count(bool stroked)
SkColor4f color
#define SkASSERT(cond)
Definition SkAssert.h:116
#define SkScalarMod(x, y)
Definition SkScalar.h:41
#define SkScalarATan2(y, x)
Definition SkScalar.h:50
static bool SkScalarNearlyZero(SkScalar x, SkScalar tolerance=SK_ScalarNearlyZero)
Definition SkScalar.h:101
#define SkScalarSin(radians)
Definition SkScalar.h:45
#define SkScalarHalf(a)
Definition SkScalar.h:75
#define SK_ScalarHalf
Definition SkScalar.h:19
#define SkScalarCos(radians)
Definition SkScalar.h:46
static SkScalar center(float pos0, float pos1)
void setBounds(const SkRect &newBounds, HasAABloat aabloat, IsHairline zeroArea)
Definition GrOp.h:279
SkScalar mapRadius(SkScalar radius) const
SkScalar getSkewY() const
Definition SkMatrix.h:430
void mapVectors(SkVector dst[], const SkVector src[], int count) const
void mapPoints(SkPoint dst[], const SkPoint src[], int count) const
Definition SkMatrix.cpp:770
SkScalar getSkewX() const
Definition SkMatrix.h:438
SkScalar getScaleX() const
Definition SkMatrix.h:415
SkScalar getScaleY() const
Definition SkMatrix.h:422
float SkScalar
Definition extension.cpp:12
SkScalar startAngle
Definition SkRecords.h:250
float fX
x-axis value
float fY
y-axis value
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition SkRect.h:646

Member Function Documentation

◆ finalize()

GrProcessorSet::Analysis ButtCapDashedCircleOp::finalize ( const GrCaps ,
const GrAppliedClip ,
GrClampType   
)
inlineoverridevirtual

This is called after the GrAppliedClip has been computed and just prior to recording the op or combining it with a previously recorded op. The op should convert any proxies or resources it owns to "pending io" status so that resource allocation can be more optimal. Additionally, at this time the op must report whether a copy of the destination (or destination texture itself) needs to be provided to the GrXferProcessor when this op executes.

Implements GrDrawOp.

Definition at line 1608 of file GrOvalOpFactory.cpp.

1609 {
1610 SkPMColor4f* color = &fCircles.front().fColor;
1611 return fHelper.finalizeProcessors(caps, clip, clampType,
1613 &fWideColor);
1614 }
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition SkPath.cpp:3824
GrProcessorSet::Analysis finalizeProcessors(const GrCaps &caps, const GrAppliedClip *clip, GrClampType clampType, GrProcessorAnalysisCoverage geometryCoverage, GrProcessorAnalysisColor *geometryColor)

◆ fixedFunctionFlags()

FixedFunctionFlags ButtCapDashedCircleOp::fixedFunctionFlags ( ) const
inlineoverridevirtual

Reimplemented from GrDrawOp.

Definition at line 1616 of file GrOvalOpFactory.cpp.

1616{ return fHelper.fixedFunctionFlags(); }
GrDrawOp::FixedFunctionFlags fixedFunctionFlags() const

◆ Make()

static DEFINE_OP_CLASS_ID GrOp::Owner ButtCapDashedCircleOp::Make ( GrRecordingContext context,
GrPaint &&  paint,
const SkMatrix viewMatrix,
SkPoint  center,
SkScalar  radius,
SkScalar  strokeWidth,
SkScalar  startAngle,
SkScalar  onAngle,
SkScalar  offAngle,
SkScalar  phaseAngle 
)
inlinestatic

Definition at line 1507 of file GrOvalOpFactory.cpp.

1516 {
1517 SkASSERT(circle_stays_circle(viewMatrix));
1518 SkASSERT(strokeWidth < 2 * radius);
1519 return Helper::FactoryHelper<ButtCapDashedCircleOp>(context, std::move(paint), viewMatrix,
1520 center, radius, strokeWidth, startAngle,
1521 onAngle, offAngle, phaseAngle);
1522 }
const Paint & paint

◆ name()

const char * ButtCapDashedCircleOp::name ( ) const
inlineoverridevirtual

Implements GrOp.

Definition at line 1598 of file GrOvalOpFactory.cpp.

1598{ return "ButtCappedDashedCircleOp"; }

◆ onCombineIfPossible()

CombineResult ButtCapDashedCircleOp::onCombineIfPossible ( GrOp t,
SkArenaAlloc ,
const GrCaps caps 
)
inlineoverrideprivatevirtual

Reimplemented from GrOp.

Definition at line 1751 of file GrOvalOpFactory.cpp.

1751 {
1753
1754 // can only represent 65535 unique vertices with 16-bit indices
1755 if (fVertCount + that->fVertCount > 65536) {
1757 }
1758
1759 if (!fHelper.isCompatible(that->fHelper, caps, this->bounds(), that->bounds())) {
1761 }
1762
1763 if (fHelper.usesLocalCoords() &&
1764 !SkMatrixPriv::CheapEqual(fViewMatrixIfUsingLocalCoords,
1765 that->fViewMatrixIfUsingLocalCoords)) {
1767 }
1768
1769 fCircles.push_back_n(that->fCircles.size(), that->fCircles.begin());
1770 fVertCount += that->fVertCount;
1771 fIndexCount += that->fIndexCount;
1772 fWideColor |= that->fWideColor;
1774 }
const T & cast() const
Definition GrOp.h:148
const SkRect & bounds() const
Definition GrOp.h:122
bool isCompatible(const GrSimpleMeshDrawOpHelper &that, const GrCaps &, const SkRect &thisBounds, const SkRect &thatBounds, bool ignoreAAType=false) const
static bool CheapEqual(const SkMatrix &a, const SkMatrix &b)
T * push_back_n(int n)
Definition SkTArray.h:262
int size() const
Definition SkTArray.h:416

◆ onCreateProgramInfo()

void ButtCapDashedCircleOp::onCreateProgramInfo ( const GrCaps caps,
SkArenaAlloc arena,
const GrSurfaceProxyView writeView,
bool  usesMSAASurface,
GrAppliedClip &&  appliedClip,
const GrDstProxyView dstProxyView,
GrXferBarrierFlags  renderPassXferBarriers,
GrLoadOp  colorLoadOp 
)
inlineoverrideprivatevirtual

Implements GrMeshDrawOp.

Definition at line 1621 of file GrOvalOpFactory.cpp.

1628 {
1629 SkASSERT(!usesMSAASurface);
1630
1631 SkMatrix localMatrix;
1632 if (!fViewMatrixIfUsingLocalCoords.invert(&localMatrix)) {
1633 return;
1634 }
1635
1636 // Setup geometry processor
1638 fWideColor,
1639 localMatrix);
1640
1641 fProgramInfo = fHelper.createProgramInfo(caps,
1642 arena,
1643 writeView,
1644 usesMSAASurface,
1645 std::move(appliedClip),
1646 dstProxyView,
1647 gp,
1649 renderPassXferBarriers,
1650 colorLoadOp);
1651 }
static GrGeometryProcessor * Make(SkArenaAlloc *arena, bool wideColor, const SkMatrix &localMatrix)
GrProgramInfo * createProgramInfo(const GrCaps *, SkArenaAlloc *, const GrSurfaceProxyView &writeView, bool usesMSAASurface, GrAppliedClip &&, const GrDstProxyView &, GrGeometryProcessor *, GrPrimitiveType, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp)
bool invert(SkMatrix *inverse) const
Definition SkMatrix.h:1206

◆ onExecute()

void ButtCapDashedCircleOp::onExecute ( GrOpFlushState flushState,
const SkRect chainBounds 
)
inlineoverrideprivatevirtual

Implements GrOp.

Definition at line 1741 of file GrOvalOpFactory.cpp.

1741 {
1742 if (!fProgramInfo || !fMesh) {
1743 return;
1744 }
1745
1746 flushState->bindPipelineAndScissorClip(*fProgramInfo, chainBounds);
1747 flushState->bindTextures(fProgramInfo->geomProc(), nullptr, fProgramInfo->pipeline());
1748 flushState->drawMesh(*fMesh);
1749 }
void drawMesh(const GrSimpleMesh &mesh)
void bindPipelineAndScissorClip(const GrProgramInfo &programInfo, const SkRect &drawBounds)
void bindTextures(const GrGeometryProcessor &geomProc, const GrSurfaceProxy &singleGeomProcTexture, const GrPipeline &pipeline)
const GrPipeline & pipeline() const
const GrGeometryProcessor & geomProc() const

◆ onPrepareDraws()

void ButtCapDashedCircleOp::onPrepareDraws ( GrMeshDrawTarget target)
inlineoverrideprivatevirtual

Implements GrMeshDrawOp.

Definition at line 1653 of file GrOvalOpFactory.cpp.

1653 {
1654 if (!fProgramInfo) {
1655 this->createProgramInfo(target);
1656 if (!fProgramInfo) {
1657 return;
1658 }
1659 }
1660
1661 sk_sp<const GrBuffer> vertexBuffer;
1662 int firstVertex;
1663 VertexWriter vertices = target->makeVertexWriter(fProgramInfo->geomProc().vertexStride(),
1664 fVertCount, &vertexBuffer, &firstVertex);
1665 if (!vertices) {
1666 SkDebugf("Could not allocate vertices\n");
1667 return;
1668 }
1669
1670 sk_sp<const GrBuffer> indexBuffer;
1671 int firstIndex = 0;
1672 uint16_t* indices = target->makeIndexSpace(fIndexCount, &indexBuffer, &firstIndex);
1673 if (!indices) {
1674 SkDebugf("Could not allocate indices\n");
1675 return;
1676 }
1677
1678 int currStartVertex = 0;
1679 for (const auto& circle : fCircles) {
1680 // The inner radius in the vertex data must be specified in normalized space so that
1681 // length() can be called with smaller values to avoid precision issues with half
1682 // floats.
1683 auto normInnerRadius = circle.fInnerRadius / circle.fOuterRadius;
1684 const SkRect& bounds = circle.fDevBounds;
1685 bool reflect = false;
1686 struct { float onAngle, totalAngle, startAngle, phaseAngle; } dashParams = {
1687 circle.fOnAngle, circle.fTotalAngle, circle.fStartAngle, circle.fPhaseAngle
1688 };
1689 if (dashParams.totalAngle < 0) {
1690 reflect = true;
1691 dashParams.totalAngle = -dashParams.totalAngle;
1692 dashParams.startAngle = -dashParams.startAngle;
1693 }
1694
1695 VertexColor color(circle.fColor, fWideColor);
1696
1697 // The bounding geometry for the circle is composed of an outer bounding octagon and
1698 // an inner bounded octagon.
1699
1700 // Compute the vertices of the outer octagon.
1702 SkScalar halfWidth = 0.5f * bounds.width();
1703
1704 auto reflectY = [=](const SkPoint& p) {
1705 return SkPoint{ p.fX, reflect ? -p.fY : p.fY };
1706 };
1707
1708 for (int i = 0; i < 8; ++i) {
1709 vertices << (center + kOctagonOuter[i] * halfWidth)
1710 << color
1711 << reflectY(kOctagonOuter[i])
1712 << circle.fOuterRadius
1713 << normInnerRadius
1714 << dashParams;
1715 }
1716
1717 // Compute the vertices of the inner octagon.
1718 for (int i = 0; i < 8; ++i) {
1719 vertices << (center + kOctagonInner[i] * circle.fInnerRadius)
1720 << color
1721 << (reflectY(kOctagonInner[i]) * normInnerRadius)
1722 << circle.fOuterRadius
1723 << normInnerRadius
1724 << dashParams;
1725 }
1726
1727 const uint16_t* primIndices = circle_type_to_indices(true);
1728 const int primIndexCount = circle_type_to_index_count(true);
1729 for (int i = 0; i < primIndexCount; ++i) {
1730 *indices++ = primIndices[i] + currStartVertex;
1731 }
1732
1733 currStartVertex += circle_type_to_vert_count(true);
1734 }
1735
1736 fMesh = target->allocMesh();
1737 fMesh->setIndexed(std::move(indexBuffer), fIndexCount, firstIndex, 0, fVertCount - 1,
1738 GrPrimitiveRestart::kNo, std::move(vertexBuffer), firstVertex);
1739 }
static const uint16_t * circle_type_to_indices(bool stroked)
static constexpr SkPoint kOctagonOuter[]
static constexpr SkPoint kOctagonInner[]
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
void createProgramInfo(const GrCaps *caps, SkArenaAlloc *arena, const GrSurfaceProxyView &writeView, bool usesMSAASurface, GrAppliedClip &&appliedClip, const GrDstProxyView &dstProxyView, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp)
uint32_t * target
void setIndexed(sk_sp< const GrBuffer > indexBuffer, int indexCount, int baseIndex, uint16_t minIndexValue, uint16_t maxIndexValue, GrPrimitiveRestart, sk_sp< const GrBuffer > vertexBuffer, int baseVertex)
static constexpr SkPoint Make(float x, float y)
constexpr float centerX() const
Definition SkRect.h:776
constexpr float centerY() const
Definition SkRect.h:785
constexpr float width() const
Definition SkRect.h:762

◆ programInfo()

GrProgramInfo * ButtCapDashedCircleOp::programInfo ( )
inlineoverrideprivatevirtual

Implements GrMeshDrawOp.

Definition at line 1619 of file GrOvalOpFactory.cpp.

1619{ return fProgramInfo; }

◆ visitProxies()

void ButtCapDashedCircleOp::visitProxies ( const GrVisitProxyFunc func) const
inlineoverridevirtual

Reimplemented from GrOp.

Definition at line 1600 of file GrOvalOpFactory.cpp.

1600 {
1601 if (fProgramInfo) {
1602 fProgramInfo->visitFPProxies(func);
1603 } else {
1604 fHelper.visitProxies(func);
1605 }
1606 }
void visitFPProxies(const GrVisitProxyFunc &func) const
void visitProxies(const GrVisitProxyFunc &func) const

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