Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: Source/core/platform/graphics/win/FontPlatformDataWin.h

Issue 99103006: Moving GraphicsContext and dependencies from core to platform. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Final patch - fixes Android Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2006, 2007 Apple Computer, Inc.
3 * Copyright (c) 2006, 2007, 2008, 2009, Google Inc. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
14 * distribution.
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #ifndef FontPlatformDataChromiumWin_h
33 #define FontPlatformDataChromiumWin_h
34
35 #include "SkPaint.h"
36 #include "SkTypeface.h"
37 #include "SkTypeface_win.h"
38 #include "core/platform/graphics/opentype/OpenTypeVerticalData.h"
39 #include "platform/SharedBuffer.h"
40 #include "platform/fonts/FontOrientation.h"
41 #include "wtf/Forward.h"
42 #include "wtf/HashTableDeletedValueType.h"
43 #include "wtf/OwnPtr.h"
44 #include "wtf/PassRefPtr.h"
45 #include "wtf/RefCounted.h"
46 #include "wtf/RefPtr.h"
47 #include "wtf/text/StringImpl.h"
48
49 #include <usp10.h>
50
51 typedef struct HFONT__ *HFONT;
52
53 namespace WebCore {
54
55 // Return a typeface associated with the hfont, and return its size and
56 // lfQuality from the hfont's LOGFONT.
57 PassRefPtr<SkTypeface> CreateTypefaceFromHFont(HFONT, int* size, int* paintTextF lags);
58
59 class FontDescription;
60 class GraphicsContext;
61 class HarfBuzzFace;
62
63 class FontPlatformData {
64 public:
65 // Used for deleted values in the font cache's hash tables. The hash table
66 // will create us with this structure, and it will compare other values
67 // to this "Deleted" one. It expects the Deleted one to be differentiable
68 // from the NULL one (created with the empty constructor), so we can't just
69 // set everything to NULL.
70 FontPlatformData(WTF::HashTableDeletedValueType);
71 FontPlatformData();
72 #if ENABLE(GDI_FONTS_ON_WINDOWS)
73 // This constructor takes ownership of the HFONT
74 FontPlatformData(HFONT, float size, FontOrientation);
75 #endif
76 FontPlatformData(float size, bool bold, bool oblique);
77 FontPlatformData(const FontPlatformData&);
78 FontPlatformData(const FontPlatformData&, float textSize);
79 FontPlatformData(PassRefPtr<SkTypeface>, const char* name, float textSize, b ool fakeBold, bool fakeItalic, FontOrientation = Horizontal, bool useSubpixelPos itioning = false);
80
81 void setupPaint(SkPaint*, GraphicsContext* = 0) const;
82
83 FontPlatformData& operator=(const FontPlatformData&);
84
85 bool isHashTableDeletedValue() const { return m_isHashTableDeletedValue; }
86
87 ~FontPlatformData();
88
89 bool isFixedPitch() const;
90 float size() const { return m_textSize; }
91 #if USE(HARFBUZZ)
92 HarfBuzzFace* harfBuzzFace() const;
93 #else
94 HFONT hfont() const { return m_font ? m_font->hfont() : 0; }
95 #endif
96 SkTypeface* typeface() const { return m_typeface.get(); }
97 SkFontID uniqueID() const { return m_typeface->uniqueID(); }
98 int paintTextFlags() const { return m_paintTextFlags; }
99
100 String fontFamilyName() const;
101
102 FontOrientation orientation() const { return m_orientation; }
103 void setOrientation(FontOrientation orientation) { m_orientation = orientati on; }
104
105 #if ENABLE(GDI_FONTS_ON_WINDOWS)
106 unsigned hash() const
107 {
108 return m_font ? m_font->hash() : NULL;
109 }
110 #else
111 unsigned hash() const;
112 #endif
113
114 bool operator==(const FontPlatformData&) const;
115
116 #if ENABLE(OPENTYPE_VERTICAL)
117 PassRefPtr<OpenTypeVerticalData> verticalData() const;
118 PassRefPtr<SharedBuffer> openTypeTable(uint32_t table) const;
119 #endif
120
121 #ifndef NDEBUG
122 String description() const;
123 #endif
124
125 #if !USE(HARFBUZZ)
126 SCRIPT_FONTPROPERTIES* scriptFontProperties() const;
127 SCRIPT_CACHE* scriptCache() const { return &m_scriptCache; }
128 static bool ensureFontLoaded(HFONT);
129 #endif
130
131 private:
132 #if !USE(HARFBUZZ)
133 // We refcount the internal HFONT so that FontPlatformData can be
134 // efficiently copied. WebKit depends on being able to copy it, and we
135 // don't really want to re-create the HFONT.
136 class RefCountedHFONT : public RefCounted<RefCountedHFONT> {
137 public:
138 static PassRefPtr<RefCountedHFONT> create(HFONT hfont)
139 {
140 return adoptRef(new RefCountedHFONT(hfont));
141 }
142
143 ~RefCountedHFONT();
144
145 HFONT hfont() const { return m_hfont; }
146 unsigned hash() const
147 {
148 return StringHasher::hashMemory<sizeof(HFONT)>(&m_hfont);
149 }
150
151 bool operator==(const RefCountedHFONT& other) const
152 {
153 return m_hfont == other.m_hfont;
154 }
155
156 private:
157 // The create() function assumes there is already a refcount of one
158 // so it can do adoptRef.
159 RefCountedHFONT(HFONT hfont) : m_hfont(hfont)
160 {
161 }
162
163 HFONT m_hfont;
164 };
165
166 RefPtr<RefCountedHFONT> m_font;
167 #endif // !USE(HARFBUZZ)
168 float m_textSize; // Point size of the font in pixels.
169 FontOrientation m_orientation;
170 bool m_fakeBold;
171 bool m_fakeItalic;
172
173 RefPtr<SkTypeface> m_typeface;
174 int m_paintTextFlags;
175
176 #if USE(HARFBUZZ)
177 mutable RefPtr<HarfBuzzFace> m_harfBuzzFace;
178 #else
179 mutable SCRIPT_CACHE m_scriptCache;
180 mutable OwnPtr<SCRIPT_FONTPROPERTIES> m_scriptFontProperties;
181 #endif
182
183 bool m_isHashTableDeletedValue;
184 bool m_useSubpixelPositioning;
185 };
186
187 } // WebCore
188
189 #endif // FontPlatformDataChromiumWin_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698