GAL: made Begin/EndDrawing calls public to have more control over timing of rendering context creation/destruction
This commit is contained in:
parent
5750e38102
commit
b59ee13fcc
|
@ -89,13 +89,13 @@ CAIRO_GAL_BASE::~CAIRO_GAL_BASE()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CAIRO_GAL_BASE::beginDrawing()
|
void CAIRO_GAL_BASE::BeginDrawing()
|
||||||
{
|
{
|
||||||
resetContext();
|
resetContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CAIRO_GAL_BASE::endDrawing()
|
void CAIRO_GAL_BASE::EndDrawing()
|
||||||
{
|
{
|
||||||
// Force remaining objects to be drawn
|
// Force remaining objects to be drawn
|
||||||
Flush();
|
Flush();
|
||||||
|
@ -1317,11 +1317,11 @@ CAIRO_GAL::~CAIRO_GAL()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CAIRO_GAL::beginDrawing()
|
void CAIRO_GAL::BeginDrawing()
|
||||||
{
|
{
|
||||||
initSurface();
|
initSurface();
|
||||||
|
|
||||||
CAIRO_GAL_BASE::beginDrawing();
|
CAIRO_GAL_BASE::BeginDrawing();
|
||||||
|
|
||||||
if( !m_validCompositor )
|
if( !m_validCompositor )
|
||||||
setCompositor();
|
setCompositor();
|
||||||
|
@ -1331,9 +1331,9 @@ void CAIRO_GAL::beginDrawing()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CAIRO_GAL::endDrawing()
|
void CAIRO_GAL::EndDrawing()
|
||||||
{
|
{
|
||||||
CAIRO_GAL_BASE::endDrawing();
|
CAIRO_GAL_BASE::EndDrawing();
|
||||||
|
|
||||||
// Merge buffers on the screen
|
// Merge buffers on the screen
|
||||||
m_compositor->DrawBuffer( m_mainBuffer );
|
m_compositor->DrawBuffer( m_mainBuffer );
|
||||||
|
|
|
@ -415,7 +415,7 @@ VECTOR2D OPENGL_GAL::getScreenPixelSize() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OPENGL_GAL::beginDrawing()
|
void OPENGL_GAL::BeginDrawing()
|
||||||
{
|
{
|
||||||
#ifdef KICAD_GAL_PROFILE
|
#ifdef KICAD_GAL_PROFILE
|
||||||
PROF_COUNTER totalRealTime( "OPENGL_GAL::beginDrawing()", true );
|
PROF_COUNTER totalRealTime( "OPENGL_GAL::beginDrawing()", true );
|
||||||
|
@ -573,7 +573,7 @@ void OPENGL_GAL::beginDrawing()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OPENGL_GAL::endDrawing()
|
void OPENGL_GAL::EndDrawing()
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( m_isContextLocked, "What happened to the context lock?" );
|
wxASSERT_MSG( m_isContextLocked, "What happened to the context lock?" );
|
||||||
|
|
||||||
|
@ -614,7 +614,7 @@ void OPENGL_GAL::endDrawing()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OPENGL_GAL::lockContext( int aClientCookie )
|
void OPENGL_GAL::LockContext( int aClientCookie )
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( !m_isContextLocked, "Context already locked." );
|
wxASSERT_MSG( !m_isContextLocked, "Context already locked." );
|
||||||
m_isContextLocked = true;
|
m_isContextLocked = true;
|
||||||
|
@ -624,7 +624,7 @@ void OPENGL_GAL::lockContext( int aClientCookie )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OPENGL_GAL::unlockContext( int aClientCookie )
|
void OPENGL_GAL::UnlockContext( int aClientCookie )
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( m_isContextLocked, "Context not locked. A GAL_CONTEXT_LOCKER RAII object must "
|
wxASSERT_MSG( m_isContextLocked, "Context not locked. A GAL_CONTEXT_LOCKER RAII object must "
|
||||||
"be stacked rather than making separate lock/unlock calls." );
|
"be stacked rather than making separate lock/unlock calls." );
|
||||||
|
|
|
@ -218,6 +218,12 @@ public:
|
||||||
///< @copydoc GAL::DrawGrid()
|
///< @copydoc GAL::DrawGrid()
|
||||||
void DrawGrid() override;
|
void DrawGrid() override;
|
||||||
|
|
||||||
|
/// @copydoc GAL::BeginDrawing()
|
||||||
|
void BeginDrawing() override;
|
||||||
|
|
||||||
|
/// @copydoc GAL::EndDrawing()
|
||||||
|
void EndDrawing() override;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Geometric transforms according to the m_currentWorld2Screen transform matrix:
|
// Geometric transforms according to the m_currentWorld2Screen transform matrix:
|
||||||
|
@ -242,12 +248,6 @@ protected:
|
||||||
*/
|
*/
|
||||||
void arc_angles_xform_and_normalize( double& aStartAngle, double& aEndAngle );
|
void arc_angles_xform_and_normalize( double& aStartAngle, double& aEndAngle );
|
||||||
|
|
||||||
/// @copydoc GAL::BeginDrawing()
|
|
||||||
void beginDrawing() override;
|
|
||||||
|
|
||||||
/// @copydoc GAL::EndDrawing()
|
|
||||||
void endDrawing() override;
|
|
||||||
|
|
||||||
void resetContext();
|
void resetContext();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -425,10 +425,10 @@ public:
|
||||||
bool SetNativeCursorStyle( KICURSOR aCursor ) override;
|
bool SetNativeCursorStyle( KICURSOR aCursor ) override;
|
||||||
|
|
||||||
/// @copydoc GAL::BeginDrawing()
|
/// @copydoc GAL::BeginDrawing()
|
||||||
void beginDrawing() override;
|
void BeginDrawing() override;
|
||||||
|
|
||||||
/// @copydoc GAL::EndDrawing()
|
/// @copydoc GAL::EndDrawing()
|
||||||
void endDrawing() override;
|
void EndDrawing() override;
|
||||||
|
|
||||||
/// Prepare Cairo surfaces for drawing
|
/// Prepare Cairo surfaces for drawing
|
||||||
void initSurface();
|
void initSurface();
|
||||||
|
|
|
@ -1086,12 +1086,26 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Use GAL_CONTEXT_LOCKER RAII object unless you know what you're doing.
|
||||||
|
virtual void LockContext( int aClientCookie ) {}
|
||||||
|
|
||||||
|
virtual void UnlockContext( int aClientCookie ) {}
|
||||||
|
|
||||||
|
/// Start/end drawing functions, draw calls can be only made in between the calls
|
||||||
|
/// to BeginDrawing()/EndDrawing(). Normally you should create a GAL_DRAWING_CONTEXT RAII
|
||||||
|
/// object, but I'm leaving these functions public for more precise (i.e. timing/profiling)
|
||||||
|
/// control of the drawing process - Tom
|
||||||
|
|
||||||
|
/// Begin the drawing, needs to be called for every new frame.
|
||||||
|
/// Use GAL_DRAWING_CONTEXT RAII object unless you know what you're doing.
|
||||||
|
virtual void BeginDrawing() {};
|
||||||
|
|
||||||
|
/// End the drawing, needs to be called for every new frame.
|
||||||
|
/// Use GAL_DRAWING_CONTEXT RAII object unless you know what you're doing.
|
||||||
|
virtual void EndDrawing() {};
|
||||||
protected:
|
protected:
|
||||||
/// Use GAL_CONTEXT_LOCKER RAII object
|
|
||||||
virtual void lockContext( int aClientCookie ) {}
|
|
||||||
|
|
||||||
virtual void unlockContext( int aClientCookie ) {}
|
|
||||||
|
|
||||||
/// Enable item update mode.
|
/// Enable item update mode.
|
||||||
/// Private: use GAL_UPDATE_CONTEXT RAII object
|
/// Private: use GAL_UPDATE_CONTEXT RAII object
|
||||||
virtual void beginUpdate() {}
|
virtual void beginUpdate() {}
|
||||||
|
@ -1099,13 +1113,7 @@ protected:
|
||||||
/// Disable item update mode.
|
/// Disable item update mode.
|
||||||
virtual void endUpdate() {}
|
virtual void endUpdate() {}
|
||||||
|
|
||||||
/// Begin the drawing, needs to be called for every new frame.
|
|
||||||
/// Private: use GAL_DRAWING_CONTEXT RAII object
|
|
||||||
virtual void beginDrawing() {};
|
|
||||||
|
|
||||||
/// End the drawing, needs to be called for every new frame.
|
|
||||||
/// Private: use GAL_DRAWING_CONTEXT RAII object
|
|
||||||
virtual void endDrawing() {};
|
|
||||||
|
|
||||||
/// Compute the scaling factor for the world->screen matrix
|
/// Compute the scaling factor for the world->screen matrix
|
||||||
inline void computeWorldScale()
|
inline void computeWorldScale()
|
||||||
|
@ -1228,12 +1236,12 @@ public:
|
||||||
m_gal( aGal )
|
m_gal( aGal )
|
||||||
{
|
{
|
||||||
m_cookie = rand();
|
m_cookie = rand();
|
||||||
m_gal->lockContext( m_cookie );
|
m_gal->LockContext( m_cookie );
|
||||||
}
|
}
|
||||||
|
|
||||||
~GAL_CONTEXT_LOCKER()
|
~GAL_CONTEXT_LOCKER()
|
||||||
{
|
{
|
||||||
m_gal->unlockContext( m_cookie );
|
m_gal->UnlockContext( m_cookie );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -1264,12 +1272,12 @@ public:
|
||||||
GAL_DRAWING_CONTEXT( GAL* aGal ) :
|
GAL_DRAWING_CONTEXT( GAL* aGal ) :
|
||||||
GAL_CONTEXT_LOCKER( aGal )
|
GAL_CONTEXT_LOCKER( aGal )
|
||||||
{
|
{
|
||||||
m_gal->beginDrawing();
|
m_gal->BeginDrawing();
|
||||||
}
|
}
|
||||||
|
|
||||||
~GAL_DRAWING_CONTEXT()
|
~GAL_DRAWING_CONTEXT()
|
||||||
{
|
{
|
||||||
m_gal->endDrawing();
|
m_gal->EndDrawing();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -289,6 +289,16 @@ public:
|
||||||
return m_isContextLocked;
|
return m_isContextLocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LockContext( int aClientCookie ) override;
|
||||||
|
|
||||||
|
void UnlockContext( int aClientCookie ) override;
|
||||||
|
|
||||||
|
/// @copydoc GAL::BeginDrawing()
|
||||||
|
void BeginDrawing() override;
|
||||||
|
|
||||||
|
/// @copydoc GAL::EndDrawing()
|
||||||
|
void EndDrawing() override;
|
||||||
|
|
||||||
///< Parameters passed to the GLU tesselator
|
///< Parameters passed to the GLU tesselator
|
||||||
struct TessParams
|
struct TessParams
|
||||||
{
|
{
|
||||||
|
@ -354,22 +364,12 @@ private:
|
||||||
GLUtesselator* m_tesselator;
|
GLUtesselator* m_tesselator;
|
||||||
std::deque< boost::shared_array<GLdouble> > m_tessIntersects;
|
std::deque< boost::shared_array<GLdouble> > m_tessIntersects;
|
||||||
|
|
||||||
void lockContext( int aClientCookie ) override;
|
|
||||||
|
|
||||||
void unlockContext( int aClientCookie ) override;
|
|
||||||
|
|
||||||
/// @copydoc GAL::BeginUpdate()
|
/// @copydoc GAL::BeginUpdate()
|
||||||
void beginUpdate() override;
|
void beginUpdate() override;
|
||||||
|
|
||||||
/// @copydoc GAL::EndUpdate()
|
/// @copydoc GAL::EndUpdate()
|
||||||
void endUpdate() override;
|
void endUpdate() override;
|
||||||
|
|
||||||
/// @copydoc GAL::BeginDrawing()
|
|
||||||
void beginDrawing() override;
|
|
||||||
|
|
||||||
/// @copydoc GAL::EndDrawing()
|
|
||||||
void endDrawing() override;
|
|
||||||
|
|
||||||
///< Update handler for OpenGL settings
|
///< Update handler for OpenGL settings
|
||||||
bool updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions ) override;
|
bool updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions ) override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue