Kaydet (Commit) 779ae371 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

reuse OpenGLContext in OGL canvas

The only thing that needs to be reimplemented is the pbuffer based
custom sprite rendering. We should use a FBO with a texture backend
for that. This will also save several OpenGL context switches!

Change-Id: I4aef33ae2499e44c8b5f41c296d8721cb94a37a1
üst a7f3c73f
...@@ -43,12 +43,12 @@ $(eval $(call gb_Library_add_exception_objects,oglcanvas,\ ...@@ -43,12 +43,12 @@ $(eval $(call gb_Library_add_exception_objects,oglcanvas,\
$(eval $(call gb_Library_use_externals,oglcanvas,\ $(eval $(call gb_Library_use_externals,oglcanvas,\
boost_headers \ boost_headers \
glew \
)) ))
ifeq ($(strip $(OS)),MACOSX) ifeq ($(strip $(OS)),MACOSX)
$(eval $(call gb_Library_use_system_darwin_frameworks,oglcanvas,\ $(eval $(call gb_Library_use_system_darwin_frameworks,oglcanvas,\
Cocoa \ Cocoa \
GLUT \
OpenGL \ OpenGL \
)) ))
......
...@@ -25,10 +25,7 @@ ...@@ -25,10 +25,7 @@
#include <basegfx/polygon/b2dpolygontriangulator.hxx> #include <basegfx/polygon/b2dpolygontriangulator.hxx>
#include <basegfx/polygon/b2dpolypolygontools.hxx> #include <basegfx/polygon/b2dpolypolygontools.hxx>
#include <GL/gl.h> #include <GL/glew.h>
#include <GL/glu.h>
#include <GL/glext.h>
using namespace ::com::sun::star; using namespace ::com::sun::star;
...@@ -161,10 +158,10 @@ namespace oglcanvas ...@@ -161,10 +158,10 @@ namespace oglcanvas
// drats. need to render to temp surface before, and then // drats. need to render to temp surface before, and then
// composite that to screen // composite that to screen
// TODO(P3): buffer pbuffer, maybe even keep content // TODO(P3): buffer texture
// (in a texture?) // TODO: moggi: reimplement as FBO with rendering to texture
pBufferContext=maCanvasHelper.getDeviceHelper()->createBufferContext(aSpriteSizePixel); pBufferContext = NULL;
pBufferContext->startBufferRendering(); // pBufferContext->startBufferRendering();
} }
// this ends up in pBufferContext, if that one's "current" // this ends up in pBufferContext, if that one's "current"
......
...@@ -36,9 +36,7 @@ ...@@ -36,9 +36,7 @@
#include "ogl_texturecache.hxx" #include "ogl_texturecache.hxx"
#include "ogl_tools.hxx" #include "ogl_tools.hxx"
#include <GL/gl.h> #include <GL/glew.h>
#include <GL/glu.h>
#include <GL/glext.h>
#include <boost/scoped_array.hpp> #include <boost/scoped_array.hpp>
......
...@@ -22,10 +22,7 @@ ...@@ -22,10 +22,7 @@
#include <com/sun/star/rendering/ARGBColor.hpp> #include <com/sun/star/rendering/ARGBColor.hpp>
#include <GL/gl.h> #include <GL/glew.h>
#include <GL/glu.h>
#include <GL/glext.h>
using namespace ::com::sun::star; using namespace ::com::sun::star;
......
...@@ -27,9 +27,6 @@ ...@@ -27,9 +27,6 @@
#include "ogl_canvascustomsprite.hxx" #include "ogl_canvascustomsprite.hxx"
#include <GL/gl.h>
#include <GL/glext.h>
#define SPRITECANVAS_SERVICE_NAME "com.sun.star.rendering.SpriteCanvas.OGL" #define SPRITECANVAS_SERVICE_NAME "com.sun.star.rendering.SpriteCanvas.OGL"
#define SPRITECANVAS_IMPLEMENTATION_NAME "com.sun.star.comp.rendering.SpriteCanvas.OGL" #define SPRITECANVAS_IMPLEMENTATION_NAME "com.sun.star.comp.rendering.SpriteCanvas.OGL"
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#ifndef INCLUDED_CANVAS_SOURCE_OPENGL_OGL_SPRITEDEVICEHELPER_HXX #ifndef INCLUDED_CANVAS_SOURCE_OPENGL_OGL_SPRITEDEVICEHELPER_HXX
#define INCLUDED_CANVAS_SOURCE_OPENGL_OGL_SPRITEDEVICEHELPER_HXX #define INCLUDED_CANVAS_SOURCE_OPENGL_OGL_SPRITEDEVICEHELPER_HXX
#include <vcl/opengl/OpenGLContext.hxx>
#include <rtl/ref.hxx> #include <rtl/ref.hxx>
#include <canvas/elapsedtime.hxx> #include <canvas/elapsedtime.hxx>
#include <com/sun/star/rendering/XGraphicDevice.hpp> #include <com/sun/star/rendering/XGraphicDevice.hpp>
...@@ -20,7 +22,6 @@ ...@@ -20,7 +22,6 @@
#include <set> #include <set>
class Window; class Window;
class SystemChildWindow; class SystemChildWindow;
namespace basegfx{ class B2IVector; class B2DHomMatrix; } namespace basegfx{ class B2IVector; class B2DHomMatrix; }
...@@ -113,26 +114,11 @@ namespace oglcanvas ...@@ -113,26 +114,11 @@ namespace oglcanvas
/// Get instance of internal texture cache /// Get instance of internal texture cache
TextureCache& getTextureCache() const; TextureCache& getTextureCache() const;
bool activateWindowContext();
// nobody except IBufferContext implementations are supposed
// to use this
bool activatePBufferContext(const ::basegfx::B2IVector& rSize,
unsigned int PBuffer) const;
bool activateWindowContext() const;
bool updatePBufferTexture( const ::basegfx::B2IVector&,
unsigned int ) const;
private: private:
void resize( const ::basegfx::B2IVector& rNewSize ); void resize( const ::basegfx::B2IVector& rNewSize );
void compileShader(unsigned int& o_rShaderHandle,
unsigned int eShaderType,
const char* pShaderSourceCode);
void linkShaders(unsigned int& o_rProgramHandle,
unsigned int nVertexProgramId,
unsigned int nFragmentProgramId);
/** Phyical output device /** Phyical output device
Deliberately not a refcounted reference, because of Deliberately not a refcounted reference, because of
...@@ -149,28 +135,16 @@ namespace oglcanvas ...@@ -149,28 +135,16 @@ namespace oglcanvas
/// For the frame counter timings /// For the frame counter timings
::canvas::tools::ElapsedTime maLastUpdate; ::canvas::tools::ElapsedTime maLastUpdate;
boost::shared_ptr<SystemChildWindow> mpChildWindow;
void* mpDisplay;
void* mpGLContext;
void* mpGLPBufContext;
void* mpFBConfig;
boost::shared_ptr<TextureCache> mpTextureCache; boost::shared_ptr<TextureCache> mpTextureCache;
unsigned int mnDummyVertexProgram;
unsigned int mnLinearTwoColorGradientFragmentProgram;
unsigned int mnLinearMultiColorGradientFragmentProgram;
unsigned int mnRadialTwoColorGradientFragmentProgram;
unsigned int mnRadialMultiColorGradientFragmentProgram;
unsigned int mnRectangularTwoColorGradientFragmentProgram;
unsigned int mnRectangularMultiColorGradientFragmentProgram;
unsigned int mnLinearTwoColorGradientProgram; unsigned int mnLinearTwoColorGradientProgram;
unsigned int mnLinearMultiColorGradientProgram; unsigned int mnLinearMultiColorGradientProgram;
unsigned int mnRadialTwoColorGradientProgram; unsigned int mnRadialTwoColorGradientProgram;
unsigned int mnRadialMultiColorGradientProgram; unsigned int mnRadialMultiColorGradientProgram;
unsigned int mnRectangularTwoColorGradientProgram; unsigned int mnRectangularTwoColorGradientProgram;
unsigned int mnRectangularMultiColorGradientProgram; unsigned int mnRectangularMultiColorGradientProgram;
OpenGLContext maContext;
}; };
} }
......
...@@ -13,9 +13,7 @@ ...@@ -13,9 +13,7 @@
#include <com/sun/star/geometry/IntegerSize2D.hpp> #include <com/sun/star/geometry/IntegerSize2D.hpp>
#include <GL/gl.h> #include <GL/glew.h>
#include <GL/glu.h>
#include <GL/glext.h>
using namespace ::com::sun::star; using namespace ::com::sun::star;
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#define INCLUDED_CANVAS_SOURCE_OPENGL_OGL_TOOLS_HXX #define INCLUDED_CANVAS_SOURCE_OPENGL_OGL_TOOLS_HXX
#include <sal/config.h> #include <sal/config.h>
#include <GL/gl.h> #include <GL/glew.h>
namespace oglcanvas namespace oglcanvas
......
...@@ -10556,8 +10556,7 @@ if test "x$enable_opengl" = "xno"; then ...@@ -10556,8 +10556,7 @@ if test "x$enable_opengl" = "xno"; then
elif test "$_os" = "Darwin"; then elif test "$_os" = "Darwin"; then
# We use frameworks on Mac OS X, no need for detail checks # We use frameworks on Mac OS X, no need for detail checks
ENABLE_OPENGL=TRUE ENABLE_OPENGL=TRUE
ENABLE_OPENGL_CANVAS= ENABLE_OPENGL_CANVAS=TRUE
add_warning "openGL canvas not adapted for Mac yet - disabling"
SYSTEM_MESA_HEADERS=TRUE SYSTEM_MESA_HEADERS=TRUE
AC_MSG_RESULT([yes]) AC_MSG_RESULT([yes])
elif test $_os = WINNT; then elif test $_os = WINNT; then
......
...@@ -162,6 +162,9 @@ public: ...@@ -162,6 +162,9 @@ public:
void setWinSize(const Size& rSize); void setWinSize(const Size& rSize);
GLWindow& getOpenGLWindow() { return m_aGLWin;} GLWindow& getOpenGLWindow() { return m_aGLWin;}
SystemChildWindow* getChildWindow();
const SystemChildWindow* getChildWindow() const;
void renderToFile(); void renderToFile();
bool isInitialized() bool isInitialized()
......
...@@ -898,4 +898,14 @@ void OpenGLContext::show() ...@@ -898,4 +898,14 @@ void OpenGLContext::show()
m_pWindow->Show(); m_pWindow->Show();
} }
SystemChildWindow* OpenGLContext::getChildWindow()
{
return m_pChildWindow;
}
const SystemChildWindow* OpenGLContext::getChildWindow() const
{
return m_pChildWindow;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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