Kaydet (Commit) 7070318e authored tarafından Markus Mohrhard's avatar Markus Mohrhard

it builds again

Change-Id: I969ff5ed6fd979e9fd126e8d0b79a518697e7915
üst e8575148
...@@ -24,6 +24,7 @@ $(eval $(call gb_Library_use_libraries,chartopengl,\ ...@@ -24,6 +24,7 @@ $(eval $(call gb_Library_use_libraries,chartopengl,\
cppu \ cppu \
cppuhelper \ cppuhelper \
sal \ sal \
vcl \
$(gb_UWINAPI) \ $(gb_UWINAPI) \
)) ))
...@@ -43,6 +44,8 @@ else ifeq ($(OS),LINUX) ...@@ -43,6 +44,8 @@ else ifeq ($(OS),LINUX)
$(eval $(call gb_Library_add_libs,chartopengl,\ $(eval $(call gb_Library_add_libs,chartopengl,\
-ldl \ -ldl \
-lGL \ -lGL \
-lGLU \
-lX11 \
)) ))
endif endif
......
...@@ -227,6 +227,8 @@ public: ...@@ -227,6 +227,8 @@ public:
getOrCreateChartRootShape( const ::com::sun::star::uno::Reference< getOrCreateChartRootShape( const ::com::sun::star::uno::Reference<
::com::sun::star::drawing::XDrawPage>& xPage ) = 0; ::com::sun::star::drawing::XDrawPage>& xPage ) = 0;
virtual void setPageSize( com::sun::star::uno::Reference < com::sun::star::drawing::XShapes > xChartShapes, const com::sun::star::awt::Size& rSize ) = 0;
virtual void createSeries( const com::sun::star::uno::Reference< virtual void createSeries( const com::sun::star::uno::Reference<
com::sun::star::drawing::XShapes> & xTarget, com::sun::star::drawing::XShapes> & xTarget,
......
...@@ -56,6 +56,39 @@ ...@@ -56,6 +56,39 @@
#include <vector> #include <vector>
#include <map> #include <map>
#include <boost/scoped_ptr.hpp>
#include <GL/gl.h>
#include <GL/glu.h>
#include <vcl/window.hxx>
#include <vcl/syschild.hxx>
#include <vcl/sysdata.hxx>
#if defined( _WIN32 )
#include <GL/glu.h>
#include <GL/glext.h>
#include <GL/wglext.h>
#elif defined( MACOSX )
#include "premac.h"
#include <Cocoa/Cocoa.h>
#include "postmac.h"
#elif defined( UNX )
#include <GL/glu.h>
#include <GL/glext.h>
namespace unx
{
#include <X11/keysym.h>
#include <X11/X.h>
#define GLX_GLXEXT_PROTOTYPES 1
#include <GL/glx.h>
#include <GL/glxext.h>
}
#endif
class SystemWindow;
class SystemChildWindow;
using namespace com::sun::star; using namespace com::sun::star;
...@@ -354,12 +387,53 @@ private: ...@@ -354,12 +387,53 @@ private:
class DummyChart : public DummyXShapes class DummyChart : public DummyXShapes
{ {
public: public:
DummyChart();
virtual DummyChart* getRootShape(); virtual DummyChart* getRootShape();
OpenglContext* getGlContext() { return mpContext; } OpenglContext* getGlContext() { return mpContext; }
virtual void SAL_CALL setPosition( const ::com::sun::star::awt::Point& aPosition ) throw(::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setSize( const ::com::sun::star::awt::Size& aSize ) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::uno::RuntimeException);
private: private:
/// Holds the information of our new child window
struct GLWindow
{
#if defined( _WIN32 )
HWND hWnd;
HDC hDC;
HGLRC hRC;
#elif defined( MACOSX )
#elif defined( UNX )
unx::Display* dpy;
int screen;
unx::Window win;
#if defined( GLX_VERSION_1_3 ) && defined( GLX_EXT_texture_from_pixmap )
unx::GLXFBConfig fbc;
#endif
unx::XVisualInfo* vi;
unx::GLXContext ctx;
bool HasGLXExtension( const char* name ) { return gluCheckExtension( (const GLubyte*) name, (const GLubyte*) GLXExtensions ); }
const char* GLXExtensions;
#endif
unsigned int bpp;
unsigned int Width;
unsigned int Height;
const GLubyte* GLExtensions;
bool HasGLExtension( const char* name ) { return gluCheckExtension( (const GLubyte*) name, GLExtensions ); }
} GLWin; /// Holds the information of our new child window
void createGLContext();
bool initWindow();
bool initOpengl();
OpenglContext* mpContext; OpenglContext* mpContext;
boost::scoped_ptr<Window> mpWindow;
boost::scoped_ptr<SystemChildWindow> pWindow;
}; };
class DummyGroup2D : public DummyXShapes class DummyGroup2D : public DummyXShapes
......
...@@ -187,6 +187,9 @@ public: ...@@ -187,6 +187,9 @@ public:
virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >
getOrCreateChartRootShape( const ::com::sun::star::uno::Reference< getOrCreateChartRootShape( const ::com::sun::star::uno::Reference<
::com::sun::star::drawing::XDrawPage>& xPage ); ::com::sun::star::drawing::XDrawPage>& xPage );
virtual void setPageSize( com::sun::star::uno::Reference < com::sun::star::drawing::XShapes > xChartShapes, const com::sun::star::awt::Size& rSize );
}; };
} }
......
...@@ -203,6 +203,8 @@ public: ...@@ -203,6 +203,8 @@ public:
getOrCreateChartRootShape( const ::com::sun::star::uno::Reference< getOrCreateChartRootShape( const ::com::sun::star::uno::Reference<
::com::sun::star::drawing::XDrawPage>& xPage ); ::com::sun::star::drawing::XDrawPage>& xPage );
virtual void setPageSize( com::sun::star::uno::Reference < com::sun::star::drawing::XShapes > xChartShapes, const com::sun::star::awt::Size& rSize );
private: private:
ShapeFactory(); ShapeFactory();
......
...@@ -2398,6 +2398,7 @@ void ChartView::createShapes() ...@@ -2398,6 +2398,7 @@ void ChartView::createShapes()
{ {
OSL_FAIL("could not set page size correctly"); OSL_FAIL("could not set page size correctly");
} }
pShapeFactory->setPageSize(xPageShapes, aPageSize);
{ {
SolarMutexGuard aSolarGuard; SolarMutexGuard aSolarGuard;
......
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
#include "CommonConverters.hxx" #include "CommonConverters.hxx"
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <vcl/window.hxx>
#include <tools/gen.hxx>
#include <algorithm> #include <algorithm>
using namespace com::sun::star; using namespace com::sun::star;
...@@ -462,6 +465,362 @@ uno::Any DummyXShapes::getByIndex(sal_Int32 nIndex) ...@@ -462,6 +465,362 @@ uno::Any DummyXShapes::getByIndex(sal_Int32 nIndex)
return aShape; return aShape;
} }
bool DummyChart::initWindow()
{
const SystemEnvData* sysData(mpWindow->GetSystemData());
#if defined( WNT )
GLWin.hWnd = sysData->hWnd;
#elif defined( UNX )
GLWin.dpy = reinterpret_cast<unx::Display*>(sysData->pDisplay);
if( unx::glXQueryExtension( GLWin.dpy, NULL, NULL ) == false )
return false;
GLWin.win = sysData->aWindow;
OSL_TRACE("parent window: %d", GLWin.win);
unx::XWindowAttributes xattr;
unx::XGetWindowAttributes( GLWin.dpy, GLWin.win, &xattr );
GLWin.screen = XScreenNumberOfScreen( xattr.screen );
unx::XVisualInfo* vi( NULL );
#if defined( GLX_VERSION_1_3 ) && defined( GLX_EXT_texture_from_pixmap )
unx::XVisualInfo* visinfo;
unx::XVisualInfo* firstVisual( NULL );
#endif
static int attrList3[] =
{
GLX_RGBA,//only TrueColor or DirectColor
//single buffered
GLX_RED_SIZE,4,//use the maximum red bits, with a minimum of 4 bits
GLX_GREEN_SIZE,4,//use the maximum green bits, with a minimum of 4 bits
GLX_BLUE_SIZE,4,//use the maximum blue bits, with a minimum of 4 bits
GLX_DEPTH_SIZE,0,//no depth buffer
None
};
static int attrList2[] =
{
GLX_RGBA,//only TrueColor or DirectColor
/// single buffered
GLX_RED_SIZE,4,/// use the maximum red bits, with a minimum of 4 bits
GLX_GREEN_SIZE,4,/// use the maximum green bits, with a minimum of 4 bits
GLX_BLUE_SIZE,4,/// use the maximum blue bits, with a minimum of 4 bits
GLX_DEPTH_SIZE,1,/// use the maximum depth bits, making sure there is a depth buffer
None
};
static int attrList1[] =
{
GLX_RGBA,//only TrueColor or DirectColor
GLX_DOUBLEBUFFER,/// only double buffer
GLX_RED_SIZE,4,/// use the maximum red bits, with a minimum of 4 bits
GLX_GREEN_SIZE,4,/// use the maximum green bits, with a minimum of 4 bits
GLX_BLUE_SIZE,4,/// use the maximum blue bits, with a minimum of 4 bits
GLX_DEPTH_SIZE,0,/// no depth buffer
None
};
static int attrList0[] =
{
GLX_RGBA,//only TrueColor or DirectColor
GLX_DOUBLEBUFFER,/// only double buffer
GLX_RED_SIZE,4,/// use the maximum red bits, with a minimum of 4 bits
GLX_GREEN_SIZE,4,/// use the maximum green bits, with a minimum of 4 bits
GLX_BLUE_SIZE,4,/// use the maximum blue bits, with a minimum of 4 bits
GLX_DEPTH_SIZE,1,/// use the maximum depth bits, making sure there is a depth buffer
None
};
static int* attrTable[] =
{
attrList0,
attrList1,
attrList2,
attrList3,
NULL
};
int** pAttributeTable = attrTable;
const SystemEnvData* pChildSysData = NULL;
pWindow.reset();
#if defined( GLX_VERSION_1_3 ) && defined( GLX_EXT_texture_from_pixmap )
unx::GLXFBConfig* fbconfigs = NULL;
int nfbconfigs, value, i = 0;
#endif
while( *pAttributeTable )
{
// try to find a visual for the current set of attributes
vi = unx::glXChooseVisual( GLWin.dpy,
GLWin.screen,
*pAttributeTable );
#if defined( GLX_VERSION_1_3 ) && defined( GLX_EXT_texture_from_pixmap )
if( vi ) {
if( !firstVisual )
firstVisual = vi;
OSL_TRACE("trying VisualID %08X", vi->visualid);
fbconfigs = glXGetFBConfigs (GLWin.dpy, GLWin.screen, &nfbconfigs);
for ( ; i < nfbconfigs; i++)
{
visinfo = glXGetVisualFromFBConfig (GLWin.dpy, fbconfigs[i]);
if( !visinfo || visinfo->visualid != vi->visualid )
continue;
glXGetFBConfigAttrib (GLWin.dpy, fbconfigs[i], GLX_DRAWABLE_TYPE, &value);
if (!(value & GLX_PIXMAP_BIT))
continue;
glXGetFBConfigAttrib (GLWin.dpy, fbconfigs[i],
GLX_BIND_TO_TEXTURE_TARGETS_EXT,
&value);
if (!(value & GLX_TEXTURE_2D_BIT_EXT))
continue;
glXGetFBConfigAttrib (GLWin.dpy, fbconfigs[i],
GLX_BIND_TO_TEXTURE_RGB_EXT,
&value);
if (value == sal_False)
continue;
glXGetFBConfigAttrib (GLWin.dpy, fbconfigs[i],
GLX_BIND_TO_MIPMAP_TEXTURE_EXT,
&value);
if (value == sal_False)
continue;
// TODO: handle non Y inverted cases
break;
}
if( i != nfbconfigs || ( firstVisual && pAttributeTable[1] == NULL ) ) {
if( i != nfbconfigs ) {
vi = glXGetVisualFromFBConfig( GLWin.dpy, fbconfigs[i] );
// TODO:moggi
// mbHasTFPVisual = true;
OSL_TRACE("found visual suitable for texture_from_pixmap");
} else {
vi = firstVisual;
// TODO:moggi
// mbHasTFPVisual = false;
OSL_TRACE("did not find visual suitable for texture_from_pixmap, using %08X", vi->visualid);
}
#else
if( vi ) {
#endif
SystemWindowData winData;
winData.nSize = sizeof(winData);
OSL_TRACE("using VisualID %08X", vi->visualid);
winData.pVisual = (void*)(vi->visual);
pWindow.reset(new SystemChildWindow(mpWindow.get(), 0, &winData, sal_False));
pChildSysData = pWindow->GetSystemData();
if( pChildSysData ) {
break;
} else {
pWindow.reset();
}
}
#if defined( GLX_VERSION_1_3 ) && defined( GLX_EXT_texture_from_pixmap )
}
#endif
++pAttributeTable;
}
#endif
#if defined( WNT )
SystemWindowData winData;
winData.nSize = sizeof(winData);
pWindow.reset(new SystemChildWindow(mpWindow.get(), 0, &winData, sal_False));
#endif
if( pWindow )
{
pWindow->SetMouseTransparent( sal_True );
pWindow->SetParentClipMode( PARENTCLIPMODE_NOCLIP );
pWindow->EnableEraseBackground( sal_False );
pWindow->SetControlForeground();
pWindow->SetControlBackground();
pWindow->EnablePaint(sal_False);
#if defined( WNT )
GLWin.hWnd = sysData->hWnd;
#elif defined( UNX )
GLWin.dpy = reinterpret_cast<unx::Display*>(pChildSysData->pDisplay);
GLWin.win = pChildSysData->aWindow;
#if defined( GLX_VERSION_1_3 ) && defined( GLX_EXT_texture_from_pixmap )
//TODO: moggi
/*
if( mbHasTFPVisual )
GLWin.fbc = fbconfigs[i];
*/
#endif
GLWin.vi = vi;
GLWin.GLXExtensions = unx::glXQueryExtensionsString( GLWin.dpy, GLWin.screen );
OSL_TRACE("available GLX extensions: %s", GLWin.GLXExtensions);
#endif
return false;
}
return true;
}
namespace {
static bool errorTriggered;
int oglErrorHandler( unx::Display* /*dpy*/, unx::XErrorEvent* /*evnt*/ )
{
errorTriggered = true;
return 0;
}
}
bool DummyChart::initOpengl()
{
mpWindow->setPosSizePixel(0,0,0,0);
GLWin.Width = 0;
GLWin.Height = 0;
#if defined( WNT )
GLWin.hDC = GetDC(GLWin.hWnd);
#elif defined( UNX )
GLWin.ctx = glXCreateContext(GLWin.dpy,
GLWin.vi,
0,
GL_TRUE);
if( GLWin.ctx == NULL )
{
OSL_TRACE("unable to create GLX context");
return false;
}
#endif
#if defined( WNT )
PIXELFORMATDESCRIPTOR PixelFormatFront = // PixelFormat Tells Windows How We Want Things To Be
{
sizeof(PIXELFORMATDESCRIPTOR),
1, // Version Number
PFD_DRAW_TO_WINDOW |
PFD_SUPPORT_OPENGL |
PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA, // Request An RGBA Format
(BYTE)32, // Select Our Color Depth
0, 0, 0, 0, 0, 0, // Color Bits Ignored
0, // No Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
64, // 32 bit Z-BUFFER
0, // 0 bit stencil buffer
0, // No Auxiliary Buffer
0, // now ignored
0, // Reserved
0, 0, 0 // Layer Masks Ignored
};
int WindowPix = ChoosePixelFormat(GLWin.hDC,&PixelFormatFront);
SetPixelFormat(GLWin.hDC,WindowPix,&PixelFormatFront);
GLWin.hRC = wglCreateContext(GLWin.hDC);
wglMakeCurrent(GLWin.hDC,GLWin.hRC);
#elif defined( UNX )
if( !glXMakeCurrent( GLWin.dpy, GLWin.win, GLWin.ctx ) )
{
OSL_TRACE("unable to select current GLX context");
return false;
}
int glxMinor, glxMajor;
double nGLXVersion = 0;
if( glXQueryVersion( GLWin.dpy, &glxMajor, &glxMinor ) )
nGLXVersion = glxMajor + 0.1*glxMinor;
OSL_TRACE("available GLX version: %f", nGLXVersion);
GLWin.GLExtensions = glGetString( GL_EXTENSIONS );
OSL_TRACE("available GL extensions: %s", GLWin.GLExtensions);
// TODO: moggi
// mbTextureFromPixmap = GLWin.HasGLXExtension( "GLX_EXT_texture_from_pixmap" );
// mbGenerateMipmap = GLWin.HasGLExtension( "GL_SGIS_generate_mipmap" );
if( GLWin.HasGLXExtension("GLX_SGI_swap_control" ) )
{
// enable vsync
typedef GLint (*glXSwapIntervalProc)(GLint);
glXSwapIntervalProc glXSwapInterval = (glXSwapIntervalProc) unx::glXGetProcAddress( (const GLubyte*) "glXSwapIntervalSGI" );
if( glXSwapInterval ) {
int (*oldHandler)(unx::Display* /*dpy*/, unx::XErrorEvent* /*evnt*/);
// replace error handler temporarily
oldHandler = unx::XSetErrorHandler( oglErrorHandler );
errorTriggered = false;
glXSwapInterval( 1 );
// sync so that we possibly get an XError
unx::glXWaitGL();
XSync(GLWin.dpy, false);
if( errorTriggered )
OSL_TRACE("error when trying to set swap interval, NVIDIA or Mesa bug?");
else
OSL_TRACE("set swap interval to 1 (enable vsync)");
// restore the error handler
unx::XSetErrorHandler( oldHandler );
}
}
#endif
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glClearColor (0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
#if defined( WNT )
SwapBuffers(GLWin.hDC);
#elif defined( UNX )
unx::glXSwapBuffers(GLWin.dpy, GLWin.win);
#endif
glEnable(GL_LIGHTING);
GLfloat light_direction[] = { 0.0 , 0.0 , 1.0 };
GLfloat materialDiffuse[] = { 1.0 , 1.0 , 1.0 , 1.0};
glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, light_direction);
glMaterialfv(GL_FRONT,GL_DIFFUSE,materialDiffuse);
glEnable(GL_LIGHT0);
glEnable(GL_NORMALIZE);
return true;
}
DummyChart::DummyChart():
mpWindow(new Window(0, WB_NOBORDER|WB_NODIALOGCONTROL))
{
setName("com.sun.star.chart2.shapes");
createGLContext();
}
void DummyChart::createGLContext()
{
}
void DummyChart::setPosition( const awt::Point& aPosition )
throw( uno::RuntimeException )
{
DummyXShape::setPosition(aPosition);
}
void DummyChart::setSize( const awt::Size& aSize )
throw( beans::PropertyVetoException, uno::RuntimeException )
{
DummyXShape::setSize(aSize);
mpWindow->SetSizePixel(Size(aSize.Width, aSize.Height));
pWindow->SetSizePixel(Size(aSize.Width, aSize.Height));
}
} }
} }
......
...@@ -77,10 +77,56 @@ using dummy::DummyCone; ...@@ -77,10 +77,56 @@ using dummy::DummyCone;
namespace opengl { namespace opengl {
namespace {
uno::Reference< drawing::XShapes > getChartShape(
const uno::Reference< drawing::XDrawPage>& xDrawPage )
{
uno::Reference< drawing::XShapes > xRet;
uno::Reference< drawing::XShapes > xShapes( xDrawPage, uno::UNO_QUERY );
if( xShapes.is() )
{
sal_Int32 nCount = xShapes->getCount();
uno::Reference< drawing::XShape > xShape;
for( sal_Int32 nN = nCount; nN--; )
{
if( xShapes->getByIndex( nN ) >>= xShape )
{
OUString aRet;
uno::Reference< beans::XPropertySet > xProp( xShape, uno::UNO_QUERY );
xProp->getPropertyValue( UNO_NAME_MISC_OBJ_NAME ) >>= aRet;
if( aRet.equals("com.sun.star.chart2.shapes") )
{
xRet = uno::Reference< drawing::XShapes >( xShape, uno::UNO_QUERY );
break;
}
}
}
}
return xRet;
}
}
uno::Reference< drawing::XShapes > OpenglShapeFactory::getOrCreateChartRootShape( uno::Reference< drawing::XShapes > OpenglShapeFactory::getOrCreateChartRootShape(
const uno::Reference< drawing::XDrawPage>& ) const uno::Reference< drawing::XDrawPage>& xDrawPage )
{
uno::Reference< drawing::XShapes > xRet( getChartShape( xDrawPage ) );
if( !xRet.is() )
{
//create the root shape
xRet = new dummy::DummyChart();
xDrawPage->add(uno::Reference< drawing::XShape >(xRet, uno::UNO_QUERY_THROW));
}
return xRet;
}
void OpenglShapeFactory::setPageSize( uno::Reference < drawing::XShapes > xChartShapes, const awt::Size& rSize )
{ {
return new dummy::DummyChart(); uno::Reference< drawing::XShape > xShape(xChartShapes, uno::UNO_QUERY_THROW);
xShape->setSize(rSize);
} }
// methods for 3D shape creation // methods for 3D shape creation
......
...@@ -74,6 +74,10 @@ uno::Reference< drawing::XShapes > ShapeFactory::getOrCreateChartRootShape( ...@@ -74,6 +74,10 @@ uno::Reference< drawing::XShapes > ShapeFactory::getOrCreateChartRootShape(
return xRet; return xRet;
} }
void ShapeFactory::setPageSize(uno::Reference< drawing::XShapes >, const awt::Size& )
{
}
// diverse PolyPolygon create methods // diverse PolyPolygon create methods
uno::Any createPolyPolygon_Cube( uno::Any createPolyPolygon_Cube(
......
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