update ooo310-m15
[ooovba.git] / applied_patches / 0569-transogl-pixmap-to-texture.diff
blobad762aa7580e68f05780c11e037152fba572aa7a
1 diff -rup slideshow/source/engine/OGLTrans-orig/OGLTrans_TransitionerImpl.cxx slideshow/source/engine/OGLTrans/OGLTrans_TransitionerImpl.cxx
2 --- slideshow/source/engine/OGLTrans-orig/OGLTrans_TransitionerImpl.cxx 2008-08-27 08:27:25.000000000 +0200
3 +++ slideshow/source/engine/OGLTrans/OGLTrans_TransitionerImpl.cxx 2008-08-27 09:03:37.000000000 +0200
4 @@ -31,6 +31,7 @@
5 #define GLX_GLXEXT_PROTOTYPES 1
6 #include "OGLTrans_TransitionImpl.hxx"
8 +#include <com/sun/star/beans/XFastPropertySet.hpp>
9 #include <com/sun/star/rendering/IntegerBitmapLayout.hpp>
10 #include <com/sun/star/rendering/ColorComponentTag.hpp>
11 #include <com/sun/star/rendering/ColorSpaceType.hpp>
12 @@ -71,18 +72,78 @@
13 namespace unx
15 #include <X11/keysym.h>
16 +#include <X11/X.h>
17 #include <GL/glx.h>
18 #include <GL/glxext.h>
20 #endif
22 +#ifdef DEBUG
23 +#include <boost/date_time/posix_time/posix_time.hpp>
24 +using namespace ::boost::posix_time;
26 +static ptime t1;
27 +static ptime t2;
28 +static ptime t3;
29 +static ptime t4;
31 +#endif
33 using namespace ::com::sun::star;
34 +using ::com::sun::star::beans::XFastPropertySet;
35 +using ::com::sun::star::uno::Any;
36 +using ::com::sun::star::uno::Reference;
37 +using ::com::sun::star::uno::Sequence;
38 +using ::com::sun::star::uno::UNO_QUERY;
39 +using ::com::sun::star::uno::UNO_QUERY_THROW;
41 namespace
44 typedef cppu::WeakComponentImplHelper1<presentation::XTransition> OGLTransitionerImplBase;
46 +namespace
48 + struct OGLFormat
49 + {
50 + GLint nInternalFormat;
51 + GLenum eFormat;
52 + GLenum eType;
53 + };
55 + /* channel ordering: (0:rgba, 1:bgra, 2:argb, 3:abgr)
56 + */
57 + int calcComponentOrderIndex(const uno::Sequence<sal_Int8>& rTags)
58 + {
59 + using namespace rendering::ColorComponentTag;
61 + static const sal_Int8 aOrderTable[] =
62 + {
63 + RGB_RED, RGB_GREEN, RGB_BLUE, ALPHA,
64 + RGB_BLUE, RGB_GREEN, RGB_RED, ALPHA,
65 + ALPHA, RGB_RED, RGB_GREEN, RGB_BLUE,
66 + ALPHA, RGB_BLUE, RGB_GREEN, RGB_RED,
67 + };
69 + const sal_Int32 nNumComps(rTags.getLength());
70 + const sal_Int8* pLine=aOrderTable;
71 + for(int i=0; i<4; ++i)
72 + {
73 + int j=0;
74 + while( j<4 && j<nNumComps && pLine[j] == rTags[j] )
75 + ++j;
77 + // all of the line passed, this is a match!
78 + if( j==nNumComps )
79 + return i;
81 + pLine+=4;
82 + }
84 + return -1;
85 + }
88 /** This is the Transitioner class for OpenGL 3D transitions in
89 * slideshow. At the moment, it's Linux only. This class is implicitly
90 * constructed from XTransitionFactory.
91 @@ -96,7 +157,7 @@ public:
92 static bool initialize( const uno::Reference< presentation::XSlideShowView >& xView );
94 // XTransition
95 - virtual void SAL_CALL update( double nTime ) throw (uno::RuntimeException);
96 + virtual void SAL_CALL update( double nTime ) throw (uno::RuntimeException);
98 protected:
99 // WeakComponentImplHelperBase
100 @@ -107,6 +168,18 @@ protected:
101 return (rBHelper.bDisposed || rBHelper.bInDispose);
104 + bool createWindow( Window* pPWindow );
105 + void createTexture( unsigned int* texID,
106 +#ifdef GLX_VERSION_1_3
107 + unx::GLXPixmap pixmap,
108 +#endif
109 + bool usePixmap,
110 + bool useMipmap,
111 + uno::Sequence<sal_Int8>& data,
112 + const OGLFormat* pFormat );
113 + void prepareEnvironment ();
114 + const OGLFormat* chooseFormats();
116 private:
117 /** After the window has been created, and the slides have been set, we'll initialize the slides with OpenGL.
119 @@ -117,23 +190,29 @@ private:
120 struct GLWindow
122 #if defined( WNT )
123 - HWND hWnd;
124 - HDC hDC;
125 - HGLRC hRC;
126 + HWND hWnd;
127 + HDC hDC;
128 + HGLRC hRC;
129 #elif defined( OS2 )
130 #elif defined( QUARTZ )
131 #elif defined( UNX )
132 - unx::Display* dpy;
133 - int screen;
134 - unx::Window win;
135 - unx::GLXContext ctx;
136 + unx::Display* dpy;
137 + int screen;
138 + unx::Window win;
139 +#ifdef GLX_VERSION_1_3
140 + unx::GLXFBConfig fbc;
141 +#endif
142 + unx::XVisualInfo* vi;
143 + unx::GLXContext ctx;
144 #endif
145 - unsigned int bpp;
146 + unsigned int bpp;
147 unsigned int Width;
148 unsigned int Height;
149 const char* GLXExtensions;
150 + const GLubyte* GLExtensions;
152 - bool HasGLXExtension( const char* name ) { return gluCheckExtension( (const GLubyte*) name, (const GLubyte*) GLXExtensions ); };
153 + bool HasGLXExtension( const char* name ) { return gluCheckExtension( (const GLubyte*) name, (const GLubyte*) GLXExtensions ); }
154 + bool HasGLExtension( const char* name ) { return gluCheckExtension( (const GLubyte*) name, GLExtensions ); }
155 } GLWin;
157 /** OpenGL handle to the leaving slide's texture
158 @@ -154,6 +233,17 @@ private:
159 /** raw bytes of the leaving bitmap
161 uno::Sequence<sal_Int8> LeavingBytes;
163 +#ifdef GLX_VERSION_1_3
164 + unx::GLXPixmap LeavingPixmap;
165 + unx::GLXPixmap EnteringPixmap;
166 +#endif
167 + bool mbUseLeavingPixmap;
168 + bool mbUseEnteringPixmap;
169 + bool mbFreeLeavingPixmap;
170 + bool mbFreeEnteringPixmap;
171 + unx::Pixmap maLeavingPixmap;
172 + unx::Pixmap maEnteringPixmap;
174 /** the form the raw bytes are in for the bitmaps
176 @@ -175,6 +265,7 @@ public:
177 /** GL version
179 static float cnGLVersion;
180 + float mnGLXVersion;
182 /** Whether Mesa is the OpenGL vendor
184 @@ -184,6 +275,13 @@ public:
185 whether the display has GLX extension
187 static bool cbGLXPresent;
189 + /**
190 + whether texture from pixmap extension is available
191 + */
192 + bool mbTextureFromPixmap;
194 + bool mbGenerateMipmap;
197 // declare the static variables as some gcc versions have problems declaring them automaticaly
198 @@ -231,25 +329,8 @@ bool OGLTransitionerImpl::initialize( co
199 return cbGLXPresent;
202 -bool OGLTransitionerImpl::initWindowFromSlideShowView( const uno::Reference< presentation::XSlideShowView >& xView, double, double)
203 +bool OGLTransitionerImpl::createWindow( Window* pPWindow )
205 - osl::MutexGuard const guard( m_aMutex );
207 - if (isDisposed())
208 - return false;
210 - /// take the XSlideShowView and extract the parent window from it. see viewmediashape.cxx
211 - uno::Reference< rendering::XCanvas > xCanvas(xView->getCanvas(), uno::UNO_QUERY_THROW);
212 - uno::Sequence< uno::Any > aDeviceParams;
213 - ::canvas::tools::getDeviceInfo( xCanvas, aDeviceParams );
214 - ::rtl::OUString aImplName;
215 - aDeviceParams[ 0 ] >>= aImplName;
216 - sal_Int64 aVal = 0;
217 - aDeviceParams[1] >>= aVal;
218 - Window* pPWindow = reinterpret_cast< Window* >( aVal );
219 - GLWin.Width = pPWindow->GetSizePixel().Width();
220 - GLWin.Height = pPWindow->GetSizePixel().Height();
222 const SystemEnvData* sysData(pPWindow->GetSystemData());
223 #if defined( WNT )
224 GLWin.hWnd = sysData->hWnd;
225 @@ -260,46 +341,54 @@ bool OGLTransitionerImpl::initWindowFrom
226 return false;
228 GLWin.win = sysData->aWindow;
229 - GLWin.screen = unx::XDefaultScreen(GLWin.dpy);
231 + unx::XWindowAttributes xattr;
232 + unx::XGetWindowAttributes( GLWin.dpy, GLWin.win, &xattr );
234 + GLWin.screen = XScreenNumberOfScreen( xattr.screen );
236 unx::XVisualInfo* vi( NULL );
237 +#ifdef GLX_VERSION_1_3
238 + unx::XVisualInfo* visinfo;
239 +#endif
240 static int attrList3[] =
242 - GLX_RGBA,//only TrueColor or DirectColor
243 + GLX_RGBA,//only TrueColor or DirectColor
244 //single buffered
245 - GLX_RED_SIZE,4,//use the maximum red bits, with a minimum of 4 bits
246 - GLX_GREEN_SIZE,4,//use the maximum green bits, with a minimum of 4 bits
247 - GLX_BLUE_SIZE,4,//use the maximum blue bits, with a minimum of 4 bits
248 + GLX_RED_SIZE,4,//use the maximum red bits, with a minimum of 4 bits
249 + GLX_GREEN_SIZE,4,//use the maximum green bits, with a minimum of 4 bits
250 + GLX_BLUE_SIZE,4,//use the maximum blue bits, with a minimum of 4 bits
251 GLX_DEPTH_SIZE,0,//no depth buffer
252 None
254 static int attrList2[] =
256 - GLX_RGBA,/// only TrueColor or DirectColor
258 + GLX_RGBA,//only TrueColor or DirectColor
259 /// single buffered
260 - GLX_RED_SIZE,4,/// use the maximum red bits, with a minimum of 4 bits
261 - GLX_GREEN_SIZE,4,/// use the maximum green bits, with a minimum of 4 bits
262 - GLX_BLUE_SIZE,4,/// use the maximum blue bits, with a minimum of 4 bits
263 - GLX_DEPTH_SIZE,1,/// use the maximum depth bits, making sure there is a depth buffer
264 + GLX_RED_SIZE,4,/// use the maximum red bits, with a minimum of 4 bits
265 + GLX_GREEN_SIZE,4,/// use the maximum green bits, with a minimum of 4 bits
266 + GLX_BLUE_SIZE,4,/// use the maximum blue bits, with a minimum of 4 bits
267 + GLX_DEPTH_SIZE,1,/// use the maximum depth bits, making sure there is a depth buffer
268 None
270 static int attrList1[] =
272 - GLX_RGBA,/// only TrueColor or DirectColor
273 + GLX_RGBA,//only TrueColor or DirectColor
274 GLX_DOUBLEBUFFER,/// only double buffer
275 - GLX_RED_SIZE,4,/// use the maximum red bits, with a minimum of 4 bits
276 - GLX_GREEN_SIZE,4,/// use the maximum green bits, with a minimum of 4 bits
277 - GLX_BLUE_SIZE,4,/// use the maximum blue bits, with a minimum of 4 bits
278 + GLX_RED_SIZE,4,/// use the maximum red bits, with a minimum of 4 bits
279 + GLX_GREEN_SIZE,4,/// use the maximum green bits, with a minimum of 4 bits
280 + GLX_BLUE_SIZE,4,/// use the maximum blue bits, with a minimum of 4 bits
281 GLX_DEPTH_SIZE,0,/// no depth buffer
282 None
284 static int attrList0[] =
286 - GLX_RGBA,/// only TrueColor or DirectColor
287 + GLX_RGBA,//only TrueColor or DirectColor
288 GLX_DOUBLEBUFFER,/// only double buffer
289 - GLX_RED_SIZE,4,/// use the maximum red bits, with a minimum of 4 bits
290 - GLX_GREEN_SIZE,4,/// use the maximum green bits, with a minimum of 4 bits
291 - GLX_BLUE_SIZE,4,/// use the maximum blue bits, with a minimum of 4 bits
292 - GLX_DEPTH_SIZE,1,/// use the maximum depth bits, making sure there is a depth buffer
293 + GLX_RED_SIZE,4,/// use the maximum red bits, with a minimum of 4 bits
294 + GLX_GREEN_SIZE,4,/// use the maximum green bits, with a minimum of 4 bits
295 + GLX_BLUE_SIZE,4,/// use the maximum blue bits, with a minimum of 4 bits
296 + GLX_DEPTH_SIZE,1,/// use the maximum depth bits, making sure there is a depth buffer
297 None
299 static int* attrTable[] =
300 @@ -314,70 +403,147 @@ bool OGLTransitionerImpl::initWindowFrom
301 const SystemEnvData* pChildSysData = NULL;
302 delete pWindow;
303 pWindow=NULL;
305 +#ifdef GLX_VERSION_1_3
306 + unx::GLXFBConfig* fbconfigs = NULL;
307 + int nfbconfigs, value, i = 0;
308 +#endif
310 while( *pAttributeTable )
312 // try to find a visual for the current set of attributes
313 vi = unx::glXChooseVisual( GLWin.dpy,
314 GLWin.screen,
315 *pAttributeTable );
317 - if( vi )
319 - SystemWindowData winData;
320 - winData.nSize = sizeof(winData);
321 - winData.pVisual = (void*)(vi->visual);
322 - pWindow=new SystemChildWindow(pPWindow, 0, &winData, FALSE);
323 - pChildSysData = pWindow->GetSystemData();
324 - if( pChildSysData )
326 - break;
328 - else
330 - delete pWindow, pWindow=NULL;
334 +#ifdef GLX_VERSION_1_3
335 + if( vi ) {
336 + OSL_TRACE("OGLTrans: using VisualID %08X", vi->visualid);
337 + fbconfigs = glXGetFBConfigs (GLWin.dpy, GLWin.screen, &nfbconfigs);
338 + for ( ; i < nfbconfigs; i++)
340 + visinfo = glXGetVisualFromFBConfig (GLWin.dpy, fbconfigs[i]);
341 + if( !visinfo || visinfo->visualid != vi->visualid )
342 + continue;
344 + glXGetFBConfigAttrib (GLWin.dpy, fbconfigs[i], GLX_DRAWABLE_TYPE, &value);
345 + if (!(value & GLX_PIXMAP_BIT))
346 + continue;
348 + glXGetFBConfigAttrib (GLWin.dpy, fbconfigs[i],
349 + GLX_BIND_TO_TEXTURE_TARGETS_EXT,
350 + &value);
351 + if (!(value & GLX_TEXTURE_2D_BIT_EXT))
352 + continue;
354 + glXGetFBConfigAttrib (GLWin.dpy, fbconfigs[i],
355 + GLX_BIND_TO_TEXTURE_RGB_EXT,
356 + &value);
357 + if (value == FALSE)
358 + continue;
360 + glXGetFBConfigAttrib (GLWin.dpy, fbconfigs[i],
361 + GLX_BIND_TO_MIPMAP_TEXTURE_EXT,
362 + &value);
363 + if (value == FALSE)
364 + continue;
366 + /* TODO: handle non Y inverted cases */
367 + break;
370 + if( i != nfbconfigs ) {
371 + vi = glXGetVisualFromFBConfig( GLWin.dpy, fbconfigs[i] );
372 +#else
373 + if( vi ) {
374 +#endif
375 + SystemWindowData winData;
376 + winData.nSize = sizeof(winData);
377 + winData.pVisual = (void*)(vi->visual);
378 + pWindow=new SystemChildWindow(pPWindow, 0, &winData, FALSE);
379 + pChildSysData = pWindow->GetSystemData();
380 + if( pChildSysData ) {
381 + break;
382 + } else {
383 + delete pWindow, pWindow=NULL;
386 +#ifdef GLX_VERSION_1_3
388 +#endif
390 ++pAttributeTable;
393 #endif
395 #if defined( WNT )
396 - const SystemEnvData* pChildSysData = NULL;
397 - SystemWindowData winData;
398 - winData.nSize = sizeof(winData);
399 - pWindow=new SystemChildWindow(pPWindow, 0, &winData, FALSE);
400 - pChildSysData = pWindow->GetSystemData();
401 + const SystemEnvData* pChildSysData = NULL;
402 + SystemWindowData winData;
403 + winData.nSize = sizeof(winData);
404 + pWindow=new SystemChildWindow(pPWindow, 0, &winData, FALSE);
405 + pChildSysData = pWindow->GetSystemData();
406 #endif
408 - if( pWindow )
410 - pWindow->SetMouseTransparent( TRUE );
411 - pWindow->SetParentClipMode( PARENTCLIPMODE_NOCLIP );
412 - pWindow->EnableEraseBackground( FALSE );
413 - pWindow->SetControlForeground();
414 - pWindow->SetControlBackground();
415 - pWindow->EnablePaint(FALSE);
416 - pWindow->SetPosSizePixel(pPWindow->GetPosPixel(),pPWindow->GetSizePixel());
417 + if( pWindow )
419 + pWindow->SetMouseTransparent( TRUE );
420 + pWindow->SetParentClipMode( PARENTCLIPMODE_NOCLIP );
421 + pWindow->EnableEraseBackground( FALSE );
422 + pWindow->SetControlForeground();
423 + pWindow->SetControlBackground();
424 + pWindow->EnablePaint(FALSE);
425 + pWindow->SetPosSizePixel(pPWindow->GetPosPixel(),pPWindow->GetSizePixel());
427 + GLWin.Width = pPWindow->GetSizePixel().Width();
428 + GLWin.Height = pPWindow->GetSizePixel().Height();
429 #if defined( WNT )
430 GLWin.hWnd = sysData->hWnd;
431 #elif defined( UNX )
432 GLWin.dpy = reinterpret_cast<unx::Display*>(pChildSysData->pDisplay);
433 GLWin.win = pChildSysData->aWindow;
434 +#ifdef GLX_VERSION_1_3
435 + GLWin.fbc = fbconfigs[i];
436 +#endif
437 + GLWin.vi = vi;
438 GLWin.GLXExtensions = unx::glXQueryExtensionsString( GLWin.dpy, GLWin.screen );
439 OSL_TRACE("available GLX extensions: %s", GLWin.GLXExtensions);
440 #endif
442 + return true;
445 + return false;
448 +bool OGLTransitionerImpl::initWindowFromSlideShowView( const uno::Reference< presentation::XSlideShowView >& xView, double, double)
450 + osl::MutexGuard const guard( m_aMutex );
452 + if (isDisposed())
453 + return false;
455 + /// take the XSlideShowView and extract the parent window from it. see viewmediashape.cxx
456 + uno::Reference< rendering::XCanvas > xCanvas(xView->getCanvas(), uno::UNO_QUERY_THROW);
457 + uno::Sequence< uno::Any > aDeviceParams;
458 + ::canvas::tools::getDeviceInfo( xCanvas, aDeviceParams );
460 + ::rtl::OUString aImplName;
461 + aDeviceParams[ 0 ] >>= aImplName;
463 + sal_Int64 aVal = 0;
464 + aDeviceParams[1] >>= aVal;
465 + if( !createWindow( reinterpret_cast< Window* >( aVal ) ) )
466 + return false;
468 #if defined( WNT )
469 GLWin.hDC = GetDC(GLWin.hWnd);
470 #elif defined( UNX )
471 GLWin.ctx = glXCreateContext(GLWin.dpy,
472 - vi,
473 + GLWin.vi,
475 GL_TRUE);
476 if( glGetError() != GL_NO_ERROR ) {
477 - OSL_TRACE("glError: %s\n", (char *)gluErrorString(glGetError()));
478 + OSL_TRACE("glError: %s", (char *)gluErrorString(glGetError()));
479 return false;
481 #endif
482 @@ -411,10 +577,22 @@ bool OGLTransitionerImpl::initWindowFrom
483 #elif defined( UNX )
484 glXMakeCurrent( GLWin.dpy, GLWin.win, GLWin.ctx );
485 if( glGetError() != GL_NO_ERROR ) {
486 - OSL_TRACE("glError: %s\n", (char *)gluErrorString(glGetError()));
487 + OSL_TRACE("glError: %s", (char *)gluErrorString(glGetError()));
488 return false;
491 + int glxMinor, glxMajor;
492 + mnGLXVersion = 0;
493 + if( glXQueryVersion( GLWin.dpy, &glxMajor, &glxMinor ) )
494 + mnGLXVersion = glxMajor + 0.1*glxMinor;
495 + OSL_TRACE("available GLX version: %f", mnGLXVersion);
497 + GLWin.GLExtensions = glGetString( GL_EXTENSIONS );
498 + OSL_TRACE("available GL extensions: %s", GLWin.GLExtensions);
500 + mbTextureFromPixmap = GLWin.HasGLXExtension( "GLX_EXT_texture_from_pixmap" );
501 + mbGenerateMipmap = GLWin.HasGLExtension( "GL_SGIS_generate_mipmap" );
503 if( GLWin.HasGLXExtension("GLX_SGI_swap_control" ) ) {
504 // enable vsync
505 typedef GLint (*glXSwapIntervalProc)(GLint);
506 @@ -453,6 +631,15 @@ bool OGLTransitionerImpl::initWindowFrom
507 return true;
511 +static bool errorTriggered;
512 +int oglErrorHandler( unx::Display* /*dpy*/, unx::XErrorEvent* /*evnt*/ )
514 + errorTriggered = true;
516 + return 0;
519 void OGLTransitionerImpl::setSlides( const uno::Reference< rendering::XBitmap >& xLeavingSlide,
520 const uno::Reference< rendering::XBitmap >& xEnteringSlide )
522 @@ -461,8 +648,10 @@ void OGLTransitionerImpl::setSlides( con
523 if (isDisposed())
524 return;
526 - uno::Reference< rendering::XIntegerBitmap > LeavingSlideIntBitmap( xLeavingSlide , uno::UNO_QUERY_THROW );
527 - uno::Reference< rendering::XIntegerBitmap > EnteringSlideIntBitmap( xEnteringSlide , uno::UNO_QUERY_THROW );
528 + Reference< rendering::XIntegerBitmap > LeavingSlideIntBitmap( xLeavingSlide , UNO_QUERY_THROW );
529 + Reference< rendering::XIntegerBitmap > EnteringSlideIntBitmap( xEnteringSlide , UNO_QUERY_THROW );
530 + Reference< XFastPropertySet > xLeavingSet( xLeavingSlide , UNO_QUERY );
531 + Reference< XFastPropertySet > xEnteringSet( xEnteringSlide , UNO_QUERY );
533 geometry::IntegerRectangle2D SlideRect;
534 SlideSize = LeavingSlideIntBitmap->getSize();
535 @@ -471,65 +660,196 @@ void OGLTransitionerImpl::setSlides( con
536 SlideRect.Y1 = 0;
537 SlideRect.Y2 = SlideSize.Height;
539 - LeavingBytes = LeavingSlideIntBitmap->getData(SlideBitmapLayout,SlideRect);
540 - EnteringBytes = EnteringSlideIntBitmap->getData(SlideBitmapLayout,SlideRect);
541 +#ifdef UNX
542 + unx::glXWaitGL();
543 + XSync(GLWin.dpy, false);
544 +#endif
546 -// TODO if(GLWin.ctx)//if we have a rendering context, let's init the slides
547 - GLInitSlides();
548 +#ifdef DEBUG
549 + t1 = microsec_clock::local_time();
550 +#endif
552 - OSL_ENSURE(SlideBitmapLayout.PlaneStride == 0,"only handle no plane stride now");
554 + mbUseLeavingPixmap = false;
555 + mbUseEnteringPixmap = false;
557 -namespace
559 - struct OGLFormat
561 - GLint nInternalFormat;
562 - GLenum eFormat;
563 - GLenum eType;
564 - };
565 +#ifdef UNX
566 +#ifdef GLX_VERSION_1_3
568 - /* channel ordering: (0:rgba, 1:bgra, 2:argb, 3:abgr)
569 - */
570 - int calcComponentOrderIndex(const uno::Sequence<sal_Int8>& rTags)
572 - using namespace rendering::ColorComponentTag;
573 + if( mnGLXVersion >= 1.2999 && mbTextureFromPixmap && xLeavingSet.is() && xEnteringSet.is() ) {
574 + Sequence< Any > leaveArgs;
575 + Sequence< Any > enterArgs;
576 + if( (xLeavingSet->getFastPropertyValue( 1 ) >>= leaveArgs) &&
577 + (xEnteringSet->getFastPropertyValue( 1 ) >>= enterArgs) ) {
578 + OSL_TRACE ("pixmaps available");
580 + sal_Int32 depth;
582 + leaveArgs[0] >>= mbFreeLeavingPixmap;
583 + enterArgs[0] >>= mbFreeEnteringPixmap;
584 + leaveArgs[1] >>= maLeavingPixmap;
585 + enterArgs[1] >>= maEnteringPixmap;
586 + leaveArgs[2] >>= depth;
588 + int pixmapAttribs[] = { GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
589 + GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGB_EXT,
590 + GLX_MIPMAP_TEXTURE_EXT, True,
591 + None };
594 + // sync so that we possibly get an pending XError, before we set our handler.
595 + // this way we will not miss any error from other code
596 + unx::glXWaitGL();
597 + XSync(GLWin.dpy, false);
599 + int (*oldHandler)(unx::Display* /*dpy*/, unx::XErrorEvent* /*evnt*/);
601 + // replace error handler temporarily
602 + oldHandler = unx::XSetErrorHandler( oglErrorHandler );
604 + errorTriggered = false;
605 + LeavingPixmap = glXCreatePixmap( GLWin.dpy, GLWin.fbc, maLeavingPixmap, pixmapAttribs );
607 + // sync so that we possibly get an XError
608 + unx::glXWaitGL();
609 + XSync(GLWin.dpy, false);
611 + if( !errorTriggered )
612 + mbUseLeavingPixmap = true;
613 + else {
614 + OSL_TRACE("XError triggered");
615 + if( mbFreeLeavingPixmap ) {
616 + unx::XFreePixmap( GLWin.dpy, maLeavingPixmap );
617 + mbFreeLeavingPixmap = false;
619 + errorTriggered = false;
622 + EnteringPixmap = glXCreatePixmap( GLWin.dpy, GLWin.fbc, maEnteringPixmap, pixmapAttribs );
624 - static const sal_Int8 aOrderTable[] =
626 - RGB_RED, RGB_GREEN, RGB_BLUE, ALPHA,
627 - RGB_BLUE, RGB_GREEN, RGB_RED, ALPHA,
628 - ALPHA, RGB_RED, RGB_GREEN, RGB_BLUE,
629 - ALPHA, RGB_BLUE, RGB_GREEN, RGB_RED,
630 - };
631 + // sync so that we possibly get an XError
632 + unx::glXWaitGL();
633 + XSync(GLWin.dpy, false);
635 + OSL_TRACE("created glx pixmap %p and %p depth: %d", LeavingPixmap, EnteringPixmap, depth);
636 + if( !errorTriggered )
637 + mbUseEnteringPixmap = true;
638 + else {
639 + OSL_TRACE("XError triggered");
640 + if( mbFreeEnteringPixmap ) {
641 + unx::XFreePixmap( GLWin.dpy, maEnteringPixmap );
642 + mbFreeEnteringPixmap = false;
646 - const sal_Int32 nNumComps(rTags.getLength());
647 - const sal_Int8* pLine=aOrderTable;
648 - for(int i=0; i<4; ++i)
650 - int j=0;
651 - while( j<4 && j<nNumComps && pLine[j] == rTags[j] )
652 - ++j;
653 + // restore the error handler
654 + unx::XSetErrorHandler( oldHandler );
658 - // all of the line passed, this is a match!
659 - if( j==nNumComps )
660 - return i;
661 +#endif
662 +#endif
663 + if( !mbUseLeavingPixmap )
664 + LeavingBytes = LeavingSlideIntBitmap->getData(SlideBitmapLayout,SlideRect);
665 + if( !mbUseEnteringPixmap )
666 + EnteringBytes = EnteringSlideIntBitmap->getData(SlideBitmapLayout,SlideRect);
668 +// TODO
669 +#ifdef UNX
670 + if(GLWin.ctx)//if we have a rendering context, let's init the slides
671 +#endif
672 + GLInitSlides();
674 - pLine+=4;
676 + OSL_ENSURE(SlideBitmapLayout.PlaneStride == 0,"only handle no plane stride now");
678 - return -1;
681 +#ifdef UNX
682 + /* flush & sync */
683 + unx::glXWaitGL();
684 + XSync( GLWin.dpy, false );
686 + // synchronized X still gives us much smoother play
687 + // I suspect some issues in above code in slideshow
688 + // synchronize whole transition for now
689 + XSynchronize( GLWin.dpy, true );
690 +#endif
693 -void OGLTransitionerImpl::GLInitSlides()
694 +void OGLTransitionerImpl::createTexture( unsigned int* texID,
695 +#ifdef GLX_VERSION_1_3
696 + unx::GLXPixmap pixmap,
697 +#endif
698 + bool usePixmap,
699 + bool useMipmap,
700 + uno::Sequence<sal_Int8>& data,
701 + const OGLFormat* pFormat )
703 - osl::MutexGuard const guard( m_aMutex );
704 + glDeleteTextures( 1, texID );
705 + glGenTextures( 1, texID );
706 + glBindTexture( GL_TEXTURE_2D, *texID );
707 + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
708 + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
710 +#ifdef GLX_VERSION_1_3
711 + unx::PFNGLXBINDTEXIMAGEEXTPROC myglXBindTexImageEXT = (unx::PFNGLXBINDTEXIMAGEEXTPROC) unx::glXGetProcAddress( (const GLubyte*) "glXBindTexImageEXT" );
713 + if( usePixmap ) {
714 + if( mbGenerateMipmap )
715 + glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, True);
716 + myglXBindTexImageEXT (GLWin.dpy, pixmap, GLX_FRONT_LEFT_EXT, NULL);
717 + if( mbGenerateMipmap && useMipmap ) {
718 + OSL_TRACE("use mipmaps");
719 + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
720 + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR); //TRILINEAR FILTERING
721 + } else {
722 + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
723 + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
725 + } else {
726 +#endif
727 + if( !pFormat )
729 + // force-convert color to ARGB8888 int color space
730 + uno::Sequence<sal_Int8> tempBytes(
731 + SlideBitmapLayout.ColorSpace->convertToIntegerColorSpace(
732 + data,
733 + canvas::tools::getStdColorSpace()));
734 + gluBuild2DMipmaps(GL_TEXTURE_2D,
735 + 4,
736 + SlideSize.Width,
737 + SlideSize.Height,
738 + GL_RGBA,
739 + GL_UNSIGNED_BYTE,
740 + &tempBytes[0]);
741 + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
742 + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR); //TRILINEAR FILTERING
744 - if (isDisposed() || pTransition->mnRequiredGLVersion > cnGLVersion)
745 - return;
746 + //anistropic filtering (to make texturing not suck when looking at polygons from oblique angles)
747 + GLfloat largest_supported_anisotropy;
748 + glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &largest_supported_anisotropy);
749 + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, largest_supported_anisotropy);
750 + } else {
751 + if( pTransition && !cbBrokenTexturesATI && !useMipmap) {
752 + glTexImage2D( GL_TEXTURE_2D, 0, pFormat->nInternalFormat, SlideSize.Width, SlideSize.Height, 0, pFormat->eFormat, pFormat->eType, &data[0] );
753 + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
754 + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
755 + } else {
756 + gluBuild2DMipmaps( GL_TEXTURE_2D, pFormat->nInternalFormat, SlideSize.Width, SlideSize.Height, pFormat->eFormat, pFormat->eType, &data[0] );
757 + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
758 + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR ); //TRILINEAR FILTERING
760 + //anistropic filtering (to make texturing not suck when looking at polygons from oblique angles)
761 + GLfloat largest_supported_anisotropy;
762 + glGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &largest_supported_anisotropy );
763 + glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, largest_supported_anisotropy );
766 +#ifdef GLX_VERSION_1_3
768 +#endif
769 + OSL_ENSURE(glIsTexture(*texID), "Can't generate Leaving slide textures in OpenGL");
772 +void OGLTransitionerImpl::prepareEnvironment()
774 glMatrixMode(GL_PROJECTION);
775 glLoadIdentity();
776 double EyePos(10.0);
777 @@ -549,11 +869,14 @@ void OGLTransitionerImpl::GLInitSlides()
778 glScaled( 1.0 / ( ( ( RealR * 2.0 * ClipN ) / ( EyePos * ( ClipR - ClipL ) ) ) - ( ( ClipR + ClipL ) / ( ClipR - ClipL ) ) ),
779 1.0 / ( ( ( RealT * 2.0 * ClipN ) / ( EyePos * ( ClipT - ClipB ) ) ) - ( ( ClipT + ClipB ) / ( ClipT - ClipB ) ) ),
780 1.0 );
781 - glFrustum(ClipL,ClipR,ClipB,ClipT,ClipN,ClipF);
782 + glFrustum(ClipL,ClipR,ClipB,ClipT,ClipN,ClipF);
783 glMatrixMode(GL_MODELVIEW);
784 glLoadIdentity();
785 glTranslated(0,0,-EyePos);
788 +const OGLFormat* OGLTransitionerImpl::chooseFormats()
790 const OGLFormat* pDetectedFormat=NULL;
791 uno::Reference<rendering::XIntegerBitmapColorSpace> xIntColorSpace(
792 SlideBitmapLayout.ColorSpace);
793 @@ -667,119 +990,50 @@ void OGLTransitionerImpl::GLInitSlides()
795 #endif
798 - glDeleteTextures(1,&GLleavingSlide);
800 - glGenTextures(1, &GLleavingSlide);
801 - glBindTexture(GL_TEXTURE_2D, GLleavingSlide);
803 - if( !pDetectedFormat )
805 - // force-convert color to ARGB8888 int color space
806 - uno::Sequence<sal_Int8> tempBytes(
807 - SlideBitmapLayout.ColorSpace->convertToIntegerColorSpace(
808 - LeavingBytes,
809 - canvas::tools::getStdColorSpace()));
810 - gluBuild2DMipmaps(GL_TEXTURE_2D,
811 - 4,
812 - SlideSize.Width,
813 - SlideSize.Height,
814 - GL_RGBA,
815 - GL_UNSIGNED_BYTE,
816 - &tempBytes[0]);
817 - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
818 - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
819 - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
820 - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);//TRILINEAR FILTERING
821 - GLfloat largest_supported_anisotropy;
822 - glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &largest_supported_anisotropy);
823 - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, largest_supported_anisotropy);//anistropic filtering (to make texturing not suck when looking at polygons from oblique angles)
826 - else
828 - if( pTransition && !cbBrokenTexturesATI && !pTransition->mbUseMipMapLeaving) {
829 - glTexImage2D(GL_TEXTURE_2D, 0, pDetectedFormat->nInternalFormat, SlideSize.Width,
830 - SlideSize.Height, 0, pDetectedFormat->eFormat, GL_UNSIGNED_BYTE, &LeavingBytes[0]);
831 - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
832 - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
833 - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
834 - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
835 - } else {
836 - gluBuild2DMipmaps(GL_TEXTURE_2D,
837 - pDetectedFormat->nInternalFormat,
838 - SlideSize.Width,
839 - SlideSize.Height,
840 - pDetectedFormat->eFormat,
841 - pDetectedFormat->eType,
842 - &LeavingBytes[0]);
843 - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
844 - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
845 - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
846 - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);//TRILINEAR FILTERING
847 - //anistropic filtering (to make texturing not suck when looking at polygons from oblique angles)
848 - GLfloat largest_supported_anisotropy;
849 - glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &largest_supported_anisotropy);
850 - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, largest_supported_anisotropy);
853 - OSL_ENSURE(glIsTexture(GLleavingSlide), "Can't generate Leaving slide textures in OpenGL");
855 - glDeleteTextures(1,&GLenteringSlide);
857 - glGenTextures(1, &GLenteringSlide);
858 - glBindTexture(GL_TEXTURE_2D, GLenteringSlide);
859 - if( !pDetectedFormat )
861 - // force-convert color to ARGB8888 int color space
862 - uno::Sequence<sal_Int8> tempBytes(
863 - SlideBitmapLayout.ColorSpace->convertToIntegerColorSpace(
864 - EnteringBytes,
865 - canvas::tools::getStdColorSpace()));
866 - gluBuild2DMipmaps(GL_TEXTURE_2D,
867 - 4,
868 - SlideSize.Width,
869 - SlideSize.Height,
870 - GL_RGBA,
871 - GL_UNSIGNED_BYTE,
872 - &tempBytes[0]);
873 - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
874 - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
875 - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
876 - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);//TRILINEAR FILTERING
877 - GLfloat largest_supported_anisotropy;
878 - glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &largest_supported_anisotropy);
879 - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, largest_supported_anisotropy);//anistropic filtering (to make texturing not suck when looking at polygons from oblique angles)
882 - else
884 - if( pTransition && !cbBrokenTexturesATI && !pTransition->mbUseMipMapEntering ) {
885 - glTexImage2D(GL_TEXTURE_2D, 0, pDetectedFormat->nInternalFormat, SlideSize.Width, SlideSize.Height, 0, pDetectedFormat->eFormat, GL_UNSIGNED_BYTE, &EnteringBytes[0]);
886 - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
887 - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
888 - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
889 - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
890 - } else {
891 - gluBuild2DMipmaps(GL_TEXTURE_2D,
892 - pDetectedFormat->nInternalFormat,
893 - SlideSize.Width,
894 - SlideSize.Height,
895 - pDetectedFormat->eFormat,
896 - pDetectedFormat->eType,
897 - &EnteringBytes[0]);
898 - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
899 - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
900 - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
901 - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);//TRILINEAR FILTERING
902 - //anistropic filtering (to make texturing not suck when looking at polygons from oblique angles)
903 - GLfloat largest_supported_anisotropy;
904 - glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &largest_supported_anisotropy);
905 - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, largest_supported_anisotropy);
909 - OSL_ENSURE( glIsTexture(GLenteringSlide), "Can't generate entering slide textures in OpenGL" );
910 + return pDetectedFormat;
913 +void OGLTransitionerImpl::GLInitSlides()
915 + osl::MutexGuard const guard( m_aMutex );
917 + if (isDisposed() || pTransition->mnRequiredGLVersion > cnGLVersion)
918 + return;
920 + prepareEnvironment();
922 + const OGLFormat* pFormat = NULL;
923 + if( !mbUseLeavingPixmap || !mbUseEnteringPixmap )
924 + pFormat = chooseFormats();
926 + createTexture( &GLleavingSlide,
927 +#ifdef GLX_VERSION_1_3
928 + LeavingPixmap,
929 +#endif
930 + mbUseLeavingPixmap,
931 + pTransition->mbUseMipMapLeaving,
932 + LeavingBytes,
933 + pFormat );
935 + createTexture( &GLenteringSlide,
936 +#ifdef GLX_VERSION_1_3
937 + EnteringPixmap,
938 +#endif
939 + mbUseEnteringPixmap,
940 + pTransition->mbUseMipMapEntering,
941 + EnteringBytes,
942 + pFormat );
944 +#ifdef UNX
945 + unx::glXWaitGL();
946 + XSync(GLWin.dpy, false);
947 +#endif
949 +#ifdef DEBUG
950 + t2 = microsec_clock::local_time();
951 + OSL_TRACE("textures created in: %s", to_simple_string( t2 - t1 ).c_str());
952 +#endif
955 void SAL_CALL OGLTransitionerImpl::update( double nTime ) throw (uno::RuntimeException)
956 @@ -789,38 +1043,80 @@ void SAL_CALL OGLTransitionerImpl::updat
957 if (isDisposed() || !cbGLXPresent || pTransition->mnRequiredGLVersion > cnGLVersion)
958 return;
960 +#ifdef DEBUG
961 + t3 = microsec_clock::local_time();
962 +#endif
964 glEnable(GL_DEPTH_TEST);
965 - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
966 + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
968 - if(pTransition)
969 - pTransition->display( nTime, GLleavingSlide, GLenteringSlide,
970 + if(pTransition)
971 + pTransition->display( nTime, GLleavingSlide, GLenteringSlide,
972 SlideSize.Width, SlideSize.Height,
973 static_cast<double>(GLWin.Width),
974 static_cast<double>(GLWin.Height) );
976 #if defined( WNT )
977 - SwapBuffers(GLWin.hDC);
978 + SwapBuffers(GLWin.hDC);
979 #elif defined( UNX )
980 unx::glXSwapBuffers(GLWin.dpy, GLWin.win);
981 #endif
982 - if( pWindow )
983 + if( pWindow )
984 pWindow->Show();
986 +#ifdef UNX
987 /* flush & sync */
988 - glFlush();
989 + unx::glXWaitGL();
990 XSync( GLWin.dpy, false );
991 +#endif
993 +#ifdef DEBUG
994 + t4 = microsec_clock::local_time();
996 + OSL_TRACE("update time: %f", nTime);
997 + OSL_TRACE("update took: %s", to_simple_string( t4 - t3 ).c_str());
998 +#endif
1001 // we are about to be disposed (someone call dispose() on us)
1002 void OGLTransitionerImpl::disposing()
1004 osl::MutexGuard const guard( m_aMutex );
1005 - glDeleteTextures(1,&GLleavingSlide);
1006 - glDeleteTextures(1,&GLenteringSlide);
1008 +#ifdef GLX_VERSION_1_3
1009 + unx::PFNGLXRELEASETEXIMAGEEXTPROC myglXReleaseTexImageEXT = (unx::PFNGLXRELEASETEXIMAGEEXTPROC) unx::glXGetProcAddress( (const GLubyte*) "glXReleaseTexImageEXT" );
1010 + if( mbUseLeavingPixmap ) {
1012 + myglXReleaseTexImageEXT( GLWin.dpy, LeavingPixmap, GLX_FRONT_LEFT_EXT );
1013 + glXDestroyGLXPixmap( GLWin.dpy, LeavingPixmap );
1014 + if( mbFreeLeavingPixmap ) {
1015 + unx::XFreePixmap( GLWin.dpy, maLeavingPixmap );
1016 + mbFreeLeavingPixmap = false;
1019 + if( mbUseEnteringPixmap ) {
1020 + myglXReleaseTexImageEXT( GLWin.dpy, EnteringPixmap, GLX_FRONT_LEFT_EXT );
1021 + glXDestroyGLXPixmap( GLWin.dpy, EnteringPixmap );
1022 + if( mbFreeLeavingPixmap ) {
1023 + unx::XFreePixmap( GLWin.dpy, maLeavingPixmap );
1024 + mbFreeLeavingPixmap = false;
1027 +#endif
1029 + if( !mbUseLeavingPixmap )
1030 + glDeleteTextures(1,&GLleavingSlide);
1031 + if( !mbUseEnteringPixmap )
1032 + glDeleteTextures(1,&GLenteringSlide);
1034 if (pTransition)
1035 pTransition->finish();
1037 +#ifdef UNX
1038 + // try to reestablish synchronize state
1039 + char* sal_synchronize = getenv("SAL_SYNCHRONIZE");
1040 + XSynchronize( GLWin.dpy, sal_synchronize && *sal_synchronize == '1' );
1041 +#endif
1043 #if defined( WNT )
1044 if (GLWin.hRC)
1045 @@ -834,7 +1130,7 @@ void OGLTransitionerImpl::disposing()
1047 glXMakeCurrent(GLWin.dpy, None, NULL);
1048 if( glGetError() != GL_NO_ERROR ) {
1049 - OSL_TRACE("glError: %s\n", (char *)gluErrorString(glGetError()));
1050 + OSL_TRACE("glError: %s", (char *)gluErrorString(glGetError()));
1052 glXDestroyContext(GLWin.dpy, GLWin.ctx);
1053 GLWin.ctx = NULL;
1054 @@ -854,6 +1150,8 @@ OGLTransitionerImpl::OGLTransitionerImpl
1055 pWindow( NULL ),
1056 EnteringBytes(),
1057 LeavingBytes(),
1058 + mbUseLeavingPixmap( false ),
1059 + mbUseEnteringPixmap( false ),
1060 SlideBitmapLayout(),
1061 SlideSize(),
1062 pTransition(pOGLTransition)
1063 @@ -901,6 +1199,8 @@ public:
1065 } else if( transitionType == animations::TransitionType::FADE && transitionSubType == animations::TransitionSubType::CROSSFADE ) {
1066 return sal_True;
1067 + } else if( transitionType == animations::TransitionType::FADE && transitionSubType == animations::TransitionSubType::FADEOVERCOLOR ) {
1068 + return sal_True;
1069 } else if( transitionType == animations::TransitionType::IRISWIPE && transitionSubType == animations::TransitionSubType::DIAMOND ) {
1070 return sal_True;
1071 } else if( transitionType == animations::TransitionType::ZOOM && transitionSubType == animations::TransitionSubType::ROTATEIN ) {
1072 @@ -924,6 +1224,7 @@ public:
1074 if( OGLTransitionerImpl::cbMesa && (
1075 ( transitionType == animations::TransitionType::FADE && transitionSubType == animations::TransitionSubType::CROSSFADE ) ||
1076 + ( transitionType == animations::TransitionType::FADE && transitionSubType == animations::TransitionSubType::FADEOVERCOLOR ) ||
1077 ( transitionType == animations::TransitionType::IRISWIPE && transitionSubType == animations::TransitionSubType::DIAMOND ) ) )
1078 return uno::Reference< presentation::XTransition >();
1080 @@ -980,6 +1281,9 @@ public:
1081 } else if( transitionType == animations::TransitionType::FADE && transitionSubType == animations::TransitionSubType::CROSSFADE ) {
1082 pTransition = new OGLTransitionImpl();
1083 pTransition->makeFadeSmoothly();
1084 + } else if( transitionType == animations::TransitionType::FADE && transitionSubType == animations::TransitionSubType::FADEOVERCOLOR ) {
1085 + pTransition = new OGLTransitionImpl();
1086 + pTransition->makeFadeThroughBlack();
1087 } else if( transitionType == animations::TransitionType::IRISWIPE && transitionSubType == animations::TransitionSubType::DIAMOND ) {
1088 pTransition = new OGLTransitionImpl();
1089 pTransition->makeDiamond();
1090 diff -rup slideshow/source/engine/OGLTrans-orig/OGLTrans_TransitionImpl.cxx slideshow/source/engine/OGLTrans/OGLTrans_TransitionImpl.cxx
1091 --- slideshow/source/engine/OGLTrans-orig/OGLTrans_TransitionImpl.cxx 2008-08-26 18:06:46.000000000 +0200
1092 +++ slideshow/source/engine/OGLTrans/OGLTrans_TransitionImpl.cxx 2008-08-26 18:07:43.000000000 +0200
1093 @@ -121,6 +121,23 @@ static void blendSlide( double depth )
1094 glEnable( GL_DEPTH_TEST );
1097 +static void slideShadow( double nTime, Primitive& primitive, double sw, double sh )
1099 + double reflectionDepth = 0.3;
1101 + glEnable(GL_BLEND);
1102 + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1103 + glDisable(GL_LIGHTING);
1105 + glPushMatrix();
1106 + primitive.applyOperations( nTime, sw, sh );
1107 + blendSlide( reflectionDepth );
1108 + glPopMatrix();
1110 + glDisable(GL_BLEND);
1111 + glEnable(GL_LIGHTING);
1114 void OGLTransitionImpl::display( double nTime, ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex,
1115 double SlideWidth, double SlideHeight, double DispWidth, double DispHeight )
1117 @@ -135,42 +152,6 @@ void OGLTransitionImpl::display( double
1120 glPushMatrix();
1121 - if ( mbReflectSlides ) {
1122 - double reflectionDepth = 0.3;
1123 - double surfaceLevel = -0.04;
1125 - /* reflected slides */
1126 - glPushMatrix();
1128 - glScaled( 1, -1, 1 );
1129 - glTranslated( 0, 2 - surfaceLevel, 0 );
1131 - glCullFace(GL_FRONT);
1132 - displaySlides( nTime, glLeavingSlideTex, glEnteringSlideTex, SlideWidthScale, SlideHeightScale );
1133 - glCullFace(GL_BACK);
1135 - glEnable(GL_BLEND);
1136 - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1137 - glDisable(GL_LIGHTING);
1139 - /* leaving slide reflection blending */
1140 - glPushMatrix();
1141 - maLeavingSlidePrimitives[0].applyOperations( nTime, SlideWidthScale, SlideHeightScale );
1142 - blendSlide( reflectionDepth );
1143 - glPopMatrix();
1145 - /* entering slide reflection blending */
1146 - glPushMatrix();
1147 - maEnteringSlidePrimitives[0].applyOperations( nTime, SlideWidthScale, SlideHeightScale );
1148 - blendSlide( reflectionDepth );
1149 - glPopMatrix();
1151 - glDisable(GL_BLEND);
1152 - glEnable(GL_LIGHTING);
1154 - glPopMatrix();
1157 displaySlides( nTime, glLeavingSlideTex, glEnteringSlideTex, SlideWidthScale, SlideHeightScale );
1158 displayScene( nTime, SlideWidth, SlideHeight, DispWidth, DispHeight );
1159 glPopMatrix();
1160 @@ -188,6 +169,28 @@ void OGLTransitionImpl::displaySlide( do
1161 //TODO change to foreach
1162 glBindTexture(GL_TEXTURE_2D, glSlideTex);
1164 + // display slide reflection
1165 + // note that depth test is turned off while blending the shadow
1166 + // so the slides has to be rendered in right order, see rochade as example
1167 + if( mbReflectSlides ) {
1168 + double surfaceLevel = -0.04;
1170 + /* reflected slides */
1171 + glPushMatrix();
1173 + glScaled( 1, -1, 1 );
1174 + glTranslated( 0, 2 - surfaceLevel, 0 );
1176 + glCullFace(GL_FRONT);
1177 + for(unsigned int i(0); i < primitives.size(); ++i)
1178 + primitives[i].display(nTime, SlideWidthScale, SlideHeightScale);
1179 + glCullFace(GL_BACK);
1181 + slideShadow( nTime, primitives[0], SlideWidthScale, SlideHeightScale );
1183 + glPopMatrix();
1186 for(unsigned int i(0); i < primitives.size(); ++i)
1187 primitives[i].display(nTime, SlideWidthScale, SlideHeightScale);
1189 @@ -452,12 +455,29 @@ void OGLTransitionImpl::makeIris()
1190 mbUseMipMapLeaving = mbUseMipMapEntering = false;
1193 +void OGLTransitionImpl::displaySlidesRochade( double nTime, ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex,
1194 + double SlideWidthScale, double SlideHeightScale )
1196 + applyOverallOperations( nTime, SlideWidthScale, SlideHeightScale );
1198 + glEnable(GL_TEXTURE_2D);
1200 + if( nTime > .5) {
1201 + displaySlide( nTime, glLeavingSlideTex, maLeavingSlidePrimitives, SlideWidthScale, SlideHeightScale );
1202 + displaySlide( nTime, glEnteringSlideTex, maEnteringSlidePrimitives, SlideWidthScale, SlideHeightScale );
1203 + } else {
1204 + displaySlide( nTime, glEnteringSlideTex, maEnteringSlidePrimitives, SlideWidthScale, SlideHeightScale );
1205 + displaySlide( nTime, glLeavingSlideTex, maLeavingSlidePrimitives, SlideWidthScale, SlideHeightScale );
1209 void OGLTransitionImpl::makeRochade()
1211 clear();
1212 Primitive Slide;
1214 mbReflectSlides = true;
1215 + mmDisplaySlides = &OGLTransitionImpl::displaySlidesRochade;
1217 double w, h;
1219 @@ -1016,6 +1036,43 @@ void OGLTransitionImpl::makeFadeSmoothly
1220 mbUseMipMapLeaving = mbUseMipMapEntering = false;
1223 +void OGLTransitionImpl::displaySlidesFadeThroughBlack( double nTime, ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex, double SlideWidthScale, double SlideHeightScale )
1225 + applyOverallOperations( nTime, SlideWidthScale, SlideHeightScale );
1227 + glDisable(GL_DEPTH_TEST);
1229 + glDisable(GL_LIGHTING);
1230 + glEnable(GL_BLEND);
1231 + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1232 + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
1233 + if( nTime < 0.5 ) {
1234 + glColor4f( 1, 1, 1, 1 - nTime*2 );
1235 + displaySlide( nTime, glLeavingSlideTex, maLeavingSlidePrimitives, SlideWidthScale, SlideHeightScale );
1236 + } else {
1237 + glColor4f( 1, 1, 1, (nTime - 0.5)*2 );
1238 + displaySlide( nTime, glEnteringSlideTex, maEnteringSlidePrimitives, SlideWidthScale, SlideHeightScale );
1240 + glDisable(GL_BLEND);
1241 + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
1242 + glEnable(GL_LIGHTING);
1244 + glEnable(GL_DEPTH_TEST);
1247 +void OGLTransitionImpl::makeFadeThroughBlack()
1249 + Primitive Slide;
1251 + Slide.pushTriangle (basegfx::B2DVector (0,0), basegfx::B2DVector (1,0), basegfx::B2DVector (0,1));
1252 + Slide.pushTriangle (basegfx::B2DVector (1,0), basegfx::B2DVector (0,1), basegfx::B2DVector (1,1));
1253 + maLeavingSlidePrimitives.push_back (Slide);
1254 + maEnteringSlidePrimitives.push_back (Slide);
1256 + mmDisplaySlides = &OGLTransitionImpl::displaySlidesFadeThroughBlack;
1257 + mbUseMipMapLeaving = mbUseMipMapEntering = false;
1260 static const char* basicVertexShader = "\n\
1261 varying vec2 v_texturePosition;\n\
1263 diff -rup slideshow/source/engine/OGLTrans-orig/OGLTrans_TransitionImpl.hxx slideshow/source/engine/OGLTrans/OGLTrans_TransitionImpl.hxx
1264 --- slideshow/source/engine/OGLTrans-orig/OGLTrans_TransitionImpl.hxx 2008-08-26 18:06:46.000000000 +0200
1265 +++ slideshow/source/engine/OGLTrans/OGLTrans_TransitionImpl.hxx 2008-08-26 18:10:02.000000000 +0200
1266 @@ -104,6 +104,7 @@ public:
1268 void makeDiamond();
1269 void makeFadeSmoothly();
1270 + void makeFadeThroughBlack();
1272 /** Whether to use mipmaping for slides textures
1274 @@ -176,6 +177,8 @@ private:
1276 void prepareDiamond( double nTime, double SlideWidth, double SlideHeight,double DispWidth, double DispHeight );
1277 void displaySlidesFadeSmoothly( double nTime, ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex, double SlideWidthScale, double SlideHeightScale );
1278 + void displaySlidesFadeThroughBlack( double nTime, ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex, double SlideWidthScale, double SlideHeightScale );
1279 + void displaySlidesRochade( double nTime, ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex, double SlideWidthScale, double SlideHeightScale );
1280 void displaySlidesShaders( double nTime, ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex, double SlideWidthScale, double SlideHeightScale );
1281 void prepareStatic( ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex );
1282 void prepareDissolve( ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex );