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

Side by Side Diff: Source/platform/fonts/shaping/SimpleShaper.h

Issue 860163004: Using FloatRect in SimpleShaper and remove GlyphBounds (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Comment fixes Created 5 years, 11 months 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 /* 1 /*
2 * Copyright (C) 2003, 2006, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2006, 2008, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Holger Hans Peter Freyther 3 * Copyright (C) 2008 Holger Hans Peter Freyther
4 * Copyright (C) 2014 Google Inc. All rights reserved. 4 * Copyright (C) 2014 Google Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
11 * This library is distributed in the hope that it will be useful, 11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details. 14 * Library General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Library General Public License 16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to 17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA. 19 * Boston, MA 02110-1301, USA.
20 * 20 *
21 */ 21 */
22 22
23 #ifndef SimpleShaper_h 23 #ifndef SimpleShaper_h
24 #define SimpleShaper_h 24 #define SimpleShaper_h
25 25
26 #include "platform/PlatformExport.h" 26 #include "platform/PlatformExport.h"
27 #include "platform/geometry/FloatPoint.h"
28 #include "platform/geometry/FloatRect.h"
27 #include "platform/text/TextRun.h" 29 #include "platform/text/TextRun.h"
28 #include "wtf/HashSet.h" 30 #include "wtf/HashSet.h"
29 #include "wtf/unicode/Unicode.h" 31 #include "wtf/unicode/Unicode.h"
30 32
31 namespace blink { 33 namespace blink {
32 34
33 class Font; 35 class Font;
34 class GlyphBuffer; 36 class GlyphBuffer;
35 class SimpleFontData; 37 class SimpleFontData;
36 class TextRun; 38 class TextRun;
37 struct GlyphData; 39 struct GlyphData;
38 40
39 struct PLATFORM_EXPORT SimpleShaper { 41 struct PLATFORM_EXPORT SimpleShaper {
40 WTF_MAKE_FAST_ALLOCATED; 42 WTF_MAKE_FAST_ALLOCATED;
41 public: 43 public:
42 class GlyphBounds { 44 SimpleShaper(const Font*, const TextRun&, HashSet<const SimpleFontData*>* fa llbackFonts = 0, FloatRect* = 0, bool forTextEmphasis = false);
43 public:
44 GlyphBounds()
45 {
46 maxGlyphBoundingBoxY = std::numeric_limits<float>::min();
47 minGlyphBoundingBoxY = std::numeric_limits<float>::max();
48 firstGlyphOverflow = 0;
49 lastGlyphOverflow = 0;
50 }
51 float maxGlyphBoundingBoxY;
52 float minGlyphBoundingBoxY;
53 float firstGlyphOverflow;
54 float lastGlyphOverflow;
55 };
56
57 SimpleShaper(const Font*, const TextRun&, HashSet<const SimpleFontData*>* fa llbackFonts = 0, GlyphBounds* = 0, bool forTextEmphasis = false);
58 45
59 unsigned advance(unsigned to, GlyphBuffer* = 0); 46 unsigned advance(unsigned to, GlyphBuffer* = 0);
60 bool advanceOneCharacter(float& width); 47 bool advanceOneCharacter(float& width);
61 48
62 const TextRun& run() const { return m_run; } 49 const TextRun& run() const { return m_run; }
63 float runWidthSoFar() const { return m_runWidthSoFar; } 50 float runWidthSoFar() const { return m_runWidthSoFar; }
64 unsigned currentOffset() { return m_currentCharacter; } 51 unsigned currentOffset() { return m_currentCharacter; }
65 52
66 private: 53 private:
67 const Font* m_font; 54 const Font* m_font;
68 const TextRun& m_run; 55 const TextRun& m_run;
69 unsigned m_currentCharacter; 56 unsigned m_currentCharacter;
70 float m_runWidthSoFar; 57 float m_runWidthSoFar;
71 float m_expansion; 58 float m_expansion;
72 float m_expansionPerOpportunity; 59 float m_expansionPerOpportunity;
73 bool m_isAfterExpansion; 60 bool m_isAfterExpansion;
74 61
75 struct CharacterData { 62 struct CharacterData {
76 UChar32 character; 63 UChar32 character;
77 unsigned clusterLength; 64 unsigned clusterLength;
78 int characterOffset; 65 int characterOffset;
79 }; 66 };
80 67
81 GlyphData glyphDataForCharacter(CharacterData&, bool normalizeSpace = false) ; 68 GlyphData glyphDataForCharacter(CharacterData&, bool normalizeSpace = false) ;
82 float characterWidth(UChar32, const GlyphData&) const; 69 float characterWidth(UChar32, const GlyphData&) const;
83 void cacheFallbackFont(const SimpleFontData*, const SimpleFontData* primaryF ont); 70 void cacheFallbackFont(const SimpleFontData*, const SimpleFontData* primaryF ont);
84 float adjustSpacing(float, const CharacterData&); 71 float adjustSpacing(float, const CharacterData&);
85 void updateGlyphBounds(const GlyphData&, float width, bool firstCharacter);
86 72
87 template <typename TextIterator> 73 template <typename TextIterator>
88 unsigned advanceInternal(TextIterator&, GlyphBuffer*); 74 unsigned advanceInternal(TextIterator&, GlyphBuffer*);
89 75
90 HashSet<const SimpleFontData*>* m_fallbackFonts; 76 HashSet<const SimpleFontData*>* m_fallbackFonts;
91 GlyphBounds* m_bounds; 77 FloatRect* m_glyphBoundingBox;
92 bool m_forTextEmphasis : 1; 78 bool m_forTextEmphasis : 1;
93 }; 79 };
94 80
95 } // namespace blink 81 } // namespace blink
96 82
97 #endif 83 #endif
OLDNEW
« no previous file with comments | « Source/platform/fonts/shaping/HarfBuzzShaper.cpp ('k') | Source/platform/fonts/shaping/SimpleShaper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698