Skip to content

Commit

Permalink
STEP #4 - paint guards & compilation.
Browse files Browse the repository at this point in the history
Change-Id: I57addc1d7d948f7e614526f24cf32181313bda1e
  • Loading branch information
mmeeks committed Nov 30, 2015
1 parent e61d556 commit 61dcd41
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 70 deletions.
6 changes: 1 addition & 5 deletions include/vcl/outdev.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -609,13 +609,9 @@ public:
/**
* Instantiate across a paint operation to defer flushing
* to the end.
*
* NB. holding a handle avoids problems with
* the underlying SalGraphics and it's implementation
* changing.
*/
class PaintScope {
void *pHandle;
VclPtr<OutputDevice> mpDev;
public:
PaintScope(OutputDevice *);
~PaintScope();
Expand Down
6 changes: 3 additions & 3 deletions vcl/inc/openglgdiimpl.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,6 @@ protected:
/// retrieve the default context for offscreen rendering
static rtl::Reference<OpenGLContext> GetDefaultContext();

/// flush contents of the back-buffer to the screen & swap.
void FlushAndSwap();

/// create a new context for rendering to the underlying window
virtual rtl::Reference<OpenGLContext> CreateWinContext() = 0;

Expand Down Expand Up @@ -350,6 +347,9 @@ public:

virtual OpenGLContext *beginPaint() override;
virtual void endPaint() override;

/// flush contents of the back-buffer to the screen & swap.
void flushAndSwap();
private:
};

Expand Down
2 changes: 1 addition & 1 deletion vcl/inc/salgdiimpl.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public:
virtual bool drawGradient(const tools::PolyPolygon& rPolygon, const Gradient& rGradient) = 0;

virtual OpenGLContext *beginPaint() { return nullptr; }
virtual OpenGLContext *endPaint() { }
virtual void endPaint() { }
};

#endif
Expand Down
1 change: 1 addition & 0 deletions vcl/inc/unx/salgdi.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ class VCLPLUG_GEN_PUBLIC X11SalGraphics : public SalGraphics
virtual SystemFontData GetSysFontData( int nFallbackLevel ) const override;

virtual OpenGLContext *BeginPaint() override;
virtual void EndPaint() override;

bool TryRenderCachedNativeControl(ControlCacheKey& aControlCacheKey,
int nX, int nY);
Expand Down
1 change: 1 addition & 0 deletions vcl/inc/win/salgdi.h
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ class WinSalGraphics : public SalGraphics
virtual SystemGraphicsData GetGraphicsData() const override;

virtual OpenGLContext *BeginPaint() override;
virtual void EndPaint() override;

/// Update settings based on the platform values
static void updateSettingsNative( AllSettings& rSettings );
Expand Down
23 changes: 13 additions & 10 deletions vcl/opengl/gdiimpl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ void OpenGLSalGraphicsImpl::Init()
}

if( mpWindowContext.is() )
mpWindowContext.reset();
mpWindowContext->reset();
mpWindowContext = CreateWinContext();
}

Expand Down Expand Up @@ -201,7 +201,7 @@ void OpenGLSalGraphicsImpl::PostDraw()
if (!IsOffscreen())
{
SAL_DEBUG("PostDraw flush ?");
FlushAndSwap();
flushAndSwap();
}
}

Expand Down Expand Up @@ -1877,13 +1877,15 @@ OpenGLContext *OpenGLSalGraphicsImpl::beginPaint()
return mpContext.get();
}

