fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / avmedia / source / opengl / oglframegrabber.cxx
blob33ee878d44f819eaf58b5136607eaa5410bd72df
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include "oglframegrabber.hxx"
12 #include <cppuhelper/supportsservice.hxx>
13 #include <vcl/bitmapex.hxx>
14 #include <vcl/graph.hxx>
15 #include <vcl/salbtype.hxx>
16 #include <vcl/bmpacc.hxx>
18 #include <vcl/opengl/OpenGLHelper.hxx>
20 #include <boost/scoped_array.hpp>
22 using namespace com::sun::star;
23 using namespace libgltf;
25 namespace avmedia { namespace ogl {
27 OGLFrameGrabber::OGLFrameGrabber( glTFHandle& rHandle )
28 : FrameGrabber_BASE()
29 , m_rHandle( rHandle )
33 OGLFrameGrabber::~OGLFrameGrabber()
37 uno::Reference< css::graphic::XGraphic > SAL_CALL OGLFrameGrabber::grabFrame( double /*fMediaTime*/ )
38 throw ( uno::RuntimeException, std::exception )
40 boost::scoped_array<sal_uInt8> pBuffer(new sal_uInt8[m_rHandle.viewport.width * m_rHandle.viewport.height * 4]);
41 glTFHandle* pHandle = &m_rHandle;
42 int nRet = gltf_renderer_get_bitmap(&pHandle, 1, reinterpret_cast<char*>(pBuffer.get()), GL_BGRA);
43 if( nRet != 0 )
45 SAL_WARN("avmedia.opengl", "Error occurred while rendering to bitmap! Error code: " << nRet);
46 return uno::Reference< css::graphic::XGraphic >();
48 BitmapEx aBitmap = OpenGLHelper::ConvertBGRABufferToBitmapEx(pBuffer.get(), m_rHandle.viewport.width, m_rHandle.viewport.height);
49 return Graphic( aBitmap ).GetXGraphic();
52 OUString SAL_CALL OGLFrameGrabber::getImplementationName() throw ( uno::RuntimeException, std::exception )
54 return OUString("com.sun.star.comp.avmedia.FrameGrabber_OpenGL");
57 sal_Bool SAL_CALL OGLFrameGrabber::supportsService( const OUString& rServiceName )
58 throw ( uno::RuntimeException, std::exception )
60 return cppu::supportsService(this, rServiceName);
63 uno::Sequence< OUString > SAL_CALL OGLFrameGrabber::getSupportedServiceNames()
64 throw ( uno::RuntimeException, std::exception )
66 uno::Sequence< OUString > aRet(1);
67 aRet[0] = "com.sun.star.media.FrameGrabber_OpenGL";
68 return aRet;
71 } // namespace ogl
72 } // namespace avmedia
74 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */