LCOV - code coverage report
Current view: top level - vcl/unx/generic/gdi - salvd.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 76 108 70.4 %
Date: 2015-06-13 12:38:46 Functions: 10 11 90.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <vcl/sysdata.hxx>
      21             : 
      22             : #include <prex.h>
      23             : #include <X11/extensions/Xrender.h>
      24             : #include <postx.h>
      25             : 
      26             : #include <unx/salunx.h>
      27             : #include <unx/saldata.hxx>
      28             : #include <unx/saldisp.hxx>
      29             : #include <unx/salgdi.h>
      30             : #include <unx/salvd.h>
      31             : #include <unx/x11/xlimits.hxx>
      32             : 
      33             : #include <salinst.hxx>
      34             : 
      35             : #include <vcl/opengl/OpenGLHelper.hxx>
      36             : #include <opengl/x11/salvd.hxx>
      37             : 
      38         177 : SalVirtualDevice* X11SalInstance::CreateX11VirtualDevice(SalGraphics* pGraphics,
      39             :         long &nDX, long &nDY, sal_uInt16 nBitCount, const SystemGraphicsData *pData,
      40             :         X11SalGraphics* pNewGraphics)
      41             : {
      42         177 :     if (OpenGLHelper::isVCLOpenGLEnabled())
      43           0 :         return new X11OpenGLSalVirtualDevice( pGraphics, nDX, nDY, nBitCount, pData );
      44             :     else
      45         177 :         return new X11SalVirtualDevice(pGraphics, nDX, nDY, nBitCount, pData, pNewGraphics);
      46             : }
      47             : 
      48           0 : SalVirtualDevice* X11SalInstance::CreateVirtualDevice(SalGraphics* pGraphics,
      49             :         long &nDX, long &nDY, sal_uInt16 nBitCount, const SystemGraphicsData *pData)
      50             : {
      51           0 :     return CreateX11VirtualDevice(pGraphics, nDX, nDY, nBitCount, pData, new X11SalGraphics());
      52             : }
      53             : 
      54         180 : void X11SalGraphics::Init( X11SalVirtualDevice *pDevice, SalColormap* pColormap,
      55             :                            bool bDeleteColormap )
      56             : {
      57         180 :     SalColormap *pOrigDeleteColormap = m_pDeleteColormap;
      58             : 
      59         180 :     SalDisplay *pDisplay  = pDevice->GetDisplay();
      60         180 :     m_nXScreen = pDevice->GetXScreenNumber();
      61             : 
      62         180 :     int nVisualDepth = pDisplay->GetColormap( m_nXScreen ).GetVisual().GetDepth();
      63         180 :     int nDeviceDepth = pDevice->GetDepth();
      64             : 
      65         180 :     if( pColormap )
      66             :     {
      67          10 :         m_pColormap = pColormap;
      68          10 :         if( bDeleteColormap )
      69          10 :             m_pDeleteColormap = pColormap;
      70             :     }
      71         170 :     else if( nDeviceDepth == nVisualDepth )
      72         170 :         m_pColormap = &pDisplay->GetColormap( m_nXScreen );
      73           0 :     else if( nDeviceDepth == 1 )
      74           0 :         m_pColormap = m_pDeleteColormap = new SalColormap();
      75             : 
      76         180 :     if (m_pDeleteColormap != pOrigDeleteColormap)
      77          10 :         delete pOrigDeleteColormap;
      78             : 
      79         180 :     m_pVDev      = pDevice;
      80         180 :     m_pFrame     = NULL;
      81             : 
      82         180 :     bWindow_     = pDisplay->IsDisplay();
      83         180 :     bVirDev_     = true;
      84             : 
      85         180 :     const Drawable aVdevDrawable = pDevice->GetDrawable();
      86         180 :     SetDrawable( aVdevDrawable, m_nXScreen );
      87         180 :     mxImpl->Init();
      88         180 : }
      89             : 
      90         177 : X11SalVirtualDevice::X11SalVirtualDevice(SalGraphics* pGraphics, long &nDX, long &nDY,
      91             :                                          sal_uInt16 nBitCount, const SystemGraphicsData *pData,
      92             :                                          X11SalGraphics* pNewGraphics) :
      93             :     pGraphics_(pNewGraphics),
      94             :     m_nXScreen(0),
      95         177 :     bGraphics_(false)
      96             : {
      97         177 :     SalColormap* pColormap = NULL;
      98         177 :     bool bDeleteColormap = false;
      99             : 
     100         177 :     if( !nBitCount && pGraphics )
     101         167 :         nBitCount = pGraphics->GetBitCount();
     102             : 
     103         177 :     pDisplay_               = vcl_sal::getSalDisplay(GetGenericData());
     104         177 :     nDepth_                 = nBitCount;
     105             : 
     106         177 :     if( pData && pData->hDrawable != None )
     107             :     {
     108             :         ::Window aRoot;
     109             :         int x, y;
     110           0 :         unsigned int w = 0, h = 0, bw, d;
     111           0 :         Display* pDisp = pDisplay_->GetDisplay();
     112             :         XGetGeometry( pDisp, pData->hDrawable,
     113           0 :                       &aRoot, &x, &y, &w, &h, &bw, &d );
     114           0 :         int nScreen = 0;
     115           0 :         while( nScreen < ScreenCount( pDisp ) )
     116             :         {
     117           0 :             if( RootWindow( pDisp, nScreen ) == aRoot )
     118           0 :                 break;
     119           0 :             nScreen++;
     120             :         }
     121           0 :         nDX_ = (long)w;
     122           0 :         nDY_ = (long)h;
     123           0 :         nDX = nDX_;
     124           0 :         nDY = nDY_;
     125           0 :         m_nXScreen = SalX11Screen( nScreen );
     126           0 :         hDrawable_ = pData->hDrawable;
     127           0 :         bExternPixmap_ = true;
     128             :     }
     129             :     else
     130             :     {
     131         177 :         nDX_ = nDX;
     132         177 :         nDY_ = nDY;
     133             :         m_nXScreen = pGraphics ? static_cast<X11SalGraphics*>(pGraphics)->GetScreenNumber() :
     134         177 :                                  vcl_sal::getSalDisplay(GetGenericData())->GetDefaultXScreen();
     135             :         hDrawable_ = limitXCreatePixmap( GetXDisplay(),
     136             :                                          pDisplay_->GetDrawable( m_nXScreen ),
     137             :                                          nDX_, nDY_,
     138         177 :                                          GetDepth() );
     139         177 :         bExternPixmap_ = false;
     140             :     }
     141             : 
     142         177 :     XRenderPictFormat* pXRenderFormat = pData ? static_cast<XRenderPictFormat*>(pData->pXRenderFormat) : NULL;
     143         177 :     if( pXRenderFormat )
     144             :     {
     145           0 :         pGraphics_->SetXRenderFormat( pXRenderFormat );
     146           0 :         if( pXRenderFormat->colormap )
     147           0 :             pColormap = new SalColormap( pDisplay_, pXRenderFormat->colormap, m_nXScreen );
     148             :         else
     149           0 :             pColormap = new SalColormap( nBitCount );
     150           0 :          bDeleteColormap = true;
     151             :     }
     152         177 :     else if( nBitCount != pDisplay_->GetVisual( m_nXScreen ).GetDepth() )
     153             :     {
     154          10 :         pColormap = new SalColormap( nBitCount );
     155          10 :         bDeleteColormap = true;
     156             :     }
     157             : 
     158         177 :     pGraphics_->SetLayout( SalLayoutFlags::NONE ); // by default no! mirroring for VirtualDevices, can be enabled with EnableRTL()
     159         177 :     pGraphics_->Init( this, pColormap, bDeleteColormap );
     160         177 : }
     161             : 
     162         513 : X11SalVirtualDevice::~X11SalVirtualDevice()
     163             : {
     164         171 :     if( pGraphics_ )
     165         171 :         delete pGraphics_;
     166         171 :     pGraphics_ = NULL;
     167             : 
     168         171 :     if( GetDrawable() && !bExternPixmap_ )
     169         171 :         XFreePixmap( GetXDisplay(), GetDrawable() );
     170         342 : }
     171             : 
     172         177 : SalGraphics* X11SalVirtualDevice::AcquireGraphics()
     173             : {
     174         177 :     if( bGraphics_ )
     175           0 :         return NULL;
     176             : 
     177         177 :     if( pGraphics_ )
     178         177 :         bGraphics_ = true;
     179             : 
     180         177 :     return pGraphics_;
     181             : }
     182             : 
     183         171 : void X11SalVirtualDevice::ReleaseGraphics( SalGraphics* )
     184         171 : { bGraphics_ = false; }
     185             : 
     186           3 : bool X11SalVirtualDevice::SetSize( long nDX, long nDY )
     187             : {
     188           3 :     if( bExternPixmap_ )
     189           0 :         return false;
     190             : 
     191           3 :     if( !nDX ) nDX = 1;
     192           3 :     if( !nDY ) nDY = 1;
     193             : 
     194             :     Pixmap h = limitXCreatePixmap( GetXDisplay(),
     195             :                               pDisplay_->GetDrawable( m_nXScreen ),
     196           3 :                               nDX, nDY, nDepth_ );
     197             : 
     198           3 :     if( !h )
     199             :     {
     200           0 :         if( !GetDrawable() )
     201             :         {
     202             :             hDrawable_ = limitXCreatePixmap( GetXDisplay(),
     203             :                                         pDisplay_->GetDrawable( m_nXScreen ),
     204           0 :                                         1, 1, nDepth_ );
     205           0 :             nDX_ = 1;
     206           0 :             nDY_ = 1;
     207             :         }
     208           0 :         return false;
     209             :     }
     210             : 
     211           3 :     if( GetDrawable() )
     212           3 :         XFreePixmap( GetXDisplay(), GetDrawable() );
     213           3 :     hDrawable_ = h;
     214             : 
     215           3 :     nDX_ = nDX;
     216           3 :     nDY_ = nDY;
     217             : 
     218           3 :     if( pGraphics_ )
     219           3 :         pGraphics_->Init( this );
     220             : 
     221           3 :     return true;
     222           9 : }
     223             : 
     224             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11