Qt 4.8
Public Functions | Static Public Functions | Protected Functions | Protected Variables | List of all members
QGLPaintDevice Class Referenceabstract

#include <qglpaintdevice_p.h>

Inheritance diagram for QGLPaintDevice:
QPaintDevice EAGLPaintDevice QBBGLPaintDevice QEglFSPaintDevice QGLFBOGLPaintDevice QGLPBufferGLPaintDevice QGLPixmapGLPaintDevice QGLWidgetGLPaintDevice QGLWindowSurfaceGLPaintDevice QX11GLPixmapData

Public Functions

virtual bool alphaRequested () const
 
virtual void beginPaint ()
 
virtual QGLContextcontext () const =0
 
int devType () const
 
virtual void endPaint ()
 
virtual void ensureActiveTarget ()
 
virtual QGLFormat format () const
 
virtual bool isFlipped () const
 
 QGLPaintDevice ()
 
virtual QSize size () const =0
 
virtual ~QGLPaintDevice ()
 
- Public Functions inherited from QPaintDevice
int colorCount () const
 
int depth () const
 
virtual HDC getDC () const
 
int height () const
 
int heightMM () const
 
int logicalDpiX () const
 
int logicalDpiY () const
 
QT_DEPRECATED int numColors () const
 
virtual QPaintEnginepaintEngine () const =0
 
bool paintingActive () const
 
int physicalDpiX () const
 
int physicalDpiY () const
 
virtual void releaseDC (HDC hdc) const
 
int width () const
 
int widthMM () const
 
virtual ~QPaintDevice ()
 

Static Public Functions

static QGLPaintDevicegetDevice (QPaintDevice *)
 
- Static Public Functions inherited from QPaintDevice
static QWSDisplayqwsDisplay ()
 

Protected Functions

int metric (QPaintDevice::PaintDeviceMetric metric) const
 
- Protected Functions inherited from QPaintDevice
 QPaintDevice ()
 

Protected Variables

GLuint m_previousFBO
 
GLuint m_thisFBO
 
- Protected Variables inherited from QPaintDevice
ushort painters
 

Additional Inherited Members

- Public Types inherited from QPaintDevice
enum  PaintDeviceMetric {
  PdmWidth = 1, PdmHeight, PdmWidthMM, PdmHeightMM,
  PdmNumColors, PdmDepth, PdmDpiX, PdmDpiY,
  PdmPhysicalDpiX, PdmPhysicalDpiY
}
 

Detailed Description

Definition at line 63 of file qglpaintdevice_p.h.

Constructors and Destructors

◆ QGLPaintDevice()

QGLPaintDevice::QGLPaintDevice ( )

Definition at line 57 of file qglpaintdevice.cpp.

58  : m_thisFBO(0)
59 {
60 }

◆ ~QGLPaintDevice()

QGLPaintDevice::~QGLPaintDevice ( )
virtual

Definition at line 62 of file qglpaintdevice.cpp.

63 {
64 }

Functions

◆ alphaRequested()

bool QGLPaintDevice::alphaRequested ( ) const
virtual

Reimplemented in QGLFBOGLPaintDevice, and QGLPixmapGLPaintDevice.

Definition at line 143 of file qglpaintdevice.cpp.

144 {
145  return context()->d_func()->reqFormat.alpha();
146 }
virtual QGLContext * context() const =0

◆ beginPaint()

void QGLPaintDevice::beginPaint ( )
virtual

Reimplemented in QGLWidgetGLPaintDevice, QGLPixmapGLPaintDevice, QX11GLPixmapData, and QEglFSPaintDevice.

Definition at line 83 of file qglpaintdevice.cpp.

Referenced by QEglFSPaintDevice::beginPaint(), QX11GLPixmapData::beginPaint(), QGLPixmapGLPaintDevice::beginPaint(), QGLWidgetGLPaintDevice::beginPaint(), and QBBGLWindowSurface::paintDevice().

