Changeset 84490 in webkit


Ignore:
Timestamp:
Apr 21, 2011 6:34:36 AM (13 years ago)
Author:
Nikolas Zimmermann
Message:

2011-04-21 Nikolas Zimmermann <nzimmermann@rim.com>

Reviewed by Dirk Schulze.

Split GlyphPage from GlyphPageTreeNode.h into its own header
https://bugs.webkit.org/show_bug.cgi?id=59096

  • GNUmakefile.list.am: Add GlyphPage.h to build.
  • WebCore.gypi: Ditto.
  • WebCore.vcproj/WebCore.vcproj: Ditto.
  • WebCore.xcodeproj/project.pbxproj: Ditto.
  • platform/graphics/GlyphPage.h: Copied from platform/graphics/GlyphPageTreeNode.h. Removed GlyphPageTreeNode class, leaving only GlyphPage.
  • platform/graphics/GlyphPageTreeNode.h: Removed GlyphPage class.
Location:
trunk/Source/WebCore
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r84489 r84490  
     12011-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
    1152011-04-21  Nikolas Zimmermann  <nzimmermann@rim.com>
    216
  • trunk/Source/WebCore/GNUmakefile.list.am

    r84489 r84490  
    24282428        Source/WebCore/platform/graphics/GlyphBuffer.h \
    24292429        Source/WebCore/platform/graphics/GlyphMetricsMap.h \
     2430        Source/WebCore/platform/graphics/GlyphPage.h \
    24302431        Source/WebCore/platform/graphics/GlyphPageTreeNode.cpp \
    24312432        Source/WebCore/platform/graphics/GlyphPageTreeNode.h \
  • trunk/Source/WebCore/WebCore.gypi

    r84489 r84490  
    823823            'platform/graphics/GlyphBuffer.h',
    824824            'platform/graphics/GlyphMetricsMap.h',
     825            'platform/graphics/GlyphPage.h',
    825826            'platform/graphics/GlyphPageTreeNode.h',
    826827            'platform/graphics/Gradient.h',
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r84489 r84490  
    2707027070                                </File>
    2707127071                                <File
     27072                                        RelativePath="..\platform\graphics\GlyphPage.h"
     27073                                        >
     27074                                </File>
     27075                                <File
    2707227076                                        RelativePath="..\platform\graphics\GlyphPageTreeNode.cpp"
    2707327077                                        >
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r84489 r84490  
    138138                087281570F26B9B600AFC596 /* OptionGroupElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 087281530F26B9B600AFC596 /* OptionGroupElement.cpp */; };
    139139                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, ); }; };
    140141                08744BAA0EDB7D86004C9E63 /* WMLOnEventElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08744BA90EDB7D86004C9E63 /* WMLOnEventElement.cpp */; };
    141142                08744BAE0EDB7D92004C9E63 /* WMLOnEventElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 08744BAD0EDB7D92004C9E63 /* WMLOnEventElement.h */; };
     
    65716572                087281530F26B9B600AFC596 /* OptionGroupElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OptionGroupElement.cpp; sourceTree = "<group>"; };
    65726573                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>"; };
    65736575                08744BA90EDB7D86004C9E63 /* WMLOnEventElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WMLOnEventElement.cpp; sourceTree = "<group>"; };
    65746576                08744BAD0EDB7D92004C9E63 /* WMLOnEventElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMLOnEventElement.h; sourceTree = "<group>"; };
     
    1788517887                                B2C3DA5B0D006CD600EF6F26 /* GlyphBuffer.h */,
    1788617888                                C5D4AA78116BAFB60069CA93 /* GlyphMetricsMap.h */,
     17889                                0873B86A136064EA00A522C2 /* GlyphPage.h */,
    1788717890                                B2C3DA5C0D006CD600EF6F26 /* GlyphPageTreeNode.cpp */,
    1788817891                                B2C3DA5D0D006CD600EF6F26 /* GlyphPageTreeNode.h */,
     
    2300823011                                977E2E0F12F0FC9C00C13379 /* XSSFilter.h in Headers */,
    2300923012                                086BBD0F136039C2008B15D8 /* Glyph.h in Headers */,
     23013                                0873B86B136064EA00A522C2 /* GlyphPage.h in Headers */,
    2301023014                        );
    2301123015                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/Source/WebCore/platform/graphics/GlyphPage.h

    r84489 r84490  
    11/*
    22 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
     3 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    2728 */
    2829
    29 #ifndef GlyphPageTreeNode_h
    30 #define GlyphPageTreeNode_h
     30#ifndef GlyphPage_h
     31#define GlyphPage_h
    3132
    3233#include "Glyph.h"
    33 #include <string.h>
    34 #include <wtf/HashMap.h>
    3534#include <wtf/PassRefPtr.h>
    3635#include <wtf/RefCounted.h>
    3736#include <wtf/unicode/Unicode.h>
    3837
    39 #ifndef NDEBUG
    40 void showGlyphPageTrees();
    41 void showGlyphPageTree(unsigned pageNumber);
    42 #endif
    43 
    4438namespace WebCore {
    4539
    46 class FontData;
     40class SimpleFontData;
    4741class GlyphPageTreeNode;
    48 class SimpleFontData;
    4942
    5043// Holds the glyph index and the corresponding SimpleFontData information for a given
     
    10598        setGlyphDataForIndex(indexForCharacter(c), g, f);
    10699    }
     100
    107101    void setGlyphDataForIndex(unsigned index, Glyph g, const SimpleFontData* f)
    108102    {
     
    111105        m_glyphFontData[index] = f;
    112106    }
     107
    113108    void setGlyphDataForIndex(unsigned index, const GlyphData& glyphData)
    114109    {
     
    146141};
    147142
    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 root
    150 // GlyphPageTreeNode for each glyph page number.  The roots do not have a
    151 // GlyphPage associated with them, and their initializePage() function is never
    152 // called to fill the glyphs.
    153 //
    154 // Each root node maps a FontData pointer to another GlyphPageTreeNode at
    155 // 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 list
    159 // for that font. These levels override their parent's page of glyphs by
    160 // filling in holes with the new font (thus making a more complete page).
    161 //
    162 // A NULL FontData pointer corresponds to the system fallback
    163 // font. It is tracked separately from the regular pages and overrides so that
    164 // the glyph pages do not get polluted with these last-resort glyphs. The
    165 // 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 different
    167 // 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 NDEBUG
    177         , m_pageNumber(0)
    178 #endif
    179     {
    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 NDEBUG
    218     void showSubtree();
    219 #endif
    220 
    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 NDEBUG
    230     unsigned m_pageNumber;
    231 
    232     friend void ::showGlyphPageTree(unsigned pageNumber);
    233 #endif
    234 };
    235 
    236143} // namespace WebCore
    237144
  • trunk/Source/WebCore/platform/graphics/GlyphPageTreeNode.h

    r84489 r84490  
    3030#define GlyphPageTreeNode_h
    3131
    32 #include "Glyph.h"
     32#include "GlyphPage.h"
    3333#include <string.h>
    3434#include <wtf/HashMap.h>
     
    4545
    4646class FontData;
    47 class GlyphPageTreeNode;
    4847class SimpleFontData;
    49 
    50 // Holds the glyph index and the corresponding SimpleFontData information for a given
    51 // 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 contiguous
    63 // range of characters in the Unicode code space. GlyphPages are indexed
    64 // starting from 0 and incrementing for each 256 glyphs.
    65 //
    66 // One page may actually include glyphs from other fonts if the characters are
    67 // 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 supposed
    69 // 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) const
    81     {
    82         unsigned index = indexForCharacter(c);
    83         return GlyphData(m_glyphs[index], m_glyphFontData[index]);
    84     }
    85 
    86     GlyphData glyphDataForIndex(unsigned index) const
    87     {
    88         ASSERT(index < size);
    89         return GlyphData(m_glyphs[index], m_glyphFontData[index]);
    90     }
    91 
    92     Glyph glyphAt(unsigned index) const
    93     {
    94         ASSERT(index < size);
    95         return m_glyphs[index];
    96     }
    97 
    98     const SimpleFontData* fontDataForCharacter(UChar32 c) const
    99     {
    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 };
    14748
    14849// The glyph page tree is a data structure that maps (FontData, glyph page number)
Note: See TracChangeset for help on using the changeset viewer.