OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/values.h" |
| 6 #include "content/common/fontmgr_messages.h" |
| 7 #include "content/renderer/fontmgr_proxy.h" |
| 8 #include "content/renderer/render_thread_impl.h" |
| 9 #include "third_party/skia/include/core/SkDataTable.h" |
| 10 #include "third_party/skia/include/core/SkStream.h" |
| 11 #include "third_party/skia/include/ports/SkRemotableFontMgr.h" |
| 12 |
| 13 namespace content { |
| 14 |
| 15 SkDataTable* FontMgrProxy::getFamilyNames() const { |
| 16 skia::RefPtr<SkDataTable> familyNames; |
| 17 content::RenderThreadImpl::current()->Send( |
| 18 new FontMsg_GetFamilyNames(FontMsgStart, &familyNames)); |
| 19 return SkSafeRef(familyNames.get()); |
| 20 } |
| 21 |
| 22 SkRemotableFontIdentitySet* FontMgrProxy::getIndex(int family_index) const { |
| 23 skia::RefPtr<SkRemotableFontIdentitySet> identities; |
| 24 content::RenderThreadImpl::current()->Send( |
| 25 new FontMsg_GetIndex(FontMsgStart, family_index, &identities)); |
| 26 return SkSafeRef(identities.get()); |
| 27 } |
| 28 |
| 29 SkFontIdentity FontMgrProxy::matchIndexStyle( |
| 30 int family_index, |
| 31 const SkFontStyle& style) const { |
| 32 SkFontIdentity identity; |
| 33 content::RenderThreadImpl::current()->Send( |
| 34 new FontMsg_MatchIndexStyle(FontMsgStart, |
| 35 family_index, |
| 36 style, |
| 37 &identity)); |
| 38 return identity; |
| 39 } |
| 40 |
| 41 SkRemotableFontIdentitySet* FontMgrProxy::matchName( |
| 42 const char family_name[]) const { |
| 43 IPC::Optional<std::string> family_name_remotable; |
| 44 if (family_name) |
| 45 family_name_remotable.emplace(std::string(family_name)); |
| 46 |
| 47 skia::RefPtr<SkRemotableFontIdentitySet> identities; |
| 48 content::RenderThreadImpl::current()->Send( |
| 49 new FontMsg_MatchName(FontMsgStart, family_name_remotable, &identities)); |
| 50 return SkSafeRef(identities.get()); |
| 51 } |
| 52 |
| 53 SkFontIdentity FontMgrProxy::matchNameStyle( |
| 54 const char family_name[], |
| 55 const SkFontStyle& style) const { |
| 56 IPC::Optional<std::string> family_name_remotable; |
| 57 if (family_name) |
| 58 family_name_remotable.emplace(std::string(family_name)); |
| 59 |
| 60 SkFontIdentity identity; |
| 61 content::RenderThreadImpl::current()->Send( |
| 62 new FontMsg_MatchNameStyle(FontMsgStart, family_name_remotable, style, |
| 63 &identity)); |
| 64 return identity; |
| 65 } |
| 66 |
| 67 SkFontIdentity FontMgrProxy::matchNameStyleCharacter( |
| 68 const char family_name[], |
| 69 const SkFontStyle& style, |
| 70 const char bpc47[], |
| 71 SkUnichar character) const { |
| 72 IPC::Optional<std::string> family_name_remotable; |
| 73 if (family_name) |
| 74 family_name_remotable.emplace(std::string(family_name)); |
| 75 |
| 76 IPC::Optional<std::string> bpc47_remotable; |
| 77 if (bpc47) |
| 78 bpc47_remotable.emplace(std::string(bpc47)); |
| 79 |
| 80 SkFontIdentity identity; |
| 81 content::RenderThreadImpl::current()->Send( |
| 82 new FontMsg_MatchNameStyleCharacter(FontMsgStart, family_name_remotable, |
| 83 style, bpc47_remotable, character, |
| 84 &identity)); |
| 85 return identity; |
| 86 } |
| 87 |
| 88 SkStreamAsset* FontMgrProxy::getData(int data_id) const { |
| 89 skia::RefPtr<SkStreamAsset> stream; |
| 90 content::RenderThreadImpl::current()->Send( |
| 91 new FontMsg_GetData(FontMsgStart, data_id, &stream)); |
| 92 return SkSafeRef(stream.get()); |
| 93 } |
| 94 |
| 95 } // namespace content |
OLD | NEW |