Branch libreoffice-5-0-4
[LibreOffice.git] / vcl / opengl / x11 / salvd.cxx
bloba613ce5f84fc820fe22b3f5e1a61e50acd9a8994
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <vcl/sysdata.hxx>
12 #include <unx/salunx.h>
13 #include <unx/saldata.hxx>
14 #include <unx/saldisp.hxx>
15 #include <unx/salgdi.h>
16 #include <unx/salvd.h>
18 #include <opengl/x11/salvd.hxx>
20 void X11SalGraphics::Init( X11OpenGLSalVirtualDevice *pDevice )
22 SalDisplay *pDisplay = pDevice->GetDisplay();
24 m_nXScreen = pDevice->GetXScreenNumber();
25 m_pColormap = &pDisplay->GetColormap( m_nXScreen );
27 m_pVDev = pDevice;
28 m_pFrame = NULL;
30 bWindow_ = pDisplay->IsDisplay();
31 bVirDev_ = true;
33 mxImpl->Init();
36 X11OpenGLSalVirtualDevice::X11OpenGLSalVirtualDevice( SalGraphics* pGraphics,
37 long &nDX, long &nDY,
38 sal_uInt16 nBitCount,
39 const SystemGraphicsData *pData ) :
40 mbGraphics( false ),
41 mnXScreen( 0 )
43 // TODO Do we really need the requested bit count?
44 if( !nBitCount && pGraphics )
45 nBitCount = pGraphics->GetBitCount();
47 // TODO Check where a VirtualDevice is created from SystemGraphicsData
48 assert( pData == NULL ); (void)pData;
50 mpDisplay = vcl_sal::getSalDisplay(GetGenericData());
51 mnDepth = nBitCount;
52 mnXScreen = pGraphics ? static_cast<X11SalGraphics*>(pGraphics)->GetScreenNumber() :
53 vcl_sal::getSalDisplay(GetGenericData())->GetDefaultXScreen();
54 mnWidth = nDX;
55 mnHeight = nDY;
56 mpGraphics = new X11SalGraphics();
57 mpGraphics->SetLayout( SalLayoutFlags::NONE );
58 mpGraphics->Init( this );
61 X11OpenGLSalVirtualDevice::~X11OpenGLSalVirtualDevice()
63 if( mpGraphics )
64 delete mpGraphics;
67 SalGraphics* X11OpenGLSalVirtualDevice::AcquireGraphics()
69 if( mbGraphics )
70 return NULL;
72 if( mpGraphics )
73 mbGraphics = true;
75 return mpGraphics;
78 void X11OpenGLSalVirtualDevice::ReleaseGraphics( SalGraphics* )
80 mbGraphics = false;
84 bool X11OpenGLSalVirtualDevice::SetSize( long nDX, long nDY )
86 if( !nDX ) nDX = 1;
87 if( !nDY ) nDY = 1;
89 mnWidth = nDX;
90 mnHeight = nDY;
91 if( mpGraphics )
92 mpGraphics->Init( this );
94 return true;
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */