Kaydet (Commit) c64a7ce1 authored tarafından Miklos Vajna's avatar Miklos Vajna

Resolves: tdf#92982 vcl rendercontext: handle buffered paint of vcl::Cursor

Instead of painting on the vcl::Window directly, take a
PaintBufferGuard, and use the vcl::RenderContext of it, that may be
either the vcl::Window or the toplevel frame's buffer.

Trigger the paint of the buffer by informing the guard what area was
painted. In case of direct painting, both the ctor and the dtor of the
guard is a NOP.

This means that finally we can also assert Invert() calls on the output
device, so that direct paint can't happen when double-buffering.

Change-Id: I0322563369dc63b3c49061cbe7c4a911cb13a2e2
üst a6c7a0bf
...@@ -398,6 +398,8 @@ public: ...@@ -398,6 +398,8 @@ public:
~PaintBufferGuard(); ~PaintBufferGuard();
/// If this is called, then the dtor will also copy rRectangle to the window from the buffer, before restoring the state. /// If this is called, then the dtor will also copy rRectangle to the window from the buffer, before restoring the state.
void SetPaintRect(const Rectangle& rRectangle); void SetPaintRect(const Rectangle& rRectangle);
/// Returns either the frame's buffer or the window, in case of no buffering.
vcl::RenderContext* GetRenderContext();
}; };
// helper methods // helper methods
......
...@@ -131,6 +131,7 @@ void OutputDevice::DrawRect( const Rectangle& rRect, ...@@ -131,6 +131,7 @@ void OutputDevice::DrawRect( const Rectangle& rRect,
void OutputDevice::Invert( const Rectangle& rRect, InvertFlags nFlags ) void OutputDevice::Invert( const Rectangle& rRect, InvertFlags nFlags )
{ {
assert(!is_double_buffered_window());
if ( !IsDeviceOutputNecessary() ) if ( !IsDeviceOutputNecessary() )
return; return;
...@@ -163,6 +164,7 @@ void OutputDevice::Invert( const Rectangle& rRect, InvertFlags nFlags ) ...@@ -163,6 +164,7 @@ void OutputDevice::Invert( const Rectangle& rRect, InvertFlags nFlags )
void OutputDevice::Invert( const Polygon& rPoly, InvertFlags nFlags ) void OutputDevice::Invert( const Polygon& rPoly, InvertFlags nFlags )
{ {
assert(!is_double_buffered_window());
if ( !IsDeviceOutputNecessary() ) if ( !IsDeviceOutputNecessary() )
return; return;
......
...@@ -44,7 +44,9 @@ struct ImplCursorData ...@@ -44,7 +44,9 @@ struct ImplCursorData
static void ImplCursorInvert( ImplCursorData* pData ) static void ImplCursorInvert( ImplCursorData* pData )
{ {
vcl::Window* pWindow = pData->mpWindow; vcl::Window* pWindow = pData->mpWindow;
vcl::RenderContext* pRenderContext = pWindow->GetOutDev(); PaintBufferGuard aGuard(pWindow->ImplGetWindowImpl()->mpFrameData, pWindow);
vcl::RenderContext* pRenderContext = aGuard.GetRenderContext();
Rectangle aPaintRect;
bool bMapMode = pRenderContext->IsMapModeEnabled(); bool bMapMode = pRenderContext->IsMapModeEnabled();
pRenderContext->EnableMapMode( false ); pRenderContext->EnableMapMode( false );
InvertFlags nInvertStyle; InvertFlags nInvertStyle;
...@@ -109,11 +111,16 @@ static void ImplCursorInvert( ImplCursorData* pData ) ...@@ -109,11 +111,16 @@ static void ImplCursorInvert( ImplCursorData* pData )
if ( pData->mnOrientation ) if ( pData->mnOrientation )
aPoly.Rotate( pData->maPixRotOff, pData->mnOrientation ); aPoly.Rotate( pData->maPixRotOff, pData->mnOrientation );
pRenderContext->Invert( aPoly, nInvertStyle ); pRenderContext->Invert( aPoly, nInvertStyle );
aPaintRect = aPoly.GetBoundRect();
} }
} }
else else
{
pRenderContext->Invert( aRect, nInvertStyle ); pRenderContext->Invert( aRect, nInvertStyle );
aPaintRect = aRect;
}
pRenderContext->EnableMapMode( bMapMode ); pRenderContext->EnableMapMode( bMapMode );
aGuard.SetPaintRect(pRenderContext->PixelToLogic(aPaintRect));
} }
void vcl::Cursor::ImplDraw() void vcl::Cursor::ImplDraw()
......
...@@ -151,6 +151,14 @@ void PaintBufferGuard::SetPaintRect(const Rectangle& rRectangle) ...@@ -151,6 +151,14 @@ void PaintBufferGuard::SetPaintRect(const Rectangle& rRectangle)
m_aPaintRect = rRectangle; m_aPaintRect = rRectangle;
} }
vcl::RenderContext* PaintBufferGuard::GetRenderContext()
{
if (mpFrameData->mpBuffer)
return mpFrameData->mpBuffer;
else
return m_pWindow;
}
class PaintHelper class PaintHelper
{ {
private: private:
......
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