OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 Google Inc. All rights reserved. | 2 * Copyright (c) 2012 Google Inc. All rights reserved. |
3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved. | 3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 16 matching lines...) Expand all Loading... |
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 */ | 30 */ |
31 | 31 |
32 #include "platform/fonts/shaping/ShapeResult.h" | 32 #include "platform/fonts/shaping/ShapeResult.h" |
33 | 33 |
34 #include "platform/fonts/Font.h" | 34 #include "platform/fonts/Font.h" |
35 #include "platform/fonts/shaping/ShapeResultInlineHeaders.h" | 35 #include "platform/fonts/shaping/ShapeResultInlineHeaders.h" |
36 #include "platform/fonts/shaping/ShapeResultSpacing.h" | 36 #include "platform/fonts/shaping/ShapeResultSpacing.h" |
| 37 #include "wtf/PtrUtil.h" |
37 #include <hb.h> | 38 #include <hb.h> |
| 39 #include <memory> |
38 | 40 |
39 namespace blink { | 41 namespace blink { |
40 | 42 |
41 float ShapeResult::RunInfo::xPositionForVisualOffset(unsigned offset, AdjustMidC
luster adjustMidCluster) const | 43 float ShapeResult::RunInfo::xPositionForVisualOffset(unsigned offset, AdjustMidC
luster adjustMidCluster) const |
42 { | 44 { |
43 ASSERT(offset < m_numCharacters); | 45 ASSERT(offset < m_numCharacters); |
44 if (rtl()) | 46 if (rtl()) |
45 offset = m_numCharacters - offset - 1; | 47 offset = m_numCharacters - offset - 1; |
46 return xPositionForOffset(offset, adjustMidCluster); | 48 return xPositionForOffset(offset, adjustMidCluster); |
47 } | 49 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 : m_width(other.m_width) | 149 : m_width(other.m_width) |
148 , m_glyphBoundingBox(other.m_glyphBoundingBox) | 150 , m_glyphBoundingBox(other.m_glyphBoundingBox) |
149 , m_primaryFont(other.m_primaryFont) | 151 , m_primaryFont(other.m_primaryFont) |
150 , m_numCharacters(other.m_numCharacters) | 152 , m_numCharacters(other.m_numCharacters) |
151 , m_numGlyphs(other.m_numGlyphs) | 153 , m_numGlyphs(other.m_numGlyphs) |
152 , m_direction(other.m_direction) | 154 , m_direction(other.m_direction) |
153 , m_hasVerticalOffsets(other.m_hasVerticalOffsets) | 155 , m_hasVerticalOffsets(other.m_hasVerticalOffsets) |
154 { | 156 { |
155 m_runs.reserveCapacity(other.m_runs.size()); | 157 m_runs.reserveCapacity(other.m_runs.size()); |
156 for (const auto& run : other.m_runs) | 158 for (const auto& run : other.m_runs) |
157 m_runs.append(adoptPtr(new ShapeResult::RunInfo(*run))); | 159 m_runs.append(wrapUnique(new ShapeResult::RunInfo(*run))); |
158 } | 160 } |
159 | 161 |
160 ShapeResult::~ShapeResult() | 162 ShapeResult::~ShapeResult() |
161 { | 163 { |
162 } | 164 } |
163 | 165 |
164 size_t ShapeResult::byteSize() const | 166 size_t ShapeResult::byteSize() const |
165 { | 167 { |
166 size_t selfByteSize = sizeof(this); | 168 size_t selfByteSize = sizeof(this); |
167 for (unsigned i = 0; i < m_runs.size(); ++i) { | 169 for (unsigned i = 0; i < m_runs.size(); ++i) { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 RefPtr<ShapeResult> result = ShapeResult::create(*this); | 273 RefPtr<ShapeResult> result = ShapeResult::create(*this); |
272 result->applySpacing(spacing, run); | 274 result->applySpacing(spacing, run); |
273 return result.release(); | 275 return result.release(); |
274 } | 276 } |
275 | 277 |
276 static inline float harfBuzzPositionToFloat(hb_position_t value) | 278 static inline float harfBuzzPositionToFloat(hb_position_t value) |
277 { | 279 { |
278 return static_cast<float>(value) / (1 << 16); | 280 return static_cast<float>(value) / (1 << 16); |
279 } | 281 } |
280 | 282 |
281 void ShapeResult::insertRun(PassOwnPtr<ShapeResult::RunInfo> runToInsert, | 283 void ShapeResult::insertRun(std::unique_ptr<ShapeResult::RunInfo> runToInsert, |
282 unsigned startGlyph, unsigned numGlyphs, hb_buffer_t* harfBuzzBuffer) | 284 unsigned startGlyph, unsigned numGlyphs, hb_buffer_t* harfBuzzBuffer) |
283 { | 285 { |
284 ASSERT(numGlyphs > 0); | 286 ASSERT(numGlyphs > 0); |
285 OwnPtr<ShapeResult::RunInfo> run(std::move(runToInsert)); | 287 std::unique_ptr<ShapeResult::RunInfo> run(std::move(runToInsert)); |
286 ASSERT(numGlyphs == run->m_glyphData.size()); | 288 ASSERT(numGlyphs == run->m_glyphData.size()); |
287 | 289 |
288 const SimpleFontData* currentFontData = run->m_fontData.get(); | 290 const SimpleFontData* currentFontData = run->m_fontData.get(); |
289 const hb_glyph_info_t* glyphInfos = | 291 const hb_glyph_info_t* glyphInfos = |
290 hb_buffer_get_glyph_infos(harfBuzzBuffer, 0); | 292 hb_buffer_get_glyph_infos(harfBuzzBuffer, 0); |
291 const hb_glyph_position_t* glyphPositions = | 293 const hb_glyph_position_t* glyphPositions = |
292 hb_buffer_get_glyph_positions(harfBuzzBuffer, 0); | 294 hb_buffer_get_glyph_positions(harfBuzzBuffer, 0); |
293 const unsigned startCluster = | 295 const unsigned startCluster = |
294 HB_DIRECTION_IS_FORWARD(hb_buffer_get_direction(harfBuzzBuffer)) | 296 HB_DIRECTION_IS_FORWARD(hb_buffer_get_direction(harfBuzzBuffer)) |
295 ? glyphInfos[startGlyph].cluster | 297 ? glyphInfos[startGlyph].cluster |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 break; | 350 break; |
349 } | 351 } |
350 } | 352 } |
351 } | 353 } |
352 // If we didn't find an existing slot to place it, append. | 354 // If we didn't find an existing slot to place it, append. |
353 if (run) | 355 if (run) |
354 m_runs.append(std::move(run)); | 356 m_runs.append(std::move(run)); |
355 } | 357 } |
356 | 358 |
357 } // namespace blink | 359 } // namespace blink |
OLD | NEW |