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 0 : X11GlyphPeer::X11GlyphPeer()
32 : {
33 0 : }
34 :
35 0 : X11GlyphPeer::~X11GlyphPeer()
36 : {
37 0 : if( !ImplGetSVData() )
38 0 : return;
39 :
40 : //Why do this here, move into dtor/shutdown of display?
41 0 : SalDisplay* pSalDisp = GetGenericData()->GetSalDisplay();
42 0 : Display* const pX11Disp = pSalDisp->GetDisplay();
43 0 : int nMaxScreens = pSalDisp->GetXScreenCount();
44 0 : XRenderPeer& rRenderPeer = XRenderPeer::GetInstance();
45 :
46 0 : for( int i = 0; i < nMaxScreens; i++ )
47 : {
48 0 : SalDisplay::RenderEntryMap& rMap = pSalDisp->GetRenderEntries( SalX11Screen (i) );
49 0 : 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 0 : rMap.clear();
57 : }
58 0 : }
59 :
60 0 : X11GlyphCache::X11GlyphCache( X11GlyphPeer& rPeer )
61 0 : : GlyphCache( rPeer )
62 : {
63 0 : }
64 :
65 : namespace
66 : {
67 : struct GlyphCacheHolder
68 : {
69 : private:
70 : X11GlyphPeer* m_pX11GlyphPeer;
71 : X11GlyphCache* m_pX11GlyphCache;
72 : public:
73 0 : GlyphCacheHolder()
74 : {
75 0 : m_pX11GlyphPeer = new X11GlyphPeer();
76 0 : m_pX11GlyphCache = new X11GlyphCache( *m_pX11GlyphPeer );
77 0 : }
78 0 : void release()
79 : {
80 0 : delete m_pX11GlyphCache;
81 0 : delete m_pX11GlyphPeer;
82 0 : m_pX11GlyphCache = NULL;
83 0 : m_pX11GlyphPeer = NULL;
84 0 : }
85 0 : X11GlyphCache& getGlyphCache()
86 : {
87 0 : return *m_pX11GlyphCache;
88 : }
89 0 : ~GlyphCacheHolder()
90 : {
91 0 : release();
92 0 : }
93 : };
94 :
95 : struct theGlyphCacheHolder :
96 : public rtl::Static<GlyphCacheHolder, theGlyphCacheHolder>
97 : {};
98 : }
99 :
100 0 : X11GlyphCache& X11GlyphCache::GetInstance()
101 : {
102 0 : 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 0 : }
114 :
115 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|