update ooo310-m15
[ooovba.git] / applied_patches / 0574-transogl-fix-remote.diff
blobf3323561c4df1ca00802efaafcb256cceedf8fe8
1 diff -rup slideshow-orig/source/engine/OGLTrans/OGLTrans_TransitionerImpl.cxx slideshow/source/engine/OGLTrans/OGLTrans_TransitionerImpl.cxx
2 --- slideshow-orig/source/engine/OGLTrans/OGLTrans_TransitionerImpl.cxx 2008-09-09 22:57:31.000000000 +0200
3 +++ slideshow/source/engine/OGLTrans/OGLTrans_TransitionerImpl.cxx 2008-09-09 22:59:28.000000000 +0200
4 @@ -145,6 +145,15 @@ namespace
8 +// not thread safe
9 +static bool errorTriggered;
10 +int oglErrorHandler( unx::Display* /*dpy*/, unx::XErrorEvent* /*evnt*/ )
12 + errorTriggered = true;
14 + return 0;
17 /** This is the Transitioner class for OpenGL 3D transitions in
18 * slideshow. At the moment, it's Linux only. This class is implicitly
19 * constructed from XTransitionFactory.
20 @@ -286,7 +295,16 @@ public:
22 bool mbTextureFromPixmap;
24 + /**
25 + whether to generate mipmaped textures
26 + */
27 bool mbGenerateMipmap;
29 + /**
30 + whether we have visual which can be used for texture_from_pixmap extension
31 + */
32 + bool mbHasTFPVisual;
34 #ifdef DEBUG
35 ptime t3;
36 ptime t4;
37 @@ -363,6 +381,7 @@ bool OGLTransitionerImpl::createWindow(
38 unx::XVisualInfo* vi( NULL );
39 #if defined( GLX_VERSION_1_3 ) && defined( GLX_EXT_texture_from_pixmap )
40 unx::XVisualInfo* visinfo;
41 + unx::XVisualInfo* firstVisual( NULL );
42 #endif
43 static int attrList3[] =
45 @@ -431,7 +450,9 @@ bool OGLTransitionerImpl::createWindow(
47 #if defined( GLX_VERSION_1_3 ) && defined( GLX_EXT_texture_from_pixmap )
48 if( vi ) {
49 - OSL_TRACE("OGLTrans: using VisualID %08X", vi->visualid);
50 + if( !firstVisual )
51 + firstVisual = vi;
52 + OSL_TRACE("trying VisualID %08X", vi->visualid);
53 fbconfigs = glXGetFBConfigs (GLWin.dpy, GLWin.screen, &nfbconfigs);
54 for ( ; i < nfbconfigs; i++)
56 @@ -465,13 +486,22 @@ bool OGLTransitionerImpl::createWindow(
57 break;
60 - if( i != nfbconfigs ) {
61 - vi = glXGetVisualFromFBConfig( GLWin.dpy, fbconfigs[i] );
62 + if( i != nfbconfigs || ( firstVisual && pAttributeTable[1] == NULL ) ) {
63 + if( i != nfbconfigs ) {
64 + vi = glXGetVisualFromFBConfig( GLWin.dpy, fbconfigs[i] );
65 + mbHasTFPVisual = true;
66 + OSL_TRACE("found visual suitable for texture_from_pixmap");
67 + } else {
68 + vi = firstVisual;
69 + mbHasTFPVisual = false;
70 + OSL_TRACE("did not find visual suitable for texture_from_pixmap, using %08X", vi->visualid);
71 + }
72 #else
73 - if( vi ) {
74 + if( vi ) {
75 #endif
76 SystemWindowData winData;
77 winData.nSize = sizeof(winData);
78 + OSL_TRACE("using VisualID %08X", vi->visualid);
79 winData.pVisual = (void*)(vi->visual);
80 pWindow=new SystemChildWindow(pPWindow, 0, &winData, FALSE);
81 pChildSysData = pWindow->GetSystemData();
82 @@ -505,17 +535,14 @@ bool OGLTransitionerImpl::createWindow(
83 pWindow->SetControlForeground();
84 pWindow->SetControlBackground();
85 pWindow->EnablePaint(FALSE);
86 - pWindow->SetPosSizePixel(pPWindow->GetPosPixel(),pPWindow->GetSizePixel());
88 - GLWin.Width = pPWindow->GetSizePixel().Width();
89 - GLWin.Height = pPWindow->GetSizePixel().Height();
90 #if defined( WNT )
91 GLWin.hWnd = sysData->hWnd;
92 #elif defined( UNX )
93 GLWin.dpy = reinterpret_cast<unx::Display*>(pChildSysData->pDisplay);
94 GLWin.win = pChildSysData->aWindow;
95 #if defined( GLX_VERSION_1_3 ) && defined( GLX_EXT_texture_from_pixmap )
96 - GLWin.fbc = fbconfigs[i];
97 + if( mbHasTFPVisual )
98 + GLWin.fbc = fbconfigs[i];
99 #endif
100 GLWin.vi = vi;
101 GLWin.GLXExtensions = unx::glXQueryExtensionsString( GLWin.dpy, GLWin.screen );
102 @@ -552,6 +579,7 @@ bool OGLTransitionerImpl::initWindowFrom
103 pWindow->SetPosSizePixel(aCanvasArea.X, aCanvasArea.Y, aCanvasArea.Width, aCanvasArea.Height);
104 GLWin.Width = aCanvasArea.Width;
105 GLWin.Height = aCanvasArea.Height;
106 + OSL_TRACE("canvas area: %d,%d - %dx%d", aCanvasArea.X, aCanvasArea.Y, aCanvasArea.Width, aCanvasArea.Height);
108 #if defined( WNT )
109 GLWin.hDC = GetDC(GLWin.hWnd);
110 @@ -560,9 +588,9 @@ bool OGLTransitionerImpl::initWindowFrom
111 GLWin.vi,
113 GL_TRUE);
114 - if( glGetError() != GL_NO_ERROR ) {
115 - OSL_TRACE("glError: %s", (char *)gluErrorString(glGetError()));
116 - return false;
117 + if( GLWin.ctx == NULL ) {
118 + OSL_TRACE("unable to create GLX context");
119 + return false;
121 #endif
123 @@ -593,11 +621,10 @@ bool OGLTransitionerImpl::initWindowFrom
124 GLWin.hRC = wglCreateContext(GLWin.hDC);
125 wglMakeCurrent(GLWin.hDC,GLWin.hRC);
126 #elif defined( UNX )
127 - glXMakeCurrent( GLWin.dpy, GLWin.win, GLWin.ctx );
128 - if( glGetError() != GL_NO_ERROR ) {
129 - OSL_TRACE("glError: %s", (char *)gluErrorString(glGetError()));
130 + if( !glXMakeCurrent( GLWin.dpy, GLWin.win, GLWin.ctx ) ) {
131 + OSL_TRACE("unable to select current GLX context");
132 return false;
136 int glxMinor, glxMajor;
137 mnGLXVersion = 0;
138 @@ -616,8 +643,26 @@ bool OGLTransitionerImpl::initWindowFrom
139 typedef GLint (*glXSwapIntervalProc)(GLint);
140 glXSwapIntervalProc glXSwapInterval = (glXSwapIntervalProc) unx::glXGetProcAddress( (const GLubyte*) "glXSwapIntervalSGI" );
141 if( glXSwapInterval ) {
142 - glXSwapInterval( 1 );
143 + int (*oldHandler)(unx::Display* /*dpy*/, unx::XErrorEvent* /*evnt*/);
145 + // replace error handler temporarily
146 + oldHandler = unx::XSetErrorHandler( oglErrorHandler );
148 + errorTriggered = false;
150 + glXSwapInterval( 1 );
152 + // sync so that we possibly get an XError
153 + unx::glXWaitGL();
154 + XSync(GLWin.dpy, false);
156 + if( errorTriggered )
157 + OSL_TRACE("error when trying to set swap interval, NVIDIA or Mesa bug?");
158 + else
159 OSL_TRACE("set swap interval to 1 (enable vsync)");
161 + // restore the error handler
162 + unx::XSetErrorHandler( oldHandler );
165 #endif
166 @@ -649,15 +694,6 @@ bool OGLTransitionerImpl::initWindowFrom
167 return true;
171 -static bool errorTriggered;
172 -int oglErrorHandler( unx::Display* /*dpy*/, unx::XErrorEvent* /*evnt*/ )
174 - errorTriggered = true;
176 - return 0;
179 void OGLTransitionerImpl::setSlides( const uno::Reference< rendering::XBitmap >& xLeavingSlide,
180 const uno::Reference< rendering::XBitmap >& xEnteringSlide )
182 @@ -693,7 +729,7 @@ void OGLTransitionerImpl::setSlides( con
183 #ifdef UNX
184 #if defined( GLX_VERSION_1_3 ) && defined( GLX_EXT_texture_from_pixmap )
186 - if( mnGLXVersion >= 1.2999 && mbTextureFromPixmap && xLeavingSet.is() && xEnteringSet.is() ) {
187 + if( mnGLXVersion >= 1.2999 && mbTextureFromPixmap && xLeavingSet.is() && xEnteringSet.is() && mbHasTFPVisual ) {
188 Sequence< Any > leaveArgs;
189 Sequence< Any > enterArgs;
190 if( (xLeavingSet->getFastPropertyValue( 1 ) >>= leaveArgs) &&
191 @@ -1128,70 +1164,72 @@ void OGLTransitionerImpl::disposing()
193 #endif
195 + if( pWindow ) {
196 #ifdef WNT
197 - wglMakeCurrent(GLWin.hDC,GLWin.hRC);
198 + wglMakeCurrent(GLWin.hDC,GLWin.hRC);
199 #endif
200 #ifdef UNX
201 - glXMakeCurrent( GLWin.dpy, GLWin.win, GLWin.ctx );
202 + glXMakeCurrent( GLWin.dpy, GLWin.win, GLWin.ctx );
203 #endif
205 #if defined( GLX_VERSION_1_3 ) && defined( GLX_EXT_texture_from_pixmap )
206 - unx::PFNGLXRELEASETEXIMAGEEXTPROC myglXReleaseTexImageEXT = (unx::PFNGLXRELEASETEXIMAGEEXTPROC) unx::glXGetProcAddress( (const GLubyte*) "glXReleaseTexImageEXT" );
207 - if( mbUseLeavingPixmap ) {
208 + unx::PFNGLXRELEASETEXIMAGEEXTPROC myglXReleaseTexImageEXT = (unx::PFNGLXRELEASETEXIMAGEEXTPROC) unx::glXGetProcAddress( (const GLubyte*) "glXReleaseTexImageEXT" );
209 + if( mbUseLeavingPixmap ) {
211 - myglXReleaseTexImageEXT( GLWin.dpy, LeavingPixmap, GLX_FRONT_LEFT_EXT );
212 - glXDestroyGLXPixmap( GLWin.dpy, LeavingPixmap );
213 - if( mbFreeLeavingPixmap ) {
214 - unx::XFreePixmap( GLWin.dpy, maLeavingPixmap );
215 - mbFreeLeavingPixmap = false;
216 + myglXReleaseTexImageEXT( GLWin.dpy, LeavingPixmap, GLX_FRONT_LEFT_EXT );
217 + glXDestroyGLXPixmap( GLWin.dpy, LeavingPixmap );
218 + if( mbFreeLeavingPixmap ) {
219 + unx::XFreePixmap( GLWin.dpy, maLeavingPixmap );
220 + mbFreeLeavingPixmap = false;
224 - if( mbUseEnteringPixmap ) {
225 - myglXReleaseTexImageEXT( GLWin.dpy, EnteringPixmap, GLX_FRONT_LEFT_EXT );
226 - glXDestroyGLXPixmap( GLWin.dpy, EnteringPixmap );
227 - if( mbFreeLeavingPixmap ) {
228 - unx::XFreePixmap( GLWin.dpy, maLeavingPixmap );
229 - mbFreeLeavingPixmap = false;
230 + if( mbUseEnteringPixmap ) {
231 + myglXReleaseTexImageEXT( GLWin.dpy, EnteringPixmap, GLX_FRONT_LEFT_EXT );
232 + glXDestroyGLXPixmap( GLWin.dpy, EnteringPixmap );
233 + if( mbFreeLeavingPixmap ) {
234 + unx::XFreePixmap( GLWin.dpy, maLeavingPixmap );
235 + mbFreeLeavingPixmap = false;
239 #endif
241 - if( !mbUseLeavingPixmap )
242 - glDeleteTextures(1,&GLleavingSlide);
243 - if( !mbUseEnteringPixmap )
244 - glDeleteTextures(1,&GLenteringSlide);
245 + if( !mbUseLeavingPixmap )
246 + glDeleteTextures(1,&GLleavingSlide);
247 + if( !mbUseEnteringPixmap )
248 + glDeleteTextures(1,&GLenteringSlide);
250 - if (pTransition)
251 - pTransition->finish();
252 + if (pTransition)
253 + pTransition->finish();
255 #ifdef UNX
256 - if( mbRestoreSync ) {
257 - // try to reestablish synchronize state
258 - char* sal_synchronize = getenv("SAL_SYNCHRONIZE");
259 - XSynchronize( GLWin.dpy, sal_synchronize && *sal_synchronize == '1' );
261 + if( mbRestoreSync ) {
262 + // try to reestablish synchronize state
263 + char* sal_synchronize = getenv("SAL_SYNCHRONIZE");
264 + XSynchronize( GLWin.dpy, sal_synchronize && *sal_synchronize == '1' );
266 #endif
268 #if defined( WNT )
269 if (GLWin.hRC)
271 - wglMakeCurrent( GLWin.hDC, 0 ); // kill Device Context
272 - wglDeleteContext( GLWin.hRC ); // Kill Render Context
273 - ReleaseDC( GLWin.hWnd, GLWin.hDC );// Release Window
274 + wglMakeCurrent( GLWin.hDC, 0 ); // kill Device Context
275 + wglDeleteContext( GLWin.hRC ); // Kill Render Context
276 + ReleaseDC( GLWin.hWnd, GLWin.hDC ); // Release Window
278 #elif defined( UNX )
279 - if(GLWin.ctx)
280 + if(GLWin.ctx)
282 - glXMakeCurrent(GLWin.dpy, None, NULL);
283 - if( glGetError() != GL_NO_ERROR ) {
284 - OSL_TRACE("glError: %s", (char *)gluErrorString(glGetError()));
286 - glXDestroyContext(GLWin.dpy, GLWin.ctx);
287 - GLWin.ctx = NULL;
288 + glXMakeCurrent(GLWin.dpy, None, NULL);
289 + if( glGetError() != GL_NO_ERROR ) {
290 + OSL_TRACE("glError: %s", (char *)gluErrorString(glGetError()));
292 + glXDestroyContext(GLWin.dpy, GLWin.ctx);
293 + GLWin.ctx = NULL;
295 #endif
296 - if (pWindow)
297 - delete pWindow;
298 + delete pWindow;
301 if (pTransition)
302 delete pTransition;