84 {
85  // Make sure our context is the current one:
86  QGLContext *ctx = context();
87  if (ctx != QGLContext::currentContext())
88  ctx->makeCurrent();
89 
90  // Record the currently bound FBO so we can restore it again
91  // in endPaint() and bind this device's FBO
92  //
93  // Note: m_thisFBO could be zero if the paint device is not
94  // backed by an FBO (e.g. window back buffer). But there could
95  // be a previous FBO bound to the context which we need to
96  // explicitly unbind. Otherwise the painting will go into
97  // the previous FBO instead of to the window.
98  m_previousFBO = ctx->d_func()->current_fbo;
99 
100  if (m_previousFBO != m_thisFBO) {
101  ctx->d_ptr->current_fbo = m_thisFBO;
103  }
104 
105  // Set the default fbo for the context to m_thisFBO so that
106  // if some raw GL code between beginNativePainting() and
107  // endNativePainting() calls QGLFramebufferObject::release(),
108  // painting will revert to the window surface's fbo.
109  ctx->d_ptr->default_fbo = m_thisFBO;
110 }
QScopedPointer< QGLContextPrivate > d_ptr
Definition: qgl.h:430
#define GL_FRAMEBUFFER_EXT
#define glBindFramebuffer
virtual QGLContext * context() const =0
static const QGLContext * currentContext()
Returns the current context, i.e.
Definition: qgl.cpp:3545
The QGLContext class encapsulates an OpenGL rendering context.
Definition: qgl.h:310
GLuint current_fbo
Definition: qgl_p.h:456
#define ctx
Definition: qgl.cpp:6094
GLuint default_fbo
Definition: qgl_p.h:457
virtual void makeCurrent()
Makes this context the current OpenGL rendering context.
Definition: qgl_egl.cpp:213

◆ context()

virtual QGLContext* QGLPaintDevice::context ( ) const
pure virtual

◆ devType()

int QGLPaintDevice::devType ( ) const
inlinevirtual

Reimplemented from QPaintDevice.

Reimplemented in EAGLPaintDevice.

Definition at line 69 of file qglpaintdevice_p.h.

◆ endPaint()

void QGLPaintDevice::endPaint ( )
virtual

Reimplemented in QGLPBufferGLPaintDevice, QGLWidgetGLPaintDevice, and QGLPixmapGLPaintDevice.

Definition at line 126 of file qglpaintdevice.cpp.

Referenced by QGLPixmapGLPaintDevice::endPaint(), QGLWidgetGLPaintDevice::endPaint(), QGLPBufferGLPaintDevice::endPaint(), and QBBGLWindowSurface::paintDevice().

127 {
128  // Make sure the FBO bound at beginPaint is re-bound again here:
129  QGLContext *ctx = context();
130  if (m_previousFBO != ctx->d_func()->current_fbo) {
133  }
134 
135  ctx->d_ptr->default_fbo = 0;
136 }
QScopedPointer< QGLContextPrivate > d_ptr
Definition: qgl.h:430
#define GL_FRAMEBUFFER_EXT
#define glBindFramebuffer
virtual QGLContext * context() const =0
The QGLContext class encapsulates an OpenGL rendering context.
Definition: qgl.h:310
GLuint current_fbo
Definition: qgl_p.h:456
#define ctx
Definition: qgl.cpp:6094
GLuint default_fbo
Definition: qgl_p.h:457

◆ ensureActiveTarget()

void QGLPaintDevice::ensureActiveTarget ( )
virtual

Definition at line 112 of file qglpaintdevice.cpp.

113 {
114  QGLContext* ctx = context();
115  if (ctx != QGLContext::currentContext())
116  ctx->makeCurrent();
117 
118  if (ctx->d_ptr->current_fbo != m_thisFBO) {
119  ctx->d_ptr->current_fbo = m_thisFBO;
121  }
122 
123  ctx->d_ptr->default_fbo = m_thisFBO;
124 }
QScopedPointer< QGLContextPrivate > d_ptr
Definition: qgl.h:430
#define GL_FRAMEBUFFER_EXT
#define glBindFramebuffer
virtual QGLContext * context() const =0
static const QGLContext * currentContext()
Returns the current context, i.e.
Definition: qgl.cpp:3545
The QGLContext class encapsulates an OpenGL rendering context.
Definition: qgl.h:310
GLuint current_fbo
Definition: qgl_p.h:456
#define ctx
Definition: qgl.cpp:6094
GLuint default_fbo
Definition: qgl_p.h:457
virtual void makeCurrent()
Makes this context the current OpenGL rendering context.
Definition: qgl_egl.cpp:213

◆ format()

QGLFormat QGLPaintDevice::format ( ) const
virtual

Reimplemented in QGLFBOGLPaintDevice.

Definition at line 138 of file qglpaintdevice.cpp.

Referenced by QGLPixelBufferPrivate::common_init(), QGL2PaintEngineExPrivate::fill(), and metric().

139 {
140  return context()->format();
141 }
virtual QGLContext * context() const =0
QGLFormat format() const
Returns the frame buffer format that was obtained (this may be a subset of what was requested)...
Definition: qgl.cpp:3495

◆ getDevice()

QGLPaintDevice * QGLPaintDevice::getDevice ( QPaintDevice pd)
static

