summaryrefslogtreecommitdiff
path: root/src/qcam/viewfinder.h
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-01-16 22:50:15 +0000
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-01-20 18:35:12 +0200
commit9977fc3fcbfa0a6aaab04118fc67f0b9b9627570 (patch)
tree4363118cd022ddcb88c4c9bbad19eac264fad6cd /src/qcam/viewfinder.h
parent026b3af8c2154ad2670528dc4ca7703ca15a64cc (diff)
qcam: Support scaling of the viewfinder
The viewfinder is drawn using a QLabel. This could support scaling through QLabel::setScaledContents(), but in a very inefficient way. To maintain reasonable efficiency, turn the viewfinder into a QWidget and draw the image directly using a QPainter. No performance change was noticed running on a fast x86 machine, and performance was 60% higher when scaling up to full screen compared to QLabel. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/qcam/viewfinder.h')
-rw-r--r--src/qcam/viewfinder.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/qcam/viewfinder.h b/src/qcam/viewfinder.h
index 33bdb146..ef5fd45b 100644
--- a/src/qcam/viewfinder.h
+++ b/src/qcam/viewfinder.h
@@ -7,13 +7,13 @@
#ifndef __QCAM_VIEWFINDER_H__
#define __QCAM_VIEWFINDER_H__
-#include <QLabel>
+#include <QWidget>
#include "format_converter.h"
class QImage;
-class ViewFinder : public QLabel
+class ViewFinder : public QWidget
{
public:
ViewFinder(QWidget *parent);
@@ -23,6 +23,10 @@ public:
unsigned int height);
void display(const unsigned char *rgb, size_t size);
+protected:
+ void paintEvent(QPaintEvent *) override;
+ QSize sizeHint() const override;
+
private:
unsigned int format_;
unsigned int width_;