Kaydet (Commit) 9d64cdc4 authored tarafından Chris Sherlock's avatar Chris Sherlock Kaydeden (comit) Caolán McNamara

Seperate initialization of OutputDevice instance

I have split OutputDevice::ImplInitGraphics() from
OutputDevice::ImplGetGraphics(). In future, we need to further
seperate out this initialization function into it's own seperate
classes. Note that ImplGetGraphics still initializes if mpGraphics
is not set.

Change-Id: I17d4778f735aa9d03bf9b37079a9d695bf95866b
Reviewed-on: https://gerrit.libreoffice.org/7777Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 4a1bb120
...@@ -359,9 +359,18 @@ public: ...@@ -359,9 +359,18 @@ public:
/** Get the graphic context that the output device uses to draw on. /** Get the graphic context that the output device uses to draw on.
If no graphics device exists, then initialize it.
@returns SalGraphics instance. @returns SalGraphics instance.
*/ */
SAL_DLLPRIVATE SalGraphics* ImplGetGraphics() const; SAL_DLLPRIVATE SalGraphics const *ImplGetGraphics() const;
SAL_DLLPRIVATE SalGraphics* ImplGetGraphics();
/** Initialize the graphics device that the output device uses to draw on.
@returns true if was able to initialize the graphics device, false otherwise.
*/
SAL_DLLPRIVATE bool ImplInitGraphics() const;
/** Release the graphics device, and remove it from the graphics device /** Release the graphics device, and remove it from the graphics device
list. list.
......
...@@ -183,7 +183,7 @@ bool OutputDevice::ImplSelectClipRegion( const Region& rRegion, SalGraphics* pGr ...@@ -183,7 +183,7 @@ bool OutputDevice::ImplSelectClipRegion( const Region& rRegion, SalGraphics* pGr
if( !pGraphics ) if( !pGraphics )
{ {
if( !mpGraphics ) if( !mpGraphics )
if( !ImplGetGraphics() ) if( !ImplInitGraphics() )
return false; return false;
pGraphics = mpGraphics; pGraphics = mpGraphics;
} }
...@@ -520,12 +520,39 @@ void OutputDevice::ReMirror( Region &rRegion ) const ...@@ -520,12 +520,39 @@ void OutputDevice::ReMirror( Region &rRegion ) const
} }
SalGraphics* OutputDevice::ImplGetGraphics() const SalGraphics* OutputDevice::ImplGetGraphics()
{ {
DBG_TESTSOLARMUTEX(); DBG_TESTSOLARMUTEX();
if ( mpGraphics ) if ( !mpGraphics )
return mpGraphics; {
if ( !ImplInitGraphics() )
{
SAL_WARN("vcl", "No mpGraphics set");
}
}
return mpGraphics;
}
SalGraphics const *OutputDevice::ImplGetGraphics() const
{
DBG_TESTSOLARMUTEX();
if ( !mpGraphics )
{
if ( !ImplInitGraphics() )
{
SAL_WARN("vcl", "No mpGraphics set");
}
}
return mpGraphics;
}
bool OutputDevice::ImplInitGraphics() const
{
DBG_TESTSOLARMUTEX();
mbInitLineColor = true; mbInitLineColor = true;
mbInitFillColor = true; mbInitFillColor = true;
...@@ -534,6 +561,8 @@ SalGraphics* OutputDevice::ImplGetGraphics() const ...@@ -534,6 +561,8 @@ SalGraphics* OutputDevice::ImplGetGraphics() const
mbInitClipRegion = true; mbInitClipRegion = true;
ImplSVData* pSVData = ImplGetSVData(); ImplSVData* pSVData = ImplGetSVData();
// TODO: move this out of OutputDevice and into subclasses
if ( meOutDevType == OUTDEV_WINDOW ) if ( meOutDevType == OUTDEV_WINDOW )
{ {
Window* pWindow = (Window*)this; Window* pWindow = (Window*)this;
...@@ -667,7 +696,7 @@ SalGraphics* OutputDevice::ImplGetGraphics() const ...@@ -667,7 +696,7 @@ SalGraphics* OutputDevice::ImplGetGraphics() const
mpGraphics->setAntiAliasB2DDraw(mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW); mpGraphics->setAntiAliasB2DDraw(mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW);
} }
return mpGraphics; return mpGraphics ? true : false;
} }
void OutputDevice::ImplReleaseGraphics( bool bRelease ) void OutputDevice::ImplReleaseGraphics( bool bRelease )
......
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