33#include <com/sun/star/beans/XFastPropertySet.hpp>
34#include <com/sun/star/rendering/IntegerBitmapLayout.hpp>
35#include <com/sun/star/rendering/ColorComponentTag.hpp>
36#include <com/sun/star/rendering/ColorSpaceType.hpp>
37#include <com/sun/star/rendering/RenderingIntent.hpp>
38#include <com/sun/star/util/Endianness.hpp>
39#include <com/sun/star/animations/TransitionType.hpp>
42#include <com/sun/star/animations/TransitionSubType.hpp>
43#include <com/sun/star/presentation/XTransitionFactory.hpp>
44#include <com/sun/star/presentation/XTransition.hpp>
45#include <com/sun/star/presentation/XSlideShowView.hpp>
46#include <com/sun/star/uno/XComponentContext.hpp>
47#include <com/sun/star/rendering/XIntegerBitmap.hpp>
48#include <com/sun/star/geometry/IntegerSize2D.hpp>
49#include <com/sun/star/lang/XServiceInfo.hpp>
70#if OSL_DEBUG_LEVEL > 0
75using ::com::sun::star::beans::XFastPropertySet;
76using ::com::sun::star::uno::Any;
77using ::com::sun::star::uno::Reference;
78using ::com::sun::star::uno::Sequence;
79using ::com::sun::star::uno::UNO_QUERY;
80using ::com::sun::star::uno::UNO_QUERY_THROW;
85typedef cppu::WeakComponentImplHelper<presentation::XTransition> OGLTransitionerImplBase;
87#if OSL_DEBUG_LEVEL > 0
91 explicit TimerContext(OUString aWhat)
92 : m_aWhat(
std::move(aWhat))
93 , m_StartTime(
std::chrono::steady_clock::
now())
98 auto const aDuration(std::chrono::steady_clock::now() - m_StartTime);
99 SAL_INFO(
"slideshow.opengl", m_aWhat <<
" took: " << std::chrono::duration_cast<std::chrono::microseconds>(aDuration).
count());
102 OUString
const m_aWhat;
103 std::chrono::steady_clock::time_point
const m_StartTime;
109 GLint nInternalFormat;
116int calcComponentOrderIndex(
const uno::Sequence<sal_Int8>& rTags)
118 using namespace rendering::ColorComponentTag;
120 static const sal_Int8 aOrderTable[] =
122 RGB_RED, RGB_GREEN, RGB_BLUE, ALPHA,
123 RGB_BLUE, RGB_GREEN, RGB_RED, ALPHA,
124 ALPHA, RGB_RED, RGB_GREEN, RGB_BLUE,
125 ALPHA, RGB_BLUE, RGB_GREEN, RGB_RED,
128 const sal_Int32 nNumComps(rTags.getLength());
130 for(
int i=0;
i<4; ++
i)
133 while( j<4 && j<nNumComps && pLine[j] == rTags[j] )
150class OGLTransitionerImpl :
private cppu::BaseMutex,
public OGLTransitionerImplBase
153 OGLTransitionerImpl();
154 OGLTransitionerImpl(
const OGLTransitionerImpl&) =
delete;
155 OGLTransitionerImpl& operator=(
const OGLTransitionerImpl&) =
delete;
156 bool setTransition(
const std::shared_ptr<OGLTransitionImpl>& pOGLTransition );
157 bool initialize(
const Reference< presentation::XSlideShowView >& xView,
158 const Reference< rendering::XBitmap >& xLeavingSlide,
159 const Reference< rendering::XBitmap >& xEnteringSlide );
162 virtual void SAL_CALL
update(
double nTime )
override;
163 virtual void SAL_CALL viewChanged(
const Reference< presentation::XSlideShowView >& rView,
164 const Reference< rendering::XBitmap >& rLeavingBitmap,
165 const Reference< rendering::XBitmap >& rEnteringBitmap )
override;
168 void disposeTextures();
171 virtual void SAL_CALL disposing()
override;
173 bool isDisposed()
const
175 return (rBHelper.bDisposed || rBHelper.bInDispose);
178 void createTexture( GLuint* texID,
180 const uno::Sequence<sal_Int8>& data,
181 const OGLFormat* pFormat );
182 const OGLFormat* chooseFormats();
185 void impl_initializeFlags(
bool const bGLXPresent );
189 void setSlides(
const Reference< rendering::XBitmap >& xLeavingSlide ,
const uno::Reference< rendering::XBitmap >& xEnteringSlide );
190 void impl_prepareSlides();
192 void impl_createTexture(
bool useMipmap,
const uno::Sequence<sal_Int8>& data,
const OGLFormat* pFormat );
194 bool initWindowFromSlideShowView(
const uno::Reference< presentation::XSlideShowView >& xView );
199 bool impl_prepareTransition();
206 GLuint maLeavingSlideGL;
209 GLuint maEnteringSlideGL;
211 Reference< presentation::XSlideShowView >
mxView;
212 Reference< rendering::XIntegerBitmap > mxLeavingBitmap;
213 Reference< rendering::XIntegerBitmap > mxEnteringBitmap;
217 uno::Sequence<sal_Int8> maEnteringBytes;
221 uno::Sequence<sal_Int8> maLeavingBytes;
227 rendering::IntegerBitmapLayout maSlideBitmapLayout;
235 std::shared_ptr<OGLTransitionImpl> mpTransition;
240 bool mbBrokenTexturesATI;
249 bool mbValidOpenGLContext;
251#if OSL_DEBUG_LEVEL > 0
252 std::chrono::steady_clock::time_point m_UpdateStartTime;
253 std::chrono::steady_clock::time_point m_UpdateEndTime;
254 std::chrono::steady_clock::time_point m_StartTime;
255 std::chrono::steady_clock::time_point m_EndTime;
256 std::chrono::steady_clock::duration m_TotalUpdateDuration;
261bool OGLTransitionerImpl::initialize(
const Reference< presentation::XSlideShowView >& xView,
262 const Reference< rendering::XBitmap >& xLeavingSlide,
263 const Reference< rendering::XBitmap >& xEnteringSlide )
265 bool const bValidContext( initWindowFromSlideShowView( xView ) );
266 impl_initializeFlags( bValidContext );
268 setSlides( xLeavingSlide, xEnteringSlide );
270 return mbValidOpenGLContext;
273void OGLTransitionerImpl::impl_initializeFlags(
bool const bValidContext )
275 mbValidOpenGLContext = bValidContext;
276 if ( bValidContext ) {
280 SAL_INFO(
"slideshow.opengl",
"GL version: " << mnGLVersion <<
"" );
282#if defined( UNX ) && !defined( MACOSX )
283 const GLubyte* vendor = glGetString( GL_VENDOR );
285 mbBrokenTexturesATI = (vendor && strcmp(
reinterpret_cast<const char *
>(vendor),
"ATI Technologies Inc." ) == 0 );
292bool OGLTransitionerImpl::initWindowFromSlideShowView(
const Reference< presentation::XSlideShowView >& xView )
294 osl::MutexGuard
const guard( m_aMutex );
303#if OSL_DEBUG_LEVEL > 0
304 TimerContext aTimerContext(
"initWindowFromSlideShowView");
308 uno::Reference< rendering::XCanvas > xCanvas(
mxView->getCanvas(), uno::UNO_QUERY_THROW);
309 uno::Sequence< uno::Any > aDeviceParams;
310 ::canvas::tools::getDeviceInfo( xCanvas, aDeviceParams );
313 aDeviceParams[ 0 ] >>= aImplName;
316 aDeviceParams[1] >>= aVal;
328 SAL_INFO(
"slideshow.opengl",
"created the context");
333 awt::Rectangle aCanvasArea =
mxView->getCanvasArea();
334 mpContext->setWinPosAndSize(
Point(aCanvasArea.X, aCanvasArea.Y),
Size(aCanvasArea.Width, aCanvasArea.Height));
335 SAL_INFO(
"slideshow.opengl",
"canvas area: " << aCanvasArea.X <<
"," << aCanvasArea.Y <<
" - " << aCanvasArea.Width <<
"x" << aCanvasArea.Height);
338 glEnable(GL_CULL_FACE);
342 glClearColor (0, 0, 0, 0);
344 glClear(GL_COLOR_BUFFER_BIT);
354void OGLTransitionerImpl::setSlides(
const uno::Reference< rendering::XBitmap >& xLeavingSlide,
355 const uno::Reference< rendering::XBitmap >& xEnteringSlide )
357 osl::MutexGuard
const guard( m_aMutex );
362 mxLeavingBitmap.set( xLeavingSlide , UNO_QUERY_THROW );
363 mxEnteringBitmap.set( xEnteringSlide , UNO_QUERY_THROW );
379 css::uno::Reference<css::beans::XFastPropertySet> xEnteringFastPropertySet(mxEnteringBitmap, css::uno::UNO_QUERY);
380 css::uno::Reference<css::beans::XFastPropertySet> xLeavingFastPropertySet(mxLeavingBitmap, css::uno::UNO_QUERY);
381 css::uno::Sequence<css::uno::Any> aEnteringBitmap;
382 css::uno::Sequence<css::uno::Any> aLeavingBitmap;
383 if (xEnteringFastPropertySet && xLeavingFastPropertySet)
385 xEnteringFastPropertySet->getFastPropertyValue(1) >>= aEnteringBitmap;
386 xLeavingFastPropertySet->getFastPropertyValue(1) >>= aLeavingBitmap;
388 if (aEnteringBitmap.getLength() == 2 && aLeavingBitmap.getLength() == 2)
393void OGLTransitionerImpl::impl_prepareSlides()
395 geometry::IntegerRectangle2D aSlideRect;
405 maLeavingBytes = mxLeavingBitmap->getData(maSlideBitmapLayout, aSlideRect);
406 maEnteringBytes = mxEnteringBitmap->getData(maSlideBitmapLayout, aSlideRect);
411 SAL_WARN_IF(maSlideBitmapLayout.PlaneStride != 0,
"slideshow.opengl",
"only handle no plane stride now");
421 mbRestoreSync = rGLWindow.Synchronize(
true);
424bool OGLTransitionerImpl::impl_prepareTransition()
426 if( mpTransition && mpTransition->getSettings().mnRequiredGLVersion <= mnGLVersion )
427 return mpTransition->prepare( maLeavingSlideGL, maEnteringSlideGL,
mpContext.get() );
431bool OGLTransitionerImpl::setTransition(
const std::shared_ptr<OGLTransitionImpl>& pTransition )
436 mpTransition = pTransition;
441 bool succeeded = impl_prepareTransition();
443 mpTransition =
nullptr;
447 impl_prepareSlides();
457void OGLTransitionerImpl::createTexture( GLuint* texID,
459 const uno::Sequence<sal_Int8>& data,
460 const OGLFormat* pFormat )
463 glDeleteTextures( 1, texID );
464 glGenTextures( 1, texID );
465 glBindTexture( GL_TEXTURE_2D, *texID );
466 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER );
467 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER );
470 impl_createTexture( useMipmap, data, pFormat );
472 SAL_WARN_IF(!glIsTexture(*texID),
"slideshow.opengl",
"Can't generate Leaving slide textures in OpenGL");
476class OGLColorSpace :
public cppu::WeakImplHelper< css::rendering::XIntegerBitmapColorSpace >
484 return rendering::ColorSpaceType::RGB;
486 virtual uno::Sequence< sal_Int8 > SAL_CALL getComponentTags( )
override
490 virtual sal_Int8 SAL_CALL getRenderingIntent( )
override
492 return rendering::RenderingIntent::PERCEPTUAL;
494 virtual uno::Sequence< beans::PropertyValue > SAL_CALL getProperties( )
override
496 return uno::Sequence< beans::PropertyValue >();
498 virtual uno::Sequence< double > SAL_CALL convertColorSpace(
const uno::Sequence< double >& deviceColor,
499 const uno::Reference< rendering::XColorSpace >& targetColorSpace )
override
503 uno::Sequence<rendering::ARGBColor> aIntermediate(
504 convertToARGB(deviceColor));
505 return targetColorSpace->convertFromARGB(aIntermediate);
507 virtual uno::Sequence< rendering::RGBColor > SAL_CALL convertToRGB(
const uno::Sequence< double >& deviceColor )
override
509 const double* pIn( deviceColor.getConstArray() );
510 const std::size_t nLen( deviceColor.getLength() );
512 "number of channels no multiple of 4",
513 static_cast<rendering::XColorSpace*
>(
this), 0);
515 uno::Sequence< rendering::RGBColor > aRes(nLen/4);
516 rendering::RGBColor*
pOut( aRes.getArray() );
517 for( std::size_t i=0;
i<nLen;
i+=4 )
519 *
pOut++ = rendering::RGBColor(pIn[0],pIn[1],pIn[2]);
524 virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertToARGB(
const uno::Sequence< double >& deviceColor )
override
526 const double* pIn( deviceColor.getConstArray() );
527 const std::size_t nLen( deviceColor.getLength() );
529 "number of channels no multiple of 4",
530 static_cast<rendering::XColorSpace*
>(
this), 0);
532 uno::Sequence< rendering::ARGBColor > aRes(nLen/4);
533 rendering::ARGBColor*
pOut( aRes.getArray() );
534 for( std::size_t i=0;
i<nLen;
i+=4 )
536 *
pOut++ = rendering::ARGBColor(pIn[3],pIn[0],pIn[1],pIn[2]);
541 virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertToPARGB(
const uno::Sequence< double >& deviceColor )
override
543 const double* pIn( deviceColor.getConstArray() );
544 const std::size_t nLen( deviceColor.getLength() );
546 "number of channels no multiple of 4",
547 static_cast<rendering::XColorSpace*
>(
this), 0);
549 uno::Sequence< rendering::ARGBColor > aRes(nLen/4);
550 rendering::ARGBColor*
pOut( aRes.getArray() );
551 for( std::size_t i=0;
i<nLen;
i+=4 )
553 *
pOut++ = rendering::ARGBColor(pIn[3],pIn[3]*pIn[0],pIn[3]*pIn[1],pIn[3]*pIn[2]);
558 virtual uno::Sequence< double > SAL_CALL convertFromRGB(
const uno::Sequence< rendering::RGBColor >& rgbColor )
override
560 const sal_Int32 nLen( rgbColor.getLength() );
562 uno::Sequence< double > aRes(nLen*4);
563 double* pColors=aRes.getArray();
564 for(
const rendering::RGBColor& rIn : rgbColor )
566 *pColors++ = rIn.Red;
567 *pColors++ = rIn.Green;
568 *pColors++ = rIn.Blue;
573 virtual uno::Sequence< double > SAL_CALL convertFromARGB(
const uno::Sequence< rendering::ARGBColor >& rgbColor )
override
575 const sal_Int32 nLen( rgbColor.getLength() );
577 uno::Sequence< double > aRes(nLen*4);
578 double* pColors=aRes.getArray();
579 for(
const rendering::ARGBColor& rIn : rgbColor )
581 *pColors++ = rIn.Red;
582 *pColors++ = rIn.Green;
583 *pColors++ = rIn.Blue;
584 *pColors++ = rIn.Alpha;
588 virtual uno::Sequence< double > SAL_CALL convertFromPARGB(
const uno::Sequence< rendering::ARGBColor >& rgbColor )
override
590 const sal_Int32 nLen( rgbColor.getLength() );
592 uno::Sequence< double > aRes(nLen*4);
593 double* pColors=aRes.getArray();
594 for(
const rendering::ARGBColor& rIn : rgbColor )
596 *pColors++ = rIn.Red/rIn.Alpha;
597 *pColors++ = rIn.Green/rIn.Alpha;
598 *pColors++ = rIn.Blue/rIn.Alpha;
599 *pColors++ = rIn.Alpha;
605 virtual sal_Int32 SAL_CALL getBitsPerPixel( )
override
609 virtual uno::Sequence< sal_Int32 > SAL_CALL getComponentBitCounts( )
override
613 virtual sal_Int8 SAL_CALL getEndianness( )
override
615 return util::Endianness::LITTLE;
617 virtual uno::Sequence<double> SAL_CALL convertFromIntegerColorSpace(
const uno::Sequence< sal_Int8 >& deviceColor,
618 const uno::Reference< rendering::XColorSpace >& targetColorSpace )
override
620 if(
dynamic_cast<OGLColorSpace*
>(targetColorSpace.get()) )
622 const sal_Int32 nLen( deviceColor.getLength() );
624 "number of channels no multiple of 4",
625 static_cast<rendering::XColorSpace*
>(
this), 0);
627 uno::Sequence<double> aRes(nLen);
628 std::transform(deviceColor.begin(), deviceColor.end(), aRes.getArray(),
636 uno::Sequence<rendering::ARGBColor> aIntermediate(
637 convertIntegerToARGB(deviceColor));
638 return targetColorSpace->convertFromARGB(aIntermediate);
641 virtual uno::Sequence< sal_Int8 > SAL_CALL convertToIntegerColorSpace(
const uno::Sequence< sal_Int8 >& deviceColor,
642 const uno::Reference< rendering::XIntegerBitmapColorSpace >& targetColorSpace )
override
644 if(
dynamic_cast<OGLColorSpace*
>(targetColorSpace.get()) )
653 uno::Sequence<rendering::ARGBColor> aIntermediate(
654 convertIntegerToARGB(deviceColor));
655 return targetColorSpace->convertIntegerFromARGB(aIntermediate);
658 virtual uno::Sequence< rendering::RGBColor > SAL_CALL convertIntegerToRGB(
const uno::Sequence< sal_Int8 >& deviceColor )
override
660 const sal_Int8* pIn( deviceColor.getConstArray() );
661 const std::size_t nLen( deviceColor.getLength() );
663 "number of channels no multiple of 4",
664 static_cast<rendering::XColorSpace*
>(
this), 0);
666 uno::Sequence< rendering::RGBColor > aRes(nLen/4);
667 rendering::RGBColor*
pOut( aRes.getArray() );
668 for( std::size_t i=0;
i<nLen;
i+=4 )
670 *
pOut++ = rendering::RGBColor(
679 virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertIntegerToARGB(
const uno::Sequence< sal_Int8 >& deviceColor )
override
681 const sal_Int8* pIn( deviceColor.getConstArray() );
682 const std::size_t nLen( deviceColor.getLength() );
684 "number of channels no multiple of 4",
685 static_cast<rendering::XColorSpace*
>(
this), 0);
687 uno::Sequence< rendering::ARGBColor > aRes(nLen/4);
688 rendering::ARGBColor*
pOut( aRes.getArray() );
689 for( std::size_t i=0;
i<nLen;
i+=4 )
691 *
pOut++ = rendering::ARGBColor(
701 virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertIntegerToPARGB(
const uno::Sequence< sal_Int8 >& deviceColor )
override
703 const sal_Int8* pIn( deviceColor.getConstArray() );
704 const std::size_t nLen( deviceColor.getLength() );
706 "number of channels no multiple of 4",
707 static_cast<rendering::XColorSpace*
>(
this), 0);
709 uno::Sequence< rendering::ARGBColor > aRes(nLen/4);
710 rendering::ARGBColor*
pOut( aRes.getArray() );
711 for( std::size_t i=0;
i<nLen;
i+=4 )
714 *
pOut++ = rendering::ARGBColor(
724 virtual uno::Sequence< sal_Int8 > SAL_CALL convertIntegerFromRGB(
const uno::Sequence< rendering::RGBColor >& rgbColor )
override
726 const sal_Int32 nLen( rgbColor.getLength() );
728 uno::Sequence< sal_Int8 > aRes(nLen*4);
730 for(
const rendering::RGBColor& rIn : rgbColor )
740 virtual uno::Sequence< sal_Int8 > SAL_CALL convertIntegerFromARGB(
const uno::Sequence< rendering::ARGBColor >& rgbColor )
override
742 const sal_Int32 nLen( rgbColor.getLength() );
744 uno::Sequence< sal_Int8 > aRes(nLen*4);
746 for(
const rendering::ARGBColor& rIn : rgbColor )
756 virtual uno::Sequence< sal_Int8 > SAL_CALL convertIntegerFromPARGB(
const uno::Sequence< rendering::ARGBColor >& rgbColor )
override
758 const sal_Int32 nLen( rgbColor.getLength() );
760 uno::Sequence< sal_Int8 > aRes(nLen*4);
762 for(
const rendering::ARGBColor& rIn : rgbColor )
779 pTags[0] = rendering::ColorComponentTag::RGB_RED;
780 pTags[1] = rendering::ColorComponentTag::RGB_GREEN;
781 pTags[2] = rendering::ColorComponentTag::RGB_BLUE;
782 pTags[3] = rendering::ColorComponentTag::ALPHA;
791uno::Reference<rendering::XIntegerBitmapColorSpace>
const &
794 static uno::Reference<rendering::XIntegerBitmapColorSpace> theSpace =
new OGLColorSpace();
799 GLint internalFormat, GLsizei width, GLsizei height, GLenum format,
800 GLenum type,
const void * data)
802 if (epoxy_has_gl_extension(
"GL_ARB_framebuffer_object")) {
804 GL_TEXTURE_2D, 0, internalFormat, width, height, 0, format, type,
806 glGenerateMipmap(GL_TEXTURE_2D);
808 glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
810 GL_TEXTURE_2D, 0, internalFormat, width, height, 0, format, type,
812 glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_FALSE);
814 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
816 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
819void OGLTransitionerImpl::impl_createTexture(
821 const uno::Sequence<sal_Int8>& data,
822 const OGLFormat* pFormat )
828 uno::Sequence<sal_Int8> tempBytes(
829 maSlideBitmapLayout.ColorSpace->convertToIntegerColorSpace(
831 getOGLColorSpace()));
832 buildMipmaps( GL_RGBA,
839 if (epoxy_has_gl_extension(
"GL_EXT_texture_filter_anisotropic"))
842 GLfloat largest_supported_anisotropy;
843 glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &largest_supported_anisotropy);
844 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, largest_supported_anisotropy);
847 if( mpTransition && !mbBrokenTexturesATI && !useMipmap) {
848 glTexImage2D( GL_TEXTURE_2D, 0, pFormat->nInternalFormat,
maSlideSize.Width,
maSlideSize.Height, 0, pFormat->eFormat, pFormat->eType, &data[0] );
849 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
850 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
852 buildMipmaps( pFormat->nInternalFormat,
maSlideSize.Width,
maSlideSize.Height, pFormat->eFormat, pFormat->eType, &data[0] );
854 if (epoxy_has_gl_extension(
"GL_EXT_texture_filter_anisotropic"))
857 GLfloat largest_supported_anisotropy;
858 glGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &largest_supported_anisotropy );
859 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, largest_supported_anisotropy );
866const OGLFormat* OGLTransitionerImpl::chooseFormats()
868 const OGLFormat* pDetectedFormat=
nullptr;
869 uno::Reference<rendering::XIntegerBitmapColorSpace> xIntColorSpace(
870 maSlideBitmapLayout.ColorSpace);
872 if( xIntColorSpace->getType() == rendering::ColorSpaceType::RGB ||
873 xIntColorSpace->getType() == rendering::ColorSpaceType::SRGB )
880 static const OGLFormat lcl_RGB24[] =
883 {3, GL_BGR, GL_UNSIGNED_BYTE},
884 {3, GL_RGB, GL_UNSIGNED_BYTE},
885 {3, GL_BGR, GL_UNSIGNED_BYTE},
886 {3, GL_RGB, GL_UNSIGNED_BYTE}
889#if defined(GL_VERSION_1_2) && defined(GLU_VERSION_1_3)
891 static const OGLFormat lcl_RGB16[] =
894 {3, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV},
895 {3, GL_RGB, GL_UNSIGNED_SHORT_5_6_5},
896 {3, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV},
897 {3, GL_RGB, GL_UNSIGNED_SHORT_5_6_5}
900 static const OGLFormat lcl_ARGB16_4[] =
903 {4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4_REV},
904 {4, GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV},
905 {4, GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4},
906 {4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4}
909 static const OGLFormat lcl_ARGB16_5[] =
912 {4, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV},
913 {4, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV},
914 {4, GL_BGRA, GL_UNSIGNED_SHORT_5_5_5_1},
915 {4, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1}
918 static const OGLFormat lcl_ARGB32[] =
921 {4, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV},
922 {4, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV},
923 {4, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8},
924 {4, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8}
927 const uno::Sequence<sal_Int8> aComponentTags(
928 xIntColorSpace->getComponentTags());
929 const uno::Sequence<sal_Int32> aComponentBitcounts(
930 xIntColorSpace->getComponentBitCounts());
931 const sal_Int32 nNumComponents( aComponentBitcounts.getLength() );
932 const sal_Int32 nBitsPerPixel( xIntColorSpace->getBitsPerPixel() );
935 const int nComponentOrderIndex(
936 calcComponentOrderIndex(aComponentTags));
937 if( nComponentOrderIndex != -1 )
939 switch( nBitsPerPixel )
942 if( nNumComponents == 3 )
944 pDetectedFormat = &lcl_RGB16[nComponentOrderIndex];
946 else if( nNumComponents == 4 )
948 if( aComponentBitcounts[1] == 4 )
950 pDetectedFormat = &lcl_ARGB16_4[nComponentOrderIndex];
952 else if( aComponentBitcounts[1] == 5 )
954 pDetectedFormat = &lcl_ARGB16_5[nComponentOrderIndex];
959 if( nNumComponents == 3 )
961 pDetectedFormat = &lcl_RGB24[nComponentOrderIndex];
965 if ( nNumComponents == 4 )
967 pDetectedFormat = &lcl_ARGB32[nComponentOrderIndex];
973 const uno::Sequence<sal_Int8> aComponentTags(
974 xIntColorSpace->getComponentTags());
975 const int nComponentOrderIndex(calcComponentOrderIndex(aComponentTags));
976 if( aComponentTags.getLength() == 3 &&
977 nComponentOrderIndex != -1 &&
978 xIntColorSpace->getBitsPerPixel() == 24 )
980 pDetectedFormat = &lcl_RGB24[nComponentOrderIndex];
985 return pDetectedFormat;
988void OGLTransitionerImpl::GLInitSlides()
990 osl::MutexGuard
const guard( m_aMutex );
992 if (isDisposed() || !mpTransition || mpTransition->getSettings().mnRequiredGLVersion > mnGLVersion)
995#if OSL_DEBUG_LEVEL > 0
996 TimerContext aTimerContext(
"texture creation");
1001 const OGLFormat* pFormat = chooseFormats();
1004 createTexture( &maLeavingSlideGL,
1005 mpTransition->getSettings().mbUseMipMapLeaving,
1009 createTexture( &maEnteringSlideGL,
1010 mpTransition->getSettings().mbUseMipMapEntering,
1019void SAL_CALL OGLTransitionerImpl::update(
double nTime )
1021#if OSL_DEBUG_LEVEL > 0
1023 m_UpdateStartTime = std::chrono::steady_clock::now();
1024 if( mnFrameCount == 1 ) {
1025 m_StartTime = m_UpdateStartTime;
1026 m_TotalUpdateDuration = std::chrono::seconds(0);
1029 osl::MutexGuard
const guard( m_aMutex );
1031 if (isDisposed() || !mbValidOpenGLContext || !mpTransition || mpTransition->getSettings().mnRequiredGLVersion > mnGLVersion)
1037 glEnable(GL_DEPTH_TEST);
1038 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
1042 mpTransition->display(nTime, maLeavingSlideGL, maEnteringSlideGL,
1044 static_cast<double>(rGLWindow.Width),
1045 static_cast<double>(rGLWindow.Height),
1054#if OSL_DEBUG_LEVEL > 0
1055 m_UpdateEndTime = std::chrono::steady_clock::now();
1057 SAL_INFO(
"slideshow.opengl",
"update time: " << nTime);
1058 SAL_INFO(
"slideshow.opengl",
"update took: " << std::chrono::duration_cast<std::chrono::milliseconds>(m_UpdateEndTime - m_UpdateStartTime).
count());
1059 m_TotalUpdateDuration += m_UpdateEndTime - m_UpdateStartTime;
1063void SAL_CALL OGLTransitionerImpl::viewChanged(
const Reference< presentation::XSlideShowView >& rView,
1064 const Reference< rendering::XBitmap >& rLeavingBitmap,
1065 const Reference< rendering::XBitmap >& rEnteringBitmap )
1067 SAL_INFO(
"slideshow.opengl",
"transitioner: view changed");
1071 initWindowFromSlideShowView( rView );
1072 setSlides( rLeavingBitmap, rEnteringBitmap );
1073 impl_prepareSlides();
1074 impl_prepareTransition();
1077void OGLTransitionerImpl::disposeTextures()
1079 if (!mbValidOpenGLContext)
1085 glDeleteTextures(1,&maLeavingSlideGL);
1086 maLeavingSlideGL = 0;
1087 glDeleteTextures(1,&maEnteringSlideGL);
1088 maEnteringSlideGL = 0;
1093void OGLTransitionerImpl::impl_dispose()
1095 if (mbValidOpenGLContext)
1101 if( mpTransition && mpTransition->getSettings().mnRequiredGLVersion <= mnGLVersion )
1102 mpTransition->finish();
1110void OGLTransitionerImpl::disposing()
1112 osl::MutexGuard
const guard( m_aMutex );
1114#if OSL_DEBUG_LEVEL > 0
1115 SAL_INFO(
"slideshow.opengl",
"dispose " <<
this);
1116 if( mnFrameCount ) {
1117 m_EndTime = std::chrono::steady_clock::now();
1118 auto const duration = m_EndTime - m_StartTime;
1120 "whole transition (frames: " << mnFrameCount
1121 <<
") took: " << std::chrono::duration_cast<std::chrono::microseconds>(duration).
count()
1123 << ((
static_cast<double>(mnFrameCount)*1000000000.0)/std::chrono::duration_cast<std::chrono::nanoseconds>(duration).
count())
1124 <<
" time spent in updates: " << std::chrono::duration_cast<std::chrono::microseconds>(m_TotalUpdateDuration).
count()
1125 <<
" percentage of transition time: "
1126 << (100*((
static_cast<double>(std::chrono::duration_cast<std::chrono::nanoseconds>(m_TotalUpdateDuration).
count()))/(
static_cast<double>(std::chrono::duration_cast<std::chrono::nanoseconds>(duration).
count()))))
1134 const char* sal_synchronize = getenv(
"SAL_SYNCHRONIZE");
1135 mpContext->getOpenGLWindow().Synchronize(sal_synchronize && *sal_synchronize ==
'1' );
1140 mpTransition.reset();
1142 mxLeavingBitmap.clear();
1143 mxEnteringBitmap.clear();
1147OGLTransitionerImpl::OGLTransitionerImpl()
1148 : OGLTransitionerImplBase(
m_aMutex)
1150 , maLeavingSlideGL(0)
1151 , maEnteringSlideGL(0)
1155 , mbRestoreSync(false)
1156 , maSlideBitmapLayout()
1158 , mbBrokenTexturesATI(false)
1160 , mbValidOpenGLContext(false)
1161#
if OSL_DEBUG_LEVEL > 0
1167typedef cppu::WeakComponentImplHelper<presentation::XTransitionFactory, lang::XServiceInfo> OGLTransitionFactoryImplBase;
1169class OGLTransitionFactoryImpl :
private cppu::BaseMutex,
public OGLTransitionFactoryImplBase
1172 explicit OGLTransitionFactoryImpl() :
1173 OGLTransitionFactoryImplBase(
m_aMutex)
1179 return {
"com.sun.star.presentation.TransitionFactory" };
1183 return "com.sun.star.comp.presentation.OGLTransitionFactory";
1191 virtual sal_Bool SAL_CALL hasTransition( sal_Int16 transitionType, sal_Int16 transitionSubType )
override
1202 if( transitionType == animations::TransitionType::MISCSHAPEWIPE ) {
1203 switch( transitionSubType )
1205 case animations::TransitionSubType::LEFTTORIGHT:
1206 case animations::TransitionSubType::TOPTOBOTTOM:
1207 case animations::TransitionSubType::TOPLEFT:
1208 case animations::TransitionSubType::TOPRIGHT:
1209 case animations::TransitionSubType::BOTTOMRIGHT:
1210 case animations::TransitionSubType::BOTTOMLEFT:
1211 case animations::TransitionSubType::TOPCENTER:
1212 case animations::TransitionSubType::RIGHTCENTER:
1213 case animations::TransitionSubType::BOTTOMCENTER:
1214 case animations::TransitionSubType::CORNERSIN:
1215 case animations::TransitionSubType::CORNERSOUT:
1216 case animations::TransitionSubType::VERTICAL:
1217 case animations::TransitionSubType::HORIZONTAL:
1218 case animations::TransitionSubType::DIAMOND:
1219 case animations::TransitionSubType::CIRCLE:
1220 case animations::TransitionSubType::HEART:
1221 case animations::TransitionSubType::FANOUTHORIZONTAL:
1222 case animations::TransitionSubType::ACROSS:
1228 }
else if( transitionType == animations::TransitionType::FADE && transitionSubType == animations::TransitionSubType::CROSSFADE ) {
1230 }
else if( transitionType == animations::TransitionType::FADE && transitionSubType == animations::TransitionSubType::FADEOVERCOLOR ) {
1232 }
else if( transitionType == animations::TransitionType::IRISWIPE && transitionSubType == animations::TransitionSubType::DIAMOND ) {
1234 }
else if( transitionType == animations::TransitionType::ZOOM && transitionSubType == animations::TransitionSubType::ROTATEIN ) {
1240 virtual uno::Reference< presentation::XTransition > SAL_CALL createTransition(
1241 sal_Int16 transitionType,
1242 sal_Int16 transitionSubType,
1243 sal_Int32 transitionFadeColor,
1244 const uno::Reference< presentation::XSlideShowView >& view,
1245 const uno::Reference< rendering::XBitmap >& leavingBitmap,
1246 const uno::Reference< rendering::XBitmap >& enteringBitmap )
override
1248 if( !hasTransition( transitionType, transitionSubType ) )
1249 return uno::Reference< presentation::XTransition >();
1252 if ( !xRes->initialize( view, leavingBitmap, enteringBitmap ) )
1253 return uno::Reference< presentation::XTransition >();
1255 std::shared_ptr<OGLTransitionImpl> pTransition;
1257 if( transitionType == animations::TransitionType::MISCSHAPEWIPE ) {
1258 switch( transitionSubType )
1260 case animations::TransitionSubType::LEFTTORIGHT:
1263 case animations::TransitionSubType::TOPTOBOTTOM:
1266 case animations::TransitionSubType::TOPLEFT:
1269 case animations::TransitionSubType::TOPRIGHT:
1272 case animations::TransitionSubType::BOTTOMRIGHT:
1275 case animations::TransitionSubType::BOTTOMLEFT:
1278 case animations::TransitionSubType::TOPCENTER:
1281 case animations::TransitionSubType::RIGHTCENTER:
1284 case animations::TransitionSubType::BOTTOMCENTER:
1287 case animations::TransitionSubType::CORNERSIN:
1290 case animations::TransitionSubType::CORNERSOUT:
1293 case animations::TransitionSubType::VERTICAL:
1296 case animations::TransitionSubType::HORIZONTAL:
1299 case animations::TransitionSubType::CIRCLE:
1302 case animations::TransitionSubType::FANOUTHORIZONTAL:
1305 case animations::TransitionSubType::ACROSS:
1308 case animations::TransitionSubType::DIAMOND:
1311 case animations::TransitionSubType::HEART:
1315 }
else if( transitionType == animations::TransitionType::FADE && transitionSubType == animations::TransitionSubType::CROSSFADE ) {
1317 }
else if( transitionType == animations::TransitionType::FADE && transitionSubType == animations::TransitionSubType::FADEOVERCOLOR ) {
1319 }
else if( transitionType == animations::TransitionType::IRISWIPE && transitionSubType == animations::TransitionSubType::DIAMOND ) {
1321 }
else if( transitionType == animations::TransitionType::ZOOM && transitionSubType == animations::TransitionSubType::ROTATEIN ) {
1325 if ( !pTransition || !xRes->setTransition(pTransition) )
1326 return uno::Reference< presentation::XTransition >();
1334extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
1336 css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any>
const&)
1338 return cppu::acquire(
new OGLTransitionFactoryImpl());
std::shared_ptr< OGLTransitionImpl > makeTurnAround()
std::shared_ptr< OGLTransitionImpl > makeHoneycomb()
std::shared_ptr< OGLTransitionImpl > makeRipple()
std::shared_ptr< OGLTransitionImpl > makeVenetianBlinds(bool vertical, int parts)
std::shared_ptr< OGLTransitionImpl > makeGlitter()
std::shared_ptr< OGLTransitionImpl > makeDiamond()
2D replacements
std::shared_ptr< OGLTransitionImpl > makeDissolve()
std::shared_ptr< OGLTransitionImpl > makeRochade()
std::shared_ptr< OGLTransitionImpl > makeRevolvingCircles(sal_uInt16 nCircles, sal_uInt16 nPointsOnCircles)
std::shared_ptr< OGLTransitionImpl > makeNByMTileFlip(sal_uInt16 n, sal_uInt16 m)
std::shared_ptr< OGLTransitionImpl > makeFallLeaving()
std::shared_ptr< OGLTransitionImpl > makeFadeSmoothly()
std::shared_ptr< OGLTransitionImpl > makeIris()
std::shared_ptr< OGLTransitionImpl > makeNewsflash()
std::shared_ptr< OGLTransitionImpl > makeStatic()
std::shared_ptr< OGLTransitionImpl > makeOutsideCubeFaceToLeft()
std::shared_ptr< OGLTransitionImpl > makeTurnDown()
std::shared_ptr< OGLTransitionImpl > makeVortex()
std::shared_ptr< OGLTransitionImpl > makeFadeThroughColor(bool white)
std::shared_ptr< OGLTransitionImpl > makeHelix(sal_uInt16 nRows)
std::shared_ptr< OGLTransitionImpl > makeInsideCubeFaceToLeft()
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * slideshow_OGLTransitionFactoryImpl_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
uno::Sequence< sal_Int32 > maBitCounts
uno::Sequence< sal_Int8 > maComponentTags
static rtl::Reference< OpenGLContext > Create()
virtual vcl::Window * GetOwnerWindow() const
void SetLeaveEnterBackgrounds(const css::uno::Sequence< css::uno::Any > &rLeaveArgs, const css::uno::Sequence< css::uno::Any > &rEnterArgs)
#define ENSURE_ARG_OR_THROW2(c, m, ifc, arg)
#define SAL_WARN_IF(condition, area, stream)
#define SAL_INFO(area, stream)
if(aStr !=aBuf) UpdateName_Impl(m_xFollowLb.get()
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
bool getType(BSTR name, Type &type)
const basegfx::B2ISize maSlideSize
uno::Reference< presentation::XSlideShowView > mxView
ParserContextSharedPtr mpContext
static float getGLVersion()
static bool supportsOpenGL()