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

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

Issue 2736873002: Update woff2 to cbea7b9 (Closed)
Patch Set: Created 3 years, 9 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/font.cc ('k') | third_party/woff2/src/variable_length.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 Google Inc. All Rights Reserved. 1 // Copyright 2013 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 if (!buffer.ReadU16(&glyph->instructions_size)) { 111 if (!buffer.ReadU16(&glyph->instructions_size)) {
112 return FONT_COMPRESSION_FAILURE(); 112 return FONT_COMPRESSION_FAILURE();
113 } 113 }
114 glyph->instructions_data = data + buffer.offset(); 114 glyph->instructions_data = data + buffer.offset();
115 if (!buffer.Skip(glyph->instructions_size)) { 115 if (!buffer.Skip(glyph->instructions_size)) {
116 return FONT_COMPRESSION_FAILURE(); 116 return FONT_COMPRESSION_FAILURE();
117 } 117 }
118 118
119 // Read the run-length coded flags. 119 // Read the run-length coded flags.
120 std::vector<std::vector<uint8_t> > flags(num_contours); 120 std::vector<std::vector<uint8_t> > flags(num_contours);
121 uint8_t flag = 0; 121 {
122 uint8_t flag_repeat = 0; 122 uint8_t flag = 0;
123 for (int i = 0; i < num_contours; ++i) { 123 uint8_t flag_repeat = 0;
124 flags[i].resize(glyph->contours[i].size()); 124 for (int i = 0; i < num_contours; ++i) {
125 for (size_t j = 0; j < glyph->contours[i].size(); ++j) { 125 flags[i].resize(glyph->contours[i].size());
126 if (flag_repeat == 0) { 126 for (size_t j = 0; j < glyph->contours[i].size(); ++j) {
127 if (!buffer.ReadU8(&flag)) { 127 if (flag_repeat == 0) {
128 return FONT_COMPRESSION_FAILURE(); 128 if (!buffer.ReadU8(&flag)) {
129 }
130 if (flag & kFLAG_REPEAT) {
131 if (!buffer.ReadU8(&flag_repeat)) {
132 return FONT_COMPRESSION_FAILURE(); 129 return FONT_COMPRESSION_FAILURE();
133 } 130 }
131 if (flag & kFLAG_REPEAT) {
132 if (!buffer.ReadU8(&flag_repeat)) {
133 return FONT_COMPRESSION_FAILURE();
134 }
135 }
136 } else {
137 flag_repeat--;
134 } 138 }
135 } else { 139 flags[i][j] = flag;
136 flag_repeat--; 140 glyph->contours[i][j].on_curve = flag & kFLAG_ONCURVE;
137 } 141 }
138 flags[i][j] = flag;
139 glyph->contours[i][j].on_curve = flag & kFLAG_ONCURVE;
140 } 142 }
141 } 143 }
142 144
143 // Read the x coordinates. 145 // Read the x coordinates.
144 int prev_x = 0; 146 int prev_x = 0;
145 for (int i = 0; i < num_contours; ++i) { 147 for (int i = 0; i < num_contours; ++i) {
146 for (size_t j = 0; j < glyph->contours[i].size(); ++j) { 148 for (size_t j = 0; j < glyph->contours[i].size(); ++j) {
147 uint8_t flag = flags[i][j]; 149 uint8_t flag = flags[i][j];
148 if (flag & kFLAG_XSHORT) { 150 if (flag & kFLAG_XSHORT) {
149 // single byte x-delta coord value 151 // single byte x-delta coord value
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 StoreInstructions(glyph, &offset, dst); 373 StoreInstructions(glyph, &offset, dst);
372 if (!StorePoints(glyph, &offset, dst, *dst_size)) { 374 if (!StorePoints(glyph, &offset, dst, *dst_size)) {
373 return FONT_COMPRESSION_FAILURE(); 375 return FONT_COMPRESSION_FAILURE();
374 } 376 }
375 } 377 }
376 *dst_size = offset; 378 *dst_size = offset;
377 return true; 379 return true;
378 } 380 }
379 381
380 } // namespace woff2 382 } // namespace woff2
OLDNEW
« no previous file with comments | « third_party/woff2/src/font.cc ('k') | third_party/woff2/src/variable_length.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698