Flutter Engine
The Flutter Engine
GrSimpleMesh.h
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
8#ifndef GrSimpleMesh_DEFINED
9#define GrSimpleMesh_DEFINED
10
14
16
17/**
18 * Used to communicate simple (non-instanced, direct) draws from GrOp to GrOpsRenderPass.
19 * TODO: Consider migrating every Op to make the appropriate draw directly on GrOpsRenderPass.
20 */
22 void set(sk_sp<const GrBuffer> vertexBuffer, int vertexCount, int baseVertex);
23 void setIndexed(sk_sp<const GrBuffer> indexBuffer, int indexCount, int baseIndex,
24 uint16_t minIndexValue, uint16_t maxIndexValue, GrPrimitiveRestart,
25 sk_sp<const GrBuffer> vertexBuffer, int baseVertex);
26 void setIndexedPatterned(sk_sp<const GrBuffer> indexBuffer, int indexCount,
27 int patternRepeatCount, int maxPatternRepetitionsInIndexBuffer,
28 sk_sp<const GrBuffer> vertexBuffer, int patternVertexCount,
29 int baseVertex);
30
39
42 int fBaseVertex = 0;
43
44 SkDEBUGCODE(bool fIsInitialized = false;)
45};
46
47inline void GrSimpleMesh::set(sk_sp<const GrBuffer> vertexBuffer, int vertexCount, int baseVertex) {
48 SkASSERT(baseVertex >= 0);
50 fVertexBuffer = std::move(vertexBuffer);
51 fVertexCount = vertexCount;
52 fBaseVertex = baseVertex;
53 SkDEBUGCODE(fIsInitialized = true;)
54}
55
56inline void GrSimpleMesh::setIndexed(sk_sp<const GrBuffer> indexBuffer, int indexCount,
57 int baseIndex, uint16_t minIndexValue, uint16_t maxIndexValue,
58 GrPrimitiveRestart primitiveRestart,
59 sk_sp<const GrBuffer> vertexBuffer, int baseVertex) {
60 SkASSERT(indexBuffer);
61 SkASSERT(indexCount >= 1);
62 SkASSERT(baseIndex >= 0);
63 SkASSERT(maxIndexValue >= minIndexValue);
64 SkASSERT(baseVertex >= 0);
65 fIndexBuffer = std::move(indexBuffer);
66 fIndexCount = indexCount;
68 fBaseIndex = baseIndex;
69 fMinIndexValue = minIndexValue;
70 fMaxIndexValue = maxIndexValue;
71 fPrimitiveRestart = primitiveRestart;
72 fVertexBuffer = std::move(vertexBuffer);
73 fBaseVertex = baseVertex;
74 SkDEBUGCODE(fIsInitialized = true;)
75}
76
78 sk_sp<const GrBuffer> indexBuffer, int indexCount, int patternRepeatCount,
79 int maxPatternRepetitionsInIndexBuffer, sk_sp<const GrBuffer> vertexBuffer,
80 int patternVertexCount, int baseVertex) {
81 SkASSERT(indexBuffer);
82 SkASSERT(indexCount >= 1);
83 SkASSERT(patternVertexCount >= 1);
84 SkASSERT(patternRepeatCount >= 1);
85 SkASSERT(maxPatternRepetitionsInIndexBuffer >= 1);
86 SkASSERT(baseVertex >= 0);
87 fIndexBuffer = std::move(indexBuffer);
88 fIndexCount = indexCount;
89 fPatternRepeatCount = patternRepeatCount;
90 fVertexCount = patternVertexCount;
91 fMaxPatternRepetitionsInIndexBuffer = maxPatternRepetitionsInIndexBuffer;
93 fVertexBuffer = std::move(vertexBuffer);
94 fBaseVertex = baseVertex;
95 SkDEBUGCODE(fIsInitialized = true;)
96}
97
98#endif
GrPrimitiveRestart
Definition: GrTypesPriv.h:56
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
void reset(T *ptr=nullptr)
Definition: SkRefCnt.h:310
void setIndexed(sk_sp< const GrBuffer > indexBuffer, int indexCount, int baseIndex, uint16_t minIndexValue, uint16_t maxIndexValue, GrPrimitiveRestart, sk_sp< const GrBuffer > vertexBuffer, int baseVertex)
Definition: GrSimpleMesh.h:56
void set(sk_sp< const GrBuffer > vertexBuffer, int vertexCount, int baseVertex)
Definition: GrSimpleMesh.h:47
sk_sp< const GrBuffer > fIndexBuffer
Definition: GrSimpleMesh.h:31
uint16_t fMinIndexValue
Definition: GrSimpleMesh.h:36
uint16_t fMaxIndexValue
Definition: GrSimpleMesh.h:37
void setIndexedPatterned(sk_sp< const GrBuffer > indexBuffer, int indexCount, int patternRepeatCount, int maxPatternRepetitionsInIndexBuffer, sk_sp< const GrBuffer > vertexBuffer, int patternVertexCount, int baseVertex)
Definition: GrSimpleMesh.h:77
int fMaxPatternRepetitionsInIndexBuffer
Definition: GrSimpleMesh.h:34
GrPrimitiveRestart fPrimitiveRestart
Definition: GrSimpleMesh.h:38
int fPatternRepeatCount
Definition: GrSimpleMesh.h:33
sk_sp< const GrBuffer > fVertexBuffer
Definition: GrSimpleMesh.h:40