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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/shaping/ShapeResult.cpp

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
OLDNEW
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
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"
38 #include <hb.h> 37 #include <hb.h>
39 #include <memory>
40 38
41 namespace blink { 39 namespace blink {
42 40
43 float ShapeResult::RunInfo::xPositionForVisualOffset(unsigned offset, AdjustMidC luster adjustMidCluster) const 41 float ShapeResult::RunInfo::xPositionForVisualOffset(unsigned offset, AdjustMidC luster adjustMidCluster) const
44 { 42 {
45 ASSERT(offset < m_numCharacters); 43 ASSERT(offset < m_numCharacters);
46 if (rtl()) 44 if (rtl())
47 offset = m_numCharacters - offset - 1; 45 offset = m_numCharacters - offset - 1;
48 return xPositionForOffset(offset, adjustMidCluster); 46 return xPositionForOffset(offset, adjustMidCluster);
49 } 47 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 : m_width(other.m_width) 147 : m_width(other.m_width)
150 , m_glyphBoundingBox(other.m_glyphBoundingBox) 148 , m_glyphBoundingBox(other.m_glyphBoundingBox)
151 , m_primaryFont(other.m_primaryFont) 149 , m_primaryFont(other.m_primaryFont)
152 , m_numCharacters(other.m_numCharacters) 150 , m_numCharacters(other.m_numCharacters)
153 , m_numGlyphs(other.m_numGlyphs) 151 , m_numGlyphs(other.m_numGlyphs)
154 , m_direction(other.m_direction) 152 , m_direction(other.m_direction)
155 , m_hasVerticalOffsets(other.m_hasVerticalOffsets) 153 , m_hasVerticalOffsets(other.m_hasVerticalOffsets)
156 { 154 {
157 m_runs.reserveCapacity(other.m_runs.size()); 155 m_runs.reserveCapacity(other.m_runs.size());
158 for (const auto& run : other.m_runs) 156 for (const auto& run : other.m_runs)
159 m_runs.append(wrapUnique(new ShapeResult::RunInfo(*run))); 157 m_runs.append(adoptPtr(new ShapeResult::RunInfo(*run)));
160 } 158 }
161 159
162 ShapeResult::~ShapeResult() 160 ShapeResult::~ShapeResult()
163 { 161 {
164 } 162 }
165 163
166 size_t ShapeResult::byteSize() const 164 size_t ShapeResult::byteSize() const
167 { 165 {
168 size_t selfByteSize = sizeof(this); 166 size_t selfByteSize = sizeof(this);
169 for (unsigned i = 0; i < m_runs.size(); ++i) { 167 for (unsigned i = 0; i < m_runs.size(); ++i) {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 RefPtr<ShapeResult> result = ShapeResult::create(*this); 271 RefPtr<ShapeResult> result = ShapeResult::create(*this);
274 result->applySpacing(spacing, run); 272 result->applySpacing(spacing, run);
275 return result.release(); 273 return result.release();
276 } 274 }
277 275
278 static inline float harfBuzzPositionToFloat(hb_position_t value) 276 static inline float harfBuzzPositionToFloat(hb_position_t value)
279 { 277 {
280 return static_cast<float>(value) / (1 << 16); 278 return static_cast<float>(value) / (1 << 16);
281 } 279 }
282 280
283 void ShapeResult::insertRun(std::unique_ptr<ShapeResult::RunInfo> runToInsert, 281 void ShapeResult::insertRun(PassOwnPtr<ShapeResult::RunInfo> runToInsert,
284 unsigned startGlyph, unsigned numGlyphs, hb_buffer_t* harfBuzzBuffer) 282 unsigned startGlyph, unsigned numGlyphs, hb_buffer_t* harfBuzzBuffer)
285 { 283 {
286 ASSERT(numGlyphs > 0); 284 ASSERT(numGlyphs > 0);
287 std::unique_ptr<ShapeResult::RunInfo> run(std::move(runToInsert)); 285 OwnPtr<ShapeResult::RunInfo> run(std::move(runToInsert));
288 ASSERT(numGlyphs == run->m_glyphData.size()); 286 ASSERT(numGlyphs == run->m_glyphData.size());
289 287
290 const SimpleFontData* currentFontData = run->m_fontData.get(); 288 const SimpleFontData* currentFontData = run->m_fontData.get();
291 const hb_glyph_info_t* glyphInfos = 289 const hb_glyph_info_t* glyphInfos =
292 hb_buffer_get_glyph_infos(harfBuzzBuffer, 0); 290 hb_buffer_get_glyph_infos(harfBuzzBuffer, 0);
293 const hb_glyph_position_t* glyphPositions = 291 const hb_glyph_position_t* glyphPositions =
294 hb_buffer_get_glyph_positions(harfBuzzBuffer, 0); 292 hb_buffer_get_glyph_positions(harfBuzzBuffer, 0);
295 const unsigned startCluster = 293 const unsigned startCluster =
296 HB_DIRECTION_IS_FORWARD(hb_buffer_get_direction(harfBuzzBuffer)) 294 HB_DIRECTION_IS_FORWARD(hb_buffer_get_direction(harfBuzzBuffer))
297 ? glyphInfos[startGlyph].cluster 295 ? glyphInfos[startGlyph].cluster
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 break; 348 break;
351 } 349 }
352 } 350 }
353 } 351 }
354 // If we didn't find an existing slot to place it, append. 352 // If we didn't find an existing slot to place it, append.
355 if (run) 353 if (run)
356 m_runs.append(std::move(run)); 354 m_runs.append(std::move(run));
357 } 355 }
358 356
359 } // namespace blink 357 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698