Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Static Public Member Functions | List of all members
skgpu::graphite::AnalyticBlurMask Class Reference

#include <AnalyticBlurMask.h>

Public Types

enum class  ShapeType { kRect , kRRect , kCircle }
 

Public Member Functions

 AnalyticBlurMask ()=delete
 
const RectdrawBounds () const
 
const SkM44deviceToScaledShape () const
 
const RectshapeData () const
 
ShapeType shapeType () const
 
const SkV2blurData () const
 
sk_sp< TextureProxyrefProxy () const
 

Static Public Member Functions

static std::optional< AnalyticBlurMaskMake (Recorder *, const Transform &localToDevice, float deviceSigma, const SkRRect &srcRRect)
 

Detailed Description

AnalyticBlurMask holds the shader inputs used to do an analytic blur over rects, rrects, or circles.

Definition at line 29 of file AnalyticBlurMask.h.

Member Enumeration Documentation

◆ ShapeType

Enumerator
kRect 
kRRect 
kCircle 

Definition at line 31 of file AnalyticBlurMask.h.

31 {
32 kRect,
33 kRRect,
34 kCircle,
35 };
@ kRRect
constexpr std::array< std::array< float, 2 >, 2 > kRect

Constructor & Destructor Documentation

◆ AnalyticBlurMask()

skgpu::graphite::AnalyticBlurMask::AnalyticBlurMask ( )
delete

Member Function Documentation

◆ blurData()

const SkV2 & skgpu::graphite::AnalyticBlurMask::blurData ( ) const
inline

Definition at line 55 of file AnalyticBlurMask.h.

55{ return fBlurData; }

◆ deviceToScaledShape()

const SkM44 & skgpu::graphite::AnalyticBlurMask::deviceToScaledShape ( ) const
inline

Definition at line 52 of file AnalyticBlurMask.h.

52{ return fDevToScaledShape; }

◆ drawBounds()

const Rect & skgpu::graphite::AnalyticBlurMask::drawBounds ( ) const
inline

Definition at line 51 of file AnalyticBlurMask.h.

51{ return fDrawBounds; }

◆ Make()

std::optional< AnalyticBlurMask > skgpu::graphite::AnalyticBlurMask::Make ( Recorder recorder,
const Transform localToDevice,
float  deviceSigma,
const SkRRect srcRRect 
)
static

Definition at line 48 of file AnalyticBlurMask.cpp.

51 {
52 // TODO: Implement SkMatrix functionality used below for Transform.
53 SkMatrix localToDevice = localToDeviceTransform;
54
55 if (srcRRect.isRect() && localToDevice.preservesRightAngles()) {
56 return MakeRect(recorder, localToDevice, deviceSigma, srcRRect.rect());
57 }
58
59 SkRRect devRRect;
60 const bool devRRectIsValid = srcRRect.transform(localToDevice, &devRRect);
61 if (devRRectIsValid && SkRRectPriv::IsCircle(devRRect)) {
62 return MakeCircle(recorder, localToDevice, deviceSigma, srcRRect.rect(), devRRect.rect());
63 }
64
65 // A local-space circle transformed by a rotation matrix will fail SkRRect::transform since it
66 // only supports scale + translate matrices, but is still a valid circle that can be blurred.
67 if (SkRRectPriv::IsCircle(srcRRect) && localToDevice.isSimilarity()) {
68 const SkRect srcRect = srcRRect.rect();
69 const SkPoint devCenter = localToDevice.mapPoint(srcRect.center());
70 const float devRadius = localToDevice.mapVector(0.0f, srcRect.width() / 2.0f).length();
71 const SkRect devRect = {devCenter.x() - devRadius,
72 devCenter.y() - devRadius,
73 devCenter.x() + devRadius,
74 devCenter.y() + devRadius};
75 return MakeCircle(recorder, localToDevice, deviceSigma, srcRect, devRect);
76 }
77
78 if (devRRectIsValid && SkRRectPriv::IsSimpleCircular(devRRect) &&
79 localToDevice.isScaleTranslate()) {
80 return MakeRRect(recorder, localToDevice, deviceSigma, srcRRect, devRRect);
81 }
82
83 return std::nullopt;
84}
bool preservesRightAngles(SkScalar tol=SK_ScalarNearlyZero) const
Definition: SkMatrix.cpp:209
SkPoint mapPoint(SkPoint pt) const
Definition: SkMatrix.h:1374
bool isScaleTranslate() const
Definition: SkMatrix.h:236
bool isSimilarity(SkScalar tol=SK_ScalarNearlyZero) const
Definition: SkMatrix.cpp:180
void mapVector(SkScalar dx, SkScalar dy, SkVector *result) const
Definition: SkMatrix.h:1524
static bool IsSimpleCircular(const SkRRect &rr)
Definition: SkRRectPriv.h:27
static bool IsCircle(const SkRRect &rr)
Definition: SkRRectPriv.h:18
const SkRect & rect() const
Definition: SkRRect.h:264
bool transform(const SkMatrix &matrix, SkRRect *dst) const
Definition: SkRRect.cpp:436
bool isRect() const
Definition: SkRRect.h:84
constexpr float y() const
Definition: SkPoint_impl.h:187
constexpr float x() const
Definition: SkPoint_impl.h:181
constexpr float width() const
Definition: SkRect.h:762
constexpr SkPoint center() const
Definition: SkRect.h:792

◆ refProxy()

sk_sp< TextureProxy > skgpu::graphite::AnalyticBlurMask::refProxy ( ) const
inline

Definition at line 56 of file AnalyticBlurMask.h.

56{ return fProxy; }

◆ shapeData()

const Rect & skgpu::graphite::AnalyticBlurMask::shapeData ( ) const
inline

Definition at line 53 of file AnalyticBlurMask.h.

53{ return fShapeData; }

◆ shapeType()

ShapeType skgpu::graphite::AnalyticBlurMask::shapeType ( ) const
inline

Definition at line 54 of file AnalyticBlurMask.h.

54{ return fShapeType; }

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