Definition at line 206 of file qglpaintdevice.cpp.

Referenced by QOpenGLPaintEngine::begin(), QGL2PaintEngineEx::begin(), and QGLOffscreen::setDevice().

207 {
208  QGLPaintDevice* glpd = 0;
209 
210  switch(pd->devType()) {
211  case QInternal::Widget:
212  // Should not be called on a non-gl widget:
213  Q_ASSERT(qobject_cast<QGLWidget*>(static_cast<QWidget*>(pd)));
214  glpd = &(static_cast<QGLWidget*>(pd)->d_func()->glDevice);
215  break;
216  case QInternal::Pbuffer:
217  glpd = &(static_cast<QGLPixelBuffer*>(pd)->d_func()->glDevice);
218  break;
220  glpd = &(static_cast<QGLFramebufferObject*>(pd)->d_func()->glDevice);
221  break;
222  case QInternal::Pixmap: {
223 #if !defined(QT_OPENGL_ES_1)
224  QPixmapData* pmd = static_cast<QPixmap*>(pd)->pixmapData();
225  if (pmd->classId() == QPixmapData::OpenGLClass)
226  glpd = static_cast<QGLPixmapData*>(pmd)->glDevice();
227 #ifdef Q_WS_X11
228  else if (pmd->classId() == QPixmapData::X11Class)
229  glpd = static_cast<QX11GLPixmapData*>(pmd);
230 #endif
231  else
232  qWarning("Pixmap type not supported for GL rendering");
233 #else
234  qWarning("Pixmap render targets not supported on OpenGL ES 1.x");
235 #endif
236  break;
237  }
238  default:
239  qWarning("QGLPaintDevice::getDevice() - Unknown device type %d", pd->devType());
240  break;
241  }
242 
243  return glpd;
244 }
The QGLFramebufferObject class encapsulates an OpenGL framebuffer object.
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
virtual int devType() const
Definition: qpaintdevice.h:167
Q_CORE_EXPORT void qWarning(const char *,...)
The QGLPixelBuffer class encapsulates an OpenGL pbuffer.
ClassId classId() const
The QGLWidget class is a widget for rendering OpenGL graphics.
Definition: qgl.h:474
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71

◆ isFlipped()

bool QGLPaintDevice::isFlipped ( ) const
virtual

Definition at line 148 of file qglpaintdevice.cpp.

Referenced by QGL2PaintEngineExPrivate::updateBrushUniforms(), and QGL2PaintEngineExPrivate::updateMatrix().

149 {
150  return false;
151 }

◆ metric()

int QGLPaintDevice::metric ( QPaintDevice::PaintDeviceMetric  metric) const
protectedvirtual

Reimplemented from QPaintDevice.

Reimplemented in QGLWindowSurfaceGLPaintDevice.

Definition at line 66 of file qglpaintdevice.cpp.

67 {
68  switch(metric) {
69  case PdmWidth:
70  return size().width();
71  case PdmHeight:
72  return size().height();
73  case PdmDepth: {
74  const QGLFormat f = format();
75  return f.redBufferSize() + f.greenBufferSize() + f.blueBufferSize() + f.alphaBufferSize();
76  }
77  default:
78  qWarning("QGLPaintDevice::metric() - metric %d not known", metric);
79  return 0;
80  }
81 }
virtual QGLFormat format() const
int greenBufferSize() const
Returns the green buffer size.
Definition: qgl.cpp:1070
virtual QSize size() const =0
int redBufferSize() const
Returns the red buffer size.
Definition: qgl.cpp:1035
int metric(QPaintDevice::PaintDeviceMetric metric) const
int width() const
Returns the width.
Definition: qsize.h:126
int alphaBufferSize() const
Returns the alpha buffer size.
Definition: qgl.cpp:1132
The QGLFormat class specifies the display format of an OpenGL rendering context.
Definition: qgl.h:175
Q_CORE_EXPORT void qWarning(const char *,...)
int height() const
Returns the height.
Definition: qsize.h:129
int blueBufferSize() const
Returns the blue buffer size.
Definition: qgl.cpp:1105

◆ size()

virtual QSize QGLPaintDevice::size ( ) const
pure virtual

Properties

◆ m_previousFBO

GLuint QGLPaintDevice::m_previousFBO
protected

Definition at line 86 of file qglpaintdevice_p.h.

Referenced by beginPaint(), and endPaint().

◆ m_thisFBO

GLuint QGLPaintDevice::m_thisFBO
protected

Definition at line 87 of file qglpaintdevice_p.h.

Referenced by beginPaint(), and ensureActiveTarget().


The documentation for this class was generated from the following files: