Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / vcl / opengl / x11 / salvd.cxx
blob9af9f02b5db4fe0f60321901c9125dd7034f4f0e
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/saldisp.hxx>
14 #include <unx/salgdi.h>
15 #include <unx/salvd.h>
17 #include <opengl/x11/salvd.hxx>
19 void X11SalGraphics::Init( X11OpenGLSalVirtualDevice *pDevice )
21 SalDisplay *pDisplay = pDevice->GetDisplay();
23 m_nXScreen = pDevice->GetXScreenNumber();
24 m_pColormap = &pDisplay->GetColormap( m_nXScreen );
26 m_pVDev = pDevice;
27 m_pFrame = nullptr;
29 bWindow_ = pDisplay->IsDisplay();
30 bVirDev_ = true;
32 mxImpl->Init();
35 X11OpenGLSalVirtualDevice::X11OpenGLSalVirtualDevice( SalGraphics const * pGraphics,
36 long nDX, long nDY,
37 const SystemGraphicsData *pData,
38 X11SalGraphics* pNewGraphics) :
39 mpGraphics(pNewGraphics),
40 mbGraphics( false ),
41 mnXScreen( 0 )
43 assert(mpGraphics);
45 // TODO Check where a VirtualDevice is created from SystemGraphicsData
46 assert( pData == nullptr ); (void)pData;
48 mpDisplay = vcl_sal::getSalDisplay(GetGenericUnixSalData());
49 mnXScreen = pGraphics ? static_cast<X11SalGraphics const *>(pGraphics)->GetScreenNumber() :
50 vcl_sal::getSalDisplay(GetGenericUnixSalData())->GetDefaultXScreen();
51 mnWidth = nDX;
52 mnHeight = nDY;
53 mpGraphics->Init( this );
56 X11OpenGLSalVirtualDevice::~X11OpenGLSalVirtualDevice()
60 SalGraphics* X11OpenGLSalVirtualDevice::AcquireGraphics()
62 if( mbGraphics )
63 return nullptr;
65 if( mpGraphics )
66 mbGraphics = true;
68 return mpGraphics.get();
71 void X11OpenGLSalVirtualDevice::ReleaseGraphics( SalGraphics* )
73 mbGraphics = false;
77 bool X11OpenGLSalVirtualDevice::SetSize( long nDX, long nDY )
79 if( !nDX ) nDX = 1;
80 if( !nDY ) nDY = 1;
82 mnWidth = nDX;
83 mnHeight = nDY;
84 if( mpGraphics )
85 mpGraphics->Init( this );
87 return true;
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */