summaryrefslogtreecommitdiff
path: root/avmedia/source/opengl/oglframegrabber.cxx
diff options
context:
space:
mode:
authorZolnai Tamás <tamas.zolnai@collabora.com>2014-04-20 18:00:33 +0200
committerZolnai Tamás <tamas.zolnai@collabora.com>2014-04-20 18:00:48 +0200
commitd8920e6d1de0698f7c132d74cc34e2f1021c6fb3 (patch)
tree83a8b9101fa46c9e3a7bd3ba32b6cab5b91b4a2e /avmedia/source/opengl/oglframegrabber.cxx
parent78609b36e0d61bd5535cfdc1ab2f1e0e59505042 (diff)
Make OGLFrameGrabber work
Steps of grabFrame - Init opengl context - Call libgltf to render - Get a RGB buffer from libgltf - Create a Bitmap from this RGB buffer Additionally: - Using mimetype is neccessary to decide which player to create. - bAllowToCreateReplacementGraphic is unneeded. Change-Id: I7fef043a3341771389144a4f4cac71b0862ef8a7
Diffstat (limited to 'avmedia/source/opengl/oglframegrabber.cxx')
-rw-r--r--avmedia/source/opengl/oglframegrabber.cxx30
1 files changed, 25 insertions, 5 deletions
diff --git a/avmedia/source/opengl/oglframegrabber.cxx b/avmedia/source/opengl/oglframegrabber.cxx
index 2aeda9720b8e..81be9c138826 100644
--- a/avmedia/source/opengl/oglframegrabber.cxx
+++ b/avmedia/source/opengl/oglframegrabber.cxx
@@ -12,13 +12,16 @@
#include <cppuhelper/supportsservice.hxx>
#include <vcl/bitmapex.hxx>
#include <vcl/graph.hxx>
+#include <vcl/salbtype.hxx>
+#include <vcl/bmpacc.hxx>
using namespace com::sun::star;
namespace avmedia { namespace ogl {
-OGLFrameGrabber::OGLFrameGrabber( const OUString& /*rUrl*/ )
+OGLFrameGrabber::OGLFrameGrabber( glTFHandle* pHandle )
: FrameGrabber_BASE()
+ , m_pHandle( pHandle )
{
}
@@ -26,12 +29,29 @@ OGLFrameGrabber::~OGLFrameGrabber()
{
}
-uno::Reference< css::graphic::XGraphic > SAL_CALL OGLFrameGrabber::grabFrame( double /*fMediaTime*/ )
+uno::Reference< css::graphic::XGraphic > SAL_CALL OGLFrameGrabber::grabFrame( double fMediaTime )
throw ( uno::RuntimeException, std::exception )
{
- // TODO: Here we need a bitmap of the model at the point specified by fMediaTime
- // See com::sun::star::media::XFrameGrabber
- BitmapEx aBitmap;
+ // TODO: libgltf should provide an RGBA buffer, not just an RGB one. See: OpenGLRender::GetAsBitmap().
+ char* pBuffer = new char[m_pHandle->viewport.width * m_pHandle->viewport.height * 3];
+ gltf_renderer_get_bitmap(m_pHandle, fMediaTime, pBuffer, 800, 600);
+ Bitmap aBitmap( Size(m_pHandle->viewport.width, m_pHandle->viewport.height), 24 );
+ {
+ Bitmap::ScopedWriteAccess pWriteAccess( aBitmap );
+ size_t nCurPos = 0;
+ for( int y = 0; y < m_pHandle->viewport.height; ++y)
+ {
+ Scanline pScan = pWriteAccess->GetScanline(y);
+ for( int x = 0; x < m_pHandle->viewport.width; ++x )
+ {
+ *pScan++ = pBuffer[nCurPos];
+ *pScan++ = pBuffer[nCurPos+1];
+ *pScan++ = pBuffer[nCurPos+2];
+ nCurPos += 3;
+ }
+ }
+ }
+ delete [] pBuffer;
return Graphic( aBitmap ).GetXGraphic();
}