| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 Google Inc. All rights reserved. | 2 * Copyright (c) 2012 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 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 #include "platform/fonts/shaping/HarfBuzzFace.h" | 31 #include "platform/fonts/shaping/HarfBuzzFace.h" |
| 32 | 32 |
| 33 #include "platform/fonts/FontCache.h" | 33 #include "platform/fonts/FontCache.h" |
| 34 #include "platform/fonts/FontPlatformData.h" | 34 #include "platform/fonts/FontPlatformData.h" |
| 35 #include "platform/fonts/SimpleFontData.h" | 35 #include "platform/fonts/SimpleFontData.h" |
| 36 #include "platform/fonts/UnicodeRangeSet.h" | 36 #include "platform/fonts/UnicodeRangeSet.h" |
| 37 #include "platform/fonts/shaping/HarfBuzzShaper.h" | 37 #include "platform/fonts/shaping/HarfBuzzShaper.h" |
| 38 #include "wtf/HashMap.h" | 38 #include "wtf/HashMap.h" |
| 39 #include "wtf/MathExtras.h" | 39 #include "wtf/MathExtras.h" |
| 40 #include "wtf/PtrUtil.h" | |
| 41 #include <memory> | |
| 42 | 40 |
| 43 #include <hb-ot.h> | 41 #include <hb-ot.h> |
| 44 #include <hb.h> | 42 #include <hb.h> |
| 45 #if OS(MACOSX) | 43 #if OS(MACOSX) |
| 46 #include <hb-coretext.h> | 44 #include <hb-coretext.h> |
| 47 #endif | 45 #endif |
| 48 | 46 |
| 49 #include <SkPaint.h> | 47 #include <SkPaint.h> |
| 50 #include <SkPath.h> | 48 #include <SkPath.h> |
| 51 #include <SkPoint.h> | 49 #include <SkPoint.h> |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 ASSERT(hbFont); | 105 ASSERT(hbFont); |
| 108 return adoptRef(new HbFontCacheEntry(hbFont)); | 106 return adoptRef(new HbFontCacheEntry(hbFont)); |
| 109 } | 107 } |
| 110 | 108 |
| 111 hb_font_t* hbFont() { return m_hbFont.get(); } | 109 hb_font_t* hbFont() { return m_hbFont.get(); } |
| 112 HarfBuzzFontData* hbFontData() { return m_hbFontData.get(); } | 110 HarfBuzzFontData* hbFontData() { return m_hbFontData.get(); } |
| 113 | 111 |
| 114 private: | 112 private: |
| 115 explicit HbFontCacheEntry(hb_font_t* font) | 113 explicit HbFontCacheEntry(hb_font_t* font) |
| 116 : m_hbFont(HbFontUniquePtr(font)) | 114 : m_hbFont(HbFontUniquePtr(font)) |
| 117 , m_hbFontData(wrapUnique(new HarfBuzzFontData())) | 115 , m_hbFontData(adoptPtr(new HarfBuzzFontData())) |
| 118 { }; | 116 { }; |
| 119 | 117 |
| 120 HbFontUniquePtr m_hbFont; | 118 HbFontUniquePtr m_hbFont; |
| 121 std::unique_ptr<HarfBuzzFontData> m_hbFontData; | 119 OwnPtr<HarfBuzzFontData> m_hbFontData; |
| 122 }; | 120 }; |
| 123 | 121 |
| 124 typedef HashMap<uint64_t, RefPtr<HbFontCacheEntry>, WTF::IntHash<uint64_t>, WTF:
:UnsignedWithZeroKeyHashTraits<uint64_t>> HarfBuzzFontCache; | 122 typedef HashMap<uint64_t, RefPtr<HbFontCacheEntry>, WTF::IntHash<uint64_t>, WTF:
:UnsignedWithZeroKeyHashTraits<uint64_t>> HarfBuzzFontCache; |
| 125 | 123 |
| 126 static HarfBuzzFontCache* harfBuzzFontCache() | 124 static HarfBuzzFontCache* harfBuzzFontCache() |
| 127 { | 125 { |
| 128 DEFINE_STATIC_LOCAL(HarfBuzzFontCache, s_harfBuzzFontCache, ()); | 126 DEFINE_STATIC_LOCAL(HarfBuzzFontCache, s_harfBuzzFontCache, ()); |
| 129 return &s_harfBuzzFontCache; | 127 return &s_harfBuzzFontCache; |
| 130 } | 128 } |
| 131 | 129 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 m_platformData->setupPaint(&m_harfBuzzFontData->m_paint); | 337 m_platformData->setupPaint(&m_harfBuzzFontData->m_paint); |
| 340 m_harfBuzzFontData->m_rangeSet = rangeSet; | 338 m_harfBuzzFontData->m_rangeSet = rangeSet; |
| 341 m_harfBuzzFontData->m_simpleFontData = FontCache::fontCache()->fontDataFromF
ontPlatformData(m_platformData).get(); | 339 m_harfBuzzFontData->m_simpleFontData = FontCache::fontCache()->fontDataFromF
ontPlatformData(m_platformData).get(); |
| 342 ASSERT(m_harfBuzzFontData->m_simpleFontData); | 340 ASSERT(m_harfBuzzFontData->m_simpleFontData); |
| 343 int scale = SkiaScalarToHarfBuzzPosition(m_platformData->size()); | 341 int scale = SkiaScalarToHarfBuzzPosition(m_platformData->size()); |
| 344 hb_font_set_scale(m_unscaledFont, scale, scale); | 342 hb_font_set_scale(m_unscaledFont, scale, scale); |
| 345 return m_unscaledFont; | 343 return m_unscaledFont; |
| 346 } | 344 } |
| 347 | 345 |
| 348 } // namespace blink | 346 } // namespace blink |
| OLD | NEW |