OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 OTS_H_ | 5 #ifndef OTS_H_ |
6 #define OTS_H_ | 6 #define OTS_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <cstdarg> | 9 #include <cstdarg> |
10 #include <cstddef> | 10 #include <cstddef> |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 166 |
167 // Round a value up to the nearest multiple of 4. Don't round the value in the | 167 // Round a value up to the nearest multiple of 4. Don't round the value in the |
168 // case that rounding up overflows. | 168 // case that rounding up overflows. |
169 template<typename T> T Round4(T value) { | 169 template<typename T> T Round4(T value) { |
170 if (std::numeric_limits<T>::max() - value < 3) { | 170 if (std::numeric_limits<T>::max() - value < 3) { |
171 return value; | 171 return value; |
172 } | 172 } |
173 return (value + 3) & ~3; | 173 return (value + 3) & ~3; |
174 } | 174 } |
175 | 175 |
| 176 template<typename T> T Round2(T value) { |
| 177 if (value == std::numeric_limits<T>::max()) { |
| 178 return value; |
| 179 } |
| 180 return (value + 1) & ~1; |
| 181 } |
| 182 |
176 bool IsValidVersionTag(uint32_t tag); | 183 bool IsValidVersionTag(uint32_t tag); |
177 | 184 |
178 #define FOR_EACH_TABLE_TYPE \ | 185 #define FOR_EACH_TABLE_TYPE \ |
179 F(cff, CFF) \ | 186 F(cff, CFF) \ |
180 F(cmap, CMAP) \ | 187 F(cmap, CMAP) \ |
181 F(cvt, CVT) \ | 188 F(cvt, CVT) \ |
182 F(fpgm, FPGM) \ | 189 F(fpgm, FPGM) \ |
183 F(gasp, GASP) \ | 190 F(gasp, GASP) \ |
184 F(gdef, GDEF) \ | 191 F(gdef, GDEF) \ |
185 F(glyf, GLYF) \ | 192 F(glyf, GLYF) \ |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 bool ots_##name##_should_serialise(OpenTypeFile *f); \ | 236 bool ots_##name##_should_serialise(OpenTypeFile *f); \ |
230 bool ots_##name##_serialise(OTSStream *s, OpenTypeFile *f); \ | 237 bool ots_##name##_serialise(OTSStream *s, OpenTypeFile *f); \ |
231 void ots_##name##_free(OpenTypeFile *f); | 238 void ots_##name##_free(OpenTypeFile *f); |
232 // TODO(yusukes): change these function names to follow Chromium coding rule. | 239 // TODO(yusukes): change these function names to follow Chromium coding rule. |
233 FOR_EACH_TABLE_TYPE | 240 FOR_EACH_TABLE_TYPE |
234 #undef F | 241 #undef F |
235 | 242 |
236 } // namespace ots | 243 } // namespace ots |
237 | 244 |
238 #endif // OTS_H_ | 245 #endif // OTS_H_ |
OLD | NEW |