Add API to get the number of OpenGL buffer swaps, including through UNO

Change-Id: Iff29ac615ad4b6516790b1cbbde0215a3cd0efe6
This commit is contained in:
Tor Lillqvist
2016-01-26 11:43:50 +02:00
parent 7c151f3914
commit 2c55288357
5 changed files with 42 additions and 1 deletions
+5
View File
@@ -186,6 +186,9 @@ public:
/// reset the GL context so this context is not implicit in subsequent GL calls.
void resetCurrent();
void swapBuffers();
static sal_Int64 getBufferSwapCounter();
void sync();
void show();
@@ -249,6 +252,8 @@ private:
ProgramCollection maPrograms;
OpenGLProgram* mpCurrentProgram;
static sal_Int64 mnBufferSwapCounter;
public:
vcl::Region maClipRegion;
int mnPainting;
@@ -22,6 +22,11 @@ interface XToolkitExperimental : XToolkit2
/** Process all pending idle events
*/
void processEventsToIdle();
/** Get the number of OpenGL buffer swaps.
*/
hyper getOpenGLBufferSwapCounter();
};
}; }; }; };
+4 -1
View File
@@ -21,7 +21,10 @@ $(eval $(call gb_Library_Library,tk))
$(eval $(call gb_Library_set_componentfile,tk,toolkit/util/tk))
$(eval $(call gb_Library_use_external,tk,boost_headers))
$(eval $(call gb_Library_use_externals,tk,\
boost_headers \
glew \
))
$(eval $(call gb_Library_set_include,tk,\
$$(INCLUDE) \
+19
View File
@@ -22,6 +22,13 @@
#include <prewin.h>
#include <postwin.h>
#endif
#if defined UNX && !defined MACOSX
#include <prex.h>
#include "GL/glxew.h"
#include <postx.h>
#undef None // Avoid clash with the one in <toolkit/awt/scrollabledialog.hxx>
#undef Status // Sigh... used for instance as parameter name in css::awt::XImageConsumer
#endif
#include <com/sun/star/awt/WindowAttribute.hpp>
#include <com/sun/star/awt/VclWindowPeerAttribute.hpp>
#include <com/sun/star/awt/WindowClass.hpp>
@@ -113,6 +120,7 @@
#include <vcl/window.hxx>
#include <vcl/wrkwin.hxx>
#include <vcl/throbber.hxx>
#include <vcl/opengl/OpenGLContext.hxx>
#include "toolkit/awt/vclxspinbutton.hxx"
#include <tools/debug.hxx>
#include <comphelper/processfactory.hxx>
@@ -195,6 +203,9 @@ public:
virtual void SAL_CALL processEventsToIdle()
throw (css::uno::RuntimeException, std::exception) override;
virtual sal_Int64 SAL_CALL getOpenGLBufferSwapCounter()
throw (css::uno::RuntimeException, std::exception) override;
// css::awt::XToolkit
css::uno::Reference< css::awt::XWindowPeer > SAL_CALL getDesktopWindow( ) throw(css::uno::RuntimeException, std::exception) override;
css::awt::Rectangle SAL_CALL getWorkArea( ) throw(css::uno::RuntimeException, std::exception) override;
@@ -1906,6 +1917,8 @@ void SAL_CALL VCLXToolkit::reschedule()
Application::Reschedule(true);
}
// css::awt::XToolkitExperimental
void SAL_CALL VCLXToolkit::processEventsToIdle()
throw (css::uno::RuntimeException, std::exception)
{
@@ -1913,6 +1926,12 @@ void SAL_CALL VCLXToolkit::processEventsToIdle()
Scheduler::ProcessEventsToIdle();
}
sal_Int64 SAL_CALL VCLXToolkit::getOpenGLBufferSwapCounter()
throw (css::uno::RuntimeException, std::exception)
{
return OpenGLContext::getBufferSwapCounter();
}
// css:awt:XToolkitRobot
void SAL_CALL VCLXToolkit::keyPress( const css::awt::KeyEvent & aKeyEvent )
+9
View File
@@ -50,6 +50,8 @@ static std::vector<GLXContext> g_vShareList;
static std::vector<HGLRC> g_vShareList;
#endif
sal_Int64 OpenGLContext::mnBufferSwapCounter = 0;
GLWindow::~GLWindow()
{
#if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID && !defined(LIBO_HEADLESS)
@@ -1535,6 +1537,8 @@ void OpenGLContext::swapBuffers()
glXSwapBuffers(m_aGLWin.dpy, m_aGLWin.win);
#endif
mnBufferSwapCounter++;
static bool bSleep = getenv("SAL_GL_SLEEP_ON_SWAP");
if (bSleep)
{
@@ -1544,6 +1548,11 @@ void OpenGLContext::swapBuffers()
}
}
sal_Int64 OpenGLContext::getBufferSwapCounter()
{
return mnBufferSwapCounter;
}
void OpenGLContext::sync()
{
OpenGLZone aZone;