This commit is contained in:
laodaming 2023-08-31 12:19:02 +08:00
parent 7030846e37
commit 474cc4ddb7

View File

@ -485,69 +485,72 @@ func (w *wsConnectItem) operationRenderTask() {
case data := <-w.extendRenderProperty.renderImageTaskCtlChan:
switch data.option {
case 0: //渲染结果回调,删除任务
//存在任务,则发送渲染结果给前端
if taskData, ok := w.extendRenderProperty.renderImageTask[data.taskId]; ok {
CombineTakesTime := "0ms"
UnityRenderTakesTime := "0ms"
uploadCombineImageTakesTime := "0ms"
uploadUnityRenderImageTakesTime := "0ms"
//合图时间
if taskData.combineTakesTime > 0 {
CombineTakesTime = fmt.Sprintf("%dms", taskData.combineTakesTime)
}
//上传刀版图时间
if taskData.uploadCombineImageTakesTime > 0 {
uploadCombineImageTakesTime = fmt.Sprintf("%dms", taskData.uploadCombineImageTakesTime)
}
//unity渲染时间
if taskData.unityRenderBeginTime > 0 && taskData.unityRenderEndTime > 0 {
UnityRenderTakesTime = fmt.Sprintf("%dms", taskData.unityRenderEndTime-taskData.unityRenderBeginTime)
}
//上传unity渲染图耗时
if taskData.uploadUnityRenderImageTakesTime > 0 {
uploadUnityRenderImageTakesTime = fmt.Sprintf("%dms", taskData.uploadUnityRenderImageTakesTime)
}
//发送到出口
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, websocket_data.RenderImageRspMsg{
RenderId: taskData.renderId,
Image: data.renderNotifyImageUrl,
RenderProcessTime: websocket_data.RenderProcessTime{
CombineTakesTime: CombineTakesTime,
UnityRenderTakesTime: UnityRenderTakesTime,
UploadCombineImageTakesTime: uploadCombineImageTakesTime,
UploadUnityRenderImageTakesTime: uploadUnityRenderImageTakesTime,
},
}))
taskData, ok := w.extendRenderProperty.renderImageTask[data.taskId]
if !ok {
continue
}
//存在任务,则发送渲染结果给前端
CombineTakesTime := "0ms"
UnityRenderTakesTime := "0ms"
uploadCombineImageTakesTime := "0ms"
uploadUnityRenderImageTakesTime := "0ms"
//合图时间
if taskData.combineTakesTime > 0 {
CombineTakesTime = fmt.Sprintf("%dms", taskData.combineTakesTime)
}
//上传刀版图时间
if taskData.uploadCombineImageTakesTime > 0 {
uploadCombineImageTakesTime = fmt.Sprintf("%dms", taskData.uploadCombineImageTakesTime)
}
//unity渲染时间
if taskData.unityRenderBeginTime > 0 && taskData.unityRenderEndTime > 0 {
UnityRenderTakesTime = fmt.Sprintf("%dms", taskData.unityRenderEndTime-taskData.unityRenderBeginTime)
}
//上传unity渲染图耗时
if taskData.uploadUnityRenderImageTakesTime > 0 {
uploadUnityRenderImageTakesTime = fmt.Sprintf("%dms", taskData.uploadUnityRenderImageTakesTime)
}
//发送到出口
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, websocket_data.RenderImageRspMsg{
RenderId: taskData.renderId,
Image: data.renderNotifyImageUrl,
RenderProcessTime: websocket_data.RenderProcessTime{
CombineTakesTime: CombineTakesTime,
UnityRenderTakesTime: UnityRenderTakesTime,
UploadCombineImageTakesTime: uploadCombineImageTakesTime,
UploadUnityRenderImageTakesTime: uploadUnityRenderImageTakesTime,
},
}))
//删除任务
delete(w.extendRenderProperty.renderImageTask, data.taskId)
case 1: //新增任务
w.extendRenderProperty.renderImageTask[data.taskId] = &renderTask{
renderId: data.renderId,
}
case 2: //修改任务属性
if taskData, ok := w.extendRenderProperty.renderImageTask[data.taskId]; ok {
//合图耗时
if data.taskProperty.combineTakesTime != 0 {
taskData.combineTakesTime = data.taskProperty.combineTakesTime
}
//上传合图耗时
if data.taskProperty.uploadCombineImageTakesTime != 0 {
taskData.uploadCombineImageTakesTime = data.taskProperty.uploadCombineImageTakesTime
}
//上传渲染结果图耗时
if data.taskProperty.uploadUnityRenderImageTakesTime != 0 {
taskData.uploadUnityRenderImageTakesTime = data.taskProperty.uploadUnityRenderImageTakesTime
}
//发送unity时间
if data.taskProperty.unityRenderBeginTime != 0 {
taskData.unityRenderBeginTime = data.taskProperty.unityRenderBeginTime
}
//收到unity返回的时间
if data.taskProperty.unityRenderEndTime != 0 {
taskData.unityRenderEndTime = data.taskProperty.unityRenderEndTime
}
taskData, ok := w.extendRenderProperty.renderImageTask[data.taskId]
if !ok {
continue
}
//合图耗时
if data.taskProperty.combineTakesTime != 0 {
taskData.combineTakesTime = data.taskProperty.combineTakesTime
}
//上传合图耗时
if data.taskProperty.uploadCombineImageTakesTime != 0 {
taskData.uploadCombineImageTakesTime = data.taskProperty.uploadCombineImageTakesTime
}
//上传渲染结果图耗时
if data.taskProperty.uploadUnityRenderImageTakesTime != 0 {
taskData.uploadUnityRenderImageTakesTime = data.taskProperty.uploadUnityRenderImageTakesTime
}
//发送unity时间
if data.taskProperty.unityRenderBeginTime != 0 {
taskData.unityRenderBeginTime = data.taskProperty.unityRenderBeginTime
}
//收到unity返回的时间
if data.taskProperty.unityRenderEndTime != 0 {
taskData.unityRenderEndTime = data.taskProperty.unityRenderEndTime
}
}
}