void OpenGLSalGraphicsImpl::FlushAndSwap()
void OpenGLSalGraphicsImpl::flushAndSwap()
{
assert( !IsOffscreen() );
assert( mpContext.is() );

OpenGLZone aZone;

VCL_GL_INFO( "vcl.opengl", "flushAndSwap" );

// glFlush(); - not needed
mpWindowContext->makeCurrent();
CHECK_GL_ERROR();
Expand All @@ -1904,20 +1906,21 @@ void OpenGLSalGraphicsImpl::FlushAndSwap()
pProgram->SetTexture( "sampler", maOffscreenTex );

GLfloat aTexCoord[8];
maOffscreenTex.GetCoord( aTexCoord, rPosAry, false );
maOffscreenTex.GetCoord( aTexCoord, aPosAry, false );
pProgram->SetTextureCoord( aTexCoord );

long nX1( rPosAry.mnDestX );
long nY1( rPosAry.mnDestY );
long nX2( nX1 + rPosAry.mnDestWidth );
long nY2( nY1 + rPosAry.mnDestHeight );
long nX1( aPosAry.mnDestX );
long nY1( aPosAry.mnDestY );
long nX2( nX1 + aPosAry.mnDestWidth );
long nY2( nY1 + aPosAry.mnDestHeight );
const SalPoint aPoints[] = { { nX1, nY2 }, { nX1, nY1 },
{ nX2, nY1 }, { nX2, nY2 }};

sal_uInt32 nPoints = 4;
std::vector<GLfloat> aVertices(nPoints * 2);
sal_uInt32 i, j;

for( i = 0, j = 0; i < 4; i++, j += 2 )
for( i = 0, j = 0; i < nPoints; i++, j += 2 )
{
aVertices[j] = GLfloat(aPoints[i].mnX);
aVertices[j+1] = GLfloat(aPoints[i].mnY);
Expand All @@ -1939,7 +1942,7 @@ void OpenGLSalGraphicsImpl::endPaint()
AcquireContext();
if( mpContext.is() &&
mpContext->mnPainting == 0 )
FlushAndSwap();
flushAndSwap();
}

bool OpenGLSalGraphicsImpl::IsForeignContext(const rtl::Reference<OpenGLContext> &xContext)
Expand Down
51 changes: 0 additions & 51 deletions vcl/source/opengl/OpenGLHelper.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1083,55 +1083,4 @@ GLXFBConfig OpenGLHelper::GetPixmapFBConfig( Display* pDisplay, bool& bInverted

#endif

OutputDevice::PaintScope::PaintScope(OutputDevice *pDev)
: pHandle( nullptr )
{
if( pDev->mpGraphics || pDev->AcquireGraphics() )
{
OpenGLContext *pContext = pDev->mpGraphics->BeginPaint();
/*
if( pContext )
{
assert( pContext->mnPainting >= 0 );
pContext->mnPainting++;
pContext->acquire();
pHandle = static_cast<void *>( pContext );
}
*/
}
}

/**
* Flush all the queued rendering commands to the screen for this context.
*/
void OutputDevice::PaintScope::flush()
{
if( pDev->mpGraphics || pDev->AcquireGraphics() )
pDev->mpGraphics->EndPaint();

#if 0
if( pHandle )
{
OpenGLContext *pContext = static_cast<OpenGLContext *>( pHandle );
pHandle = nullptr;
pContext->mnPainting--;
assert( pContext->mnPainting >= 0 );
if( pContext->mnPainting == 0 )
{
pContext->makeCurrent();
pContext->AcquireDefaultFramebuffer();
glFlush();
pContext->swapBuffers();
CHECK_GL_ERROR();
}
pContext->release();
}
#endif
}

OutputDevice::PaintScope::~PaintScope()
{
flush();
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
22 changes: 22 additions & 0 deletions vcl/source/outdev/outdev.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -845,4 +845,26 @@ bool OutputDevice::DrawEPS( const Point& rPoint, const Size& rSize,
return bDrawn;
}

OutputDevice::PaintScope::PaintScope(OutputDevice *pDev)
: mpDev( pDev )
{
SalGraphics *mpGraphics = mpDev->GetGraphics();
if (mpGraphics)
mpGraphics->BeginPaint();
}

OutputDevice::PaintScope::~PaintScope()
{
flush();
}

/// Flush all the queued rendering commands to the screen for this context.
void OutputDevice::PaintScope::flush()
{
SalGraphics *mpGraphics = mpDev->GetGraphics();
if (mpGraphics)
mpGraphics->EndPaint();
}


/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
5 changes: 5 additions & 0 deletions vcl/unx/generic/gdi/salgdi.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,11 @@ OpenGLContext *X11SalGraphics::BeginPaint()
return mxImpl->beginPaint();
}

void X11SalGraphics::EndPaint()
{
return mxImpl->endPaint();
}

SalGeometryProvider *X11SalGraphics::GetGeometryProvider() const
{
if (m_pFrame)
Expand Down
5 changes: 5 additions & 0 deletions vcl/win/source/gdi/salgdi.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1051,4 +1051,9 @@ OpenGLContext *WinSalGraphics::BeginPaint()
return mpImpl->beginPaint();
}

void WinSalGraphics::EndPaint()
{
return mpImpl->endPaint();
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

0 comments on commit 61dcd41

Please sign in to comment.