10 #include "qwt_plot_opengl_canvas.h" 
   12 #include "qwt_painter.h" 
   15 #include <qpainterpath.h> 
   16 #include <qcoreevent.h> 
   17 #include <qopenglframebufferobject.h> 
   18 #include <qopenglpaintdevice.h> 
   20 class QwtPlotOpenGLCanvas::PrivateData
 
   39     QOpenGLFramebufferObject* fbo;
 
   49     : QOpenGLWidget( plot )
 
   52     QSurfaceFormat fmt = format();
 
   66         const QSurfaceFormat& format, 
QwtPlot* plot )
 
   67     : QOpenGLWidget( plot )
 
   73 void QwtPlotOpenGLCanvas::init( 
const QSurfaceFormat& format )
 
   75     m_data = 
new PrivateData;
 
   76     m_data->numSamples = format.samples();
 
   81     setAttribute( Qt::WA_OpaquePaintEvent, 
true );
 
  103     if ( m_data->isPolished )
 
  104         QOpenGLWidget::paintEvent( 
event );
 
  114     const bool ok = QOpenGLWidget::event( 
event );
 
  116     if ( 
event->type() == QEvent::PolishRequest )
 
  122         m_data->isPolished = 
true;
 
  125     if ( 
event->type() == QEvent::PolishRequest ||
 
  126         event->type() == QEvent::StyleChange )
 
  131         setAttribute( Qt::WA_StyledBackground,
 
  132             testAttribute( Qt::WA_StyleSheet ) );
 
  150     m_data->fboDirty = 
true;
 
  153 void QwtPlotOpenGLCanvas::clearBackingStore()
 
  181     const bool hasFocusIndicator =
 
  187         QOpenGLFramebufferObject::hasOpenGLFramebufferBlit() )
 
  190         const QSize fboSize = size() * pixelRatio;
 
  192         if ( hasFocusIndicator )
 
  193             painter.begin( 
this );
 
  207             if ( m_data->fbo->size() != fboSize )
 
  214         if ( m_data->fbo == NULL )
 
  216             QOpenGLFramebufferObjectFormat fboFormat;
 
  217             fboFormat.setSamples( m_data->numSamples );
 
  218             fboFormat.setAttachment( QOpenGLFramebufferObject::CombinedDepthStencil );
 
  220             m_data->fbo = 
new QOpenGLFramebufferObject( fboSize, fboFormat );
 
  221             m_data->fboDirty = 
true;
 
  224         if ( m_data->fboDirty )
 
  228             QOpenGLPaintDevice pd( fboSize );
 
  230             QPainter fboPainter( &pd );
 
  231             fboPainter.scale( pixelRatio, pixelRatio );
 
  235             m_data->fboDirty = 
false;
 
  238         QOpenGLFramebufferObject::blitFramebuffer( NULL, m_data->fbo );
 
  242         painter.begin( 
this );
 
  246     if ( hasFocusIndicator )
 
  257 #include "moc_qwt_plot_opengl_canvas.cpp" 
static qreal devicePixelRatio(const QPaintDevice *)
FocusIndicator focusIndicator() const
QPainterPath canvasBorderPath(const QRect &rect) const
virtual void drawFocusIndicator(QPainter *)
Base class of QwtPlotOpenGLCanvas and QwtPlotGLCanvas.
bool testPaintAttribute(PaintAttribute) const
@ BackingStore
Paint double buffered reusing the content of the pixmap buffer when possible.
void setFrameShape(QFrame::Shape)
void setFrameShadow(QFrame::Shadow)
void draw(QPainter *)
Helper function for the derived plot canvas.
virtual void paintEvent(QPaintEvent *) override
virtual void initializeGL() override
No operation - reserved for some potential use in the future.
virtual ~QwtPlotOpenGLCanvas()
Destructor.
Q_INVOKABLE QPainterPath borderPath(const QRect &) const
QwtPlotOpenGLCanvas(QwtPlot *=NULL)
Constructor.
virtual void paintGL() override
Paint the plot.
virtual void resizeGL(int width, int height) override
No operation - reserved for some potential use in the future.
virtual bool event(QEvent *) override
virtual Q_INVOKABLE void invalidateBackingStore() override
Invalidate the internal backing store.