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 "rtl/ustring.hxx"
31 : : #include "osl/module.h"
32 : : #include "osl/thread.h"
33 : :
34 : : #include "unx/saldisp.hxx"
35 : : #include "unx/saldata.hxx"
36 : : #include "unx/salgdi.h"
37 : :
38 : : #include "gcach_xpeer.hxx"
39 : : #include "xrender_peer.hxx"
40 : :
41 : : // ===========================================================================
42 : :
43 : 0 : X11GlyphPeer::X11GlyphPeer()
44 : : {
45 : 0 : }
46 : :
47 : : // ---------------------------------------------------------------------------
48 : :
49 : 0 : X11GlyphPeer::~X11GlyphPeer()
50 : : {
51 : 0 : if( !ImplGetSVData() )
52 : : return;
53 : :
54 : : //Why do this here, move into dtor/shutdown of display?
55 : 0 : SalDisplay* pSalDisp = GetGenericData()->GetSalDisplay();
56 : 0 : Display* const pX11Disp = pSalDisp->GetDisplay();
57 : 0 : int nMaxScreens = pSalDisp->GetXScreenCount();
58 : 0 : XRenderPeer& rRenderPeer = XRenderPeer::GetInstance();
59 : :
60 : 0 : for( int i = 0; i < nMaxScreens; i++ )
61 : : {
62 : 0 : SalDisplay::RenderEntryMap& rMap = pSalDisp->GetRenderEntries( SalX11Screen (i) );
63 : 0 : for( SalDisplay::RenderEntryMap::iterator it = rMap.begin(); it != rMap.end(); ++it )
64 : : {
65 : 0 : if( it->second.m_aPixmap )
66 : 0 : ::XFreePixmap( pX11Disp, it->second.m_aPixmap );
67 : 0 : if( it->second.m_aPicture )
68 : 0 : rRenderPeer.FreePicture( it->second.m_aPicture );
69 : : }
70 : 0 : rMap.clear();
71 : : }
72 : 0 : }
73 : :
74 : : // ===========================================================================
75 : :
76 : 0 : X11GlyphCache::X11GlyphCache( X11GlyphPeer& rPeer )
77 : 0 : : GlyphCache( rPeer )
78 : : {
79 : 0 : }
80 : :
81 : : // ---------------------------------------------------------------------------
82 : :
83 : : namespace
84 : : {
85 : : struct GlyphCacheHolder
86 : : {
87 : : private:
88 : : X11GlyphPeer* m_pX11GlyphPeer;
89 : : X11GlyphCache* m_pX11GlyphCache;
90 : : public:
91 : 0 : GlyphCacheHolder()
92 : : {
93 : 0 : m_pX11GlyphPeer = new X11GlyphPeer();
94 : 0 : m_pX11GlyphCache = new X11GlyphCache( *m_pX11GlyphPeer );
95 : 0 : }
96 : 0 : void release()
97 : : {
98 : 0 : delete m_pX11GlyphCache;
99 : 0 : delete m_pX11GlyphPeer;
100 : 0 : m_pX11GlyphCache = NULL;
101 : 0 : m_pX11GlyphPeer = NULL;
102 : 0 : }
103 : 0 : X11GlyphCache& getGlyphCache()
104 : : {
105 : 0 : return *m_pX11GlyphCache;
106 : : }
107 : 0 : ~GlyphCacheHolder()
108 : : {
109 : 0 : release();
110 : 0 : }
111 : : };
112 : :
113 : : struct theGlyphCacheHolder :
114 : : public rtl::Static<GlyphCacheHolder, theGlyphCacheHolder>
115 : : {};
116 : : }
117 : :
118 : 0 : X11GlyphCache& X11GlyphCache::GetInstance()
119 : : {
120 : 0 : return theGlyphCacheHolder::get().getGlyphCache();
121 : : }
122 : :
123 : : // ---------------------------------------------------------------------------
124 : :
125 : 0 : void X11GlyphCache::KillInstance()
126 : : {
127 : 0 : return theGlyphCacheHolder::get().release();
128 : : }
129 : :
130 : : // ===========================================================================
131 : :
132 : 0 : void X11SalGraphics::releaseGlyphPeer()
133 : : {
134 : 0 : X11GlyphCache::KillInstance();
135 : 0 : }
136 : :
137 : : // ===========================================================================
138 : :
139 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|