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

Side by Side Diff: webkit/port/platform/graphics/chromium/FontPlatformDataLinux.h

Issue 10414: Use Skia to render fonts (Closed)
Patch Set: Created 12 years, 1 month 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef FontPlatformDataLinux_h 5 #ifndef FontPlatformDataLinux_h
6 #define FontPlatformDataLinux_h 6 #define FontPlatformDataLinux_h
7 7
8 #include "config.h" 8 #include "config.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 10
11 #include <pango/pango.h>
12
13 #include "StringImpl.h" 11 #include "StringImpl.h"
14 #include "NotImplemented.h" 12 #include "NotImplemented.h"
15 #include <wtf/PassRefPtr.h> 13 #include <wtf/PassRefPtr.h>
16 #include <wtf/RefCounted.h> 14 #include <wtf/RefCounted.h>
17 15
16 class SkPaint;
17 class SkTypeface;
18
18 namespace WebCore { 19 namespace WebCore {
19 20
20 class FontDescription; 21 class FontDescription;
21 22
23 // -----------------------------------------------------------------------------
24 // FontPlatformData is the handle which WebKit has on a specific face. A face
25 // is the tuple of (font, size, ...etc). Here we are just wrapping a Skia
26 // SkTypeface pointer and dealing with the reference counting etc.
27 // -----------------------------------------------------------------------------
22 class FontPlatformData { 28 class FontPlatformData {
23 public: 29 public:
24 // Used for deleted values in the font cache's hash tables. The hash table 30 // Used for deleted values in the font cache's hash tables. The hash table
25 // will create us with this structure, and it will compare other values 31 // will create us with this structure, and it will compare other values
26 // to this "Deleted" one. It expects the Deleted one to be differentiable 32 // to this "Deleted" one. It expects the Deleted one to be differentiable
27 // from the NULL one (created with the empty constructor), so we can't just 33 // from the NULL one (created with the empty constructor), so we can't just
28 // set everything to NULL. 34 // set everything to NULL.
29 FontPlatformData(WTF::HashTableDeletedValueType) 35 FontPlatformData(WTF::HashTableDeletedValueType)
30 : m_context(0) 36 : m_typeface(hashTableDeletedFontValue())
31 , m_font(hashTableDeletedFontValue()) 37 , m_textSize(0)
38 , m_fakeBold(false)
39 , m_fakeItalic(false)
32 { } 40 { }
33 41
34 FontPlatformData() 42 FontPlatformData()
35 : m_context(0) 43 : m_typeface(0)
36 , m_font(0) 44 , m_textSize(0)
45 , m_fakeBold(false)
46 , m_fakeItalic(false)
37 { } 47 { }
38 48
39 FontPlatformData(const FontDescription&, const AtomicString& family); 49 FontPlatformData(float textSize, bool fakeBold, bool fakeItalic)
50 : m_typeface(0)
51 , m_textSize(textSize)
52 , m_fakeBold(fakeBold)
53 , m_fakeItalic(fakeItalic)
54 { }
40 55
41 FontPlatformData(float size, bool bold, bool oblique); 56 FontPlatformData(const FontPlatformData&);
42 57 FontPlatformData(SkTypeface *, float textSize, bool fakeBold, bool fakeItali c);
58 FontPlatformData(const FontPlatformData& src, float textSize);
43 ~FontPlatformData(); 59 ~FontPlatformData();
44 60
45 static bool init(); 61 // -------------------------------------------------------------------------
62 // Return true iff this font is monospaced (i.e. every glyph has an equal x
63 // advance)
64 // -------------------------------------------------------------------------
65 bool isFixedPitch() const;
46 66
47 bool isFixedPitch() const; 67 // -------------------------------------------------------------------------
48 float size() const { return m_size; } 68 // Setup a Skia painting context to use this font.
69 // -------------------------------------------------------------------------
70 void setupPaint(SkPaint*) const;
49 71
50 unsigned hash() const 72 unsigned hash() const;
51 { 73 float size() const { return m_textSize; }
52 notImplemented();
53 return 0;
54 }
55 74
56 bool operator==(const FontPlatformData& other) const; 75 bool operator==(const FontPlatformData& other) const;
57 bool isHashTableDeletedValue() const { return m_font == hashTableDeletedFont Value(); } 76 FontPlatformData& operator=(const FontPlatformData& src);
58 77 bool isHashTableDeletedValue() const { return m_typeface == hashTableDeleted FontValue(); }
59 static PangoFontMap* m_fontMap;
60 static GHashTable* m_hashTable;
61
62 PangoContext* m_context;
63 PangoFont* m_font;
64
65 float m_size;
66 bool m_syntheticBold;
67 bool m_syntheticOblique;
68 78
69 private: 79 private:
70 static PangoFont* hashTableDeletedFontValue() { return reinterpret_cast<Pang oFont*>(-1); } 80 SkTypeface* m_typeface;
81 float m_textSize;
82 bool m_fakeBold;
83 bool m_fakeItalic;
84
85 SkTypeface* hashTableDeletedFontValue() const { return reinterpret_cast<SkTy peface*>(-1); }
71 }; 86 };
72 87
73 } // namespace WebCore 88 } // namespace WebCore
74 89
75 #endif // ifdef FontPlatformData_h 90 #endif // ifdef FontPlatformData_h
OLDNEW
« no previous file with comments | « webkit/port/platform/graphics/chromium/FontLinux.cpp ('k') | webkit/port/platform/graphics/chromium/FontPlatformDataLinux.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698