Kaydet (Commit) fe701018 authored tarafından Zolnai Tamás's avatar Zolnai Tamás

Introduce HAVE_FEATURE_GLTF to enable/disable gltf related code

When it is a release build then enable it only on Windows and
Linux.

Change-Id: I7c462aeb75e6ab60eeaa0fa42ca7853a6369b742
üst 3d3fc58a
......@@ -47,6 +47,12 @@ $(eval $(call gb_Library_use_libraries,avmedia,\
$(gb_UWINAPI) \
))
ifeq ($(ENABLE_GLTF),TRUE)
$(eval $(call gb_Library_add_exception_objects,avmedia,\
avmedia/source/framework/modeltools \
))
endif
ifneq (,$(filter COLLADA2GLTF,$(BUILD_TYPE)))
$(eval $(call gb_Library_set_warnings_not_errors,avmedia))
......@@ -74,7 +80,6 @@ $(eval $(call gb_Library_add_exception_objects,avmedia,\
avmedia/source/framework/mediamisc \
avmedia/source/framework/mediaplayer \
avmedia/source/framework/mediatoolbox \
avmedia/source/framework/modeltools \
avmedia/source/framework/soundhandler \
avmedia/source/viewer/mediaevent_impl \
avmedia/source/viewer/mediawindow \
......
......@@ -17,6 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <config_features.h>
#ifndef INCLUDED_AVMEDIA_SOURCE_INC_MEDIAMISC_HXX
#define INCLUDED_AVMEDIA_SOURCE_INC_MEDIAMISC_HXX
......@@ -42,7 +44,10 @@ class ResMgr;
// Mime types
#define AVMEDIA_MIMETYPE_COMMON "application/vnd.sun.star.media"
#if HAVE_FEATURE_GLTF
#define AVMEDIA_MIMETYPE_JSON "application/vnd.gltf+json"
#endif
namespace avmedia
......
......@@ -16,6 +16,9 @@
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <config_features.h>
#include <iostream>
#include "mediawindow_impl.hxx"
#include "mediaevent_impl.hxx"
......@@ -83,10 +86,12 @@ MediaChildWindow::MediaChildWindow( Window* pParent ) :
{
}
#if HAVE_FEATURE_GLTF
MediaChildWindow::MediaChildWindow( Window* pParent, SystemWindowData* pData ) :
SystemChildWindow( pParent, WB_CLIPCHILDREN, pData )
{
}
#endif
MediaChildWindow::~MediaChildWindow()
{
......@@ -242,10 +247,12 @@ uno::Reference< media::XPlayer > MediaWindowImpl::createPlayer( const OUString&
xPlayer = createPlayer(rURL, aServiceName, xContext);
}
}
#if HAVE_FEATURE_GLTF
else if ( *pMimeType == AVMEDIA_MIMETYPE_JSON )
{
xPlayer = createPlayer(rURL, AVMEDIA_OPENGL_MANAGER_SERVICE_NAME, xContext);
}
#endif
return xPlayer;
}
......@@ -501,12 +508,14 @@ void MediaWindowImpl::onURLChanged()
{
mpChildWindow.reset(new MediaChildWindow(this) );
}
#if HAVE_FEATURE_GLTF
else if ( m_sMimeType == AVMEDIA_MIMETYPE_JSON )
{
SystemWindowData aWinData = OpenGLContext::generateWinData(this);
mpChildWindow.reset(new MediaChildWindow(this,&aWinData));
mbEventTransparent = false;
}
#endif
if( !mpChildWindow )
return;
mpChildWindow->SetHelpId( HID_AVMEDIA_PLAYERWINDOW );
......
......@@ -137,4 +137,9 @@
*/
#define HAVE_EXPORT_VALIDATION 0
/*
* Whether we have glTF support.
*/
#define HAVE_FEATURE_GLTF 0
#endif
......@@ -10512,12 +10512,18 @@ AC_SUBST(ENABLE_OPENCL)
dnl ===================================================================
dnl Check whether to enable glTF support
dnl ===================================================================
AC_MSG_CHECKING([whether to enable glTF support])
if test "$ENABLE_RELEASE_BUILD" = "TRUE"; then
if test $_os == iOS -o $_os == Android -o $_os = Darwin; then
enable_gltf=no
fi
fi
ENABLE_GLTF=
AC_MSG_CHECKING([whether to enable glTF support])
if test "x$enable_gltf" != "xno"; then
ENABLE_GLTF=TRUE
AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_FEATURE_GLTF,1)
BUILD_TYPE="$BUILD_TYPE LIBGLTF"
if test "$test_freetype" = "no"; then
BUILD_TYPE="$BUILD_TYPE FREETYPE"
......
......@@ -25,6 +25,7 @@
#include <svx/svdotext.hxx>
#include <svx/svdoashp.hxx>
#include <svx/svdograf.hxx>
#include <svx/svdogrp.hxx>
#include <svx/svdomedia.hxx>
#include <svx/svdoole2.hxx>
......@@ -46,6 +47,8 @@
#include <com/sun/star/chart2/data/XDataSequence.hpp>
#include <com/sun/star/chart2/data/XNumericalDataSequence.hpp>
#include <config_features.h>
using namespace ::com::sun::star;
/// Impress import filters tests.
......@@ -715,17 +718,26 @@ void SdFiltersTest::testMediaEmbedding()
const SdrPage *pPage = pDoc->GetPage (1);
CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
#if HAVE_FEATURE_GLTF
// First object is a glTF model
SdrMediaObj *pModelObj = dynamic_cast<SdrMediaObj*>( pPage->GetObj( 1 ));
SdrMediaObj *pModelObj = dynamic_cast<SdrMediaObj*>( pPage->GetObj( 2 ));
CPPUNIT_ASSERT_MESSAGE( "missing model", pModelObj != NULL);
CPPUNIT_ASSERT_EQUAL( OUString( "vnd.sun.star.Package:Model/duck/duck.json" ), pModelObj->getMediaProperties().getURL());
CPPUNIT_ASSERT_EQUAL( OUString( "vnd.sun.star.Package:Model/jeep/jeep.json" ), pModelObj->getMediaProperties().getURL());
CPPUNIT_ASSERT_EQUAL( OUString( "application/vnd.gltf+json" ), pModelObj->getMediaProperties().getMimeType());
#else
// If glTF is not supported, then the fallback image is imported
SdrGrafObj *pGrafic = dynamic_cast<SdrGrafObj*>( pPage->GetObj( 2 ));
CPPUNIT_ASSERT_MESSAGE( "Could not load glTF fallback image", pGrafic != NULL);
CPPUNIT_ASSERT_EQUAL( OUString( "vnd.sun.star.Package:Pictures/jeep.png" ), pGrafic->GetGrafStreamURL());
#endif
// Second object is a sound
SdrMediaObj *pMediaObj = dynamic_cast<SdrMediaObj*>( pPage->GetObj( 2 ));
SdrMediaObj *pMediaObj = dynamic_cast<SdrMediaObj*>( pPage->GetObj( 3 ));
CPPUNIT_ASSERT_MESSAGE( "missing media object", pMediaObj != NULL);
CPPUNIT_ASSERT_EQUAL( OUString( "vnd.sun.star.Package:Media/button-1.wav" ), pMediaObj->getMediaProperties().getURL());
CPPUNIT_ASSERT_EQUAL( OUString( "application/vnd.sun.star.media" ), pMediaObj->getMediaProperties().getMimeType());
xDocShRef->DoClose();
}
void SdFiltersTest::testBnc870237()
......
......@@ -85,6 +85,8 @@
#include <boost/scoped_ptr.hpp>
#include "glob.hrc"
#include <config_features.h>
using namespace com::sun::star;
namespace sd {
......@@ -93,7 +95,6 @@ TYPEINIT1( FuInsertGraphic, FuPoor );
TYPEINIT1( FuInsertClipboard, FuPoor );
TYPEINIT1( FuInsertOLE, FuPoor );
TYPEINIT1( FuInsertAVMedia, FuPoor );
TYPEINIT1( FuInsert3DModel, FuPoor );
FuInsertGraphic::FuInsertGraphic (
ViewShell* pViewSh,
......@@ -763,6 +764,9 @@ void FuInsertAVMedia::DoExecute( SfxRequest& rReq )
}
}
#if HAVE_FEATURE_GLTF
TYPEINIT1( FuInsert3DModel, FuPoor );
FuInsert3DModel::FuInsert3DModel(
ViewShell* pViewSh,
::sd::Window* pWin,
......@@ -826,7 +830,7 @@ void FuInsert3DModel::DoExecute( SfxRequest& )
mpWindow->LeaveWait();
}
}
#endif
} // end of namespace sd
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -21,6 +21,7 @@
#define INCLUDED_SD_SOURCE_UI_INC_FUINSERT_HXX
#include "fupoor.hxx"
#include <config_features.h>
namespace sd {
......@@ -104,7 +105,7 @@ private:
SdDrawDocument* pDoc,
SfxRequest& rReq);
};
#if HAVE_FEATURE_GLTF
class FuInsert3DModel
: public FuPoor
{
......@@ -122,7 +123,7 @@ private:
SdDrawDocument* pDoc,
SfxRequest& rReq);
};
#endif
} // end of namespace sd
#endif
......
......@@ -32,6 +32,8 @@
#include <comphelper/processfactory.hxx>
#include <config_features.h>
#include <editeng/editdata.hxx>
#include <editeng/eeitem.hxx>
#include <editeng/flditem.hxx>
......@@ -1164,7 +1166,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
Invalidate(SID_DRAWTBX_INSERT);
}
break;
#if HAVE_FEATURE_GLTF
case SID_INSERT_3DMODEL:
{
SetCurrentFunction( FuInsert3DModel::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
......@@ -1175,6 +1177,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
Invalidate(SID_DRAWTBX_INSERT);
}
break;
#endif
case SID_COPYOBJECTS:
{
......
......@@ -80,6 +80,8 @@
#include "fubullet.hxx"
#include "fuformatpaintbrush.hxx"
#include <config_features.h>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
......@@ -1658,6 +1660,14 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet )
}
}
#if !HAVE_FEATURE_GLTF
if (SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_INSERT_3DMODEL))
{
rSet.DisableItem(SID_INSERT_3DMODEL);
rSet.Put(SfxVisibilityItem(SID_INSERT_3DMODEL, false));
}
#endif
GetModeSwitchingMenuState (rSet);
}
......
......@@ -61,6 +61,8 @@
#include <svx/svdoashp.hxx>
#include "glob.hrc"
#include <config_features.h>
using namespace com::sun::star;
namespace sd {
......@@ -289,6 +291,7 @@ SdrMediaObj* View::InsertMediaURL( const OUString& rMediaURL, sal_Int8& rAction,
return InsertMediaObj( realURL, "application/vnd.sun.star.media", rAction, rPos, rSize );
}
#if HAVE_FEATURE_GLTF
SdrMediaObj* View::Insert3DModelURL(
const OUString& rModelURL, sal_Int8& rAction,
const Point& rPos, const Size& rSize,
......@@ -313,6 +316,7 @@ SdrMediaObj* View::Insert3DModelURL(
pRetObject->setMediaProperties(aItem);
return pRetObject;
}
#endif
SdrMediaObj* View::InsertMediaObj( const OUString& rMediaURL, const OUString& rMimeType, sal_Int8& rAction,
const Point& rPos, const Size& rSize )
......
......@@ -469,6 +469,7 @@ namespace slideshow
rRangePix.getMinY(),
rRangePix.getMaxX() - rRangePix.getMinX(),
rRangePix.getMaxY() - rRangePix.getMinY() );
#if HAVE_FEATURE_GLTF
if( avmedia::IsModel(rMimeType) )
{
mpEventHandlerParent.reset(new Window(pWindow, WB_NOBORDER|WB_NODIALOGCONTROL));
......@@ -482,6 +483,7 @@ namespace slideshow
Size( aAWTRect.Width, aAWTRect.Height ) );
}
else
#endif
{
mpMediaWindow.reset( new SystemChildWindow( pWindow, WB_CLIPCHILDREN ) );
mpMediaWindow->SetPosSizePixel( Point( aAWTRect.X, aAWTRect.Y ),
......
......@@ -17,6 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <config_features.h>
#include <svx/svdomedia.hxx>
#include <rtl/ustring.hxx>
......@@ -263,6 +265,7 @@ uno::Reference<io::XInputStream> SdrMediaObj::GetInputStream()
return tempFile.openStream();
}
#if HAVE_FEATURE_GLTF
static bool lcl_HandleJsonPackageURL(
const OUString& rURL,
SdrModel* const pModel,
......@@ -321,6 +324,7 @@ static bool lcl_HandleJsonPackageURL(
}
return true;
}
#endif
/// copy a stream from XStorage to temp file
static bool lcl_HandlePackageURL(
......@@ -401,9 +405,11 @@ void SdrMediaObj::mediaPropertiesChanged( const ::avmedia::MediaItem& rNewProper
{
OUString tempFileURL;
bool bSuccess;
#if HAVE_FEATURE_GLTF
if( url.endsWith(".json") )
bSuccess = lcl_HandleJsonPackageURL(url, GetModel(), tempFileURL);
else
#endif
bSuccess = lcl_HandlePackageURL( url, GetModel(), tempFileURL);
if (bSuccess)
{
......
......@@ -114,6 +114,8 @@
#include "XMLImageMapExport.hxx"
#include <boost/scoped_ptr.hpp>
#include <config_features.h>
using namespace ::com::sun::star;
using namespace ::xmloff::EnhancedCustomShapeToken;
using namespace ::xmloff::token;
......@@ -3157,6 +3159,7 @@ lcl_StoreMediaAndGetURL(SvXMLExport & rExport,
}
}
#if HAVE_FEATURE_GLTF
static void lcl_StoreJsonExternalsAndFallback(
SvXMLExport& rExport,
const uno::Reference<beans::XPropertySet> xPropSet,
......@@ -3243,6 +3246,7 @@ static void lcl_StoreJsonExternalsAndFallback(
}
}
}
#endif
void XMLShapeExport::ImpExportMediaShape(
const uno::Reference< drawing::XShape >& xShape,
......@@ -3270,8 +3274,10 @@ void XMLShapeExport::ImpExportMediaShape(
OUString const persistentURL =
lcl_StoreMediaAndGetURL(GetExport(), xPropSet, aMediaURL, sMimeType);
#if HAVE_FEATURE_GLTF
if( sMimeType == "application/vnd.gltf+json" )
lcl_StoreJsonExternalsAndFallback(GetExport(), xPropSet, aMediaURL);
#endif
mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_HREF, persistentURL );
mrExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
......
......@@ -82,6 +82,8 @@
#include <basegfx/polygon/b2dpolypolygontools.hxx>
#include <basegfx/vector/b2dvector.hxx>
#include <config_features.h>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::drawing;
......@@ -3076,10 +3078,12 @@ void SdXMLPluginShapeContext::StartElement( const ::com::sun::star::uno::Referen
if( nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( aLocalName, XML_MIME_TYPE ) )
{
if( xAttrList->getValueByIndex( n ).equalsAscii( "application/vnd.sun.star.media" ) ||
xAttrList->getValueByIndex( n ).equalsAscii( "application/vnd.gltf+json" ))
if( xAttrList->getValueByIndex( n ).equalsAscii( "application/vnd.sun.star.media" ) )
mbMedia = true;
#if HAVE_FEATURE_GLTF
if( xAttrList->getValueByIndex( n ).equalsAscii( "application/vnd.gltf+json" ) )
mbMedia = true;
#endif
// leave this loop
n = nAttrCount - 1;
}
......@@ -3595,6 +3599,7 @@ SvXMLImportContext *SdXMLFrameShapeContext::CreateChildContext( sal_uInt16 nPref
}
}
}
#if HAVE_FEATURE_GLTF
// For glTF models the fallback image is placed before the real shape.
// So we need to remove the fallback image after real shape is detected.
else if ( mxImplContext.Is() && IsXMLToken(mxImplContext->GetLocalName(), XML_IMAGE) &&
......@@ -3607,7 +3612,7 @@ SvXMLImportContext *SdXMLFrameShapeContext::CreateChildContext( sal_uInt16 nPref
if( pContext )
removeGraphicFromImportContext(*mxImplContext);
}
#endif
// call parent for content
if(!pContext)
pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment