Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Static Public Member Functions | List of all members
EllipseOp Class Referencefinal
Inheritance diagram for EllipseOp:
GrMeshDrawOp GrDrawOp GrOp SkNoncopyable

Public Member Functions

 EllipseOp (GrProcessorSet *processorSet, const SkPMColor4f &color, const SkMatrix &viewMatrix, const DeviceSpaceParams &params, const SkStrokeRec &stroke)
 
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 GrProcessorSet::Analysis finalize (const GrCaps &, const GrAppliedClip *, GrClampType)=0
 
virtual bool usesStencil () const
 
- Public Member Functions inherited from GrOp
virtual ~GrOp ()=default
 
virtual const char * name () const =0
 
virtual void visitProxies (const GrVisitProxyFunc &) const
 
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, const SkRect &ellipse, const SkStrokeRec &stroke)
 
- 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 ()
 

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)
 
virtual FixedFunctionFlags fixedFunctionFlags () const
 
- Static Protected Member Functions inherited from GrMeshDrawOp
static bool CombinedQuadCountWillOverflow (GrAAType aaType, bool willBeUpgradedToAA, int combinedQuadCount)
 

Detailed Description

Definition at line 1821 of file GrOvalOpFactory.cpp.

Constructor & Destructor Documentation

◆ EllipseOp()

EllipseOp::EllipseOp ( GrProcessorSet processorSet,
const SkPMColor4f color,
const SkMatrix viewMatrix,
const DeviceSpaceParams &  params,
const SkStrokeRec stroke 
)
inline

Definition at line 1913 of file GrOvalOpFactory.cpp.

1916 : INHERITED(ClassID())
1917 , fHelper(processorSet, GrAAType::kCoverage)
1918 , fUseScale(false) {
1919 SkStrokeRec::Style style = stroke.getStyle();
1920 bool isStrokeOnly =
1922
1923 fEllipses.emplace_back(Ellipse{color, params.fXRadius, params.fYRadius,
1924 params.fInnerXRadius, params.fInnerYRadius,
1925 SkRect::MakeLTRB(params.fCenter.fX - params.fXRadius,
1926 params.fCenter.fY - params.fYRadius,
1927 params.fCenter.fX + params.fXRadius,
1928 params.fCenter.fY + params.fYRadius)});
1929
1930 this->setBounds(fEllipses.back().fDevBounds, HasAABloat::kYes, IsHairline::kNo);
1931
1932 fStroked = isStrokeOnly && params.fInnerXRadius > 0 && params.fInnerYRadius > 0;
1933 fViewMatrixIfUsingLocalCoords = viewMatrix;
1934 }
void setBounds(const SkRect &newBounds, HasAABloat aabloat, IsHairline zeroArea)
Definition: GrOp.h:279
T & emplace_back(Args &&... args)
Definition: SkTArray.h:248
DlColor color
const EmbeddedViewParams * params
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition: SkRect.h:646

Member Function Documentation

◆ finalize()

GrProcessorSet::Analysis EllipseOp::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 1946 of file GrOvalOpFactory.cpp.

1947 {
1948 fUseScale = !caps.shaderCaps()->fFloatIs32Bits &&
1949 !caps.shaderCaps()->fHasLowFragmentPrecision;
1950 SkPMColor4f* color = &fEllipses.front().fColor;
1951 return fHelper.finalizeProcessors(caps, clip, clampType,
1953 &fWideColor);
1954 }
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
GrProcessorSet::Analysis finalizeProcessors(const GrCaps &caps, const GrAppliedClip *clip, GrClampType clampType, GrProcessorAnalysisCoverage geometryCoverage, GrProcessorAnalysisColor *geometryColor)

◆ fixedFunctionFlags()

FixedFunctionFlags EllipseOp::fixedFunctionFlags ( ) const
inlineoverridevirtual

Reimplemented from GrDrawOp.

Definition at line 1956 of file GrOvalOpFactory.cpp.

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

◆ Make()

static DEFINE_OP_CLASS_ID GrOp::Owner EllipseOp::Make ( GrRecordingContext context,
GrPaint &&  paint,
const SkMatrix viewMatrix,
const SkRect ellipse,
const SkStrokeRec stroke 
)
inlinestatic

Definition at line 1836 of file GrOvalOpFactory.cpp.

