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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/GlyphBuffer.h

Issue 2502413004: WTF/std normalization: replace WTF::Vector::last with ::back (Closed)
Patch Set: rebase Created 4 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 /* 1 /*
2 * Copyright (C) 2006, 2009, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2009, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2007-2008 Torch Mobile Inc. 3 * Copyright (C) 2007-2008 Torch Mobile Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 void add(Glyph glyph, const SimpleFontData* font, const FloatPoint& offset) { 104 void add(Glyph glyph, const SimpleFontData* font, const FloatPoint& offset) {
105 // cannot mix x-only/xy offsets 105 // cannot mix x-only/xy offsets
106 ASSERT(isEmpty() || hasVerticalOffsets()); 106 ASSERT(isEmpty() || hasVerticalOffsets());
107 107
108 m_fontData.append(font); 108 m_fontData.append(font);
109 m_glyphs.append(glyph); 109 m_glyphs.append(glyph);
110 m_offsets.append(offset.x()); 110 m_offsets.append(offset.x());
111 m_offsets.append(offset.y()); 111 m_offsets.append(offset.y());
112 } 112 }
113 113
114 void reverseForSimpleRTL(float afterOffset, float totalWidth) {
115 ASSERT(!hasVerticalOffsets());
116
117 if (isEmpty())
118 return;
119
120 m_fontData.reverse();
121 m_glyphs.reverse();
122
123 // | .. [X0 X1 .. Xn] .. |
124 // ^ ^ ^
125 // 0 afterOffset totalWidth
126 //
127 // The input buffer is shaped using RTL advances, but since the right edge
128 // is unknown at that time, offsets are computed as if the advances were
129 // LTR. This method performs the required adjustments by reconstructing
130 // advances and positioning offsets in an RTL progression.
131
132 // FIXME: we should get rid of this (idea: store negative offsets while
133 // shaping, and adjust the initial advance accordingly -> should
134 // yield correctly positioned RTL glyphs without any post-shape
135 // munging).
136 SECURITY_DCHECK(!m_offsets.isEmpty());
137 for (unsigned i = 0; i + 1 < m_offsets.size(); ++i)
138 m_offsets[i] = totalWidth - m_offsets[i + 1];
139 m_offsets.back() = totalWidth - afterOffset;
140
141 m_offsets.reverse();
142 }
143
114 protected: 144 protected:
115 Vector<const SimpleFontData*, 2048> m_fontData; 145 Vector<const SimpleFontData*, 2048> m_fontData;
116 Vector<Glyph, 2048> m_glyphs; 146 Vector<Glyph, 2048> m_glyphs;
117 147
118 // Glyph positioning: either x-only offsets, or interleaved x,y offsets 148 // Glyph positioning: either x-only offsets, or interleaved x,y offsets
119 // (depending on the buffer-wide positioning mode). This matches the 149 // (depending on the buffer-wide positioning mode). This matches the
120 // glyph positioning format used by Skia. 150 // glyph positioning format used by Skia.
121 Vector<float, 2048> m_offsets; 151 Vector<float, 2048> m_offsets;
122 }; 152 };
123 153
124 } // namespace blink 154 } // namespace blink
125 155
126 #endif 156 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/blob/BlobData.cpp ('k') | third_party/WebKit/Source/platform/geometry/Region.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698