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

Side by Side Diff: third_party/woff2/src/woff2_enc.cc

Issue 1959303002: Update woff2 to a15a8ab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « third_party/woff2/src/woff2_dec.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 Google Inc. All Rights Reserved. 1 // Copyright 2014 Google Inc. All Rights Reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 // then this function will also return false. 265 // then this function will also return false.
266 266
267 size_t total_transform_length = 0; 267 size_t total_transform_length = 0;
268 for (const auto& font : font_collection.fonts) { 268 for (const auto& font : font_collection.fonts) {
269 total_transform_length += ComputeTotalTransformLength(font); 269 total_transform_length += ComputeTotalTransformLength(font);
270 } 270 }
271 size_t compression_buffer_size = CompressedBufferSize(total_transform_length); 271 size_t compression_buffer_size = CompressedBufferSize(total_transform_length);
272 std::vector<uint8_t> compression_buf(compression_buffer_size); 272 std::vector<uint8_t> compression_buf(compression_buffer_size);
273 uint32_t total_compressed_length = compression_buffer_size; 273 uint32_t total_compressed_length = compression_buffer_size;
274 274
275 // Collect all transformed data into one place. 275 // Collect all transformed data into one place in output order.
276 std::vector<uint8_t> transform_buf(total_transform_length); 276 std::vector<uint8_t> transform_buf(total_transform_length);
277 size_t transform_offset = 0; 277 size_t transform_offset = 0;
278 for (const auto& font : font_collection.fonts) { 278 for (const auto& font : font_collection.fonts) {
279 for (const auto& i : font.tables) { 279 for (const auto tag : font.OutputOrderedTags()) {
280 const Font::Table* table = font.FindTable(i.second.tag ^ 0x80808080); 280 const Font::Table& original = font.tables.at(tag);
281 if (i.second.IsReused()) continue; 281 if (original.IsReused()) continue;
282 if (i.second.tag & 0x80808080) continue; 282 if (tag & 0x80808080) continue;
283 const Font::Table* table_to_store = font.FindTable(tag ^ 0x80808080);
284 if (table_to_store == NULL) table_to_store = &original;
283 285
284 if (table == NULL) table = &i.second; 286 StoreBytes(table_to_store->data, table_to_store->length,
285 StoreBytes(table->data, table->length,
286 &transform_offset, &transform_buf[0]); 287 &transform_offset, &transform_buf[0]);
287 } 288 }
288 } 289 }
290
289 // Compress all transformed data in one stream. 291 // Compress all transformed data in one stream.
290 if (!Woff2Compress(transform_buf.data(), total_transform_length, 292 if (!Woff2Compress(transform_buf.data(), total_transform_length,
291 &compression_buf[0], 293 &compression_buf[0],
292 &total_compressed_length, 294 &total_compressed_length,
293 params.brotli_quality)) { 295 params.brotli_quality)) {
294 #ifdef FONT_COMPRESSION_BIN 296 #ifdef FONT_COMPRESSION_BIN
295 fprintf(stderr, "Compression of combined table failed.\n"); 297 fprintf(stderr, "Compression of combined table failed.\n");
296 #endif 298 #endif
297 return FONT_COMPRESSION_FAILURE(); 299 return FONT_COMPRESSION_FAILURE();
298 } 300 }
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 #ifdef FONT_COMPRESSION_BIN 463 #ifdef FONT_COMPRESSION_BIN
462 fprintf(stderr, "Mismatch between computed and actual length " 464 fprintf(stderr, "Mismatch between computed and actual length "
463 "(%zd vs %zd)\n", *result_length, offset); 465 "(%zd vs %zd)\n", *result_length, offset);
464 #endif 466 #endif
465 return FONT_COMPRESSION_FAILURE(); 467 return FONT_COMPRESSION_FAILURE();
466 } 468 }
467 return true; 469 return true;
468 } 470 }
469 471
470 } // namespace woff2 472 } // namespace woff2
OLDNEW
« no previous file with comments | « third_party/woff2/src/woff2_dec.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698