Changeset 84490 in webkit
- Timestamp:
- Apr 21, 2011 6:34:36 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r84489 r84490 1 2011-04-21 Nikolas Zimmermann <nzimmermann@rim.com> 2 3 Reviewed by Dirk Schulze. 4 5 Split GlyphPage from GlyphPageTreeNode.h into its own header 6 https://bugs.webkit.org/show_bug.cgi?id=59096 7 8 * GNUmakefile.list.am: Add GlyphPage.h to build. 9 * WebCore.gypi: Ditto. 10 * WebCore.vcproj/WebCore.vcproj: Ditto. 11 * WebCore.xcodeproj/project.pbxproj: Ditto. 12 * platform/graphics/GlyphPage.h: Copied from platform/graphics/GlyphPageTreeNode.h. Removed GlyphPageTreeNode class, leaving only GlyphPage. 13 * platform/graphics/GlyphPageTreeNode.h: Removed GlyphPage class. 14 1 15 2011-04-21 Nikolas Zimmermann <nzimmermann@rim.com> 2 16 -
trunk/Source/WebCore/GNUmakefile.list.am
r84489 r84490 2428 2428 Source/WebCore/platform/graphics/GlyphBuffer.h \ 2429 2429 Source/WebCore/platform/graphics/GlyphMetricsMap.h \ 2430 Source/WebCore/platform/graphics/GlyphPage.h \ 2430 2431 Source/WebCore/platform/graphics/GlyphPageTreeNode.cpp \ 2431 2432 Source/WebCore/platform/graphics/GlyphPageTreeNode.h \ -
trunk/Source/WebCore/WebCore.gypi
r84489 r84490 823 823 'platform/graphics/GlyphBuffer.h', 824 824 'platform/graphics/GlyphMetricsMap.h', 825 'platform/graphics/GlyphPage.h', 825 826 'platform/graphics/GlyphPageTreeNode.h', 826 827 'platform/graphics/Gradient.h', -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r84489 r84490 27070 27070 </File> 27071 27071 <File 27072 RelativePath="..\platform\graphics\GlyphPage.h" 27073 > 27074 </File> 27075 <File 27072 27076 RelativePath="..\platform\graphics\GlyphPageTreeNode.cpp" 27073 27077 > -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r84489 r84490 138 138 087281570F26B9B600AFC596 /* OptionGroupElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 087281530F26B9B600AFC596 /* OptionGroupElement.cpp */; }; 139 139 087281580F26B9B600AFC596 /* OptionGroupElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 087281540F26B9B600AFC596 /* OptionGroupElement.h */; }; 140 0873B86B136064EA00A522C2 /* GlyphPage.h in Headers */ = {isa = PBXBuildFile; fileRef = 0873B86A136064EA00A522C2 /* GlyphPage.h */; settings = {ATTRIBUTES = (Private, ); }; }; 140 141 08744BAA0EDB7D86004C9E63 /* WMLOnEventElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08744BA90EDB7D86004C9E63 /* WMLOnEventElement.cpp */; }; 141 142 08744BAE0EDB7D92004C9E63 /* WMLOnEventElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 08744BAD0EDB7D92004C9E63 /* WMLOnEventElement.h */; }; … … 6571 6572 087281530F26B9B600AFC596 /* OptionGroupElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OptionGroupElement.cpp; sourceTree = "<group>"; }; 6572 6573 087281540F26B9B600AFC596 /* OptionGroupElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OptionGroupElement.h; sourceTree = "<group>"; }; 6574 0873B86A136064EA00A522C2 /* GlyphPage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GlyphPage.h; sourceTree = "<group>"; }; 6573 6575 08744BA90EDB7D86004C9E63 /* WMLOnEventElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WMLOnEventElement.cpp; sourceTree = "<group>"; }; 6574 6576 08744BAD0EDB7D92004C9E63 /* WMLOnEventElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMLOnEventElement.h; sourceTree = "<group>"; }; … … 17885 17887 B2C3DA5B0D006CD600EF6F26 /* GlyphBuffer.h */, 17886 17888 C5D4AA78116BAFB60069CA93 /* GlyphMetricsMap.h */, 17889 0873B86A136064EA00A522C2 /* GlyphPage.h */, 17887 17890 B2C3DA5C0D006CD600EF6F26 /* GlyphPageTreeNode.cpp */, 17888 17891 B2C3DA5D0D006CD600EF6F26 /* GlyphPageTreeNode.h */, … … 23008 23011 977E2E0F12F0FC9C00C13379 /* XSSFilter.h in Headers */, 23009 23012 086BBD0F136039C2008B15D8 /* Glyph.h in Headers */, 23013 0873B86B136064EA00A522C2 /* GlyphPage.h in Headers */, 23010 23014 ); 23011 23015 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/WebCore/platform/graphics/GlyphPage.h
r84489 r84490 1 1 /* 2 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 3 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 27 28 */ 28 29 29 #ifndef GlyphPage TreeNode_h30 #define GlyphPage TreeNode_h30 #ifndef GlyphPage_h 31 #define GlyphPage_h 31 32 32 33 #include "Glyph.h" 33 #include <string.h>34 #include <wtf/HashMap.h>35 34 #include <wtf/PassRefPtr.h> 36 35 #include <wtf/RefCounted.h> 37 36 #include <wtf/unicode/Unicode.h> 38 37 39 #ifndef NDEBUG40 void showGlyphPageTrees();41 void showGlyphPageTree(unsigned pageNumber);42 #endif43 44 38 namespace WebCore { 45 39 46 class FontData;40 class SimpleFontData; 47 41 class GlyphPageTreeNode; 48 class SimpleFontData;49 42 50 43 // Holds the glyph index and the corresponding SimpleFontData information for a given … … 105 98 setGlyphDataForIndex(indexForCharacter(c), g, f); 106 99 } 100 107 101 void setGlyphDataForIndex(unsigned index, Glyph g, const SimpleFontData* f) 108 102 { … … 111 105 m_glyphFontData[index] = f; 112 106 } 107 113 108 void setGlyphDataForIndex(unsigned index, const GlyphData& glyphData) 114 109 { … … 146 141 }; 147 142 148 // The glyph page tree is a data structure that maps (FontData, glyph page number)149 // to a GlyphPage. Level 0 (the "root") is special. There is one root150 // GlyphPageTreeNode for each glyph page number. The roots do not have a151 // GlyphPage associated with them, and their initializePage() function is never152 // called to fill the glyphs.153 //154 // Each root node maps a FontData pointer to another GlyphPageTreeNode at155 // level 1 (the "root child") that stores the actual glyphs for a specific font data.156 // These nodes will only have a GlyphPage if they have glyphs for that range.157 //158 // Levels greater than one correspond to subsequent levels of the fallback list159 // for that font. These levels override their parent's page of glyphs by160 // filling in holes with the new font (thus making a more complete page).161 //162 // A NULL FontData pointer corresponds to the system fallback163 // font. It is tracked separately from the regular pages and overrides so that164 // the glyph pages do not get polluted with these last-resort glyphs. The165 // system fallback page is not populated at construction like the other pages,166 // but on demand for each glyph, because the system may need to use different167 // fallback fonts for each. This lazy population is done by the Font.168 class GlyphPageTreeNode {169 public:170 GlyphPageTreeNode()171 : m_parent(0)172 , m_level(0)173 , m_isSystemFallback(false)174 , m_customFontCount(0)175 , m_systemFallbackChild(0)176 #ifndef NDEBUG177 , m_pageNumber(0)178 #endif179 {180 }181 182 ~GlyphPageTreeNode();183 184 static HashMap<int, GlyphPageTreeNode*>* roots;185 static GlyphPageTreeNode* pageZeroRoot;186 187 static GlyphPageTreeNode* getRootChild(const FontData* fontData, unsigned pageNumber)188 {189 return getRoot(pageNumber)->getChild(fontData, pageNumber);190 }191 192 static void pruneTreeCustomFontData(const FontData*);193 static void pruneTreeFontData(const SimpleFontData*);194 195 void pruneCustomFontData(const FontData*);196 void pruneFontData(const SimpleFontData*, unsigned level = 0);197 198 GlyphPageTreeNode* parent() const { return m_parent; }199 GlyphPageTreeNode* getChild(const FontData*, unsigned pageNumber);200 201 // Returns a page of glyphs (or NULL if there are no glyphs in this page's character range).202 GlyphPage* page() const { return m_page.get(); }203 204 // Returns the level of this node. See class-level comment.205 unsigned level() const { return m_level; }206 207 // The system fallback font has special rules (see above).208 bool isSystemFallback() const { return m_isSystemFallback; }209 210 static size_t treeGlyphPageCount();211 size_t pageCount() const;212 213 private:214 static GlyphPageTreeNode* getRoot(unsigned pageNumber);215 void initializePage(const FontData*, unsigned pageNumber);216 217 #ifndef NDEBUG218 void showSubtree();219 #endif220 221 GlyphPageTreeNode* m_parent;222 RefPtr<GlyphPage> m_page;223 unsigned m_level : 31;224 bool m_isSystemFallback : 1;225 unsigned m_customFontCount;226 HashMap<const FontData*, GlyphPageTreeNode*> m_children;227 GlyphPageTreeNode* m_systemFallbackChild;228 229 #ifndef NDEBUG230 unsigned m_pageNumber;231 232 friend void ::showGlyphPageTree(unsigned pageNumber);233 #endif234 };235 236 143 } // namespace WebCore 237 144 -
trunk/Source/WebCore/platform/graphics/GlyphPageTreeNode.h
r84489 r84490 30 30 #define GlyphPageTreeNode_h 31 31 32 #include "Glyph .h"32 #include "GlyphPage.h" 33 33 #include <string.h> 34 34 #include <wtf/HashMap.h> … … 45 45 46 46 class FontData; 47 class GlyphPageTreeNode;48 47 class SimpleFontData; 49 50 // Holds the glyph index and the corresponding SimpleFontData information for a given51 // character.52 struct GlyphData {53 GlyphData(Glyph g = 0, const SimpleFontData* f = 0)54 : glyph(g)55 , fontData(f)56 {57 }58 Glyph glyph;59 const SimpleFontData* fontData;60 };61 62 // A GlyphPage contains a fixed-size set of GlyphData mappings for a contiguous63 // range of characters in the Unicode code space. GlyphPages are indexed64 // starting from 0 and incrementing for each 256 glyphs.65 //66 // One page may actually include glyphs from other fonts if the characters are67 // missing in the primary font. It is owned by exactly one GlyphPageTreeNode,68 // although multiple nodes may reference it as their "page" if they are supposed69 // to be overriding the parent's node, but provide no additional information.70 class GlyphPage : public RefCounted<GlyphPage> {71 public:72 static PassRefPtr<GlyphPage> create(GlyphPageTreeNode* owner)73 {74 return adoptRef(new GlyphPage(owner));75 }76 77 static const size_t size = 256; // Covers Latin-1 in a single page.78 79 unsigned indexForCharacter(UChar32 c) const { return c % size; }80 GlyphData glyphDataForCharacter(UChar32 c) const81 {82 unsigned index = indexForCharacter(c);83 return GlyphData(m_glyphs[index], m_glyphFontData[index]);84 }85 86 GlyphData glyphDataForIndex(unsigned index) const87 {88 ASSERT(index < size);89 return GlyphData(m_glyphs[index], m_glyphFontData[index]);90 }91 92 Glyph glyphAt(unsigned index) const93 {94 ASSERT(index < size);95 return m_glyphs[index];96 }97 98 const SimpleFontData* fontDataForCharacter(UChar32 c) const99 {100 return m_glyphFontData[indexForCharacter(c)];101 }102 103 void setGlyphDataForCharacter(UChar32 c, Glyph g, const SimpleFontData* f)104 {105 setGlyphDataForIndex(indexForCharacter(c), g, f);106 }107 void setGlyphDataForIndex(unsigned index, Glyph g, const SimpleFontData* f)108 {109 ASSERT(index < size);110 m_glyphs[index] = g;111 m_glyphFontData[index] = f;112 }113 void setGlyphDataForIndex(unsigned index, const GlyphData& glyphData)114 {115 setGlyphDataForIndex(index, glyphData.glyph, glyphData.fontData);116 }117 118 void copyFrom(const GlyphPage& other)119 {120 memcpy(m_glyphs, other.m_glyphs, sizeof(m_glyphs));121 memcpy(m_glyphFontData, other.m_glyphFontData, sizeof(m_glyphFontData));122 }123 124 void clear()125 {126 memset(m_glyphs, 0, sizeof(m_glyphs));127 memset(m_glyphFontData, 0, sizeof(m_glyphFontData));128 }129 130 GlyphPageTreeNode* owner() const { return m_owner; }131 132 // Implemented by the platform.133 bool fill(unsigned offset, unsigned length, UChar* characterBuffer, unsigned bufferLength, const SimpleFontData*);134 135 private:136 GlyphPage(GlyphPageTreeNode* owner)137 : m_owner(owner)138 {139 }140 141 // Separate arrays, rather than array of GlyphData, to save space.142 Glyph m_glyphs[size];143 const SimpleFontData* m_glyphFontData[size];144 145 GlyphPageTreeNode* m_owner;146 };147 48 148 49 // The glyph page tree is a data structure that maps (FontData, glyph page number)
Note: See TracChangeset
for help on using the changeset viewer.