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

Side by Side Diff: Source/WebCore/platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp

Issue 11192060: Merge 153128 - Source/WebCore: [HarfBuzz] harfbuzz expects log_clusters to have same length as othe… (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1271/
Patch Set: Created 8 years, 2 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 | « LayoutTests/fast/text/international/harfbuzz-buffer-overrun-expected.txt ('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 /* 1 /*
2 * Copyright (c) 2010 Google Inc. All rights reserved. 2 * Copyright (c) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 NormalizeMode mode = m_run.rtl() ? NormalizeMirrorChars : DoNotNormalizeMirr orChars; 63 NormalizeMode mode = m_run.rtl() ? NormalizeMirrorChars : DoNotNormalizeMirr orChars;
64 setNormalizedBuffer(mode); 64 setNormalizedBuffer(mode);
65 65
66 memset(&m_item, 0, sizeof(m_item)); 66 memset(&m_item, 0, sizeof(m_item));
67 // We cannot know, ahead of time, how many glyphs a given script run 67 // We cannot know, ahead of time, how many glyphs a given script run
68 // will produce. We take a guess that script runs will not produce more 68 // will produce. We take a guess that script runs will not produce more
69 // than twice as many glyphs as there are code points plus a bit of 69 // than twice as many glyphs as there are code points plus a bit of
70 // padding and fallback if we find that we are wrong. 70 // padding and fallback if we find that we are wrong.
71 createGlyphArrays((m_normalizedBufferLength + 2) * 2); 71 createGlyphArrays((m_normalizedBufferLength + 2) * 2);
72 72
73 m_item.log_clusters = new unsigned short[m_normalizedBufferLength];
74
75 m_item.face = 0; 73 m_item.face = 0;
76 m_item.font = allocHarfbuzzFont(); 74 m_item.font = allocHarfbuzzFont();
77 75
78 m_item.item.bidiLevel = m_run.rtl(); 76 m_item.item.bidiLevel = m_run.rtl();
79 77
80 m_item.string = m_normalizedBuffer.get(); 78 m_item.string = m_normalizedBuffer.get();
81 m_item.stringLength = m_normalizedBufferLength; 79 m_item.stringLength = m_normalizedBufferLength;
82 80
83 reset(startingX); 81 reset(startingX);
84 m_startingY = startingY; 82 m_startingY = startingY;
85 83
86 setPadding(m_run.expansion()); 84 setPadding(m_run.expansion());
87 } 85 }
88 86
89 ComplexTextController::~ComplexTextController() 87 ComplexTextController::~ComplexTextController()
90 { 88 {
91 fastFree(m_item.font); 89 fastFree(m_item.font);
92 deleteGlyphArrays(); 90 deleteGlyphArrays();
93 delete[] m_item.log_clusters;
94 } 91 }
95 92
96 void ComplexTextController::reset(int offset) 93 void ComplexTextController::reset(int offset)
97 { 94 {
98 m_indexOfNextScriptRun = 0; 95 m_indexOfNextScriptRun = 0;
99 m_offsetX = offset; 96 m_offsetX = offset;
100 } 97 }
101 98
102 void ComplexTextController::setupForRTL() 99 void ComplexTextController::setupForRTL()
103 { 100 {
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 m_item.font->x_scale = scale; 289 m_item.font->x_scale = scale;
293 m_item.font->y_scale = scale; 290 m_item.font->y_scale = scale;
294 } 291 }
295 292
296 void ComplexTextController::deleteGlyphArrays() 293 void ComplexTextController::deleteGlyphArrays()
297 { 294 {
298 delete[] m_item.glyphs; 295 delete[] m_item.glyphs;
299 delete[] m_item.attributes; 296 delete[] m_item.attributes;
300 delete[] m_item.advances; 297 delete[] m_item.advances;
301 delete[] m_item.offsets; 298 delete[] m_item.offsets;
299 delete[] m_item.log_clusters;
302 delete[] m_glyphs16; 300 delete[] m_glyphs16;
303 delete[] m_positions; 301 delete[] m_positions;
304 } 302 }
305 303
306 void ComplexTextController::createGlyphArrays(int size) 304 void ComplexTextController::createGlyphArrays(int size)
307 { 305 {
308 m_item.glyphs = new HB_Glyph[size]; 306 m_item.glyphs = new HB_Glyph[size];
309 m_item.attributes = new HB_GlyphAttributes[size]; 307 m_item.attributes = new HB_GlyphAttributes[size];
310 m_item.advances = new HB_Fixed[size]; 308 m_item.advances = new HB_Fixed[size];
311 m_item.offsets = new HB_FixedPoint[size]; 309 m_item.offsets = new HB_FixedPoint[size];
310 m_item.log_clusters = new unsigned short[size];
312 311
313 m_glyphs16 = new uint16_t[size]; 312 m_glyphs16 = new uint16_t[size];
314 m_positions = new SkPoint[size]; 313 m_positions = new SkPoint[size];
315 314
316 m_item.num_glyphs = size; 315 m_item.num_glyphs = size;
317 m_glyphsArrayCapacity = size; // Save the GlyphArrays size. 316 m_glyphsArrayCapacity = size; // Save the GlyphArrays size.
318 resetGlyphArrays(); 317 resetGlyphArrays();
319 } 318 }
320 319
321 void ComplexTextController::resetGlyphArrays() 320 void ComplexTextController::resetGlyphArrays()
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 // Compute the starting glyph within this span. |from| and |to| are 501 // Compute the starting glyph within this span. |from| and |to| are
503 // global offsets that may intersect arbitrarily with our local run. 502 // global offsets that may intersect arbitrarily with our local run.
504 fromGlyph = m_item.log_clusters[fromChar < 0 ? 0 : fromChar]; 503 fromGlyph = m_item.log_clusters[fromChar < 0 ? 0 : fromChar];
505 if (toChar >= static_cast<int>(numCodePoints())) 504 if (toChar >= static_cast<int>(numCodePoints()))
506 glyphLength = length() - fromGlyph; 505 glyphLength = length() - fromGlyph;
507 else 506 else
508 glyphLength = m_item.log_clusters[toChar] - fromGlyph; 507 glyphLength = m_item.log_clusters[toChar] - fromGlyph;
509 } 508 }
510 509
511 } // namespace WebCore 510 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/text/international/harfbuzz-buffer-overrun-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698