]> git.sesse.net Git - kdenlive/blobdiff - src/abstractscopewidget.h
Update scopes using a frame image from the consumer-frame-show event
[kdenlive] / src / abstractscopewidget.h
index 67c76c9e4be27cddb7dc47aa71b3b7c4972e886c..415c8bc2c50e190673422ce5fc7fe04f3c3af0d4 100644 (file)
@@ -68,6 +68,8 @@ public:
     virtual ~AbstractScopeWidget(); // Must be virtual because of inheritance, to avoid memory leaks
     QPalette m_scopePalette;
 
+    ///// Unimplemented /////
+
     virtual QString widgetName() const = 0;
 
 protected:
@@ -95,7 +97,9 @@ protected:
     /** Offset from the widget's borders */
     const uchar offset;
 
-    /** The rect on the widget we're painting in. */
+    /** The rect on the widget we're painting in.
+        Can be used by the implementing widget, e.g. in the render methods.
+        Is updated when necessary (size changes). */
     QRect m_scopeRect;
 
     /** Images storing the calculated layers. Will be used on repaint events. */
@@ -103,10 +107,17 @@ protected:
     QImage m_imgScope;
     QImage m_imgBackground;
 
+    /** The acceleration factors can be accessed also by other renderer tasks,
+        e.g. to display the scope's acceleration factor in the HUD renderer. */
+    int m_accelFactorHUD;
+    int m_accelFactorScope;
+    int m_accelFactorBackground;
+
 
     ///// Unimplemented Methods /////
 
-    /** Where on the widget we can paint in */
+    /** Where on the widget we can paint in.
+        May also update other variables that depend on the widget's size.  */
     virtual QRect scopeRect() = 0;
 
     /** @brief HUD renderer. Must emit signalHUDRenderingFinished(). @see renderScope */
@@ -114,7 +125,7 @@ protected:
     /** @brief Scope renderer. Must emit signalScopeRenderingFinished()
         when calculation has finished, to allow multi-threading.
         accelerationFactor hints how much faster than usual the calculation should be accomplished, if possible. */
-    virtual QImage renderScope(uint accelerationFactor) = 0;
+    virtual QImage renderScope(uint accelerationFactor, QImage) = 0;
     /** @brief Background renderer. Must emit signalBackgroundRenderingFinished(). @see renderScope */
     virtual QImage renderBackground(uint accelerationFactor) = 0;
 
@@ -127,11 +138,28 @@ protected:
     /** @see isHUDDependingOnInput() */
     virtual bool isBackgroundDependingOnInput() const = 0;
 
-    ///// Methods /////
+    ///// Can be reimplemented /////
+    /** Calculates the acceleration factor to be used by the render thread.
+        This method can be refined in the subclass if required. */
+    virtual uint calculateAccelFactorHUD(uint oldMseconds, uint oldFactor);
+    virtual uint calculateAccelFactorScope(uint oldMseconds, uint oldFactor);
+    virtual uint calculateAccelFactorBackground(uint oldMseconds, uint oldFactor);
+
+    ///// Reimplemented /////
 
     void mouseReleaseEvent(QMouseEvent *);
     void paintEvent(QPaintEvent *);
+    void raise();
     void resizeEvent(QResizeEvent *);
+    void showEvent(QShowEvent *);
+
+protected slots:
+    /** Forces an update of all layers. */
+    void forceUpdate();
+    void forceUpdateHUD();
+    void forceUpdateScope();
+    void forceUpdateBackground();
+    void slotAutoRefreshToggled(bool);
 
 signals:
     /** mseconds represent the time taken for the calculation,
@@ -165,9 +193,7 @@ private:
     QFuture<QImage> m_threadScope;
     QFuture<QImage> m_threadBackground;
 
-    int m_accelFactorHUD;
-    int m_accelFactorScope;
-    int m_accelFactorBackground;
+    QImage m_scopeImage;
 
     bool initialDimensionUpdateDone;
     void prodHUDThread();
@@ -182,6 +208,7 @@ private slots:
     void slotActiveMonitorChanged(bool isClipMonitor);
     void customContextMenuRequested(const QPoint &pos);
     void slotRenderZoneUpdated();
+    void slotRenderZoneUpdated(QImage);
     void slotHUDRenderingFinished(uint mseconds, uint accelerationFactor);
     void slotScopeRenderingFinished(uint mseconds, uint accelerationFactor);
     void slotBackgroundRenderingFinished(uint mseconds, uint accelerationFactor);