LCOV - code coverage report
Current view: top level - vcl/unx/generic/gdi - gcach_xpeer.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 34 43 79.1 %
Date: 2015-06-13 12:38:46 Functions: 11 13 84.6 %
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 "rtl/ustring.hxx"
      21             : #include "osl/module.h"
      22             : #include "osl/thread.h"
      23             : 
      24             : #include "unx/saldisp.hxx"
      25             : #include "unx/saldata.hxx"
      26             : #include "unx/salgdi.h"
      27             : 
      28             : #include "gcach_xpeer.hxx"
      29             : #include "xrender_peer.hxx"
      30             : 
      31           3 : X11GlyphPeer::X11GlyphPeer()
      32             : {
      33           3 : }
      34             : 
      35           9 : X11GlyphPeer::~X11GlyphPeer()
      36             : {
      37           3 :     if( !ImplGetSVData() )
      38           0 :         return;
      39             : 
      40             :     //Why do this here, move into dtor/shutdown of display?
      41           3 :     SalDisplay* pSalDisp = vcl_sal::getSalDisplay(GetGenericData());
      42           3 :     Display* const pX11Disp = pSalDisp->GetDisplay();
      43           3 :     int nMaxScreens = pSalDisp->GetXScreenCount();
      44           3 :     XRenderPeer& rRenderPeer = XRenderPeer::GetInstance();
      45             : 
      46           6 :     for( int i = 0; i < nMaxScreens; i++ )
      47             :     {
      48           3 :         SalDisplay::RenderEntryMap& rMap = pSalDisp->GetRenderEntries( SalX11Screen (i) );
      49           3 :         for( SalDisplay::RenderEntryMap::iterator it = rMap.begin(); it != rMap.end(); ++it )
      50             :         {
      51           0 :             if( it->second.m_aPixmap )
      52           0 :                 ::XFreePixmap( pX11Disp, it->second.m_aPixmap );
      53           0 :             if( it->second.m_aPicture )
      54           0 :                 rRenderPeer.FreePicture( it->second.m_aPicture );
      55             :         }
      56           3 :         rMap.clear();
      57             :     }
      58           6 : }
      59             : 
      60           3 : X11GlyphCache::X11GlyphCache( X11GlyphPeer& rPeer )
      61           3 : :   GlyphCache( rPeer )
      62             : {
      63           3 : }
      64             : 
      65             : namespace
      66             : {
      67             :     struct GlyphCacheHolder
      68             :     {
      69             :     private:
      70             :         X11GlyphPeer* m_pX11GlyphPeer;
      71             :         X11GlyphCache* m_pX11GlyphCache;
      72             :     public:
      73           3 :         GlyphCacheHolder()
      74             :         {
      75           3 :             m_pX11GlyphPeer = new X11GlyphPeer();
      76           3 :             m_pX11GlyphCache = new X11GlyphCache( *m_pX11GlyphPeer );
      77           3 :         }
      78           3 :         void release()
      79             :         {
      80           3 :             delete m_pX11GlyphCache;
      81           3 :             delete m_pX11GlyphPeer;
      82           3 :             m_pX11GlyphCache = NULL;
      83           3 :             m_pX11GlyphPeer = NULL;
      84           3 :         }
      85           3 :         X11GlyphCache& getGlyphCache()
      86             :         {
      87           3 :             return *m_pX11GlyphCache;
      88             :         }
      89           3 :         ~GlyphCacheHolder()
      90             :         {
      91           3 :             release();
      92           3 :         }
      93             :     };
      94             : 
      95             :     struct theGlyphCacheHolder :
      96             :         public rtl::Static<GlyphCacheHolder, theGlyphCacheHolder>
      97             :     {};
      98             : }
      99             : 
     100           3 : X11GlyphCache& X11GlyphCache::GetInstance()
     101             : {
     102           3 :     return theGlyphCacheHolder::get().getGlyphCache();
     103             : }
     104             : 
     105           0 : void X11GlyphCache::KillInstance()
     106             : {
     107           0 :     return theGlyphCacheHolder::get().release();
     108             : }
     109             : 
     110           0 : void X11SalGraphics::releaseGlyphPeer()
     111             : {
     112           0 :     X11GlyphCache::KillInstance();
     113           9 : }
     114             : 
     115             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11