Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Typedefs | Enumerations | Functions | Variables
skgpu::ganesh::QuadPerEdgeAA Namespace Reference

Classes

class  QuadPerEdgeAAGeometryProcessor
 
class  Tessellator
 
struct  VertexSpec
 

Typedefs

using Saturate = skgpu::ganesh::TextureOp::Saturate
 

Enumerations

enum class  CoverageMode { kNone , kWithPosition , kWithColor }
 
enum class  Subset : bool { kNo = false , kYes = true }
 
enum class  ColorType { kNone , kByte , kFloat , kLast = kFloat }
 
enum class  IndexBufferOption { kPictureFramed , kIndexedRects , kTriStrips , kLast = kTriStrips }
 

Functions

IndexBufferOption CalcIndexBufferOption (GrAAType aa, int numQuads)
 
ColorType MinColorType (SkPMColor4f color)
 
sk_sp< const GrBufferGetIndexBuffer (GrMeshDrawTarget *target, IndexBufferOption indexBufferOption)
 
int QuadLimit (IndexBufferOption option)
 
void IssueDraw (const GrCaps &caps, GrOpsRenderPass *renderPass, const VertexSpec &spec, int runningQuadCount, int quadsInDraw, int maxVerts, int absVertBufferOffset)
 
GrGeometryProcessorMakeProcessor (SkArenaAlloc *arena, const VertexSpec &spec)
 
GrGeometryProcessorMakeTexturedProcessor (SkArenaAlloc *arena, const VertexSpec &spec, const GrShaderCaps &caps, const GrBackendFormat &backendFormat, GrSamplerState samplerState, const skgpu::Swizzle &swizzle, sk_sp< GrColorSpaceXform > textureColorSpaceXform, Saturate saturate)
 

Variables

static const int kColorTypeCount = static_cast<int>(ColorType::kLast) + 1
 
static const int kIndexBufferOptionCount = static_cast<int>(IndexBufferOption::kLast) + 1
 

Typedef Documentation

◆ Saturate

Definition at line 30 of file QuadPerEdgeAA.h.

Enumeration Type Documentation

◆ ColorType

Enumerator
kNone 
kByte 
kFloat 
kLast 

Definition at line 34 of file QuadPerEdgeAA.h.

◆ CoverageMode

Enumerator
kNone 
kWithPosition 
kWithColor 

Definition at line 32 of file QuadPerEdgeAA.h.

◆ IndexBufferOption

Enumerator
kPictureFramed 
kIndexedRects 
kTriStrips 
kLast 

Definition at line 37 of file QuadPerEdgeAA.h.

37 {
38 kPictureFramed, // geometrically AA'd -> 8 verts/quad + an index buffer
39 kIndexedRects, // non-AA'd but indexed -> 4 verts/quad + an index buffer
40 kTriStrips, // non-AA'd -> 4 verts/quad but no index buffer
42};

◆ Subset

enum class skgpu::ganesh::QuadPerEdgeAA::Subset : bool
strong
Enumerator
kNo 
kYes 

Definition at line 33 of file QuadPerEdgeAA.h.

33: bool { kNo = false, kYes = true };
@ kYes
Do pre-clip the geometry before applying the (perspective) matrix.
@ kNo
Don't pre-clip the geometry before applying the (perspective) matrix.

Function Documentation

◆ CalcIndexBufferOption()

IndexBufferOption skgpu::ganesh::QuadPerEdgeAA::CalcIndexBufferOption ( GrAAType  aa,
int  numQuads 
)

Definition at line 305 of file QuadPerEdgeAA.cpp.

305 {
306 if (aa == GrAAType::kCoverage) {
307 return IndexBufferOption::kPictureFramed;
308 } else if (numQuads > 1) {
309 return IndexBufferOption::kIndexedRects;
310 } else {
311 return IndexBufferOption::kTriStrips;
312 }
313}

◆ GetIndexBuffer()

sk_sp< const GrBuffer > skgpu::ganesh::QuadPerEdgeAA::GetIndexBuffer ( GrMeshDrawTarget target,
IndexBufferOption  indexBufferOption 
)

Definition at line 460 of file QuadPerEdgeAA.cpp.

461 {
462 auto resourceProvider = target->resourceProvider();
463
464 switch (indexBufferOption) {
465 case IndexBufferOption::kPictureFramed: return resourceProvider->refAAQuadIndexBuffer();
466 case IndexBufferOption::kIndexedRects: return resourceProvider->refNonAAQuadIndexBuffer();
467 case IndexBufferOption::kTriStrips: // fall through
468 default: return nullptr;
469 }
470}
uint32_t * target

◆ IssueDraw()

void skgpu::ganesh::QuadPerEdgeAA::IssueDraw ( const GrCaps caps,
GrOpsRenderPass renderPass,
const VertexSpec spec,
int  runningQuadCount,
int  quadsInDraw,
int  maxVerts,
int  absVertBufferOffset 
)

Definition at line 482 of file QuadPerEdgeAA.cpp.