1840 {
1841 DeviceSpaceParams params;
1842 // do any matrix crunching before we reset the draw state for device coords
1843 params.fCenter = SkPoint::Make(ellipse.centerX(), ellipse.centerY());
1844 viewMatrix.mapPoints(&params.fCenter, 1);
1845 SkScalar ellipseXRadius = SkScalarHalf(ellipse.width());
1846 SkScalar ellipseYRadius = SkScalarHalf(ellipse.height());
1847 params.fXRadius = SkScalarAbs(viewMatrix[SkMatrix::kMScaleX] * ellipseXRadius +
1848 viewMatrix[SkMatrix::kMSkewX] * ellipseYRadius);
1849 params.fYRadius = SkScalarAbs(viewMatrix[SkMatrix::kMSkewY] * ellipseXRadius +
1850 viewMatrix[SkMatrix::kMScaleY] * ellipseYRadius);
1851
1852 // do (potentially) anisotropic mapping of stroke
1853 SkVector scaledStroke;
1854 SkScalar strokeWidth = stroke.getWidth();
1855 scaledStroke.fX = SkScalarAbs(
1856 strokeWidth * (viewMatrix[SkMatrix::kMScaleX] + viewMatrix[SkMatrix::kMSkewY]));
1857 scaledStroke.fY = SkScalarAbs(
1858 strokeWidth * (viewMatrix[SkMatrix::kMSkewX] + viewMatrix[SkMatrix::kMScaleY]));
1859
1860 SkStrokeRec::Style style = stroke.getStyle();
1861 bool isStrokeOnly =
1863 bool hasStroke = isStrokeOnly || SkStrokeRec::kStrokeAndFill_Style == style;
1864
1865 params.fInnerXRadius = 0;
1866 params.fInnerYRadius = 0;
1867 if (hasStroke) {
1868 if (SkScalarNearlyZero(scaledStroke.length())) {
1869 scaledStroke.set(SK_ScalarHalf, SK_ScalarHalf);
1870 } else {
1871 scaledStroke.scale(SK_ScalarHalf);
1872 }
1873
1874 // we only handle thick strokes for near-circular ellipses
1875 if (scaledStroke.length() > SK_ScalarHalf &&
1876 (0.5f * params.fXRadius > params.fYRadius ||
1877 0.5f * params.fYRadius > params.fXRadius)) {
1878 return nullptr;
1879 }
1880
1881 // we don't handle it if curvature of the stroke is less than curvature of the ellipse
1882 if (scaledStroke.fX * (params.fXRadius * params.fYRadius) <
1883 (scaledStroke.fY * scaledStroke.fY) * params.fXRadius ||
1884 scaledStroke.fY * (params.fXRadius * params.fXRadius) <
1885 (scaledStroke.fX * scaledStroke.fX) * params.fYRadius) {
1886 return nullptr;
1887 }
1888
1889 // this is legit only if scale & translation (which should be the case at the moment)
1890 if (isStrokeOnly) {
1891 params.fInnerXRadius = params.fXRadius - scaledStroke.fX;
1892 params.fInnerYRadius = params.fYRadius - scaledStroke.fY;
1893 }
1894
1895 params.fXRadius += scaledStroke.fX;
1896 params.fYRadius += scaledStroke.fY;
1897 }
1898
1899 // For large ovals with low precision floats, we fall back to the path renderer.
1900 // To compute the AA at the edge we divide by the gradient, which is clamped to a
1901 // minimum value to avoid divides by zero. With large ovals and low precision this
1902 // leads to blurring at the edge of the oval.
1903 const SkScalar kMaxOvalRadius = 16384;
1904 if (!context->priv().caps()->shaderCaps()->fFloatIs32Bits &&
1905 (params.fXRadius >= kMaxOvalRadius || params.fYRadius >= kMaxOvalRadius)) {
1906 return nullptr;
1907 }
1908
1909 return Helper::FactoryHelper<EllipseOp>(context, std::move(paint), viewMatrix,
1910 params, stroke);
1911 }
static const int strokeWidth
Definition: BlurTest.cpp:60
static bool SkScalarNearlyZero(SkScalar x, SkScalar tolerance=SK_ScalarNearlyZero)
Definition: SkScalar.h:101
#define SkScalarHalf(a)
Definition: SkScalar.h:75
#define SK_ScalarHalf
Definition: SkScalar.h:19
#define SkScalarAbs(x)
Definition: SkScalar.h:39
const GrCaps * caps() const
const GrShaderCaps * shaderCaps() const
Definition: GrCaps.h:63
GrRecordingContextPriv priv()
static constexpr int kMScaleX
horizontal scale factor
Definition: SkMatrix.h:353
void mapPoints(SkPoint dst[], const SkPoint src[], int count) const
Definition: SkMatrix.cpp:770
static constexpr int kMSkewY
vertical skew factor
Definition: SkMatrix.h:356
static constexpr int kMScaleY
vertical scale factor
Definition: SkMatrix.h:357
static constexpr int kMSkewX
horizontal skew factor
Definition: SkMatrix.h:354
@ kStrokeAndFill_Style
Definition: SkStrokeRec.h:36
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
float fX
x-axis value
Definition: SkPoint_impl.h:164
static constexpr SkPoint Make(float x, float y)
Definition: SkPoint_impl.h:173
void set(float x, float y)
Definition: SkPoint_impl.h:200
float length() const
Definition: SkPoint_impl.h:282
void scale(float scale, SkPoint *dst) const
Definition: SkPoint.cpp:17
float fY
y-axis value
Definition: SkPoint_impl.h:165
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 fFloatIs32Bits
Definition: SkSLUtil.h:100

◆ name()

const char * EllipseOp::name ( ) const
inlineoverridevirtual

Implements GrOp.

Definition at line 1936 of file GrOvalOpFactory.cpp.

1936{ return "EllipseOp"; }

◆ visitProxies()

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

Reimplemented from GrOp.

Definition at line 1938 of file GrOvalOpFactory.cpp.

1938 {
1939 if (fProgramInfo) {
1940 fProgramInfo->visitFPProxies(func);
1941 } else {
1942 fHelper.visitProxies(func);
1943 }
1944 }
void visitFPProxies(const GrVisitProxyFunc &func) const
Definition: GrProgramInfo.h:64
void visitProxies(const GrVisitProxyFunc &func) const

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