Changeset 88081 in webkit
- Timestamp:
- Jun 3, 2011 5:22:09 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r88080 r88081 1 2011-06-03 Cary Clark <caryclark@google.com> 2 3 Reviewed by Eric Seidel. 4 5 Support FontCustomPlatformData on Skia-Mac-Chrome variant 6 https://bugs.webkit.org/show_bug.cgi?id=62040 7 8 Canvas text is only recognized by Skia if it is registered 9 by creating a new SkTypeface. Skia uses CGFont to measure 10 and render the glyphs, then takes care of managing the glyph 11 cache. 12 13 Skia on Mac Chrome is not yet enabled, so this change 14 does not affect existing code, and requires no new tests. 15 16 * platform/graphics/mac/FontCustomPlatformData.cpp: 17 (WebCore::RemoteFontStream::RemoteFontStream): 18 (WebCore::RemoteFontStream::~RemoteFontStream): 19 (WebCore::RemoteFontStream::rewind): 20 (WebCore::RemoteFontStream::read): 21 Turn the buffer into a stream. This is identical to 22 the implementation in skia/FontCustomPlatformData.cpp. 23 While that file could be modified instead of this one, 24 it was simpler to add SkTypeface streaming to this instead 25 of adding all CGFont support to the skia platform file. 26 27 (WebCore::FontCustomPlatformData::~FontCustomPlatformData): 28 Release the SkTypeface reference. 29 30 (WebCore::createFontCustomPlatformData): 31 Associate the buffer stream with a SkTypeface so Skia 32 can find the custom font data. 33 34 * platform/graphics/mac/FontCustomPlatformData.h: 35 (WebCore::FontCustomPlatformData::FontCustomPlatformData): 36 Add a slot to hold the SkTypeface. 37 1 38 2011-06-03 Steve Falkenburg <sfalken@apple.com> 2 39 -
trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp
r85036 r88081 28 28 #include <ApplicationServices/ApplicationServices.h> 29 29 30 #if USE(SKIA_ON_MAC_CHROME) 31 #include "SkStream.h" 32 #include "SkTypeface.h" 33 #endif 34 30 35 namespace WebCore { 36 37 #if USE(SKIA_ON_MAC_CHROME) 38 class RemoteFontStream : public SkStream { 39 public: 40 explicit RemoteFontStream(PassRefPtr<SharedBuffer> buffer) 41 : m_buffer(buffer) 42 , m_offset(0) 43 { 44 } 45 46 virtual ~RemoteFontStream() 47 { 48 } 49 50 virtual bool rewind() 51 { 52 m_offset = 0; 53 return true; 54 } 55 56 virtual size_t read(void* buffer, size_t size) 57 { 58 if (!buffer && !size) { 59 // This is request for the length of the stream. 60 return m_buffer->size(); 61 } 62 // This is a request to read bytes or skip bytes (when buffer is 0). 63 if (!m_buffer->data() || !m_buffer->size()) 64 return 0; 65 size_t left = m_buffer->size() - m_offset; 66 size_t bytesToConsume = std::min(left, size); 67 if (buffer) 68 std::memcpy(buffer, m_buffer->data() + m_offset, bytesToConsume); 69 m_offset += bytesToConsume; 70 return bytesToConsume; 71 } 72 73 private: 74 RefPtr<SharedBuffer> m_buffer; 75 size_t m_offset; 76 }; 77 #endif 31 78 32 79 FontCustomPlatformData::~FontCustomPlatformData() … … 35 82 if (m_atsContainer) 36 83 ATSFontDeactivate(m_atsContainer, NULL, kATSOptionFlagsDefault); 84 #endif 85 #if USE(SKIA_ON_MAC_CHROME) 86 SkSafeUnref(m_typeface); 37 87 #endif 38 88 CGFontRelease(m_cgFont); … … 110 160 #endif // !defined(BUILDING_ON_LEOPARD) 111 161 112 return new FontCustomPlatformData(containerRef, cgFontRef.releaseRef()); 162 FontCustomPlatformData* fontCustomPlatformData = new FontCustomPlatformData(containerRef, cgFontRef.releaseRef()); 163 #if USE(SKIA_ON_MAC_CHROME) 164 RemoteFontStream* stream = new RemoteFontStream(buffer); 165 fontCustomPlatformData->m_typeface = SkTypeface::CreateFromStream(stream); 166 #endif 167 return fontCustomPlatformData; 113 168 } 114 169 -
trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h
r80582 r88081 34 34 typedef UInt32 ATSFontRef; 35 35 36 #if USE(SKIA_ON_MAC_CHROME) 37 struct SkTypeface; 38 #endif 39 36 40 namespace WebCore { 37 41 … … 45 49 : m_atsContainer(container) 46 50 , m_cgFont(cgFont) 51 #if USE(SKIA_ON_MAC_CHROME) 52 , m_typeface(0) 53 #endif 47 54 { 48 55 } … … 56 63 ATSFontContainerRef m_atsContainer; 57 64 CGFontRef m_cgFont; 65 #if USE(SKIA_ON_MAC_CHROME) 66 SkTypeface* m_typeface; 67 #endif 58 68 }; 59 69
Note: See TracChangeset
for help on using the changeset viewer.