| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 return OTS_FAILURE(); | 151 return OTS_FAILURE(); |
| 152 } | 152 } |
| 153 std::memcpy(value, buffer_ + offset_, sizeof(uint64_t)); | 153 std::memcpy(value, buffer_ + offset_, sizeof(uint64_t)); |
| 154 offset_ += 8; | 154 offset_ += 8; |
| 155 return true; | 155 return true; |
| 156 } | 156 } |
| 157 | 157 |
| 158 const uint8_t *buffer() const { return buffer_; } | 158 const uint8_t *buffer() const { return buffer_; } |
| 159 size_t offset() const { return offset_; } | 159 size_t offset() const { return offset_; } |
| 160 size_t length() const { return length_; } | 160 size_t length() const { return length_; } |
| 161 size_t remaining() const { return length_ - offset_; } |
| 161 | 162 |
| 162 void set_offset(size_t newoffset) { offset_ = newoffset; } | 163 void set_offset(size_t newoffset) { offset_ = newoffset; } |
| 163 | 164 |
| 164 private: | 165 private: |
| 165 const uint8_t * const buffer_; | 166 const uint8_t * const buffer_; |
| 166 const size_t length_; | 167 const size_t length_; |
| 167 size_t offset_; | 168 size_t offset_; |
| 168 }; | 169 }; |
| 169 | 170 |
| 170 // Round a value up to the nearest multiple of 4. Don't round the value in the | 171 // Round a value up to the nearest multiple of 4. Don't round the value in the |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 #define F(name, capname) \ | 224 #define F(name, capname) \ |
| 224 bool ots_##name##_parse(Font *f, const uint8_t *d, size_t l); \ | 225 bool ots_##name##_parse(Font *f, const uint8_t *d, size_t l); \ |
| 225 bool ots_##name##_should_serialise(Font *f); \ | 226 bool ots_##name##_should_serialise(Font *f); \ |
| 226 bool ots_##name##_serialise(OTSStream *s, Font *f); \ | 227 bool ots_##name##_serialise(OTSStream *s, Font *f); \ |
| 227 void ots_##name##_reuse(Font *f, Font *o);\ | 228 void ots_##name##_reuse(Font *f, Font *o);\ |
| 228 void ots_##name##_free(Font *f); | 229 void ots_##name##_free(Font *f); |
| 229 FOR_EACH_TABLE_TYPE | 230 FOR_EACH_TABLE_TYPE |
| 230 #undef F | 231 #undef F |
| 231 | 232 |
| 232 struct Font { | 233 struct Font { |
| 233 Font(const OpenTypeFile *f) { | 234 explicit Font(const OpenTypeFile *f) |
| 234 file = f; | 235 : file(f), |
| 236 version(0), |
| 237 num_tables(0), |
| 238 search_range(0), |
| 239 entry_selector(0), |
| 240 range_shift(0) { |
| 235 #define F(name, capname) \ | 241 #define F(name, capname) \ |
| 236 name = NULL; \ | 242 name = NULL; \ |
| 237 name##_reused = false; | 243 name##_reused = false; |
| 238 FOR_EACH_TABLE_TYPE | 244 FOR_EACH_TABLE_TYPE |
| 239 #undef F | 245 #undef F |
| 240 } | 246 } |
| 241 | 247 |
| 242 ~Font() { | 248 ~Font() { |
| 243 #define F(name, capname) \ | 249 #define F(name, capname) \ |
| 244 if (!name##_reused) {\ | 250 if (!name##_reused) {\ |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 struct OpenTypeFile { | 285 struct OpenTypeFile { |
| 280 OTSContext *context; | 286 OTSContext *context; |
| 281 TableMap tables; | 287 TableMap tables; |
| 282 }; | 288 }; |
| 283 | 289 |
| 284 } // namespace ots | 290 } // namespace ots |
| 285 | 291 |
| 286 #undef FOR_EACH_TABLE_TYPE | 292 #undef FOR_EACH_TABLE_TYPE |
| 287 | 293 |
| 288 #endif // OTS_H_ | 294 #endif // OTS_H_ |
| OLD | NEW |