/src/skia/src/gpu/ganesh/GrSimpleMesh.h
Line | Count | Source (jump to first uncovered line) |
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 | | |
11 | | #include "include/core/SkRefCnt.h" |
12 | | #include "include/private/base/SkAssert.h" |
13 | | #include "include/private/base/SkDebug.h" |
14 | | #include "include/private/gpu/ganesh/GrTypesPriv.h" |
15 | | #include "src/gpu/ganesh/GrBuffer.h" |
16 | | |
17 | | #include <cstdint> |
18 | | #include <utility> |
19 | | |
20 | | /** |
21 | | * Used to communicate simple (non-instanced, direct) draws from GrOp to GrOpsRenderPass. |
22 | | * TODO: Consider migrating every Op to make the appropriate draw directly on GrOpsRenderPass. |
23 | | */ |
24 | | struct GrSimpleMesh { |
25 | | void set(sk_sp<const GrBuffer> vertexBuffer, int vertexCount, int baseVertex); |
26 | | void setIndexed(sk_sp<const GrBuffer> indexBuffer, int indexCount, int baseIndex, |
27 | | uint16_t minIndexValue, uint16_t maxIndexValue, GrPrimitiveRestart, |
28 | | sk_sp<const GrBuffer> vertexBuffer, int baseVertex); |
29 | | void setIndexedPatterned(sk_sp<const GrBuffer> indexBuffer, int indexCount, |
30 | | int patternRepeatCount, int maxPatternRepetitionsInIndexBuffer, |
31 | | sk_sp<const GrBuffer> vertexBuffer, int patternVertexCount, |
32 | | int baseVertex); |
33 | | |
34 | | sk_sp<const GrBuffer> fIndexBuffer; |
35 | | int fIndexCount; |
36 | | int fPatternRepeatCount; |
37 | | int fMaxPatternRepetitionsInIndexBuffer; |
38 | | int fBaseIndex; |
39 | | uint16_t fMinIndexValue; |
40 | | uint16_t fMaxIndexValue; |
41 | | GrPrimitiveRestart fPrimitiveRestart = GrPrimitiveRestart::kNo; |
42 | | |
43 | | sk_sp<const GrBuffer> fVertexBuffer; |
44 | | int fVertexCount; |
45 | | int fBaseVertex = 0; |
46 | | |
47 | | SkDEBUGCODE(bool fIsInitialized = false;) |
48 | | }; |
49 | | |
50 | 14.1k | inline void GrSimpleMesh::set(sk_sp<const GrBuffer> vertexBuffer, int vertexCount, int baseVertex) { |
51 | 14.1k | SkASSERT(baseVertex >= 0); |
52 | 14.1k | fIndexBuffer.reset(); |
53 | 14.1k | fVertexBuffer = std::move(vertexBuffer); |
54 | 14.1k | fVertexCount = vertexCount; |
55 | 14.1k | fBaseVertex = baseVertex; |
56 | 14.1k | SkDEBUGCODE(fIsInitialized = true;) |
57 | 14.1k | } |
58 | | |
59 | | inline void GrSimpleMesh::setIndexed(sk_sp<const GrBuffer> indexBuffer, int indexCount, |
60 | | int baseIndex, uint16_t minIndexValue, uint16_t maxIndexValue, |
61 | | GrPrimitiveRestart primitiveRestart, |
62 | 84.3k | sk_sp<const GrBuffer> vertexBuffer, int baseVertex) { |
63 | 84.3k | SkASSERT(indexBuffer); |
64 | 84.3k | SkASSERT(indexCount >= 1); |
65 | 84.3k | SkASSERT(baseIndex >= 0); |
66 | 84.3k | SkASSERT(maxIndexValue >= minIndexValue); |
67 | 84.3k | SkASSERT(baseVertex >= 0); |
68 | 84.3k | fIndexBuffer = std::move(indexBuffer); |
69 | 84.3k | fIndexCount = indexCount; |
70 | 84.3k | fPatternRepeatCount = 0; |
71 | 84.3k | fBaseIndex = baseIndex; |
72 | 84.3k | fMinIndexValue = minIndexValue; |
73 | 84.3k | fMaxIndexValue = maxIndexValue; |
74 | 84.3k | fPrimitiveRestart = primitiveRestart; |
75 | 84.3k | fVertexBuffer = std::move(vertexBuffer); |
76 | 84.3k | fBaseVertex = baseVertex; |
77 | 84.3k | SkDEBUGCODE(fIsInitialized = true;) |
78 | 84.3k | } |
79 | | |
80 | | inline void GrSimpleMesh::setIndexedPatterned( |
81 | | sk_sp<const GrBuffer> indexBuffer, int indexCount, int patternRepeatCount, |
82 | | int maxPatternRepetitionsInIndexBuffer, sk_sp<const GrBuffer> vertexBuffer, |
83 | 10.9k | int patternVertexCount, int baseVertex) { |
84 | 10.9k | SkASSERT(indexBuffer); |
85 | 10.9k | SkASSERT(indexCount >= 1); |
86 | 10.9k | SkASSERT(patternVertexCount >= 1); |
87 | 10.9k | SkASSERT(patternRepeatCount >= 1); |
88 | 10.9k | SkASSERT(maxPatternRepetitionsInIndexBuffer >= 1); |
89 | 10.9k | SkASSERT(baseVertex >= 0); |
90 | 10.9k | fIndexBuffer = std::move(indexBuffer); |
91 | 10.9k | fIndexCount = indexCount; |
92 | 10.9k | fPatternRepeatCount = patternRepeatCount; |
93 | 10.9k | fVertexCount = patternVertexCount; |
94 | 10.9k | fMaxPatternRepetitionsInIndexBuffer = maxPatternRepetitionsInIndexBuffer; |
95 | 10.9k | fPrimitiveRestart = GrPrimitiveRestart::kNo; |
96 | 10.9k | fVertexBuffer = std::move(vertexBuffer); |
97 | 10.9k | fBaseVertex = baseVertex; |
98 | 10.9k | SkDEBUGCODE(fIsInitialized = true;) |
99 | 10.9k | } GrSimpleMesh::setIndexedPatterned(sk_sp<GrBuffer const>, int, int, int, sk_sp<GrBuffer const>, int, int) Line | Count | Source | 83 | 10.9k | int patternVertexCount, int baseVertex) { | 84 | 10.9k | SkASSERT(indexBuffer); | 85 | 10.9k | SkASSERT(indexCount >= 1); | 86 | 10.9k | SkASSERT(patternVertexCount >= 1); | 87 | 10.9k | SkASSERT(patternRepeatCount >= 1); | 88 | 10.9k | SkASSERT(maxPatternRepetitionsInIndexBuffer >= 1); | 89 | 10.9k | SkASSERT(baseVertex >= 0); | 90 | 10.9k | fIndexBuffer = std::move(indexBuffer); | 91 | 10.9k | fIndexCount = indexCount; | 92 | 10.9k | fPatternRepeatCount = patternRepeatCount; | 93 | 10.9k | fVertexCount = patternVertexCount; | 94 | 10.9k | fMaxPatternRepetitionsInIndexBuffer = maxPatternRepetitionsInIndexBuffer; | 95 | 10.9k | fPrimitiveRestart = GrPrimitiveRestart::kNo; | 96 | 10.9k | fVertexBuffer = std::move(vertexBuffer); | 97 | 10.9k | fBaseVertex = baseVertex; | 98 | 10.9k | SkDEBUGCODE(fIsInitialized = true;) | 99 | 10.9k | } |
Unexecuted instantiation: GrSimpleMesh::setIndexedPatterned(sk_sp<GrBuffer const>, int, int, int, sk_sp<GrBuffer const>, int, int) |
100 | | |
101 | | #endif |