88 SK_ABORT(
"Unknown vertex attrib type");
99 SkASSERT(index >= 0 && index < fAttribArrayStates.
size());
101 AttribArrayState* array = &fAttribArrayStates[index];
102 const char* offsetAsPtr;
103 bool bufferChanged =
false;
105 if (!array->fUsingCpuBuffer) {
106 bufferChanged =
true;
107 array->fUsingCpuBuffer =
true;
109 offsetAsPtr =
static_cast<const GrCpuBuffer*
>(vertexBuffer)->
data() + offsetInBytes;
111 auto gpuBuffer =
static_cast<const GrGpuBuffer*
>(vertexBuffer);
112 if (array->fUsingCpuBuffer || array->fVertexBufferUniqueID != gpuBuffer->uniqueID()) {
113 bufferChanged =
true;
114 array->fVertexBufferUniqueID = gpuBuffer->
uniqueID();
116 offsetAsPtr =
reinterpret_cast<const char*
>(offsetInBytes);
119 array->fCPUType != cpuType ||
120 array->fGPUType != gpuType ||
121 array->fStride != stride ||
122 array->fOffset != offsetAsPtr) {
144 array->fCPUType = cpuType;
145 array->fGPUType = gpuType;
146 array->fStride = stride;
147 array->fOffset = offsetAsPtr;
150 SkASSERT(0 == divisor || 1 == divisor);
152 array->fDivisor = divisor;
160 if (!fEnableStateIsValid || enabledCount != fNumEnabledArrays) {
161 int firstIdxToEnable = fEnableStateIsValid ? fNumEnabledArrays : 0;
162 for (
int i = firstIdxToEnable;
i < enabledCount; ++
i) {
166 int endIdxToDisable = fEnableStateIsValid ? fNumEnabledArrays : fAttribArrayStates.
size();
167 for (
int i = enabledCount;
i < endIdxToDisable; ++
i) {
171 fNumEnabledArrays = enabledCount;
178 (!fEnableStateIsValid || enablePrimitiveRestart != fPrimitiveRestartEnabled)) {
185 fPrimitiveRestartEnabled = enablePrimitiveRestart;
188 fEnableStateIsValid =
true;
195 , fAttribArrays(attribCount)
204 return &fAttribArrays;
216 if (fIndexBufferUniqueID != glBuffer->
uniqueID()) {
219 fIndexBufferUniqueID = glBuffer->
uniqueID();
#define GR_GL_UNSIGNED_SHORT
#define GR_GL_ELEMENT_ARRAY_BUFFER
#define GR_GL_UNSIGNED_INT
#define GR_GL_UNSIGNED_BYTE
#define GR_GL_PRIMITIVE_RESTART_FIXED_INDEX
#define GR_GL_CALL(IFACE, X)
static AttribLayout attrib_layout(GrVertexAttribType type)
@ kUShort_norm_GrVertexAttribType
@ kFloat2_GrVertexAttribType
@ kUShort2_GrVertexAttribType
@ kUInt_GrVertexAttribType
@ kUByte4_norm_GrVertexAttribType
@ kUByte_GrVertexAttribType
@ kShort2_GrVertexAttribType
@ kUShort4_norm_GrVertexAttribType
@ kInt_GrVertexAttribType
@ kByte_GrVertexAttribType
@ kByte4_GrVertexAttribType
@ kFloat3_GrVertexAttribType
@ kFloat_GrVertexAttribType
@ kByte2_GrVertexAttribType
@ kFloat4_GrVertexAttribType
@ kShort4_GrVertexAttribType
@ kUShort2_norm_GrVertexAttribType
@ kInt3_GrVertexAttribType
@ kHalf2_GrVertexAttribType
@ kHalf4_GrVertexAttribType
@ kUByte4_GrVertexAttribType
@ kUByte2_GrVertexAttribType
@ kInt4_GrVertexAttribType
@ kUByte_norm_GrVertexAttribType
@ kInt2_GrVertexAttribType
@ kHalf_GrVertexAttribType
#define SK_ABORT(message,...)
static constexpr bool SkSLTypeIsFloatType(SkSLType type)
static constexpr uint32_t SK_InvalidUniqueID
virtual bool isCpuBuffer() const =0
const GrShaderCaps * shaderCaps() const
bool drawInstancedSupport() const
bool usePrimitiveRestart() const
void set(GrGLGpu *, int attribIndex, const GrBuffer *vertexBuffer, GrVertexAttribType cpuType, SkSLType gpuType, GrGLsizei stride, size_t offsetInBytes, int divisor=0)
void enableVertexArrays(const GrGLGpu *, int enabledCount, GrPrimitiveRestart=GrPrimitiveRestart::kNo)
GrGLuint bufferID() const
void bindVertexArray(GrGLuint id)
const GrGLInterface * glInterface() const
GrGLenum bindBuffer(GrGpuBufferType type, const GrBuffer *)
GrGLVertexArray(GrGLint id, int attribCount)
GrGLAttribArrayState * bind(GrGLGpu *)
void invalidateCachedState()
GrGLAttribArrayState * bindWithIndexBuffer(GrGLGpu *gpu, const GrBuffer *indexBuffer)
UniqueID uniqueID() const
const GrCaps * caps() const
std::shared_ptr< const fml::Mapping > data