483 {
484 if (spec.indexBufferOption() == IndexBufferOption::kTriStrips) {
485 int offset = absVertBufferOffset +
486 runningQuadCount * GrResourceProvider::NumVertsPerNonAAQuad();
487 renderPass->draw(4, offset);
488 return;
489 }
490
491 SkASSERT(spec.indexBufferOption() == IndexBufferOption::kPictureFramed ||
492 spec.indexBufferOption() == IndexBufferOption::kIndexedRects);
493
494 int maxNumQuads, numIndicesPerQuad, numVertsPerQuad;
495
496 if (spec.indexBufferOption() == IndexBufferOption::kPictureFramed) {
497 // AA uses 8 vertices and 30 indices per quad, basically nested rectangles
498 maxNumQuads = GrResourceProvider::MaxNumAAQuads();
499 numIndicesPerQuad = GrResourceProvider::NumIndicesPerAAQuad();
500 numVertsPerQuad = GrResourceProvider::NumVertsPerAAQuad();
501 } else {
502 // Non-AA uses 4 vertices and 6 indices per quad
504 numIndicesPerQuad = GrResourceProvider::NumIndicesPerNonAAQuad();
506 }
507
508 SkASSERT(runningQuadCount + quadsInDraw <= maxNumQuads);
509
510 if (caps.avoidLargeIndexBufferDraws()) {
511 // When we need to avoid large index buffer draws we modify the base vertex of the draw
512 // which, in GL, requires rebinding all vertex attrib arrays, so a base index is generally
513 // preferred.
514 int offset = absVertBufferOffset + runningQuadCount * numVertsPerQuad;
515
516 renderPass->drawIndexPattern(numIndicesPerQuad, quadsInDraw, maxNumQuads, numVertsPerQuad,
517 offset);
518 } else {
519 int baseIndex = runningQuadCount * numIndicesPerQuad;
520 int numIndicesToDraw = quadsInDraw * numIndicesPerQuad;
521
522 int minVertex = runningQuadCount * numVertsPerQuad;
523 int maxVertex = (runningQuadCount + quadsInDraw) * numVertsPerQuad - 1; // inclusive
524
525 renderPass->drawIndexed(numIndicesToDraw, baseIndex, minVertex, maxVertex,
526 absVertBufferOffset);
527 }
528}
#define SkASSERT(cond)
Definition SkAssert.h:116
bool avoidLargeIndexBufferDraws() const
Definition GrCaps.h:433
void draw(int vertexCount, int baseVertex)
void drawIndexPattern(int patternIndexCount, int patternRepeatCount, int maxPatternRepetitionsInIndexBuffer, int patternVertexCount, int baseVertex)
void drawIndexed(int indexCount, int baseIndex, uint16_t minIndexValue, uint16_t maxIndexValue, int baseVertex)
static int NumIndicesPerNonAAQuad()
static int NumVertsPerNonAAQuad()
Point offset
IndexBufferOption indexBufferOption() const

◆ MakeProcessor()

GrGeometryProcessor * skgpu::ganesh::QuadPerEdgeAA::MakeProcessor ( SkArenaAlloc arena,
const VertexSpec spec 
)

Definition at line 909 of file QuadPerEdgeAA.cpp.

909 {
910 return QuadPerEdgeAAGeometryProcessor::Make(arena, spec);
911}

◆ MakeTexturedProcessor()

GrGeometryProcessor * skgpu::ganesh::QuadPerEdgeAA::MakeTexturedProcessor ( SkArenaAlloc arena,
const VertexSpec spec,
const GrShaderCaps caps,
const GrBackendFormat backendFormat,
GrSamplerState  samplerState,
const skgpu::Swizzle swizzle,
sk_sp< GrColorSpaceXform textureColorSpaceXform,
Saturate  saturate 
)

Definition at line 913 of file QuadPerEdgeAA.cpp.

920 {
921 return QuadPerEdgeAAGeometryProcessor::Make(arena, spec, caps, backendFormat, samplerState,
922 swizzle, std::move(textureColorSpaceXform),
923 saturate);
924}

◆ MinColorType()

ColorType skgpu::ganesh::QuadPerEdgeAA::MinColorType ( SkPMColor4f  color)

Definition at line 316 of file QuadPerEdgeAA.cpp.

316 {
317 if (color == SK_PMColor4fWHITE) {
318 return ColorType::kNone;
319 } else {
320 return color.fitsInBytes() ? ColorType::kByte : ColorType::kFloat;
321 }
322}
SkColor4f color
constexpr SkPMColor4f SK_PMColor4fWHITE

◆ QuadLimit()

int skgpu::ganesh::QuadPerEdgeAA::QuadLimit ( IndexBufferOption  option)

Definition at line 472 of file QuadPerEdgeAA.cpp.

472 {
473 switch (option) {
474 case IndexBufferOption::kPictureFramed: return GrResourceProvider::MaxNumAAQuads();
475 case IndexBufferOption::kIndexedRects: return GrResourceProvider::MaxNumNonAAQuads();
476 case IndexBufferOption::kTriStrips: return SK_MaxS32; // not limited by an indexBuffer
477 }
478
480}
#define SkUNREACHABLE
Definition SkAssert.h:135
static constexpr int32_t SK_MaxS32
Definition SkMath.h:21

Variable Documentation

◆ kColorTypeCount

const int skgpu::ganesh::QuadPerEdgeAA::kColorTypeCount = static_cast<int>(ColorType::kLast) + 1
static

Definition at line 35 of file QuadPerEdgeAA.h.

◆ kIndexBufferOptionCount

const int skgpu::ganesh::QuadPerEdgeAA::kIndexBufferOptionCount = static_cast<int>(IndexBufferOption::kLast) + 1
static

Definition at line 43 of file QuadPerEdgeAA.h.