Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
GrMeshDrawOp.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
9
14
15GrMeshDrawOp::GrMeshDrawOp(uint32_t classID) : INHERITED(classID) {}
16
18
20 this->createProgramInfo(&target->caps(),
21 target->allocator(),
22 target->writeView(),
23 target->usesMSAASurface(),
24 target->detachAppliedClip(),
25 target->dstProxyView(),
26 target->renderPassBarriers(),
27 target->colorLoadOp());
28}
29
31 bool willBeUpgradedToAA,
32 int combinedQuadCount) {
33 bool willBeAA = (aaType == GrAAType::kCoverage) || willBeUpgradedToAA;
34
35 return combinedQuadCount > (willBeAA ? GrResourceProvider::MaxNumAAQuads()
37}
38
39// This onPrepareDraws implementation assumes the derived Op only has a single programInfo -
40// which is the majority of the cases.
42 const GrSurfaceProxyView& writeView,
44 const GrDstProxyView& dstProxyView,
45 GrXferBarrierFlags renderPassXferBarriers,
46 GrLoadOp colorLoadOp) {
47 SkArenaAlloc* arena = context->priv().recordTimeAllocator();
48
49 // http://skbug.com/12201 -- DDL does not yet support DMSAA.
50 bool usesMSAASurface = writeView.asRenderTargetProxy()->numSamples() > 1;
51
52 // This is equivalent to a GrOpFlushState::detachAppliedClip
53 GrAppliedClip appliedClip = clip ? std::move(*clip) : GrAppliedClip::Disabled();
54
55 this->createProgramInfo(context->priv().caps(), arena, writeView, usesMSAASurface,
56 std::move(appliedClip), dstProxyView, renderPassXferBarriers,
57 colorLoadOp);
58
59 // TODO: at this point we've created both the program info and desc in the recording context's
60 // arena. In the DDL case, it would be cool if 'recordProgramInfo' could return the
61 // pre-existing versions if the program has already been seen. We could then return the
62 // memory for the current copy to the arena.
63 context->priv().recordProgramInfo(this->programInfo());
64}
65
66//////////////////////////////////////////////////////////////////////////////
67
69 size_t vertexStride, sk_sp<const GrBuffer> indexBuffer,
70 int verticesPerRepetition, int indicesPerRepetition,
71 int repeatCount, int maxRepetitions) {
72 this->init(target, primitiveType, vertexStride, std::move(indexBuffer), verticesPerRepetition,
73 indicesPerRepetition, repeatCount, maxRepetitions);
74}
75
77 size_t vertexStride, sk_sp<const GrBuffer> indexBuffer,
78 int verticesPerRepetition, int indicesPerRepetition,
79 int repeatCount, int maxRepetitions) {
81 if (!indexBuffer) {
82 return;
83 }
84 sk_sp<const GrBuffer> vertexBuffer;
85 int firstVertex;
86 int vertexCount = verticesPerRepetition * repeatCount;
87 fVertices = target->makeVertexSpace(vertexStride, vertexCount, &vertexBuffer, &firstVertex);
88 if (!fVertices) {
89 SkDebugf("Vertices could not be allocated for patterned rendering.");
90 return;
91 }
92 SkASSERT(vertexBuffer);
93 fMesh = target->allocMesh();
94 fPrimitiveType = primitiveType;
95
96 SkASSERT(maxRepetitions ==
97 static_cast<int>(indexBuffer->size() / (sizeof(uint16_t) * indicesPerRepetition)));
98 fMesh->setIndexedPatterned(std::move(indexBuffer), indicesPerRepetition, repeatCount,
99 maxRepetitions, std::move(vertexBuffer), verticesPerRepetition,
100 firstVertex);
101}
102
104 const GrGeometryProcessor* gp) const {
105 target->recordDraw(gp, fMesh, 1, fPrimitiveType);
106}
107
110 const GrGeometryProcessor* gp,
111 const GrSurfaceProxy* const primProcProxies[]) const {
112 target->recordDraw(gp, fMesh, 1, primProcProxies, fPrimitiveType);
113}
114
115//////////////////////////////////////////////////////////////////////////////
116
118 size_t vertexStride,
119 int quadsToDraw) {
120 sk_sp<const GrGpuBuffer> indexBuffer = target->resourceProvider()->refNonAAQuadIndexBuffer();
121 if (!indexBuffer) {
122 SkDebugf("Could not get quad index buffer.");
123 return;
124 }
125 this->init(target, GrPrimitiveType::kTriangles, vertexStride, std::move(indexBuffer),
129}
GrPrimitiveType
Definition GrTypesPriv.h:42
GrAAType
GrLoadOp
GrXferBarrierFlags
#define SkASSERT(cond)
Definition SkAssert.h:116
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition SkPath.cpp:3824
static GrAppliedClip Disabled()
const GrCaps * caps() const
void recordDraw(GrMeshDrawTarget *, const GrGeometryProcessor *) const
void init(GrMeshDrawTarget *, GrPrimitiveType, size_t vertexStride, sk_sp< const GrBuffer > indexBuffer, int verticesPerRepetition, int indicesPerRepetition, int repeatCount, int maxRepetitions)
virtual GrProgramInfo * programInfo()=0
void createProgramInfo(const GrCaps *caps, SkArenaAlloc *arena, const GrSurfaceProxyView &writeView, bool usesMSAASurface, GrAppliedClip &&appliedClip, const GrDstProxyView &dstProxyView, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp)
GrMeshDrawOp(uint32_t classID)
virtual void onPrePrepareDraws(GrRecordingContext *, const GrSurfaceProxyView &writeView, GrAppliedClip *, const GrDstProxyView &, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp)
virtual void onPrepareDraws(GrMeshDrawTarget *)=0
void onPrepare(GrOpFlushState *state) final
static bool CombinedQuadCountWillOverflow(GrAAType aaType, bool willBeUpgradedToAA, int combinedQuadCount)
virtual const GrCaps & caps() const =0
void recordProgramInfo(const GrProgramInfo *programInfo)
SkArenaAlloc * recordTimeAllocator()
GrRecordingContextPriv priv()
static int NumIndicesPerNonAAQuad()
static int NumVertsPerNonAAQuad()
GrRenderTargetProxy * asRenderTargetProxy() const
AtkStateType state
uint32_t * target
void setIndexedPatterned(sk_sp< const GrBuffer > indexBuffer, int indexCount, int patternRepeatCount, int maxPatternRepetitionsInIndexBuffer, sk_sp< const GrBuffer > vertexBuffer, int patternVertexCount, int baseVertex)