Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Friends | List of all members
GrPipeline Class Reference

#include <GrPipeline.h>

Classes

struct  InitArgs
 

Public Member Functions

bool isScissorTestEnabled () const
 
const GrWindowRectsStategetWindowRectsState () const
 
bool usesConservativeRaster () const
 
bool isWireframe () const
 
bool snapVerticesToPixelCenters () const
 
bool hasStencilClip () const
 
GrXferBarrierType xferBarrierType (const GrCaps &) const
 
void genKey (skgpu::KeyBuilder *, const GrCaps &) const
 
const skgpu::SwizzlewriteSwizzle () const
 
void visitProxies (const GrVisitProxyFunc &) const
 
void setDstTextureUniforms (const GrGLSLProgramDataManager &pdm, GrGLSLBuiltinUniformHandles *fBuiltinUniformHandles) const
 
GrFragmentProcessors
int numFragmentProcessors () const
 
int numColorFragmentProcessors () const
 
bool isColorFragmentProcessor (int idx) const
 
bool isCoverageFragmentProcessor (int idx) const
 
bool usesLocalCoords () const
 
void visitTextureEffects (const std::function< void(const GrTextureEffect &)> &) const
 
const GrXferProcessorgetXferProcessor () const
 
bool usesDstTexture () const
 
bool usesDstInputAttachment () const
 
const GrSurfaceProxyViewdstProxyView () const
 
SkIPoint dstTextureOffset () const
 
GrDstSampleFlags dstSampleFlags () const
 
GrTexturepeekDstTexture () const
 
const GrFragmentProcessorgetFragmentProcessor (int idx) const
 

Friends

bool operator& (Flags, InputFlags)
 

Creation

enum class  InputFlags : uint8_t { kNone = 0 , kConservativeRaster = (1 << 1) , kWireframe = (1 << 2) , kSnapVerticesToPixelCenters = (1 << 3) }
 
 GrPipeline (GrScissorTest scissor, SkBlendMode blend, const skgpu::Swizzle &writeSwizzle, InputFlags flags=InputFlags::kNone)
 
 GrPipeline (GrScissorTest, sk_sp< const GrXferProcessor >, const skgpu::Swizzle &writeSwizzle, InputFlags=InputFlags::kNone)
 
 GrPipeline (const InitArgs &args, sk_sp< const GrXferProcessor >, const GrAppliedHardClip &)
 
 GrPipeline (const InitArgs &, GrProcessorSet &&, GrAppliedClip &&)
 
 GrPipeline (const GrPipeline &)=delete
 
GrPipelineoperator= (const GrPipeline &)=delete
 

Detailed Description

This immutable object contains information needed to build a shader program and set API state for a draw. It is used along with a GrGeometryProcessor and a source of geometric data to draw.

Definition at line 36 of file GrPipeline.h.

Member Enumeration Documentation

◆ InputFlags

enum class GrPipeline::InputFlags : uint8_t
strong
Enumerator
kNone 
kConservativeRaster 

Cause every pixel to be rasterized that is touched by the triangle anywhere (not just at pixel center). Additionally, if using MSAA, the sample mask will always have 100% coverage. NOTE: The primitive type must be a triangle type.

kWireframe 

Draws triangles as outlines.

kSnapVerticesToPixelCenters 

Modifies the vertex shader so that vertices will be positioned at pixel centers.

Definition at line 43 of file GrPipeline.h.

43 : uint8_t {
44 kNone = 0,
45 /**
46 * Cause every pixel to be rasterized that is touched by the triangle anywhere (not just at
47 * pixel center). Additionally, if using MSAA, the sample mask will always have 100%
48 * coverage.
49 * NOTE: The primitive type must be a triangle type.
50 */
51 kConservativeRaster = (1 << 1),
52 /**
53 * Draws triangles as outlines.
54 */
55 kWireframe = (1 << 2),
56 /**
57 * Modifies the vertex shader so that vertices will be positioned at pixel centers.
58 */
59 kSnapVerticesToPixelCenters = (1 << 3), // This value must be last. (See kLastInputFlag.)
60 };
@ kNone
Definition: layer.h:53

