tagging audio streams and changing audio sink to pulseaudio
[profile/ivi/webkit-efl.git] / Source / WebCore / platform / graphics / FontFallbackList.h
1 /*
2  * Copyright (C) 2006, 2010 Apple Inc. All rights reserved.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB.  If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  *
19  */
20
21 #ifndef FontFallbackList_h
22 #define FontFallbackList_h
23
24 #include "FontSelector.h"
25 #include "SimpleFontData.h"
26 #include <wtf/Forward.h>
27 #include <wtf/MainThread.h>
28
29 namespace WebCore {
30
31 class Font;
32 class GlyphPageTreeNode;
33 class GraphicsContext;
34 class IntRect;
35 class FontDescription;
36 class FontPlatformData;
37 class FontSelector;
38
39 const int cAllFamiliesScanned = -1;
40
41 class FontFallbackList : public RefCounted<FontFallbackList> {
42 public:
43     static PassRefPtr<FontFallbackList> create() { return adoptRef(new FontFallbackList()); }
44
45     ~FontFallbackList() { releaseFontData(); }
46     void invalidate(PassRefPtr<FontSelector>);
47     
48     bool isFixedPitch(const Font* f) const { if (m_pitch == UnknownPitch) determinePitch(f); return m_pitch == FixedPitch; };
49     void determinePitch(const Font*) const;
50
51     bool loadingCustomFonts() const { return m_loadingCustomFonts; }
52
53     FontSelector* fontSelector() const { return m_fontSelector.get(); }
54     // FIXME: It should be possible to combine fontSelectorVersion and generation.
55     unsigned fontSelectorVersion() const { return m_fontSelectorVersion; }
56     unsigned generation() const { return m_generation; }
57
58     struct GlyphPagesHashTraits : HashTraits<int> {
59         static const int minimumTableSize = 16;
60     };
61     typedef HashMap<int, GlyphPageTreeNode*, DefaultHash<int>::Hash, GlyphPagesHashTraits> GlyphPages;
62     GlyphPageTreeNode* glyphPageZero() const { return m_pageZero; }
63     const GlyphPages& glyphPages() const { return m_pages; }
64
65 private:
66     friend class SVGTextRunRenderingContext;
67     void setGlyphPageZero(GlyphPageTreeNode* pageZero) { m_pageZero = pageZero; }
68     void setGlyphPages(const GlyphPages& pages) { m_pages = pages; }
69
70     FontFallbackList();
71
72     const SimpleFontData* primarySimpleFontData(const Font* f)
73     { 
74         ASSERT(isMainThread());
75         if (!m_cachedPrimarySimpleFontData)
76             m_cachedPrimarySimpleFontData = primaryFontData(f)->fontDataForCharacter(' ');
77         return m_cachedPrimarySimpleFontData;
78     }
79
80     const FontData* primaryFontData(const Font* f) const { return fontDataAt(f, 0); }
81     const FontData* fontDataAt(const Font*, unsigned index) const;
82
83     void setPlatformFont(const FontPlatformData&);
84
85     void releaseFontData();
86
87     mutable Vector<pair<const FontData*, bool>, 1> m_fontList;
88     mutable GlyphPages m_pages;
89     mutable GlyphPageTreeNode* m_pageZero;
90     mutable const SimpleFontData* m_cachedPrimarySimpleFontData;
91     RefPtr<FontSelector> m_fontSelector;
92     unsigned m_fontSelectorVersion;
93     mutable int m_familyIndex;
94     unsigned short m_generation;
95     mutable unsigned m_pitch : 3; // Pitch
96     mutable bool m_loadingCustomFonts : 1;
97
98     friend class Font;
99 };
100
101 }
102
103 #endif