| Index: content/renderer/fontmgr_proxy.cc
|
| ===================================================================
|
| --- content/renderer/fontmgr_proxy.cc (revision 0)
|
| +++ content/renderer/fontmgr_proxy.cc (working copy)
|
| @@ -0,0 +1,95 @@
|
| +// Copyright (c) 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "base/values.h"
|
| +#include "content/common/fontmgr_messages.h"
|
| +#include "content/renderer/fontmgr_proxy.h"
|
| +#include "content/renderer/render_thread_impl.h"
|
| +#include "third_party/skia/include/core/SkDataTable.h"
|
| +#include "third_party/skia/include/core/SkStream.h"
|
| +#include "third_party/skia/include/ports/SkRemotableFontMgr.h"
|
| +
|
| +namespace content {
|
| +
|
| +SkDataTable* FontMgrProxy::getFamilyNames() const {
|
| + skia::RefPtr<SkDataTable> familyNames;
|
| + content::RenderThreadImpl::current()->Send(
|
| + new FontMsg_GetFamilyNames(FontMsgStart, &familyNames));
|
| + return SkSafeRef(familyNames.get());
|
| +}
|
| +
|
| +SkRemotableFontIdentitySet* FontMgrProxy::getIndex(int family_index) const {
|
| + skia::RefPtr<SkRemotableFontIdentitySet> identities;
|
| + content::RenderThreadImpl::current()->Send(
|
| + new FontMsg_GetIndex(FontMsgStart, family_index, &identities));
|
| + return SkSafeRef(identities.get());
|
| +}
|
| +
|
| +SkFontIdentity FontMgrProxy::matchIndexStyle(
|
| + int family_index,
|
| + const SkFontStyle& style) const {
|
| + SkFontIdentity identity;
|
| + content::RenderThreadImpl::current()->Send(
|
| + new FontMsg_MatchIndexStyle(FontMsgStart,
|
| + family_index,
|
| + style,
|
| + &identity));
|
| + return identity;
|
| +}
|
| +
|
| +SkRemotableFontIdentitySet* FontMgrProxy::matchName(
|
| + const char family_name[]) const {
|
| + IPC::Optional<std::string> family_name_remotable;
|
| + if (family_name)
|
| + family_name_remotable.emplace(std::string(family_name));
|
| +
|
| + skia::RefPtr<SkRemotableFontIdentitySet> identities;
|
| + content::RenderThreadImpl::current()->Send(
|
| + new FontMsg_MatchName(FontMsgStart, family_name_remotable, &identities));
|
| + return SkSafeRef(identities.get());
|
| +}
|
| +
|
| +SkFontIdentity FontMgrProxy::matchNameStyle(
|
| + const char family_name[],
|
| + const SkFontStyle& style) const {
|
| + IPC::Optional<std::string> family_name_remotable;
|
| + if (family_name)
|
| + family_name_remotable.emplace(std::string(family_name));
|
| +
|
| + SkFontIdentity identity;
|
| + content::RenderThreadImpl::current()->Send(
|
| + new FontMsg_MatchNameStyle(FontMsgStart, family_name_remotable, style,
|
| + &identity));
|
| + return identity;
|
| +}
|
| +
|
| +SkFontIdentity FontMgrProxy::matchNameStyleCharacter(
|
| + const char family_name[],
|
| + const SkFontStyle& style,
|
| + const char bpc47[],
|
| + SkUnichar character) const {
|
| + IPC::Optional<std::string> family_name_remotable;
|
| + if (family_name)
|
| + family_name_remotable.emplace(std::string(family_name));
|
| +
|
| + IPC::Optional<std::string> bpc47_remotable;
|
| + if (bpc47)
|
| + bpc47_remotable.emplace(std::string(bpc47));
|
| +
|
| + SkFontIdentity identity;
|
| + content::RenderThreadImpl::current()->Send(
|
| + new FontMsg_MatchNameStyleCharacter(FontMsgStart, family_name_remotable,
|
| + style, bpc47_remotable, character,
|
| + &identity));
|
| + return identity;
|
| +}
|
| +
|
| +SkStreamAsset* FontMgrProxy::getData(int data_id) const {
|
| + skia::RefPtr<SkStreamAsset> stream;
|
| + content::RenderThreadImpl::current()->Send(
|
| + new FontMsg_GetData(FontMsgStart, data_id, &stream));
|
| + return SkSafeRef(stream.get());
|
| +}
|
| +
|
| +} // namespace content
|
|
|