40 constexpr static Attribute kInstanceAttribs[] = {
50 const char*
name() const final {
return "tessellate_BoundingBoxShader"; }
57std::unique_ptr<GrGeometryProcessor::ProgramImpl> BoundingBoxShader::makeProgramImpl(
69 void onEmitCode(EmitArgs&
args, GrGPArgs* gpArgs)
final {
70 args.fVaryingHandler->emitAttributes(
args.fGeomProc);
73 if (
args.fShaderCaps->fVertexIDSupport) {
76 args.fVertBuilder->codeAppend(
77 "float2 unitCoord = float2(sk_VertexID & 1, sk_VertexID >> 1);");
79 args.fVertBuilder->codeAppend(
81 "float2x2 M_ = inverse(float2x2(matrix2d.xy, matrix2d.zw));"
82 "float2 bloat = float2(abs(M_[0]) + abs(M_[1])) * .25;"
85 "float2 localcoord = mix(pathBounds.xy - bloat, pathBounds.zw + bloat, unitCoord);"
86 "float2 vertexpos = float2x2(matrix2d.xy, matrix2d.zw) * localcoord + translate;"
95 args.fFragBuilder->codeAppendf(
"half4 %s = %s;",
args.fOutputColor,
color);
96 args.fFragBuilder->codeAppendf(
"const half4 %s = half4(1);",
args.fOutputCoverage);
102 return std::make_unique<Impl>();
110 if (fCoverBBoxProgram) {
145 args, fAAType, appliedClip.hardClip(), pipelineFlags);
149 if (fTotalCombinedPathVerbCnt > 50 &&
162 args.fCaps->shaderCaps()->fInfinitySupport);
165 args.fCaps->shaderCaps()->fInfinitySupport);
171 fTessellator->patchAttribs());
180 auto* bboxShader =
args.fArena->make<BoundingBoxShader>(fColor, *
args.fCaps->shaderCaps());
182 std::move(appliedClip),
183 std::move(fProcessors));
191 args.fUsesMSAASurface,
194 args.fXferBarrierFlags,
207 this->prePreparePrograms({context->
priv().recordTimeAllocator(), writeView, usesMSAASurface,
208 &dstProxyView, renderPassXferBarriers, colorLoadOp,
211 if (fStencilFanProgram) {
214 if (fStencilPathProgram) {
217 if (fCoverBBoxProgram) {
235 if (fStencilFanProgram) {
245 int maxTrianglesInFans =
std::max(fTotalCombinedPathVerbCnt - 2, 0);
246 int fanTriangleCount = 0;
247 if (VertexWriter triangleVertexWriter =
248 vertexAlloc.lockWriter(
sizeof(
SkPoint), maxTrianglesInFans * 3)) {
249 for (
auto [pathMatrix,
path,
color] : *fPathDrawList) {
250 tess::AffineMatrix
m(pathMatrix);
251 for (tess::PathMiddleOutFanIter it(
path); !it.done();) {
252 for (
auto [p0, p1, p2] : it.nextStack()) {
253 triangleVertexWriter <<
m.map2Points(p0, p1) <<
m.mapPoint(p2);
260 SkASSERT(fanTriangleCount <= maxTrianglesInFans);
261 fFanVertexCount = fanTriangleCount * 3;
262 vertexAlloc.unlock(fFanVertexCount);
267 fTessellator->prepare(flushState,
268 tessShader->viewMatrix(),
270 fTotalCombinedPathVerbCnt);
272 if (fCoverBBoxProgram) {
278 SkDEBUGCODE(
int pathCount = 0;)
279 for (
auto [pathMatrix,
path,
color] : *fPathDrawList) {
280 SkDEBUGCODE(
auto end = vertexWriter.mark(instanceStride));
281 vertexWriter << pathMatrix.getScaleX()
282 << pathMatrix.getSkewY()
283 << pathMatrix.getSkewX()
284 << pathMatrix.getScaleY()
285 << pathMatrix.getTranslateX()
286 << pathMatrix.getTranslateY();
287 if (
path.isInverseFillType()) {
292 SkASSERT(rtBounds == fOriginalDrawBounds);
295 vertexWriter << pathSpaceRTBounds;
297 vertexWriter <<
path.getBounds();
300 vertexWriter <<
path.getBounds();
302 SkASSERT(vertexWriter.mark() == end);
303 SkDEBUGCODE(++pathCount;)
309 constexpr static SkPoint kUnitQuad[4] = {{0,0}, {0,1}, {1,0}, {1,1}};
323 if (fCoverBBoxProgram &&
325 !fBBoxVertexBufferIfNoIDSupport) {
330 if (fFanVertexCount > 0) {
334 flushState->
bindBuffers(
nullptr,
nullptr, fFanBuffer);
335 flushState->
draw(fFanVertexCount, fFanBaseVertex);
341 fTessellator->draw(flushState);
344 if (fCoverBBoxProgram) {
348 flushState->
bindBuffers(
nullptr, fBBoxBuffer, fBBoxVertexBufferIfNoIDSupport);
349 flushState->
drawInstanced(fPathCount, fBBoxBaseInstance, 4, 0);
std::function< void(GrSurfaceProxy *, skgpu::Mipmapped)> GrVisitProxyFunc
GrFillRule GrFillRuleForPathFillType(SkPathFillType fillType)
@ kFloat2_GrVertexAttribType
@ kFloat4_GrVertexAttribType
#define SKGPU_DEFINE_STATIC_UNIQUE_KEY(name)
constexpr SkPMColor4f SK_PMColor4fTRANSPARENT
static bool SkPathFillType_IsInverse(SkPathFillType ft)
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
static GrAppliedClip Disabled()
const GrCaps * caps() const
const GrShaderCaps * shaderCaps() const
void setData(const GrGLSLProgramDataManager &pdman, const GrFragmentProcessor &processor)
virtual void set4f(UniformHandle, float, float, float, float) const =0
void setInstanceAttributesWithImplicitOffsets(const Attribute *attrs, int attrCount)
virtual std::unique_ptr< ProgramImpl > makeProgramImpl(const GrShaderCaps &) const =0
virtual void addToKey(const GrShaderCaps &, skgpu::KeyBuilder *) const =0
size_t instanceStride() const
bool hasVertexAttributes() const
void setVertexAttributesWithImplicitOffsets(const Attribute *attrs, int attrCount)
skgpu::VertexWriter makeVertexWriter(size_t vertexSize, int vertexCount, sk_sp< const GrBuffer > *, int *startVertex)
GrLoadOp colorLoadOp() const final
const GrDstProxyView & dstProxyView() const final
GrXferBarrierFlags renderPassBarriers() const final
SkArenaAlloc * allocator() override
void bindPipelineAndScissorClip(const GrProgramInfo &programInfo, const SkRect &drawBounds)
void bindBuffers(sk_sp< const GrBuffer > indexBuffer, sk_sp< const GrBuffer > instanceBuffer, sk_sp< const GrBuffer > vertexBuffer, GrPrimitiveRestart primitiveRestart=GrPrimitiveRestart::kNo)
const GrSurfaceProxyView & writeView() const final
void drawInstanced(int instanceCount, int baseInstance, int vertexCount, int baseVertex)
GrResourceProvider * resourceProvider() const final
GrAppliedClip detachAppliedClip() final
const GrCaps & caps() const final
void bindTextures(const GrGeometryProcessor &geomProc, const GrSurfaceProxy &singleGeomProcTexture, const GrPipeline &pipeline)
void draw(int vertexCount, int baseVertex)
bool usesMSAASurface() const final
const SkRect & bounds() const
static const GrUserStencilSettings * StencilPathSettings(GrFillRule fillRule)
static GrPathTessellationShader * MakeSimpleTriangleShader(SkArenaAlloc *, const SkMatrix &viewMatrix, const SkPMColor4f &)
static const GrPipeline * MakeStencilOnlyPipeline(const ProgramArgs &, GrAAType, const GrAppliedHardClip &, GrPipeline::InputFlags=GrPipeline::InputFlags::kNone)
static GrPathTessellationShader * Make(const GrShaderCaps &, SkArenaAlloc *, const SkMatrix &viewMatrix, const SkPMColor4f &, PatchAttribs)
static const GrUserStencilSettings * TestAndResetStencilSettings(bool isInverseFill=false)
void visitProxies(const GrVisitProxyFunc &) const
void visitProxies(const GrVisitProxyFunc &) const
Analysis finalize(const GrProcessorAnalysisColor &, const GrProcessorAnalysisCoverage, const GrAppliedClip *, const GrUserStencilSettings *, const GrCaps &, GrClampType, SkPMColor4f *inputColorOverride)
virtual const char * name() const =0
const GrPipeline & pipeline() const
const GrGeometryProcessor & geomProc() const
void recordProgramInfo(const GrProgramInfo *programInfo)
GrRecordingContextPriv priv()
sk_sp< const GrGpuBuffer > findOrMakeStaticBuffer(GrGpuBufferType intendedType, size_t size, const skgpu::UniqueKey &key, InitializeBufferFn)
static GrProgramInfo * CreateProgramInfo(const GrCaps *, SkArenaAlloc *, const GrPipeline *, const GrSurfaceProxyView &writeView, bool usesMSAASurface, GrGeometryProcessor *, GrPrimitiveType, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp, const GrUserStencilSettings *=&GrUserStencilSettings::kUnused)
GrRenderTargetProxy * asRenderTargetProxy() const
SkRect backingStoreBoundsRect() const
static const GrPipeline * MakePipeline(const ProgramArgs &, GrAAType, GrAppliedClip &&, GrProcessorSet &&)
static GrProgramInfo * MakeProgram(const ProgramArgs &args, const GrTessellationShader *shader, const GrPipeline *pipeline, const GrUserStencilSettings *stencil)
static bool InverseMapRect(const SkMatrix &mx, SkRect *dst, const SkRect &src)
static const SkMatrix & I()
static PathCurveTessellator * Make(SkArenaAlloc *arena, bool infinitySupport, PatchAttribs attribs=PatchAttribs::kNone)
static PathWedgeTessellator * Make(SkArenaAlloc *arena, bool infinitySupport, PatchAttribs attribs=PatchAttribs::kNone)
FlutterSemanticsFlag flags
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
static float max(float r, float g, float b)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
SKGPU_DECLARE_STATIC_UNIQUE_KEY(gUnitQuadBufferKey)