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

Generated by: LCOV version 1.10