Constructor & Destructor Documentation

◆ GrPipeline() [1/5]

GrPipeline::GrPipeline ( GrScissorTest  scissor,
SkBlendMode  blend,
const skgpu::Swizzle writeSwizzle,
InputFlags  flags = InputFlags::kNone 
)
inline

Creates a simple pipeline with default settings and no processors. The provided blend mode must be "Porter Duff" (<= kLastCoeffMode). If using GrScissorTest::kEnabled, the caller must specify a scissor rectangle through the DynamicState struct.

Definition at line 74 of file GrPipeline.h.

78 : GrPipeline(scissor,
81 flags) {}
const skgpu::Swizzle & writeSwizzle() const
Definition: GrPipeline.h:197
GrPipeline(GrScissorTest scissor, SkBlendMode blend, const skgpu::Swizzle &writeSwizzle, InputFlags flags=InputFlags::kNone)
Definition: GrPipeline.h:74
static sk_sp< const GrXferProcessor > MakeNoCoverageXP(SkBlendMode)
FlutterSemanticsFlag flags
static SkColor blend(SkColor dst, SkColor src, void(*mode)(float, float, float, float *, float *, float *))
Definition: hsl.cpp:142

◆ GrPipeline() [2/5]

GrPipeline::GrPipeline ( GrScissorTest  scissorTest,
sk_sp< const GrXferProcessor xp,
const skgpu::Swizzle writeSwizzle,
InputFlags  inputFlags = InputFlags::kNone 
)

Definition at line 66 of file GrPipeline.cpp.

70 : fWindowRectsState()
71 , fFlags((Flags)inputFlags)
72 , fXferProcessor(std::move(xp))
73 , fWriteSwizzle(writeSwizzle) {
74 if (GrScissorTest::kEnabled == scissorTest) {
75 fFlags |= Flags::kScissorTestEnabled;
76 }
77}

◆ GrPipeline() [3/5]

GrPipeline::GrPipeline ( const InitArgs args,
sk_sp< const GrXferProcessor xferProcessor,
const GrAppliedHardClip hardClip 
)

Definition at line 18 of file GrPipeline.cpp.

21 : fDstProxy(args.fDstProxyView)
22 , fWindowRectsState(hardClip.windowRectsState())
23 , fXferProcessor(std::move(xferProcessor))
24 , fWriteSwizzle(args.fWriteSwizzle) {
25 fFlags = (Flags)args.fInputFlags;
26 if (hardClip.hasStencilClip()) {
27 fFlags |= Flags::kHasStencilClip;
28 }
29 if (hardClip.scissorState().enabled()) {
30 fFlags |= Flags::kScissorTestEnabled;
31 }
32 // If we have any special dst sample flags we better also have a dst proxy
34}
#define SkASSERT(cond)
Definition: SkAssert.h:116
const GrScissorState & scissorState() const
Definition: GrAppliedClip.h:41
bool hasStencilClip() const
Definition: GrAppliedClip.h:44
const GrWindowRectsState & windowRectsState() const
Definition: GrAppliedClip.h:42
GrDstSampleFlags dstSampleFlags() const
Definition: GrPipeline.h:142
const GrSurfaceProxyView & dstProxyView() const
Definition: GrPipeline.h:138
bool enabled() const
if(end==-1)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args

◆ GrPipeline() [4/5]

GrPipeline::GrPipeline ( const InitArgs args,
GrProcessorSet &&  processors,
GrAppliedClip &&  appliedClip 
)

Definition at line 36 of file GrPipeline.cpp.

38 : GrPipeline(args, processors.refXferProcessor(), appliedClip.hardClip()) {
39 SkASSERT(processors.isFinalized());
40 // Copy GrFragmentProcessors from GrProcessorSet to Pipeline
41 fNumColorProcessors = processors.hasColorFragmentProcessor() ? 1 : 0;
42 int numTotalProcessors = fNumColorProcessors +
43 (processors.hasCoverageFragmentProcessor() ? 1 : 0) +
44 (appliedClip.hasCoverageFragmentProcessor() ? 1 : 0);
45 fFragmentProcessors.reset(numTotalProcessors);
46
47 int currFPIdx = 0;
48 if (processors.hasColorFragmentProcessor()) {
49 fFragmentProcessors[currFPIdx++] = processors.detachColorFragmentProcessor();
50 }
51 if (processors.hasCoverageFragmentProcessor()) {
52 fFragmentProcessors[currFPIdx++] = processors.detachCoverageFragmentProcessor();
53 }
54 if (appliedClip.hasCoverageFragmentProcessor()) {
55 fFragmentProcessors[currFPIdx++] = appliedClip.detachCoverageFragmentProcessor();
56 }
57}
const GrAppliedHardClip & hardClip() const
std::unique_ptr< GrFragmentProcessor > detachCoverageFragmentProcessor()
int hasCoverageFragmentProcessor() const
std::unique_ptr< GrFragmentProcessor > detachCoverageFragmentProcessor()
bool hasCoverageFragmentProcessor() const
std::unique_ptr< GrFragmentProcessor > detachColorFragmentProcessor()
bool isFinalized() const
bool hasColorFragmentProcessor() const
sk_sp< const GrXferProcessor > refXferProcessor() const
void reset(int count)
Definition: SkTemplates.h:195

◆ GrPipeline() [5/5]

GrPipeline::GrPipeline ( const GrPipeline )
delete

Member Function Documentation

◆ dstProxyView()

const GrSurfaceProxyView & GrPipeline::dstProxyView ( ) const
inline

This returns the GrSurfaceProxyView for the texture used to access the dst color. If the GrXferProcessor does not use the dst color then the proxy on the GrSurfaceProxyView will be nullptr.

Definition at line 138 of file GrPipeline.h.

138{ return fDstProxy.proxyView(); }
const GrSurfaceProxyView & proxyView() const

◆ dstSampleFlags()

GrDstSampleFlags GrPipeline::dstSampleFlags ( ) const
inline

Definition at line 142 of file GrPipeline.h.

142{ return fDstProxy.dstSampleFlags(); }
GrDstSampleFlags dstSampleFlags() const

◆ dstTextureOffset()

SkIPoint GrPipeline::dstTextureOffset ( ) const
inline

Definition at line 140 of file GrPipeline.h.

140{ return fDstProxy.offset(); }
const SkIPoint & offset() const

◆ genKey()

void GrPipeline::genKey ( skgpu::KeyBuilder b,
const GrCaps caps 
) const

Definition at line 79 of file GrPipeline.cpp.

79 {
80 // kSnapVerticesToPixelCenters is implemented in a shader.
82 b->add32((uint32_t)fFlags & ~(uint32_t)ignoredFlags, "flags");
83
84 const skgpu::BlendInfo& blendInfo = this->getXferProcessor().getBlendInfo();
85
86 static constexpr uint32_t kBlendCoeffSize = 5;
87 static constexpr uint32_t kBlendEquationSize = 5;
88 static_assert(static_cast<int>(skgpu::BlendCoeff::kLast) < (1 << kBlendCoeffSize));
89 static_assert(static_cast<int>(skgpu::BlendEquation::kLast) < (1 << kBlendEquationSize));
90
91 b->addBool(blendInfo.fWritesColor, "writesColor");
92 b->addBits(kBlendCoeffSize, static_cast<int>(blendInfo.fSrcBlend), "srcBlend");
93 b->addBits(kBlendCoeffSize, static_cast<int>(blendInfo.fDstBlend), "dstBlend");
94 b->addBits(kBlendEquationSize, static_cast<int>(blendInfo.fEquation), "equation");
95 b->addBool(this->usesDstInputAttachment(), "inputAttach");
96}
bool usesDstInputAttachment() const
Definition: GrPipeline.h:129
const GrXferProcessor & getXferProcessor() const
Definition: GrPipeline.h:116
skgpu::BlendInfo getBlendInfo() const
static bool b
skgpu::BlendCoeff fDstBlend
Definition: Blend.h:96
bool fWritesColor
Definition: Blend.h:98
skgpu::BlendCoeff fSrcBlend
Definition: Blend.h:95

◆ getFragmentProcessor()

const GrFragmentProcessor & GrPipeline::getFragmentProcessor ( int  idx) const
inline

Definition at line 157 of file GrPipeline.h.

157 {
158 return *fFragmentProcessors[idx];
159 }

◆ getWindowRectsState()

const GrWindowRectsState & GrPipeline::getWindowRectsState ( ) const
inline

Definition at line 167 of file GrPipeline.h.

167{ return fWindowRectsState; }

◆ getXferProcessor()

const GrXferProcessor & GrPipeline::getXferProcessor ( ) const
inline

Definition at line 116 of file GrPipeline.h.

116 {
117 if (fXferProcessor) {
118 return *fXferProcessor;
119 } else {
120 // A null xp member means the common src-over case. GrXferProcessor's ref'ing
121 // mechanism is not thread safe so we do not hold a ref on this global.
123 }
124 }
static const GrXferProcessor & SimpleSrcOverXP()

◆ hasStencilClip()

bool GrPipeline::hasStencilClip ( ) const
inline

Definition at line 174 of file GrPipeline.h.

174 {
175 return SkToBool(fFlags & Flags::kHasStencilClip);
176 }
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35

◆ isColorFragmentProcessor()

bool GrPipeline::isColorFragmentProcessor ( int  idx) const
inline

Definition at line 101 of file GrPipeline.h.

101{ return idx < fNumColorProcessors; }

◆ isCoverageFragmentProcessor()

bool GrPipeline::isCoverageFragmentProcessor ( int  idx) const
inline

Definition at line 102 of file GrPipeline.h.

102{ return idx >= fNumColorProcessors; }

◆ isScissorTestEnabled()

bool GrPipeline::isScissorTestEnabled ( ) const
inline

Definition at line 163 of file GrPipeline.h.

163 {
164 return SkToBool(fFlags & Flags::kScissorTestEnabled);
165 }

◆ isWireframe()

bool GrPipeline::isWireframe ( ) const
inline

Definition at line 170 of file GrPipeline.h.

170{ return fFlags & InputFlags::kWireframe; }

◆ numColorFragmentProcessors()

int GrPipeline::numColorFragmentProcessors ( ) const
inline

Definition at line 100 of file GrPipeline.h.

100{ return fNumColorProcessors; }

◆ numFragmentProcessors()

int GrPipeline::numFragmentProcessors ( ) const
inline

Definition at line 99 of file GrPipeline.h.

99{ return fFragmentProcessors.count(); }

◆ operator=()

GrPipeline & GrPipeline::operator= ( const GrPipeline )
delete

◆ peekDstTexture()

GrTexture * GrPipeline::peekDstTexture ( ) const
inline

If this GrXferProcessor uses a texture to access the dst color, returns that texture.

Definition at line 145 of file GrPipeline.h.

145 {
146 if (!this->usesDstTexture()) {
147 return nullptr;
148 }
149
150 if (GrTextureProxy* dstProxy = this->dstProxyView().asTextureProxy()) {
151 return dstProxy->peekTexture();
152 }
153
154 return nullptr;
155 }
bool usesDstTexture() const
Definition: GrPipeline.h:128

◆ setDstTextureUniforms()

void GrPipeline::setDstTextureUniforms ( const GrGLSLProgramDataManager pdm,
GrGLSLBuiltinUniformHandles fBuiltinUniformHandles 
) const

Definition at line 115 of file GrPipeline.cpp.

