Qt 4.8
Public Functions | Public Variables | List of all members
ShivaVGWindowSurfacePrivate Class Reference

Public Functions

void ensureContext (QWidget *widget)
 
 ShivaVGWindowSurfacePrivate ()
 
 ~ShivaVGWindowSurfacePrivate ()
 

Public Variables

GLXContext context
 
GLXDrawable drawable
 
QVGPaintEngineengine
 
bool isCurrent
 
bool needsResize
 
QSize size
 

Detailed Description

Definition at line 76 of file shivavgwindowsurface.cpp.

Constructors and Destructors

◆ ShivaVGWindowSurfacePrivate()

ShivaVGWindowSurfacePrivate::ShivaVGWindowSurfacePrivate ( )
inline

Definition at line 79 of file shivavgwindowsurface.cpp.

80  : isCurrent(false)
81  , needsResize(true)
82  , engine(0)
83 #if defined(QVG_USE_FBO)
84  , fbo(0)
85  , texture(0)
86 #endif
87 #if defined(Q_WS_X11)
88  , drawable(0)
89  , context(0)
90 #endif
91  {
92  }

◆ ~ShivaVGWindowSurfacePrivate()

ShivaVGWindowSurfacePrivate::~ShivaVGWindowSurfacePrivate ( )

Definition at line 162 of file shivavgwindowsurface.cpp.

163 {
164 #if defined(QVG_USE_FBO)
165  if (fbo) {
166  glDeleteTextures(1, &texture);
167  glDeleteFramebuffersEXT(1, &fbo);
168  }
169 #endif
170 }

Functions

◆ ensureContext()

void ShivaVGWindowSurfacePrivate::ensureContext ( QWidget widget)

Definition at line 172 of file shivavgwindowsurface.cpp.

Referenced by ShivaVGWindowSurface::flush(), and ShivaVGWindowSurface::paintDevice().

173 {
174 #if defined(Q_WS_X11)
175  Window win = widget->winId();
176  if (win != drawable) {
177  if (context)
178  glXDestroyContext(X11->display, context);
179  drawable = win;
180  }
181  if (context == 0) {
182  const QX11Info *xinfo = qt_x11Info(widget);
183  int spec[64];
184  int i = 0;
185  spec[i++] = GLX_DOUBLEBUFFER;
186  spec[i++] = GLX_DEPTH_SIZE;
187  spec[i++] = 1;
188  spec[i++] = GLX_STENCIL_SIZE;
189  spec[i++] = 1;
190  spec[i++] = GLX_RGBA;
191  spec[i++] = GLX_RED_SIZE;
192  spec[i++] = 1;
193  spec[i++] = GLX_GREEN_SIZE;
194  spec[i++] = 1;
195  spec[i++] = GLX_BLUE_SIZE;
196  spec[i++] = 1;
197  spec[i++] = GLX_SAMPLE_BUFFERS_ARB;
198  spec[i++] = 1;
199  spec[i++] = GLX_SAMPLES_ARB;
200  spec[i++] = 4;
201  spec[i] = XNone;
202  XVisualInfo *visual = glXChooseVisual
203  (xinfo->display(), xinfo->screen(), spec);
204  context = glXCreateContext(X11->display, visual, 0, True);
205  if (!context)
206  qWarning("glXCreateContext: could not create GL context for VG rendering");
207  }
208 #else
209  Q_UNUSED(widget);
210 #endif
211 #if defined(QVG_USE_FBO)
212  if (needsResize && fbo) {
213 #if defined(Q_WS_X11)
214  glXMakeCurrent(X11->display, drawable, context);
215 #endif
216  glDeleteTextures(1, &texture);
217  glDeleteFramebuffersEXT(1, &fbo);
218 #if defined(Q_WS_X11)
219  glXMakeCurrent(X11->display, 0, 0);
220 #endif
221  fbo = 0;
222  texture = 0;
223  }
224  if (!fbo) {
225 #if defined(Q_WS_X11)
226  glXMakeCurrent(X11->display, drawable, context);
227 #endif
228  glGenFramebuffersEXT(1, &fbo);
229  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
230 
231  glGenTextures(1, &texture);
232  glBindTexture(GL_TEXTURE_2D, texture);
233  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, size.width(), size.height(), 0,
234  GL_RGBA, GL_UNSIGNED_BYTE, NULL);
239  glFramebufferTexture2DEXT
241  texture, 0);
242 
243  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
244 #if defined(Q_WS_X11)
245  glXMakeCurrent(X11->display, 0, 0);
246 #endif
247  }
248 #endif
249  needsResize = false;
250 }
#define GL_CLAMP_TO_EDGE
Definition: glfunctions.h:62
#define GL_TEXTURE_MIN_FILTER
#define GL_TEXTURE_WRAP_S
#define GL_FRAMEBUFFER_EXT
#define X11
Definition: qt_x11_p.h:724
#define GL_TEXTURE_2D
#define GL_COLOR_ATTACHMENT0_EXT
#define GLX_SAMPLE_BUFFERS_ARB
Definition: qgl_x11.cpp:96
int width() const
Returns the width.
Definition: qsize.h:126
QX11Info * qt_x11Info(const QPaintDevice *pd)
Q_CORE_EXPORT void qWarning(const char *,...)
#define GLX_SAMPLES_ARB
Definition: qgl_x11.cpp:97
#define GL_TEXTURE_WRAP_T
The QX11Info class provides information about the X display configuration.
Definition: qx11info_x11.h:63
#define GL_UNSIGNED_BYTE
int height() const
Returns the height.
Definition: qsize.h:129
#define GL_RGBA
WId winId() const
Returns the window system identifier of the widget.
Definition: qwidget.cpp:2557
#define GL_TEXTURE_MAG_FILTER
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
static Display * display()
Returns the default display for the application.
int screen() const
Returns the number of the screen currently in use.
#define GL_NEAREST

Properties

◆ context

GLXContext ShivaVGWindowSurfacePrivate::context

◆ drawable

GLXDrawable ShivaVGWindowSurfacePrivate::drawable

◆ engine

QVGPaintEngine* ShivaVGWindowSurfacePrivate::engine

Definition at line 100 of file shivavgwindowsurface.cpp.

Referenced by ShivaVGWindowSurface::paintEngine().

◆ isCurrent

bool ShivaVGWindowSurfacePrivate::isCurrent

◆ needsResize

bool ShivaVGWindowSurfacePrivate::needsResize

Definition at line 99 of file shivavgwindowsurface.cpp.

Referenced by ShivaVGWindowSurface::setGeometry().

◆ size

QSize ShivaVGWindowSurfacePrivate::size

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