LCOV - code coverage report
Current view: top level - vcl/unx/generic/gdi - salvd.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 127 0.0 %
Date: 2012-08-25 Functions: 0 11 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <vcl/sysdata.hxx>
      31                 :            : 
      32                 :            : #include <tools/prex.h>
      33                 :            : #include <X11/extensions/Xrender.h>
      34                 :            : #include <tools/postx.h>
      35                 :            : 
      36                 :            : #include <unx/salunx.h>
      37                 :            : #include <unx/saldata.hxx>
      38                 :            : #include <unx/saldisp.hxx>
      39                 :            : #include <unx/salgdi.h>
      40                 :            : #include <unx/salvd.h>
      41                 :            : #include <unx/x11/xlimits.hxx>
      42                 :            : 
      43                 :            : #include <salinst.hxx>
      44                 :            : 
      45                 :            : // -=-= SalInstance =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
      46                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
      47                 :          0 : SalVirtualDevice* X11SalInstance::CreateVirtualDevice( SalGraphics* pGraphics,
      48                 :            :                                                        long nDX, long nDY,
      49                 :            :                                                        sal_uInt16 nBitCount, const SystemGraphicsData *pData )
      50                 :            : {
      51                 :          0 :     X11SalVirtualDevice *pVDev = new X11SalVirtualDevice();
      52                 :          0 :     if( !nBitCount && pGraphics )
      53                 :          0 :         nBitCount = pGraphics->GetBitCount();
      54                 :            : 
      55                 :          0 :     if( pData && pData->hDrawable != None )
      56                 :            :     {
      57                 :            :         XLIB_Window aRoot;
      58                 :            :         int x, y;
      59                 :          0 :         unsigned int w = 0, h = 0, bw, d;
      60                 :          0 :         Display* pDisp = GetGenericData()->GetSalDisplay()->GetDisplay();
      61                 :            :         XGetGeometry( pDisp, pData->hDrawable,
      62                 :          0 :                       &aRoot, &x, &y, &w, &h, &bw, &d );
      63                 :          0 :         int nScreen = 0;
      64                 :          0 :         while( nScreen < ScreenCount( pDisp ) )
      65                 :            :         {
      66                 :          0 :             if( RootWindow( pDisp, nScreen ) == aRoot )
      67                 :          0 :                 break;
      68                 :          0 :             nScreen++;
      69                 :            :         }
      70                 :          0 :         nDX = (long)w;
      71                 :          0 :         nDY = (long)h;
      72                 :          0 :         if( !pVDev->Init( GetGenericData()->GetSalDisplay(), nDX, nDY, nBitCount,
      73                 :            :                           SalX11Screen( nScreen ), pData->hDrawable,
      74                 :          0 :                 static_cast< XRenderPictFormat* >( pData->pXRenderFormat )) )
      75                 :            :         {
      76                 :          0 :             delete pVDev;
      77                 :          0 :             return NULL;
      78                 :          0 :         }
      79                 :            :     }
      80                 :          0 :     else if( !pVDev->Init( GetGenericData()->GetSalDisplay(), nDX, nDY, nBitCount,
      81                 :            :                            pGraphics ? static_cast<X11SalGraphics*>(pGraphics)->GetScreenNumber() :
      82                 :          0 :                                        GetGenericData()->GetSalDisplay()->GetDefaultXScreen() ) )
      83                 :            :     {
      84                 :          0 :         delete pVDev;
      85                 :          0 :         return NULL;
      86                 :            :     }
      87                 :            : 
      88                 :          0 :     pVDev->InitGraphics( pVDev );
      89                 :          0 :     return pVDev;
      90                 :            : }
      91                 :            : 
      92                 :          0 : void X11SalInstance::DestroyVirtualDevice( SalVirtualDevice* pDevice )
      93                 :            : {
      94                 :          0 :     delete pDevice;
      95                 :          0 : }
      96                 :            : 
      97                 :            : // -=-= SalGraphicsData =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
      98                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
      99                 :          0 : void X11SalGraphics::Init( X11SalVirtualDevice *pDevice, SalColormap* pColormap,
     100                 :            :                            bool bDeleteColormap )
     101                 :            : {
     102                 :          0 :     SalColormap *pOrigDeleteColormap = m_pDeleteColormap;
     103                 :            : 
     104                 :          0 :     SalDisplay *pDisplay  = pDevice->GetDisplay();
     105                 :          0 :     m_nXScreen = pDevice->GetXScreenNumber();
     106                 :            : 
     107                 :          0 :     int nVisualDepth = pDisplay->GetColormap( m_nXScreen ).GetVisual().GetDepth();
     108                 :          0 :     int nDeviceDepth = pDevice->GetDepth();
     109                 :            : 
     110                 :          0 :     if( pColormap )
     111                 :            :     {
     112                 :          0 :         m_pColormap = pColormap;
     113                 :          0 :         if( bDeleteColormap )
     114                 :          0 :             m_pDeleteColormap = pColormap;
     115                 :            :     }
     116                 :            :     else
     117                 :          0 :     if( nDeviceDepth == nVisualDepth )
     118                 :          0 :         m_pColormap = &pDisplay->GetColormap( m_nXScreen );
     119                 :            :     else
     120                 :          0 :     if( nDeviceDepth == 1 )
     121                 :          0 :         m_pColormap = m_pDeleteColormap = new SalColormap();
     122                 :            : 
     123                 :          0 :     if (m_pDeleteColormap != pOrigDeleteColormap)
     124                 :          0 :         delete pOrigDeleteColormap;
     125                 :            : 
     126                 :          0 :     const Drawable aVdevDrawable = pDevice->GetDrawable();
     127                 :          0 :     SetDrawable( aVdevDrawable, m_nXScreen );
     128                 :            : 
     129                 :          0 :     m_pVDev      = pDevice;
     130                 :          0 :     m_pFrame     = NULL;
     131                 :            : 
     132                 :          0 :     bWindow_     = pDisplay->IsDisplay();
     133                 :          0 :     bVirDev_     = sal_True;
     134                 :          0 : }
     135                 :            : 
     136                 :            : // -=-= SalVirDevData / SalVirtualDevice -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     137                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     138                 :          0 : sal_Bool X11SalVirtualDevice::Init( SalDisplay *pDisplay,
     139                 :            :                                     long nDX, long nDY,
     140                 :            :                                     sal_uInt16 nBitCount,
     141                 :            :                                     SalX11Screen nXScreen,
     142                 :            :                                     Pixmap hDrawable,
     143                 :            :                                     XRenderPictFormat* pXRenderFormat )
     144                 :            : {
     145                 :          0 :     SalColormap* pColormap = NULL;
     146                 :          0 :     bool bDeleteColormap = false;
     147                 :            : 
     148                 :          0 :     pDisplay_               = pDisplay;
     149                 :          0 :     pGraphics_              = new X11SalGraphics();
     150                 :          0 :     m_nXScreen              = nXScreen;
     151                 :          0 :     if( pXRenderFormat ) {
     152                 :          0 :         pGraphics_->SetXRenderFormat( pXRenderFormat );
     153                 :          0 :         if( pXRenderFormat->colormap )
     154                 :          0 :             pColormap = new SalColormap( pDisplay, pXRenderFormat->colormap, m_nXScreen );
     155                 :            :         else
     156                 :          0 :             pColormap = new SalColormap( nBitCount );
     157                 :          0 :          bDeleteColormap = true;
     158                 :            :     }
     159                 :          0 :     else if( nBitCount != pDisplay->GetVisual( m_nXScreen ).GetDepth() )
     160                 :            :     {
     161                 :          0 :         pColormap = new SalColormap( nBitCount );
     162                 :          0 :         bDeleteColormap = true;
     163                 :            :     }
     164                 :          0 :     pGraphics_->SetLayout( 0 ); // by default no! mirroring for VirtualDevices, can be enabled with EnableRTL()
     165                 :          0 :     nDX_                    = nDX;
     166                 :          0 :     nDY_                    = nDY;
     167                 :          0 :     nDepth_                 = nBitCount;
     168                 :            : 
     169                 :          0 :     if( hDrawable == None )
     170                 :            :         hDrawable_          = limitXCreatePixmap( GetXDisplay(),
     171                 :            :                                              pDisplay_->GetDrawable( m_nXScreen ),
     172                 :            :                                              nDX_, nDY_,
     173                 :          0 :                                              GetDepth() );
     174                 :            :     else
     175                 :            :     {
     176                 :          0 :         hDrawable_ = hDrawable;
     177                 :          0 :         bExternPixmap_ = sal_True;
     178                 :            :     }
     179                 :            : 
     180                 :          0 :     pGraphics_->Init( this, pColormap, bDeleteColormap );
     181                 :            : 
     182                 :          0 :     return hDrawable_ != None ? sal_True : sal_False;
     183                 :            : }
     184                 :            : 
     185                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     186                 :          0 : X11SalVirtualDevice::X11SalVirtualDevice() :
     187                 :          0 :     m_nXScreen( 0 )
     188                 :            : {
     189                 :          0 :     pDisplay_               = (SalDisplay*)ILLEGAL_POINTER;
     190                 :          0 :     pGraphics_              = NULL;
     191                 :          0 :     hDrawable_              = None;
     192                 :          0 :     nDX_                    = 0;
     193                 :          0 :     nDY_                    = 0;
     194                 :          0 :     nDepth_                 = 0;
     195                 :          0 :     bGraphics_              = sal_False;
     196                 :          0 :     bExternPixmap_          = sal_False;
     197                 :          0 : }
     198                 :            : 
     199                 :            : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     200                 :          0 : X11SalVirtualDevice::~X11SalVirtualDevice()
     201                 :            : {
     202                 :          0 :     if( pGraphics_ )
     203                 :          0 :         delete pGraphics_;
     204                 :          0 :     pGraphics_ = NULL;
     205                 :            : 
     206                 :          0 :     if( GetDrawable() && !bExternPixmap_ )
     207                 :          0 :         XFreePixmap( GetXDisplay(), GetDrawable() );
     208                 :          0 : }
     209                 :            : 
     210                 :          0 : SalGraphics* X11SalVirtualDevice::GetGraphics()
     211                 :            : {
     212                 :          0 :     if( bGraphics_ )
     213                 :          0 :         return NULL;
     214                 :            : 
     215                 :          0 :     if( pGraphics_ )
     216                 :          0 :         bGraphics_ = sal_True;
     217                 :            : 
     218                 :          0 :     return pGraphics_;
     219                 :            : }
     220                 :            : 
     221                 :          0 : void X11SalVirtualDevice::ReleaseGraphics( SalGraphics* )
     222                 :          0 : { bGraphics_ = sal_False; }
     223                 :            : 
     224                 :          0 : sal_Bool X11SalVirtualDevice::SetSize( long nDX, long nDY )
     225                 :            : {
     226                 :          0 :     if( bExternPixmap_ )
     227                 :          0 :         return sal_False;
     228                 :            : 
     229                 :          0 :     if( !nDX ) nDX = 1;
     230                 :          0 :     if( !nDY ) nDY = 1;
     231                 :            : 
     232                 :            :     Pixmap h = limitXCreatePixmap( GetXDisplay(),
     233                 :            :                               pDisplay_->GetDrawable( m_nXScreen ),
     234                 :          0 :                               nDX, nDY, nDepth_ );
     235                 :            : 
     236                 :          0 :     if( !h )
     237                 :            :     {
     238                 :          0 :         if( !GetDrawable() )
     239                 :            :         {
     240                 :            :             hDrawable_ = limitXCreatePixmap( GetXDisplay(),
     241                 :            :                                         pDisplay_->GetDrawable( m_nXScreen ),
     242                 :          0 :                                         1, 1, nDepth_ );
     243                 :          0 :             nDX_ = 1;
     244                 :          0 :             nDY_ = 1;
     245                 :            :         }
     246                 :          0 :         return sal_False;
     247                 :            :     }
     248                 :            : 
     249                 :          0 :     if( GetDrawable() )
     250                 :          0 :         XFreePixmap( GetXDisplay(), GetDrawable() );
     251                 :          0 :     hDrawable_ = h;
     252                 :            : 
     253                 :          0 :     nDX_ = nDX;
     254                 :          0 :     nDY_ = nDY;
     255                 :            : 
     256                 :          0 :     if( pGraphics_ )
     257                 :          0 :         InitGraphics( this );
     258                 :            : 
     259                 :          0 :     return sal_True;
     260                 :            : }
     261                 :            : 
     262                 :          0 : void X11SalVirtualDevice::GetSize( long& rWidth, long& rHeight )
     263                 :            : {
     264                 :          0 :     rWidth  = GetWidth();
     265                 :          0 :     rHeight = GetHeight();
     266                 :          0 : }
     267                 :            : 
     268                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10