LCOV - code coverage report
Current view: top level - libreoffice/vcl/unx/generic/gdi - salvd.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 127 0.0 %
Date: 2012-12-27 Functions: 0 11 0.0 %
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             : 
      21             : #include <vcl/sysdata.hxx>
      22             : 
      23             : #include <tools/prex.h>
      24             : #include <X11/extensions/Xrender.h>
      25             : #include <tools/postx.h>
      26             : 
      27             : #include <unx/salunx.h>
      28             : #include <unx/saldata.hxx>
      29             : #include <unx/saldisp.hxx>
      30             : #include <unx/salgdi.h>
      31             : #include <unx/salvd.h>
      32             : #include <unx/x11/xlimits.hxx>
      33             : 
      34             : #include <salinst.hxx>
      35             : 
      36             : // -=-= SalInstance =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
      37             : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
      38           0 : SalVirtualDevice* X11SalInstance::CreateVirtualDevice( SalGraphics* pGraphics,
      39             :                                                        long nDX, long nDY,
      40             :                                                        sal_uInt16 nBitCount, const SystemGraphicsData *pData )
      41             : {
      42           0 :     X11SalVirtualDevice *pVDev = new X11SalVirtualDevice();
      43           0 :     if( !nBitCount && pGraphics )
      44           0 :         nBitCount = pGraphics->GetBitCount();
      45             : 
      46           0 :     if( pData && pData->hDrawable != None )
      47             :     {
      48             :         XLIB_Window aRoot;
      49             :         int x, y;
      50           0 :         unsigned int w = 0, h = 0, bw, d;
      51           0 :         Display* pDisp = GetGenericData()->GetSalDisplay()->GetDisplay();
      52             :         XGetGeometry( pDisp, pData->hDrawable,
      53           0 :                       &aRoot, &x, &y, &w, &h, &bw, &d );
      54           0 :         int nScreen = 0;
      55           0 :         while( nScreen < ScreenCount( pDisp ) )
      56             :         {
      57           0 :             if( RootWindow( pDisp, nScreen ) == aRoot )
      58           0 :                 break;
      59           0 :             nScreen++;
      60             :         }
      61           0 :         nDX = (long)w;
      62           0 :         nDY = (long)h;
      63           0 :         if( !pVDev->Init( GetGenericData()->GetSalDisplay(), nDX, nDY, nBitCount,
      64             :                           SalX11Screen( nScreen ), pData->hDrawable,
      65           0 :                 static_cast< XRenderPictFormat* >( pData->pXRenderFormat )) )
      66             :         {
      67           0 :             delete pVDev;
      68           0 :             return NULL;
      69           0 :         }
      70             :     }
      71           0 :     else if( !pVDev->Init( GetGenericData()->GetSalDisplay(), nDX, nDY, nBitCount,
      72             :                            pGraphics ? static_cast<X11SalGraphics*>(pGraphics)->GetScreenNumber() :
      73           0 :                                        GetGenericData()->GetSalDisplay()->GetDefaultXScreen() ) )
      74             :     {
      75           0 :         delete pVDev;
      76           0 :         return NULL;
      77             :     }
      78             : 
      79           0 :     pVDev->InitGraphics( pVDev );
      80           0 :     return pVDev;
      81             : }
      82             : 
      83           0 : void X11SalInstance::DestroyVirtualDevice( SalVirtualDevice* pDevice )
      84             : {
      85           0 :     delete pDevice;
      86           0 : }
      87             : 
      88             : // -=-= SalGraphicsData =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
      89             : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
      90           0 : void X11SalGraphics::Init( X11SalVirtualDevice *pDevice, SalColormap* pColormap,
      91             :                            bool bDeleteColormap )
      92             : {
      93           0 :     SalColormap *pOrigDeleteColormap = m_pDeleteColormap;
      94             : 
      95           0 :     SalDisplay *pDisplay  = pDevice->GetDisplay();
      96           0 :     m_nXScreen = pDevice->GetXScreenNumber();
      97             : 
      98           0 :     int nVisualDepth = pDisplay->GetColormap( m_nXScreen ).GetVisual().GetDepth();
      99           0 :     int nDeviceDepth = pDevice->GetDepth();
     100             : 
     101           0 :     if( pColormap )
     102             :     {
     103           0 :         m_pColormap = pColormap;
     104           0 :         if( bDeleteColormap )
     105           0 :             m_pDeleteColormap = pColormap;
     106             :     }
     107             :     else
     108           0 :     if( nDeviceDepth == nVisualDepth )
     109           0 :         m_pColormap = &pDisplay->GetColormap( m_nXScreen );
     110             :     else
     111           0 :     if( nDeviceDepth == 1 )
     112           0 :         m_pColormap = m_pDeleteColormap = new SalColormap();
     113             : 
     114           0 :     if (m_pDeleteColormap != pOrigDeleteColormap)
     115           0 :         delete pOrigDeleteColormap;
     116             : 
     117           0 :     const Drawable aVdevDrawable = pDevice->GetDrawable();
     118           0 :     SetDrawable( aVdevDrawable, m_nXScreen );
     119             : 
     120           0 :     m_pVDev      = pDevice;
     121           0 :     m_pFrame     = NULL;
     122             : 
     123           0 :     bWindow_     = pDisplay->IsDisplay();
     124           0 :     bVirDev_     = sal_True;
     125           0 : }
     126             : 
     127             : // -=-= SalVirDevData / SalVirtualDevice -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     128             : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     129           0 : sal_Bool X11SalVirtualDevice::Init( SalDisplay *pDisplay,
     130             :                                     long nDX, long nDY,
     131             :                                     sal_uInt16 nBitCount,
     132             :                                     SalX11Screen nXScreen,
     133             :                                     Pixmap hDrawable,
     134             :                                     XRenderPictFormat* pXRenderFormat )
     135             : {
     136           0 :     SalColormap* pColormap = NULL;
     137           0 :     bool bDeleteColormap = false;
     138             : 
     139           0 :     pDisplay_               = pDisplay;
     140           0 :     pGraphics_              = new X11SalGraphics();
     141           0 :     m_nXScreen              = nXScreen;
     142           0 :     if( pXRenderFormat ) {
     143           0 :         pGraphics_->SetXRenderFormat( pXRenderFormat );
     144           0 :         if( pXRenderFormat->colormap )
     145           0 :             pColormap = new SalColormap( pDisplay, pXRenderFormat->colormap, m_nXScreen );
     146             :         else
     147           0 :             pColormap = new SalColormap( nBitCount );
     148           0 :          bDeleteColormap = true;
     149             :     }
     150           0 :     else if( nBitCount != pDisplay->GetVisual( m_nXScreen ).GetDepth() )
     151             :     {
     152           0 :         pColormap = new SalColormap( nBitCount );
     153           0 :         bDeleteColormap = true;
     154             :     }
     155           0 :     pGraphics_->SetLayout( 0 ); // by default no! mirroring for VirtualDevices, can be enabled with EnableRTL()
     156           0 :     nDX_                    = nDX;
     157           0 :     nDY_                    = nDY;
     158           0 :     nDepth_                 = nBitCount;
     159             : 
     160           0 :     if( hDrawable == None )
     161             :         hDrawable_          = limitXCreatePixmap( GetXDisplay(),
     162             :                                              pDisplay_->GetDrawable( m_nXScreen ),
     163             :                                              nDX_, nDY_,
     164           0 :                                              GetDepth() );
     165             :     else
     166             :     {
     167           0 :         hDrawable_ = hDrawable;
     168           0 :         bExternPixmap_ = sal_True;
     169             :     }
     170             : 
     171           0 :     pGraphics_->Init( this, pColormap, bDeleteColormap );
     172             : 
     173           0 :     return hDrawable_ != None ? sal_True : sal_False;
     174             : }
     175             : 
     176             : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     177           0 : X11SalVirtualDevice::X11SalVirtualDevice() :
     178           0 :     m_nXScreen( 0 )
     179             : {
     180           0 :     pDisplay_               = NULL;
     181           0 :     pGraphics_              = NULL;
     182           0 :     hDrawable_              = None;
     183           0 :     nDX_                    = 0;
     184           0 :     nDY_                    = 0;
     185           0 :     nDepth_                 = 0;
     186           0 :     bGraphics_              = sal_False;
     187           0 :     bExternPixmap_          = sal_False;
     188           0 : }
     189             : 
     190             : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     191           0 : X11SalVirtualDevice::~X11SalVirtualDevice()
     192             : {
     193           0 :     if( pGraphics_ )
     194           0 :         delete pGraphics_;
     195           0 :     pGraphics_ = NULL;
     196             : 
     197           0 :     if( GetDrawable() && !bExternPixmap_ )
     198           0 :         XFreePixmap( GetXDisplay(), GetDrawable() );
     199           0 : }
     200             : 
     201           0 : SalGraphics* X11SalVirtualDevice::GetGraphics()
     202             : {
     203           0 :     if( bGraphics_ )
     204           0 :         return NULL;
     205             : 
     206           0 :     if( pGraphics_ )
     207           0 :         bGraphics_ = sal_True;
     208             : 
     209           0 :     return pGraphics_;
     210             : }
     211             : 
     212           0 : void X11SalVirtualDevice::ReleaseGraphics( SalGraphics* )
     213           0 : { bGraphics_ = sal_False; }
     214             : 
     215           0 : sal_Bool X11SalVirtualDevice::SetSize( long nDX, long nDY )
     216             : {
     217           0 :     if( bExternPixmap_ )
     218           0 :         return sal_False;
     219             : 
     220           0 :     if( !nDX ) nDX = 1;
     221           0 :     if( !nDY ) nDY = 1;
     222             : 
     223             :     Pixmap h = limitXCreatePixmap( GetXDisplay(),
     224             :                               pDisplay_->GetDrawable( m_nXScreen ),
     225           0 :                               nDX, nDY, nDepth_ );
     226             : 
     227           0 :     if( !h )
     228             :     {
     229           0 :         if( !GetDrawable() )
     230             :         {
     231             :             hDrawable_ = limitXCreatePixmap( GetXDisplay(),
     232             :                                         pDisplay_->GetDrawable( m_nXScreen ),
     233           0 :                                         1, 1, nDepth_ );
     234           0 :             nDX_ = 1;
     235           0 :             nDY_ = 1;
     236             :         }
     237           0 :         return sal_False;
     238             :     }
     239             : 
     240           0 :     if( GetDrawable() )
     241           0 :         XFreePixmap( GetXDisplay(), GetDrawable() );
     242           0 :     hDrawable_ = h;
     243             : 
     244           0 :     nDX_ = nDX;
     245           0 :     nDY_ = nDY;
     246             : 
     247           0 :     if( pGraphics_ )
     248           0 :         InitGraphics( this );
     249             : 
     250           0 :     return sal_True;
     251             : }
     252             : 
     253           0 : void X11SalVirtualDevice::GetSize( long& rWidth, long& rHeight )
     254             : {
     255           0 :     rWidth  = GetWidth();
     256           0 :     rHeight = GetHeight();
     257           0 : }
     258             : 
     259             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10