void WebGLContext::BufferData(GLenum target, const dom::Nullable<dom::ArrayBuffer>& maybeSrc, GLenum usage) { const FuncScope funcScope(*this, "bufferData"); if (IsContextLost()) return; if (!ValidateNonNull("src", maybeSrc)) return; const auto& src = maybeSrc.Value(); src.ComputeLengthAndData(); BufferDataImpl(target, src.LengthAllowShared(), src.DataAllowShared(), usage); }
void WebGLContext::BufferData(GLenum target, const dom::ArrayBufferView& src, GLenum usage, GLuint srcElemOffset, GLuint srcElemCountOverride) { const FuncScope funcScope(*this, "bufferData"); if (IsContextLost()) return; uint8_t* bytes; size_t byteLen; if (!ValidateArrayBufferView(src, srcElemOffset, srcElemCountOverride, LOCAL_GL_INVALID_VALUE, &bytes, &byteLen)) { return; } BufferDataImpl(target, byteLen, bytes, usage); }
void WebGLContext::BufferData(GLenum target, const dom::ArrayBufferView& src, GLenum usage, GLuint srcElemOffset, GLuint srcElemCountOverride) { const char funcName[] = "bufferData"; if (IsContextLost()) return; uint8_t* bytes; size_t byteLen; if (!ValidateArrayBufferView(funcName, src, srcElemOffset, srcElemCountOverride, &bytes, &byteLen)) { return; } BufferDataImpl(target, byteLen, bytes, usage); }
void WebGLContext::BufferData(GLenum target, WebGLsizeiptr size, GLenum usage) { const char funcName[] = "bufferData"; if (IsContextLost()) return; if (!ValidateNonNegative(funcName, "size", size)) return; //// const UniqueBuffer zeroBuffer(calloc(size, 1)); if (!zeroBuffer) return ErrorOutOfMemory("%s: Failed to allocate zeros.", funcName); BufferDataImpl(target, size_t(size), (const uint8_t*)zeroBuffer.get(), usage); }
void WebGLContext::BufferData(GLenum target, WebGLsizeiptr size, GLenum usage) { const FuncScope funcScope(*this, "bufferData"); if (IsContextLost()) return; if (!ValidateNonNegative("size", size)) return; //// const auto checkedSize = CheckedInt<size_t>(size); if (!checkedSize.isValid()) return ErrorOutOfMemory("size too large for platform."); const UniqueBuffer zeroBuffer(calloc(checkedSize.value(), 1u)); if (!zeroBuffer) return ErrorOutOfMemory("Failed to allocate zeros."); BufferDataImpl(target, uint64_t{checkedSize.value()}, (const uint8_t*)zeroBuffer.get(), usage); }