update ooo310-m15
[ooovba.git] / applied_patches / 0561-transogl-mesa-fallback.diff
blobb3964009cbae4fabddcbc1eaa61de745a2767ee7
1 --- slideshow/source/engine/OGLTrans/OGLTrans_TransitionerImpl.cxx.oglfallback~ 2008-07-07 21:07:47.072846349 +0200
2 +++ slideshow/source/engine/OGLTrans/OGLTrans_TransitionerImpl.cxx 2008-07-07 21:11:50.175122546 +0200
3 @@ -93,6 +93,7 @@ public:
4 explicit OGLTransitionerImpl(OGLTransitionImpl* pOGLTransition);
5 bool initWindowFromSlideShowView( const uno::Reference< presentation::XSlideShowView >& xView, double, double);
6 void setSlides( const uno::Reference< rendering::XBitmap >& xLeavingSlide , const uno::Reference< rendering::XBitmap >& xEnteringSlide );
7 + static void initialize( const uno::Reference< presentation::XSlideShowView >& xView );
9 // XTransition
10 virtual void SAL_CALL update( double nTime ) throw (uno::RuntimeException);
11 @@ -166,14 +167,62 @@ private:
12 */
13 OGLTransitionImpl* pTransition;
15 +public:
16 /** whether we are running on ATI fglrx with bug related to textures
18 - bool mbBrokenTexturesATI;
19 + static bool cbBrokenTexturesATI;
21 + /** GL version
22 + */
23 + static float cnGLVersion;
25 - /* GL version */
26 - float mnGLVersion;
27 + /** Whether Mesa is the OpenGL vendor
28 + */
29 + static bool cbMesa;
32 +void OGLTransitionerImpl::initialize( const uno::Reference< presentation::XSlideShowView >& xView )
34 + // not thread safe
35 + static bool initialized = false;
37 + if( !initialized ) {
38 + OGLTransitionerImpl *instance;
40 + instance = new OGLTransitionerImpl( NULL );
41 + instance->initWindowFromSlideShowView( xView, 0, 0 );
43 + if( instance->GLWin.HasGLXExtension("GLX_SGI_swap_control" ) ) {
44 + // enable vsync
45 + typedef GLint (*glXSwapIntervalProc)(GLint);
46 + glXSwapIntervalProc glXSwapInterval = (glXSwapIntervalProc) unx::glXGetProcAddress( (const GLubyte*) "glXSwapIntervalSGI" );
47 + if( glXSwapInterval ) {
48 + glXSwapInterval( 1 );
49 + OSL_TRACE("set swap interval to 1 (enable vsync)");
50 + }
51 + }
53 + const GLubyte* version = glGetString( GL_VERSION );
54 + if( version && version[0] ) {
55 + cnGLVersion = version[0] - '0';
56 + if( version[1] == '.' && version[2] )
57 + cnGLVersion += (version[2] - '0')/10.0;
58 + } else
59 + cnGLVersion = 1.0;
60 + OSL_TRACE("GL version: %s parsed: %f", version, cnGLVersion );
62 + const GLubyte* vendor = glGetString( GL_VENDOR );
63 + cbMesa = ( vendor && strstr( (const char *) vendor, "Mesa" ) );
64 + OSL_TRACE("GL vendor: %s identified as Mesa: %d", vendor, cbMesa );
66 + /* TODO: check for version once the bug in fglrx driver is fixed */
67 + cbBrokenTexturesATI = (strcmp( (const char *) glGetString( GL_VENDOR ), "ATI Technologies Inc." ) == 0 );
69 + delete instance;
70 + initialized = true;
71 + }
74 bool OGLTransitionerImpl::initWindowFromSlideShowView( const uno::Reference< presentation::XSlideShowView >& xView, double, double)
76 osl::MutexGuard const guard( m_aMutex );
77 @@ -349,27 +398,6 @@ bool OGLTransitionerImpl::initWindowFrom
78 wglMakeCurrent(GLWin.hDC,GLWin.hRC);
79 #elif defined( UNX )
80 glXMakeCurrent( GLWin.dpy, GLWin.win, GLWin.ctx );
81 - if(GLWin.HasGLXExtension("GLX_SGI_swap_control")) {
82 - // enable vsync
83 - typedef GLint (*glXSwapIntervalProc)(GLint);
84 - glXSwapIntervalProc glXSwapInterval = (glXSwapIntervalProc) unx::glXGetProcAddress( (const GLubyte*) "glXSwapIntervalSGI" );
85 - if( glXSwapInterval ) {
86 - glXSwapInterval( 1 );
87 - OSL_TRACE("set swap interval to 1 (enable vsync)");
88 - }
89 - }
91 - const GLubyte* version = glGetString( GL_VERSION );
92 - if( version && version[0] ) {
93 - mnGLVersion = version[0] - '0';
94 - if( version[1] == '.' && version[2] )
95 - mnGLVersion += (version[2] - '0')/10.0;
96 - } else
97 - mnGLVersion = 1.0;
98 - OSL_TRACE("GL version: %s parsed: %f", version, mnGLVersion );
100 - /* TODO: check for version once the bug in fglrx driver is fixed */
101 - mbBrokenTexturesATI = (strcmp( (const char *) glGetString( GL_VENDOR ), "ATI Technologies Inc." ) == 0 );
102 #endif
103 glEnable(GL_CULL_FACE);
104 glCullFace(GL_BACK);
105 @@ -392,7 +420,7 @@ bool OGLTransitionerImpl::initWindowFrom
106 if( LeavingBytes.hasElements() && EnteringBytes.hasElements())
107 GLInitSlides();//we already have uninitialized slides, let's initialize
109 - if( pTransition && pTransition->mnRequiredGLVersion <= mnGLVersion )
110 + if( pTransition && pTransition->mnRequiredGLVersion <= cnGLVersion )
111 pTransition->prepare( GLleavingSlide, GLenteringSlide );
113 return true;
114 @@ -472,7 +500,7 @@ void OGLTransitionerImpl::GLInitSlides()
116 osl::MutexGuard const guard( m_aMutex );
118 - if (isDisposed() || pTransition->mnRequiredGLVersion > mnGLVersion)
119 + if (isDisposed() || pTransition->mnRequiredGLVersion > cnGLVersion)
120 return;
122 glMatrixMode(GL_PROJECTION);
123 @@ -643,7 +671,7 @@ void OGLTransitionerImpl::GLInitSlides()
125 else
127 - if( pTransition && !mbBrokenTexturesATI && !pTransition->mbUseMipMapLeaving) {
128 + if( pTransition && !cbBrokenTexturesATI && !pTransition->mbUseMipMapLeaving) {
129 glTexImage2D(GL_TEXTURE_2D, 0, pDetectedFormat->nInternalFormat, SlideSize.Width,
130 SlideSize.Height, &LeavingBytes[0]);
131 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
132 @@ -699,7 +727,7 @@ void OGLTransitionerImpl::GLInitSlides()
134 else
136 - if( pTransition && !mbBrokenTexturesATI && !pTransition->mbUseMipMapEntering ) {
137 + if( pTransition && !cbBrokenTexturesATI && !pTransition->mbUseMipMapEntering ) {
138 glTexImage2D(GL_TEXTURE_2D, 0, pDetectedFormat->nInternalFormat, SlideSize.Width, SlideSize.Height, 0, Format, GL_UNSIGNED_BYTE, &EnteringBytes[0]);
139 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
140 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
141 @@ -731,7 +759,7 @@ void SAL_CALL OGLTransitionerImpl::updat
143 osl::MutexGuard const guard( m_aMutex );
145 - if (isDisposed() || pTransition->mnRequiredGLVersion > mnGLVersion)
146 + if (isDisposed() || pTransition->mnRequiredGLVersion > cnGLVersion)
147 return;
149 glEnable(GL_DEPTH_TEST);
150 @@ -856,6 +884,14 @@ public:
151 if( !hasTransition( transitionType, transitionSubType ) )
152 return uno::Reference< presentation::XTransition >();
154 + OGLTransitionerImpl::initialize( view );
156 + if( OGLTransitionerImpl::cbMesa && (
157 + ( transitionType == animations::TransitionType::FADE && transitionSubType == animations::TransitionSubType::CROSSFADE ) ||
158 + ( transitionType == animations::TransitionType::IRISWIPE && transitionSubType == animations::TransitionSubType::DIAMOND ) ) )
159 + return uno::Reference< presentation::XTransition >();
162 OGLTransitionImpl* pTransition;
164 if( transitionType == animations::TransitionType::MISCSHAPEWIPE ) {
165 --- slideshow/source/engine/transitions/slidetransitionfactory.cxx.oglfallback~ 2008-06-24 14:14:57.000000000 +0200
166 +++ slideshow/source/engine/transitions/slidetransitionfactory.cxx 2008-07-07 21:13:52.386845822 +0200
167 @@ -127,7 +127,8 @@ public:
168 rViewContainer,
169 rScreenUpdater,
170 rEventMultiplexer ),
171 - maTransitions()
172 + maTransitions(),
173 + mbSuccess( false )
175 // create one transition per view
176 UnoViewVector::const_iterator aCurrView (rViewContainer.begin());
177 @@ -139,19 +140,24 @@ public:
178 const ::basegfx::B2DPoint aOffsetPixel(
179 aViewTransform * ::basegfx::B2DPoint() );
181 - maTransitions.push_back(
182 - xFactory->createTransition(
183 + uno::Reference<presentation::XTransition> rTransition = xFactory->createTransition(
184 nTransitionType,
185 nTransitionSubType,
186 (*aCurrView)->getUnoView(),
187 getLeavingBitmap(ViewEntry(*aCurrView))->getXBitmap(),
188 getEnteringBitmap(ViewEntry(*aCurrView))->getXBitmap(),
189 - basegfx::unotools::point2DFromB2DPoint(aOffsetPixel) ) );
190 + basegfx::unotools::point2DFromB2DPoint(aOffsetPixel) );
192 + if( rTransition.is() )
193 + maTransitions.push_back( rTransition );
194 + else
195 + return;
197 ENSURE_OR_THROW(maTransitions.back().is(),
198 "Failed to create plugin transition");
199 ++aCurrView;
201 + mbSuccess = true;
204 virtual bool operator()( double t )
205 @@ -163,9 +169,17 @@ public:
206 return true;
209 + bool Success()
211 + return mbSuccess;
214 private:
215 // One transition object per view
216 std::vector< uno::Reference<presentation::XTransition> > maTransitions;
218 + // bool
219 + bool mbSuccess;
223 @@ -688,7 +702,7 @@ NumberAnimationSharedPtr createPluginTra
224 const SoundPlayerSharedPtr& pSoundPlayer,
225 EventMultiplexer& rEventMultiplexer)
227 - return NumberAnimationSharedPtr(
228 + PluginSlideChange* pTransition =
229 new PluginSlideChange(
230 nTransitionType,
231 nTransitionSubType,
232 @@ -698,7 +712,14 @@ NumberAnimationSharedPtr createPluginTra
233 rScreenUpdater,
234 xFactory,
235 pSoundPlayer,
236 - rEventMultiplexer ));
237 + rEventMultiplexer );
239 + if( pTransition->Success() )
240 + return NumberAnimationSharedPtr( pTransition );
241 + else {
242 + delete pTransition;
243 + return NumberAnimationSharedPtr();
247 } // anon namespace
248 @@ -736,7 +757,7 @@ NumberAnimationSharedPtr TransitionFacto
249 xOptionalFactory->hasTransition(nTransitionType, nTransitionSubType) )
251 // #i82460# - optional plugin factory claims this transition. delegate.
252 - return NumberAnimationSharedPtr(
253 + NumberAnimationSharedPtr pTransition(
254 createPluginTransition(
255 nTransitionType,
256 nTransitionSubType,
257 @@ -747,6 +768,9 @@ NumberAnimationSharedPtr TransitionFacto
258 xOptionalFactory,
259 pSoundPlayer,
260 rEventMultiplexer ));
262 + if( pTransition.get() )
263 + return pTransition;
266 const TransitionInfo* pTransitionInfo(