void EinkMessageHandler::producesEinkBuffersByGpu(int startFrameIndex, int totalFrames) { const nsecs_t start = systemTime(); // EinkBufferQueue ALOGD("producesEinkBuffersByGpu # startFrameIndex:%d, totalFrames:%d, wiskyWaveform:%d", startFrameIndex, totalFrames, mCurrentWaveform->mode); // Dequeue using DequeueBufferInput = IGraphicBufferProducer::DequeueBufferInput; using DequeueBufferOutput = IGraphicBufferProducer::DequeueBufferOutput; DequeueBufferInput dequeueInput; dequeueInput.width = mCurrentGrayBuffer->getWidth(); dequeueInput.height = mCurrentGrayBuffer->getHeight(); dequeueInput.format = HAL_PIXEL_FORMAT_RGBA_8888; dequeueInput.usage = EINK_GRALLOC_USAGE; dequeueInput.getTimestamps = false; vector<DequeueBufferInput> dequeueInputs(totalFrames, dequeueInput); vector<DequeueBufferOutput> dequeueOutputs; mEinkProducer->dequeueBuffers(dequeueInputs, &dequeueOutputs); // Request vector<int32_t> requestInputs; requestInputs.reserve(totalFrames); for (const DequeueBufferOutput &dequeueOutput : dequeueOutputs) { ALOGE_IF(dequeueOutput.result != NO_ERROR, "producesEinkBuffersByGpu # EinkBufferQueue dequeueBuffers slot%d:%s (%d)", dequeueOutput.slot, strerror(-dequeueOutput.result), dequeueOutput.result); requestInputs.emplace_back(dequeueOutput.slot); } using RequestBufferOutput = IGraphicBufferProducer::RequestBufferOutput; vector<RequestBufferOutput> requestOutputs; mEinkProducer->requestBuffers(requestInputs, &requestOutputs); sp<GraphicBuffer> graphicBuffers[totalFrames]; int j = 0; for (const RequestBufferOutput &requestOutput : requestOutputs) { ALOGE_IF(requestOutput.result != NO_ERROR, "producesEinkBuffersByGpu # EinkBufferQueue requestBuffers:%s (%d)", strerror(-requestOutput.result), requestOutput.result); graphicBuffers[j++] = requestOutput.buffer; } mGpuDecodeEink->composeEinkBuffersByGpu(graphicBuffers, mCurrentGrayBuffer, mPreviousGrayBuffer, startFrameIndex, totalFrames, mCurrentWaveform); // Queue using QueueBufferInput = IGraphicBufferProducer::QueueBufferInput; using QueueBufferOutput = IGraphicBufferProducer::QueueBufferOutput; vector<QueueBufferInput> queueInputs; queueInputs.reserve(totalFrames); for (const DequeueBufferOutput &dequeueOutput : dequeueOutputs) { queueInputs .emplace_back(systemTime(), false, HAL_DATASPACE_UNKNOWN, Rect(mCurrentGrayBuffer->getWidth(), mCurrentGrayBuffer->getHeight()), NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, Fence::NO_FENCE) .slot = dequeueOutput.slot; } vector<QueueBufferOutput> queueOutputs; mEinkProducer->queueBuffers(queueInputs, &queueOutputs); for (const QueueBufferOutput &queueOutput : queueOutputs) { ALOGE_IF(queueOutput.result != NO_ERROR, "producesEinkBuffersByGpu # EinkBufferQueue queueBuffers:%s (%d)", strerror(-queueOutput.result), queueOutput.result); } ALOGD("producesEinkBuffersByGpu # total time:%ld ms", long(ns2ms(systemTime() - start))); }
时间: 2024-04-04 19:35:47 浏览: 129
Video-file-playback-controls.zip_OpenCV_C/C++_
这段代码是一个函数,用于在GPU上生成E-ink屏幕所需的缓冲区,并将这些缓冲区排队到E-ink生产者中。具体来说,该函数先通过EinkBufferQueue对E-ink屏幕的缓冲区进行出队和请求操作,然后利用GPU对这些缓冲区进行组合和处理,最后再通过EinkBufferQueue将处理后的缓冲区排队到E-ink生产者中。该函数的参数包括起始帧索引、总帧数和当前的波形模式等。
阅读全文