qcam: viewfinder: Make the viewfinder hold a reference to a buffer

The viewfinder is currently expected to render frames to the screen
synchronously in the display() function, or at least to copy data so
that the buffer can be queued in a new request when the function
returns. This prevents optimisations when the capture format is
identical to the display format.

Make the viewfinder take ownership of the buffer, and notify of its
release through a signal. The release is currently still synchronous,
this will be addressed in a subsequent patch.

Rename the ViewFinder::display() function to render() to better describe
its purpose, as it's meant to start the rendering and not display the
frame synchronously.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Laurent Pinchart 2020-03-23 02:34:36 +02:00
parent b73192036d
commit 615f7438ad
5 changed files with 16 additions and 14 deletions

View file

@ -63,6 +63,8 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)
connect(&titleTimer_, SIGNAL(timeout()), this, SLOT(updateTitle()));
viewfinder_ = new ViewFinder(this);
connect(viewfinder_, &ViewFinder::renderComplete,
this, &MainWindow::queueRequest);
setCentralWidget(viewfinder_);
adjustSize();
@ -518,15 +520,8 @@ void MainWindow::processCapture()
<< "timestamp:" << metadata.timestamp
<< "fps:" << fixed << qSetRealNumberPrecision(2) << fps;
/* Display the buffer and requeue it to the camera. */
display(buffer);
queueRequest(buffer);
}
void MainWindow::display(FrameBuffer *buffer)
{
viewfinder_->display(buffer, &mappedBuffers_[buffer]);
/* Render the frame on the viewfinder. */
viewfinder_->render(buffer, &mappedBuffers_[buffer]);
}
void MainWindow::queueRequest(FrameBuffer *buffer)