116 {
117 GrTexture* dstTexture = this->peekDstTexture();
118
119 if (dstTexture) {
120 if (fBuiltinUniformHandles->fDstTextureCoordsUni.isValid()) {
121 float scaleX = 1.f;
122 float scaleY = 1.f;
123 if (dstTexture->textureType() == GrTextureType::kRectangle) {
124 // When we have a rectangle texture, we use the scaleX component to store the height
125 // in case we need to flip the coords when using a bottom left origin.
126 scaleX = dstTexture->height();
127 } else {
128 scaleX /= dstTexture->width();
129 scaleY /= dstTexture->height();
130 }
131 pdm.set4f(fBuiltinUniformHandles->fDstTextureCoordsUni,
132 static_cast<float>(this->dstTextureOffset().fX),
133 static_cast<float>(this->dstTextureOffset().fY),
134 scaleX,
135 scaleY);
136 }
137 } else {
138 SkASSERT(!fBuiltinUniformHandles->fDstTextureCoordsUni.isValid());
139 }
140}
virtual void set4f(UniformHandle, float, float, float, float) const =0
GrTexture * peekDstTexture() const
Definition: GrPipeline.h:145
int height() const
Definition: GrSurface.h:37
int width() const
Definition: GrSurface.h:32
GrTextureType textureType() const
Definition: GrTexture.h:55
GrGLSLProgramDataManager::UniformHandle fDstTextureCoordsUni

◆ snapVerticesToPixelCenters()

bool GrPipeline::snapVerticesToPixelCenters ( ) const
inline

Definition at line 171 of file GrPipeline.h.

171 {
173 }

◆ usesConservativeRaster()

bool GrPipeline::usesConservativeRaster ( ) const
inline

Definition at line 169 of file GrPipeline.h.

◆ usesDstInputAttachment()

bool GrPipeline::usesDstInputAttachment ( ) const
inline

Definition at line 129 of file GrPipeline.h.

129 {
131 }

◆ usesDstTexture()

bool GrPipeline::usesDstTexture ( ) const
inline

Definition at line 128 of file GrPipeline.h.

128{ return this->dstProxyView() && !this->usesDstInputAttachment(); }

◆ usesLocalCoords()

bool GrPipeline::usesLocalCoords ( ) const
inline

Definition at line 104 of file GrPipeline.h.

104 {
105 // The sample coords for the top level FPs are implicitly the GP's local coords.
106 for (const auto& fp : fFragmentProcessors) {
107 if (fp->usesSampleCoords()) {
108 return true;
109 }
110 }
111 return false;
112 }
const uint32_t fp

◆ visitProxies()

void GrPipeline::visitProxies ( const GrVisitProxyFunc func) const

Definition at line 105 of file GrPipeline.cpp.

105 {
106 // This iteration includes any clip coverage FPs
107 for (auto& fp : fFragmentProcessors) {
108 fp->visitProxies(func);
109 }
110 if (this->usesDstTexture()) {
111 func(this->dstProxyView().proxy(), skgpu::Mipmapped::kNo);
112 }
113}

◆ visitTextureEffects()

void GrPipeline::visitTextureEffects ( const std::function< void(const GrTextureEffect &)> &  func) const

Definition at line 98 of file GrPipeline.cpp.

99 {
100 for (auto& fp : fFragmentProcessors) {
101 fp->visitTextureEffects(func);
102 }
103}

◆ writeSwizzle()

const skgpu::Swizzle & GrPipeline::writeSwizzle ( ) const
inline

Definition at line 197 of file GrPipeline.h.

197{ return fWriteSwizzle; }

◆ xferBarrierType()

GrXferBarrierType GrPipeline::xferBarrierType ( const GrCaps caps) const

Definition at line 59 of file GrPipeline.cpp.

59 {
62 }
63 return this->getXferProcessor().xferBarrierType(caps);
64}
@ kTexture_GrXferBarrierType
virtual GrXferBarrierType xferBarrierType(const GrCaps &caps) const

Friends And Related Function Documentation

◆ operator&

bool operator& ( GrPipeline::Flags  flags,
GrPipeline::InputFlags  inputFlag 
)
friend

Definition at line 237 of file GrPipeline.h.

237 {
238 return (flags & (GrPipeline::Flags)inputFlag);
239}

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