summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorbbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-16 09:57:51 +0000
committerbbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-16 09:57:51 +0000
commit725056b71817b5b35c49bad39ddc44d7156c4086 (patch)
tree7f83956f8bb9a224c913d9a22b71078a595d32ab /ppapi
parentaffb072ce9b81d57d8b62c281eedeab7ab14a29c (diff)
downloadchromium_src-725056b71817b5b35c49bad39ddc44d7156c4086.zip
chromium_src-725056b71817b5b35c49bad39ddc44d7156c4086.tar.gz
chromium_src-725056b71817b5b35c49bad39ddc44d7156c4086.tar.bz2
Add Pepper TrueType font API plumbing.
Adds Font resource and host, font singleton resource and host. Adds PPAPI IPC messages to communicate with renderer and browser. Adds Browser process font listing helper class abstraction and impls for Windows, Mac, and Linux. Font family enumeration is done in the browser process and is a rework of the trusted BrowserFont API. Adds Renderer process font helper class abstraction and impl stubs. Font operations are done in the renderer process because of Linux sandbox restrictions. BUG=79375 Review URL: https://chromiumcodereview.appspot.com/12600019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@188576 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/ppapi_proxy.gypi4
-rw-r--r--ppapi/ppapi_shared.gypi3
-rw-r--r--ppapi/proxy/interface_list.cc1
-rw-r--r--ppapi/proxy/ppapi_messages.h26
-rw-r--r--ppapi/proxy/ppapi_param_traits.cc37
-rw-r--r--ppapi/proxy/ppapi_param_traits.h10
-rw-r--r--ppapi/proxy/ppb_instance_proxy.cc4
-rw-r--r--ppapi/proxy/resource_creation_proxy.cc9
-rw-r--r--ppapi/proxy/resource_creation_proxy.h3
-rw-r--r--ppapi/proxy/serialized_structs.cc34
-rw-r--r--ppapi/proxy/serialized_structs.h25
-rw-r--r--ppapi/proxy/truetype_font_resource.cc130
-rw-r--r--ppapi/proxy/truetype_font_resource.h73
-rw-r--r--ppapi/proxy/truetype_font_singleton_resource.cc68
-rw-r--r--ppapi/proxy/truetype_font_singleton_resource.h55
-rw-r--r--ppapi/shared_impl/resource.h2
-rw-r--r--ppapi/shared_impl/singleton_resource_id.h1
-rw-r--r--ppapi/tests/all_c_includes.h1
-rw-r--r--ppapi/thunk/interfaces_ppb_public_dev.h2
-rw-r--r--ppapi/thunk/ppb_truetype_font_api.h36
-rw-r--r--ppapi/thunk/ppb_truetype_font_singleton_api.h34
-rw-r--r--ppapi/thunk/ppb_truetype_font_thunk.cc94
-rw-r--r--ppapi/thunk/resource_creation_api.h4
23 files changed, 656 insertions, 0 deletions
diff --git a/ppapi/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi
index 92e2238..4a5df15 100644
--- a/ppapi/ppapi_proxy.gypi
+++ b/ppapi/ppapi_proxy.gypi
@@ -166,6 +166,10 @@
'proxy/resource_creation_proxy.h',
'proxy/talk_resource.cc',
'proxy/talk_resource.h',
+ 'proxy/truetype_font_resource.cc',
+ 'proxy/truetype_font_resource.h',
+ 'proxy/truetype_font_singleton_resource.cc',
+ 'proxy/truetype_font_singleton_resource.h',
'proxy/udp_socket_private_resource.cc',
'proxy/udp_socket_private_resource.h',
'proxy/url_request_info_resource.cc',
diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi
index 2a8f83f..6bfb2d9 100644
--- a/ppapi/ppapi_shared.gypi
+++ b/ppapi/ppapi_shared.gypi
@@ -217,6 +217,9 @@
'thunk/ppb_tcp_socket_private_api.h',
'thunk/ppb_tcp_socket_private_thunk.cc',
'thunk/ppb_text_input_thunk.cc',
+ 'thunk/ppb_truetype_font_api.h',
+ 'thunk/ppb_truetype_font_singleton_api.h',
+ 'thunk/ppb_truetype_font_thunk.cc',
'thunk/ppb_udp_socket_private_api.h',
'thunk/ppb_udp_socket_private_thunk.cc',
'thunk/ppb_url_loader_api.h',
diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc
index 71444ce..4beeaab 100644
--- a/ppapi/proxy/interface_list.cc
+++ b/ppapi/proxy/interface_list.cc
@@ -25,6 +25,7 @@
#include "ppapi/c/dev/ppb_testing_dev.h"
#include "ppapi/c/dev/ppb_text_input_dev.h"
#include "ppapi/c/dev/ppb_trace_event_dev.h"
+#include "ppapi/c/dev/ppb_truetype_font_dev.h"
#include "ppapi/c/dev/ppb_url_util_dev.h"
#include "ppapi/c/dev/ppb_var_deprecated.h"
#include "ppapi/c/dev/ppb_video_capture_dev.h"
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index 4e9c0e2..9ccd930 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -22,6 +22,7 @@
#include "ppapi/c/dev/pp_video_dev.h"
#include "ppapi/c/dev/ppb_directory_reader_dev.h"
#include "ppapi/c/dev/ppb_text_input_dev.h"
+#include "ppapi/c/dev/ppb_truetype_font_dev.h"
#include "ppapi/c/dev/ppb_url_util_dev.h"
#include "ppapi/c/dev/ppp_printing_dev.h"
#include "ppapi/c/pp_bool.h"
@@ -84,6 +85,11 @@ IPC_ENUM_TRAITS(PP_PrintOutputFormat_Dev)
IPC_ENUM_TRAITS(PP_PrintScalingOption_Dev)
IPC_ENUM_TRAITS(PP_PrivateFontCharset)
IPC_ENUM_TRAITS(PP_TextInput_Type)
+IPC_ENUM_TRAITS(PP_TrueTypeFontFamily_Dev)
+IPC_ENUM_TRAITS(PP_TrueTypeFontStyle_Dev)
+IPC_ENUM_TRAITS(PP_TrueTypeFontWeight_Dev)
+IPC_ENUM_TRAITS(PP_TrueTypeFontWidth_Dev)
+IPC_ENUM_TRAITS(PP_TrueTypeFontCharset_Dev)
IPC_ENUM_TRAITS(PP_VideoDecodeError_Dev)
IPC_ENUM_TRAITS(PP_VideoDecoder_Profile)
@@ -1414,6 +1420,26 @@ IPC_MESSAGE_CONTROL2(PpapiHostMsg_Graphics2D_ReadImageData,
PP_Point /* top_left */)
IPC_MESSAGE_CONTROL0(PpapiPluginMsg_Graphics2D_ReadImageDataAck)
+// TrueTypeFont.
+IPC_MESSAGE_CONTROL0(PpapiHostMsg_TrueTypeFontSingleton_Create)
+IPC_MESSAGE_CONTROL0(PpapiHostMsg_TrueTypeFontSingleton_GetFontFamilies)
+IPC_MESSAGE_CONTROL1(PpapiPluginMsg_TrueTypeFontSingleton_GetFontFamiliesReply,
+ std::vector<std::string> /* font_families */)
+IPC_MESSAGE_CONTROL1(PpapiHostMsg_TrueTypeFont_Create,
+ ppapi::proxy::SerializedTrueTypeFontDesc /* desc */)
+IPC_MESSAGE_CONTROL0(PpapiHostMsg_TrueTypeFont_Describe)
+IPC_MESSAGE_CONTROL1(PpapiPluginMsg_TrueTypeFont_DescribeReply,
+ ppapi::proxy::SerializedTrueTypeFontDesc /* desc */)
+IPC_MESSAGE_CONTROL0(PpapiHostMsg_TrueTypeFont_GetTableTags)
+IPC_MESSAGE_CONTROL1(PpapiPluginMsg_TrueTypeFont_GetTableTagsReply,
+ std::vector<uint32_t> /* tags */)
+IPC_MESSAGE_CONTROL3(PpapiHostMsg_TrueTypeFont_GetTable,
+ uint32_t /* table */,
+ int32_t /* offset */,
+ int32_t /* max_data_length */)
+IPC_MESSAGE_CONTROL1(PpapiPluginMsg_TrueTypeFont_GetTableReply,
+ std::string /* data */)
+
// HostResolverPrivate, plugin -> host -> plugin
IPC_MESSAGE_CONTROL0(PpapiHostMsg_HostResolverPrivate_Create)
IPC_MESSAGE_CONTROL2(PpapiHostMsg_HostResolverPrivate_Resolve,
diff --git a/ppapi/proxy/ppapi_param_traits.cc b/ppapi/proxy/ppapi_param_traits.cc
index e457503..b654b22 100644
--- a/ppapi/proxy/ppapi_param_traits.cc
+++ b/ppapi/proxy/ppapi_param_traits.cc
@@ -560,7 +560,44 @@ void ParamTraits<ppapi::proxy::SerializedFontDescription>::Log(
const param_type& p,
std::string* l) {
}
+#endif // !defined(OS_NACL) && !defined(NACL_WIN64)
+
+// ppapi::proxy::SerializedTrueTypeFontDesc ------------------------------------
+
+// static
+void ParamTraits<ppapi::proxy::SerializedTrueTypeFontDesc>::Write(
+ Message* m,
+ const param_type& p) {
+ ParamTraits<std::string>::Write(m, p.family);
+ ParamTraits<PP_TrueTypeFontFamily_Dev>::Write(m, p.generic_family);
+ ParamTraits<PP_TrueTypeFontStyle_Dev>::Write(m, p.style);
+ ParamTraits<PP_TrueTypeFontWeight_Dev>::Write(m, p.weight);
+ ParamTraits<PP_TrueTypeFontWidth_Dev>::Write(m, p.width);
+ ParamTraits<PP_TrueTypeFontCharset_Dev>::Write(m, p.charset);
+}
+
+// static
+bool ParamTraits<ppapi::proxy::SerializedTrueTypeFontDesc>::Read(
+ const Message* m,
+ PickleIterator* iter,
+ param_type* r) {
+ return
+ ParamTraits<std::string>::Read(m, iter, &r->family) &&
+ ParamTraits<PP_TrueTypeFontFamily_Dev>::Read(m, iter,
+ &r->generic_family) &&
+ ParamTraits<PP_TrueTypeFontStyle_Dev>::Read(m, iter, &r->style) &&
+ ParamTraits<PP_TrueTypeFontWeight_Dev>::Read(m, iter, &r->weight) &&
+ ParamTraits<PP_TrueTypeFontWidth_Dev>::Read(m, iter, &r->width) &&
+ ParamTraits<PP_TrueTypeFontCharset_Dev>::Read(m, iter, &r->charset);
+}
+
+// static
+void ParamTraits<ppapi::proxy::SerializedTrueTypeFontDesc>::Log(
+ const param_type& p,
+ std::string* l) {
+}
+#if !defined(OS_NACL) && !defined(NACL_WIN64)
// ppapi::PepperFilePath -------------------------------------------------------
// static
diff --git a/ppapi/proxy/ppapi_param_traits.h b/ppapi/proxy/ppapi_param_traits.h
index 7556e35..38ec6f3 100644
--- a/ppapi/proxy/ppapi_param_traits.h
+++ b/ppapi/proxy/ppapi_param_traits.h
@@ -33,6 +33,7 @@ struct PPBFlash_DrawGlyphs_Params;
struct PPBURLLoader_UpdateProgress_Params;
struct SerializedDirEntry;
struct SerializedFontDescription;
+struct SerializedTrueTypeFontDesc;
class SerializedFlashMenu;
class SerializedHandle;
class SerializedVar;
@@ -117,6 +118,15 @@ struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::proxy::SerializedFontDescription> {
};
template<>
+struct PPAPI_PROXY_EXPORT
+ ParamTraits<ppapi::proxy::SerializedTrueTypeFontDesc> {
+ typedef ppapi::proxy::SerializedTrueTypeFontDesc param_type;
+ static void Write(Message* m, const param_type& p);
+ static bool Read(const Message* m, PickleIterator* iter, param_type* r);
+ static void Log(const param_type& p, std::string* l);
+};
+
+template<>
struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::proxy::SerializedHandle> {
typedef ppapi::proxy::SerializedHandle param_type;
static void Write(Message* m, const param_type& p);
diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc
index df83edc..58b1593 100644
--- a/ppapi/proxy/ppb_instance_proxy.cc
+++ b/ppapi/proxy/ppb_instance_proxy.cc
@@ -27,6 +27,7 @@
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/serialized_var.h"
+#include "ppapi/proxy/truetype_font_singleton_resource.h"
#include "ppapi/shared_impl/ppapi_globals.h"
#include "ppapi/shared_impl/ppb_url_util_shared.h"
#include "ppapi/shared_impl/ppb_view_shared.h"
@@ -357,6 +358,9 @@ Resource* PPB_Instance_Proxy::GetSingletonResource(PP_Instance instance,
case GAMEPAD_SINGLETON_ID:
new_singleton = new GamepadResource(connection, instance);
break;
+ case TRUETYPE_FONT_SINGLETON_ID:
+ new_singleton = new TrueTypeFontSingletonResource(connection, instance);
+ break;
// Flash/trusted resources aren't needed for NaCl.
#if !defined(OS_NACL) && !defined(NACL_WIN64)
case BROWSER_FONT_SINGLETON_ID:
diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc
index a821a15..4aec036 100644
--- a/ppapi/proxy/resource_creation_proxy.cc
+++ b/ppapi/proxy/resource_creation_proxy.cc
@@ -38,6 +38,7 @@
#include "ppapi/proxy/ppb_x509_certificate_private_proxy.h"
#include "ppapi/proxy/printing_resource.h"
#include "ppapi/proxy/talk_resource.h"
+#include "ppapi/proxy/truetype_font_resource.h"
#include "ppapi/proxy/udp_socket_private_resource.h"
#include "ppapi/proxy/url_request_info_resource.h"
#include "ppapi/proxy/url_response_info_resource.h"
@@ -143,6 +144,14 @@ PP_Resource ResourceCreationProxy::CreateResourceArray(
return object->GetReference();
}
+PP_Resource ResourceCreationProxy::CreateTrueTypeFont(
+ PP_Instance instance,
+ const PP_TrueTypeFontDesc_Dev& desc) {
+ return (new TrueTypeFontResource(GetConnection(),
+ instance, desc))->GetReference();
+
+}
+
PP_Resource ResourceCreationProxy::CreateURLLoader(PP_Instance instance) {
return PPB_URLLoader_Proxy::CreateProxyResource(instance);
}
diff --git a/ppapi/proxy/resource_creation_proxy.h b/ppapi/proxy/resource_creation_proxy.h
index 940b254..2a95c12 100644
--- a/ppapi/proxy/resource_creation_proxy.h
+++ b/ppapi/proxy/resource_creation_proxy.h
@@ -75,6 +75,9 @@ class ResourceCreationProxy : public InterfaceProxy,
virtual PP_Resource CreateResourceArray(PP_Instance instance,
const PP_Resource elements[],
uint32_t size) OVERRIDE;
+ virtual PP_Resource CreateTrueTypeFont(
+ PP_Instance instance,
+ const PP_TrueTypeFontDesc_Dev& desc) OVERRIDE;
virtual PP_Resource CreateURLLoader(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateURLRequestInfo(
PP_Instance instance,
diff --git a/ppapi/proxy/serialized_structs.cc b/ppapi/proxy/serialized_structs.cc
index ebd7ed0..8c984d5 100644
--- a/ppapi/proxy/serialized_structs.cc
+++ b/ppapi/proxy/serialized_structs.cc
@@ -80,6 +80,40 @@ void SerializedFontDescription::SetToPPBrowserFontDescription(
desc->word_spacing = word_spacing;
}
+SerializedTrueTypeFontDesc::SerializedTrueTypeFontDesc()
+ : family(),
+ generic_family(),
+ style(),
+ weight(),
+ width(),
+ charset() {
+}
+
+SerializedTrueTypeFontDesc::~SerializedTrueTypeFontDesc() {}
+
+void SerializedTrueTypeFontDesc::SetFromPPTrueTypeFontDesc(
+ const PP_TrueTypeFontDesc_Dev& desc) {
+ StringVar* string_var = StringVar::FromPPVar(desc.family);
+ family = string_var ? string_var->value() : std::string();
+
+ generic_family = desc.generic_family;
+ style = desc.style;
+ weight = desc.weight;
+ width = desc.width;
+ charset = desc.charset;
+}
+
+void SerializedTrueTypeFontDesc::CopyToPPTrueTypeFontDesc(
+ PP_TrueTypeFontDesc_Dev* desc) const {
+ desc->family = StringVar::StringToPPVar(family);
+
+ desc->generic_family = generic_family;
+ desc->style = style;
+ desc->weight = weight;
+ desc->width = width;
+ desc->charset = charset;
+}
+
PPBFlash_DrawGlyphs_Params::PPBFlash_DrawGlyphs_Params()
: instance(0),
font_desc(),
diff --git a/ppapi/proxy/serialized_structs.h b/ppapi/proxy/serialized_structs.h
index dcb99817..4844d6b 100644
--- a/ppapi/proxy/serialized_structs.h
+++ b/ppapi/proxy/serialized_structs.h
@@ -11,6 +11,7 @@
#include "base/logging.h"
#include "base/shared_memory.h"
#include "build/build_config.h"
+#include "ppapi/c/dev/ppb_truetype_font_dev.h"
#include "ppapi/c/pp_bool.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_point.h"
@@ -56,6 +57,30 @@ struct PPAPI_PROXY_EXPORT SerializedFontDescription {
int32_t word_spacing;
};
+struct PPAPI_PROXY_EXPORT SerializedTrueTypeFontDesc {
+ SerializedTrueTypeFontDesc();
+ ~SerializedTrueTypeFontDesc();
+
+ // Sets this to correspond to the contents of a PP_TrueTypeFontDesc_Dev.
+ //
+ // The reference count of the desc.family PP_Var will be unchanged and the
+ // caller is responsible for releasing it.
+ void SetFromPPTrueTypeFontDesc(const PP_TrueTypeFontDesc_Dev& desc);
+
+ // Converts this to a PP_FontDescription_Dev.
+ //
+ // The desc.family PP_Var will have one reference assigned to it. The caller
+ // is responsible for releasing it.
+ void CopyToPPTrueTypeFontDesc(PP_TrueTypeFontDesc_Dev* desc) const;
+
+ std::string family;
+ PP_TrueTypeFontFamily_Dev generic_family;
+ PP_TrueTypeFontStyle_Dev style;
+ PP_TrueTypeFontWeight_Dev weight;
+ PP_TrueTypeFontWidth_Dev width;
+ PP_TrueTypeFontCharset_Dev charset;
+};
+
struct SerializedDirEntry {
std::string name;
bool is_dir;
diff --git a/ppapi/proxy/truetype_font_resource.cc b/ppapi/proxy/truetype_font_resource.cc
new file mode 100644
index 0000000..0b07195
--- /dev/null
+++ b/ppapi/proxy/truetype_font_resource.cc
@@ -0,0 +1,130 @@
+// Copyright (c) 2013 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 "ppapi/proxy/truetype_font_resource.h"
+
+#include "base/bind.h"
+#include "ipc/ipc_message.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/shared_impl/array_writer.h"
+#include "ppapi/shared_impl/ppapi_globals.h"
+#include "ppapi/shared_impl/resource_tracker.h"
+#include "ppapi/shared_impl/var.h"
+#include "ppapi/thunk/enter.h"
+
+using ppapi::thunk::EnterResourceNoLock;
+using ppapi::thunk::PPB_TrueTypeFont_API;
+
+namespace {
+
+} // namespace
+
+namespace ppapi {
+namespace proxy {
+
+TrueTypeFontResource::TrueTypeFontResource(
+ Connection connection,
+ PP_Instance instance,
+ const PP_TrueTypeFontDesc_Dev& desc)
+ : PluginResource(connection, instance) {
+ SerializedTrueTypeFontDesc serialized_desc;
+ serialized_desc.SetFromPPTrueTypeFontDesc(desc);
+ SendCreate(RENDERER, PpapiHostMsg_TrueTypeFont_Create(serialized_desc));
+}
+
+TrueTypeFontResource::~TrueTypeFontResource() {
+}
+
+PPB_TrueTypeFont_API* TrueTypeFontResource::AsPPB_TrueTypeFont_API() {
+ return this;
+}
+
+int32_t TrueTypeFontResource::Describe(
+ PP_TrueTypeFontDesc_Dev* desc,
+ scoped_refptr<TrackedCallback> callback) {
+
+ Call<PpapiPluginMsg_TrueTypeFont_DescribeReply>(RENDERER,
+ PpapiHostMsg_TrueTypeFont_Describe(),
+ base::Bind(&TrueTypeFontResource::OnPluginMsgDescribeComplete, this,
+ callback, desc));
+ return PP_OK_COMPLETIONPENDING;
+}
+
+int32_t TrueTypeFontResource::GetTableTags(
+ const PP_ArrayOutput& output,
+ scoped_refptr<TrackedCallback> callback) {
+ Call<PpapiPluginMsg_TrueTypeFont_GetTableTagsReply>(RENDERER,
+ PpapiHostMsg_TrueTypeFont_GetTableTags(),
+ base::Bind(&TrueTypeFontResource::OnPluginMsgGetTableTagsComplete, this,
+ callback, output));
+ return PP_OK_COMPLETIONPENDING;
+}
+
+int32_t TrueTypeFontResource::GetTable(
+ uint32_t table,
+ int32_t offset,
+ int32_t max_data_length,
+ const PP_ArrayOutput& output,
+ scoped_refptr<TrackedCallback> callback) {
+ Call<PpapiPluginMsg_TrueTypeFont_GetTableReply>(RENDERER,
+ PpapiHostMsg_TrueTypeFont_GetTable(table, offset, max_data_length),
+ base::Bind(&TrueTypeFontResource::OnPluginMsgGetTableComplete, this,
+ callback, output));
+ return PP_OK_COMPLETIONPENDING;
+}
+
+void TrueTypeFontResource::OnPluginMsgDescribeComplete(
+ scoped_refptr<TrackedCallback> callback,
+ PP_TrueTypeFontDesc_Dev* pp_desc,
+ const ResourceMessageReplyParams& params,
+ const ppapi::proxy::SerializedTrueTypeFontDesc& desc) {
+ int32_t result = params.result();
+ if (result == PP_OK)
+ desc.CopyToPPTrueTypeFontDesc(pp_desc);
+ callback->Run(result);
+}
+
+void TrueTypeFontResource::OnPluginMsgGetTableTagsComplete(
+ scoped_refptr<TrackedCallback> callback,
+ PP_ArrayOutput array_output,
+ const ResourceMessageReplyParams& params,
+ const std::vector<uint32_t>& tag_array) {
+ // The result code should contain the data size if it's positive.
+ int32_t result = params.result();
+ DCHECK((result < 0 && tag_array.size() == 0) ||
+ result == static_cast<int32_t>(tag_array.size()));
+
+ ArrayWriter output;
+ output.set_pp_array_output(array_output);
+ if (output.is_valid())
+ output.StoreArray(&tag_array[0], std::max(0, result));
+ else
+ result = PP_ERROR_FAILED;
+
+ callback->Run(result);
+}
+
+void TrueTypeFontResource::OnPluginMsgGetTableComplete(
+ scoped_refptr<TrackedCallback> callback,
+ PP_ArrayOutput array_output,
+ const ResourceMessageReplyParams& params,
+ const std::string& data) {
+ // The result code should contain the data size if it's positive.
+ int32_t result = params.result();
+ DCHECK((result < 0 && data.size() == 0) ||
+ result == static_cast<int32_t>(data.size()));
+
+ ArrayWriter output;
+ output.set_pp_array_output(array_output);
+ if (output.is_valid())
+ output.StoreArray(data.data(), std::max(0, result));
+ else
+ result = PP_ERROR_FAILED;
+
+ callback->Run(result);
+}
+
+} // namespace proxy
+} // namespace ppapi
diff --git a/ppapi/proxy/truetype_font_resource.h b/ppapi/proxy/truetype_font_resource.h
new file mode 100644
index 0000000..6aac2d5
--- /dev/null
+++ b/ppapi/proxy/truetype_font_resource.h
@@ -0,0 +1,73 @@
+// Copyright (c) 2013 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.
+
+#ifndef PPAPI_PROXY_TRUETYPE_FONT_RESOURCE_H_
+#define PPAPI_PROXY_TRUETYPE_FONT_RESOURCE_H_
+
+#include <string>
+
+#include "ppapi/proxy/connection.h"
+#include "ppapi/proxy/plugin_resource.h"
+#include "ppapi/proxy/ppapi_proxy_export.h"
+#include "ppapi/shared_impl/var.h"
+#include "ppapi/thunk/ppb_truetype_font_api.h"
+
+namespace ppapi {
+
+class TrackedCallback;
+
+namespace proxy {
+
+struct SerializedTrueTypeFontDesc;
+
+class PPAPI_PROXY_EXPORT TrueTypeFontResource
+ : public PluginResource,
+ public thunk::PPB_TrueTypeFont_API {
+ public:
+ TrueTypeFontResource(Connection connection,
+ PP_Instance instance,
+ const PP_TrueTypeFontDesc_Dev& desc);
+ virtual ~TrueTypeFontResource();
+
+ // Resource overrides.
+ virtual thunk::PPB_TrueTypeFont_API* AsPPB_TrueTypeFont_API() OVERRIDE;
+
+ // PPB_TrueTypeFont_API implementation.
+ virtual int32_t Describe(
+ PP_TrueTypeFontDesc_Dev* desc,
+ scoped_refptr<TrackedCallback> callback) OVERRIDE;
+ virtual int32_t GetTableTags(
+ const PP_ArrayOutput& output,
+ scoped_refptr<TrackedCallback> callback) OVERRIDE;
+ virtual int32_t GetTable(
+ uint32_t table,
+ int32_t offset,
+ int32_t max_data_length,
+ const PP_ArrayOutput& output,
+ scoped_refptr<TrackedCallback> callback) OVERRIDE;
+
+ private:
+ void OnPluginMsgDescribeComplete(
+ scoped_refptr<TrackedCallback> callback,
+ PP_TrueTypeFontDesc_Dev* pp_desc,
+ const ResourceMessageReplyParams& params,
+ const ppapi::proxy::SerializedTrueTypeFontDesc& desc);
+ void OnPluginMsgGetTableTagsComplete(
+ scoped_refptr<TrackedCallback> callback,
+ PP_ArrayOutput array_output,
+ const ResourceMessageReplyParams& params,
+ const std::vector<uint32_t>& data);
+ void OnPluginMsgGetTableComplete(
+ scoped_refptr<TrackedCallback> callback,
+ PP_ArrayOutput array_output,
+ const ResourceMessageReplyParams& params,
+ const std::string& data);
+
+ DISALLOW_COPY_AND_ASSIGN(TrueTypeFontResource);
+};
+
+} // namespace proxy
+} // namespace ppapi
+
+#endif // PPAPI_PROXY_TRUETYPE_FONT_RESOURCE_H_
diff --git a/ppapi/proxy/truetype_font_singleton_resource.cc b/ppapi/proxy/truetype_font_singleton_resource.cc
new file mode 100644
index 0000000..b812bf1
--- /dev/null
+++ b/ppapi/proxy/truetype_font_singleton_resource.cc
@@ -0,0 +1,68 @@
+// Copyright (c) 2013 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 "ppapi/proxy/truetype_font_singleton_resource.h"
+
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/shared_impl/array_writer.h"
+#include "ppapi/shared_impl/tracked_callback.h"
+#include "ppapi/shared_impl/var.h"
+
+namespace ppapi {
+namespace proxy {
+
+TrueTypeFontSingletonResource::TrueTypeFontSingletonResource(
+ Connection connection,
+ PP_Instance instance)
+ : PluginResource(connection, instance) {
+ SendCreate(BROWSER, PpapiHostMsg_TrueTypeFontSingleton_Create());
+}
+
+TrueTypeFontSingletonResource::~TrueTypeFontSingletonResource() {
+}
+
+thunk::PPB_TrueTypeFont_Singleton_API*
+TrueTypeFontSingletonResource::AsPPB_TrueTypeFont_Singleton_API() {
+ return this;
+}
+
+int32_t TrueTypeFontSingletonResource::GetFontFamilies(
+ PP_Instance instance,
+ const PP_ArrayOutput& output,
+ const scoped_refptr<TrackedCallback>& callback) {
+ Call<PpapiPluginMsg_TrueTypeFontSingleton_GetFontFamiliesReply>(BROWSER,
+ PpapiHostMsg_TrueTypeFontSingleton_GetFontFamilies(),
+ base::Bind(
+ &TrueTypeFontSingletonResource::OnPluginMsgGetFontFamiliesComplete,
+ this, callback, output));
+ return PP_OK_COMPLETIONPENDING;
+}
+
+void TrueTypeFontSingletonResource::OnPluginMsgGetFontFamiliesComplete(
+ scoped_refptr<TrackedCallback> callback,
+ PP_ArrayOutput array_output,
+ const ResourceMessageReplyParams& params,
+ const std::vector<std::string>& font_families) {
+ // The result code should contain the data size if it's positive.
+ int32_t result = params.result();
+ DCHECK((result < 0 && font_families.size() == 0) ||
+ result == static_cast<int32_t>(font_families.size()));
+
+ ArrayWriter output;
+ output.set_pp_array_output(array_output);
+ if (output.is_valid()) {
+ std::vector< scoped_refptr<Var> > font_family_vars;
+ for (size_t i = 0; i < font_families.size(); i++)
+ font_family_vars.push_back(
+ scoped_refptr<Var>(new StringVar(font_families[i])));
+ output.StoreVarVector(font_family_vars);
+ } else {
+ result = PP_ERROR_FAILED;
+ }
+
+ callback->Run(result);
+}
+
+} // namespace proxy
+} // namespace ppapi
diff --git a/ppapi/proxy/truetype_font_singleton_resource.h b/ppapi/proxy/truetype_font_singleton_resource.h
new file mode 100644
index 0000000..03c9c7d
--- /dev/null
+++ b/ppapi/proxy/truetype_font_singleton_resource.h
@@ -0,0 +1,55 @@
+// Copyright (c) 2013 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.
+
+#ifndef PPAPI_PROXY_TRUETYPE_FONT_SINGLETON_RESOURCE_H_
+#define PPAPI_PROXY_TRUETYPE_FONT_SINGLETON_RESOURCE_H_
+
+#include <string>
+#include <vector>
+
+#include "ppapi/proxy/connection.h"
+#include "ppapi/proxy/plugin_resource.h"
+#include "ppapi/thunk/ppb_truetype_font_singleton_api.h"
+
+namespace ppapi {
+
+class TrackedCallback;
+
+namespace proxy {
+
+struct SerializedTrueTypeFontDescription;
+
+// This handles the singleton calls (that don't take a PP_Resource parameter)
+// on the TrueType font interface.
+class TrueTypeFontSingletonResource
+ : public PluginResource,
+ public thunk::PPB_TrueTypeFont_Singleton_API {
+ public:
+ TrueTypeFontSingletonResource(Connection connection, PP_Instance instance);
+ virtual ~TrueTypeFontSingletonResource();
+
+ // Resource override.
+ virtual thunk::PPB_TrueTypeFont_Singleton_API*
+ AsPPB_TrueTypeFont_Singleton_API() OVERRIDE;
+
+ // thunk::PPB_TrueTypeFont_Singleton_API implementation.
+ virtual int32_t GetFontFamilies(
+ PP_Instance instance,
+ const PP_ArrayOutput& output,
+ const scoped_refptr<TrackedCallback>& callback) OVERRIDE;
+
+ private:
+ void OnPluginMsgGetFontFamiliesComplete(
+ scoped_refptr<TrackedCallback> callback,
+ PP_ArrayOutput array_output,
+ const ResourceMessageReplyParams& params,
+ const std::vector<std::string>& data);
+
+ DISALLOW_COPY_AND_ASSIGN(TrueTypeFontSingletonResource);
+};
+
+} // namespace proxy
+} // namespace ppapi
+
+#endif // PPAPI_PROXY_TRUETYPE_FONT_SINGLETON_RESOURCE_H_
diff --git a/ppapi/shared_impl/resource.h b/ppapi/shared_impl/resource.h
index 3213e8b..fd86ddd 100644
--- a/ppapi/shared_impl/resource.h
+++ b/ppapi/shared_impl/resource.h
@@ -59,6 +59,8 @@
F(PPB_ResourceArray_API) \
F(PPB_Scrollbar_API) \
F(PPB_Talk_Private_API) \
+ F(PPB_TrueTypeFont_API) \
+ F(PPB_TrueTypeFont_Singleton_API) \
F(PPB_TCPServerSocket_Private_API) \
F(PPB_TCPSocket_Private_API) \
F(PPB_UDPSocket_Private_API) \
diff --git a/ppapi/shared_impl/singleton_resource_id.h b/ppapi/shared_impl/singleton_resource_id.h
index a63dc40..d7db485 100644
--- a/ppapi/shared_impl/singleton_resource_id.h
+++ b/ppapi/shared_impl/singleton_resource_id.h
@@ -20,6 +20,7 @@ enum SingletonResourceID {
FLASH_FULLSCREEN_SINGLETON_ID,
FLASH_SINGLETON_ID,
GAMEPAD_SINGLETON_ID,
+ TRUETYPE_FONT_SINGLETON_ID,
};
} // namespace ppapi
diff --git a/ppapi/tests/all_c_includes.h b/ppapi/tests/all_c_includes.h
index bd6911c..7d7a690 100644
--- a/ppapi/tests/all_c_includes.h
+++ b/ppapi/tests/all_c_includes.h
@@ -29,6 +29,7 @@
#include "ppapi/c/dev/ppb_testing_dev.h"
#include "ppapi/c/dev/ppb_text_input_dev.h"
#include "ppapi/c/dev/ppb_trace_event_dev.h"
+#include "ppapi/c/dev/ppb_truetype_font_dev.h"
#include "ppapi/c/dev/ppb_url_util_dev.h"
#include "ppapi/c/dev/ppb_var_deprecated.h"
#include "ppapi/c/dev/ppb_video_decoder_dev.h"
diff --git a/ppapi/thunk/interfaces_ppb_public_dev.h b/ppapi/thunk/interfaces_ppb_public_dev.h
index 708b6ef..d0570d9 100644
--- a/ppapi/thunk/interfaces_ppb_public_dev.h
+++ b/ppapi/thunk/interfaces_ppb_public_dev.h
@@ -28,6 +28,8 @@ PROXIED_IFACE(NoAPIName, PPB_RESOURCEARRAY_DEV_INTERFACE_0_1,
PPB_ResourceArray_Dev_0_1)
PROXIED_IFACE(PPB_Instance, PPB_TEXTINPUT_DEV_INTERFACE_0_2,
PPB_TextInput_Dev_0_2)
+PROXIED_IFACE(NoAPIName, PPB_TRUETYPEFONT_DEV_INTERFACE_0_1,
+ PPB_TrueTypeFont_Dev_0_1)
PROXIED_IFACE(NoAPIName, PPB_VIEW_DEV_INTERFACE_0_1,
PPB_View_Dev_0_1)
UNPROXIED_IFACE(PPB_Instance, PPB_ZOOM_DEV_INTERFACE_0_2, PPB_Zoom_Dev_0_2)
diff --git a/ppapi/thunk/ppb_truetype_font_api.h b/ppapi/thunk/ppb_truetype_font_api.h
new file mode 100644
index 0000000..9df6c98
--- /dev/null
+++ b/ppapi/thunk/ppb_truetype_font_api.h
@@ -0,0 +1,36 @@
+// Copyright (c) 2013 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.
+
+#ifndef PPAPI_THUNK_PPB_TRUETYPE_FONT_API_H_
+#define PPAPI_THUNK_PPB_TRUETYPE_FONT_API_H_
+
+#include "base/memory/ref_counted.h"
+#include "ppapi/c/dev/ppb_truetype_font_dev.h"
+#include "ppapi/thunk/ppapi_thunk_export.h"
+
+namespace ppapi {
+
+class TrackedCallback;
+
+namespace thunk {
+
+class PPAPI_THUNK_EXPORT PPB_TrueTypeFont_API {
+ public:
+ virtual ~PPB_TrueTypeFont_API() {}
+
+ virtual int32_t Describe(PP_TrueTypeFontDesc_Dev* desc,
+ scoped_refptr<TrackedCallback> callback) = 0;
+ virtual int32_t GetTableTags(const PP_ArrayOutput& output,
+ scoped_refptr<TrackedCallback> callback) = 0;
+ virtual int32_t GetTable(uint32_t table,
+ int32_t offset,
+ int32_t max_data_length,
+ const PP_ArrayOutput& output,
+ scoped_refptr<TrackedCallback> callback) = 0;
+};
+
+} // namespace thunk
+} // namespace ppapi
+
+#endif // PPAPI_THUNK_PPB_TRUETYPE_FONT_API_H_
diff --git a/ppapi/thunk/ppb_truetype_font_singleton_api.h b/ppapi/thunk/ppb_truetype_font_singleton_api.h
new file mode 100644
index 0000000..514bab1
--- /dev/null
+++ b/ppapi/thunk/ppb_truetype_font_singleton_api.h
@@ -0,0 +1,34 @@
+// Copyright (c) 2013 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.
+
+#ifndef PPAPI_THUNK_PPB_TRUETYPE_FONT_SINGLETON_API_H_
+#define PPAPI_THUNK_PPB_TRUETYPE_FONT_SINGLETON_API_H_
+
+#include "ppapi/c/pp_array_output.h"
+#include "ppapi/c/pp_completion_callback.h"
+#include "ppapi/c/pp_instance.h"
+#include "ppapi/c/pp_var.h"
+#include "ppapi/shared_impl/singleton_resource_id.h"
+#include "ppapi/shared_impl/tracked_callback.h"
+
+namespace ppapi {
+namespace thunk {
+
+class PPB_TrueTypeFont_Singleton_API {
+ public:
+ virtual ~PPB_TrueTypeFont_Singleton_API() {}
+
+ virtual int32_t GetFontFamilies(
+ PP_Instance instance,
+ const PP_ArrayOutput& output,
+ const scoped_refptr<TrackedCallback>& callback) = 0;
+
+ static const SingletonResourceID kSingletonResourceID =
+ TRUETYPE_FONT_SINGLETON_ID;
+};
+
+} // namespace thunk
+} // namespace ppapi
+
+#endif // PPAPI_THUNK_PPB_TRUETYPE_FONT_SINGLETON_API_H_
diff --git a/ppapi/thunk/ppb_truetype_font_thunk.cc b/ppapi/thunk/ppb_truetype_font_thunk.cc
new file mode 100644
index 0000000..b941c84
--- /dev/null
+++ b/ppapi/thunk/ppb_truetype_font_thunk.cc
@@ -0,0 +1,94 @@
+// Copyright (c) 2013 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 "ppapi/c/dev/ppb_truetype_font_dev.h"
+#include "ppapi/c/pp_completion_callback.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/shared_impl/tracked_callback.h"
+#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/ppb_instance_api.h"
+#include "ppapi/thunk/ppb_truetype_font_api.h"
+#include "ppapi/thunk/ppb_truetype_font_singleton_api.h"
+#include "ppapi/thunk/resource_creation_api.h"
+#include "ppapi/thunk/thunk.h"
+
+namespace ppapi {
+namespace thunk {
+
+namespace {
+
+int32_t GetFontFamilies(PP_Instance instance,
+ PP_ArrayOutput output,
+ PP_CompletionCallback callback) {
+ EnterInstanceAPI<PPB_TrueTypeFont_Singleton_API> enter(instance, callback);
+ if (enter.failed())
+ return PP_ERROR_FAILED;
+ return enter.functions()->GetFontFamilies(instance, output, enter.callback());
+}
+
+PP_Resource Create(PP_Instance instance,
+ const PP_TrueTypeFontDesc_Dev* desc) {
+ EnterResourceCreation enter(instance);
+ if (enter.failed())
+ return 0;
+ return enter.functions()->CreateTrueTypeFont(instance, *desc);
+}
+
+PP_Bool IsFont(PP_Resource resource) {
+ EnterResource<PPB_TrueTypeFont_API> enter(resource, false);
+ return PP_FromBool(enter.succeeded());
+}
+
+int32_t Describe(PP_Resource font,
+ PP_TrueTypeFontDesc_Dev* desc,
+ PP_CompletionCallback callback) {
+ EnterResource<PPB_TrueTypeFont_API> enter(font, callback, true);
+ if (enter.failed())
+ return enter.retval();
+ return enter.SetResult(enter.object()->Describe(desc, enter.callback()));
+}
+
+int32_t GetTableTags(PP_Resource font,
+ PP_ArrayOutput output,
+ PP_CompletionCallback callback) {
+ EnterResource<PPB_TrueTypeFont_API> enter(font, callback, true);
+ if (enter.failed())
+ return enter.retval();
+ return enter.SetResult(enter.object()->GetTableTags(output,
+ enter.callback()));
+}
+
+int32_t GetTable(PP_Resource font,
+ uint32_t table,
+ int32_t offset,
+ int32_t max_data_length,
+ PP_ArrayOutput output,
+ PP_CompletionCallback callback) {
+ EnterResource<PPB_TrueTypeFont_API> enter(font, callback, true);
+ if (enter.failed())
+ return enter.retval();
+ return enter.SetResult(enter.object()->GetTable(table,
+ offset,
+ max_data_length,
+ output,
+ enter.callback()));
+}
+
+const PPB_TrueTypeFont_Dev_0_1 g_ppb_truetypefont_thunk_0_1 = {
+ &GetFontFamilies,
+ &Create,
+ &IsFont,
+ &Describe,
+ &GetTableTags,
+ &GetTable
+};
+
+} // namespace
+
+const PPB_TrueTypeFont_Dev_0_1* GetPPB_TrueTypeFont_Dev_0_1_Thunk() {
+ return &g_ppb_truetypefont_thunk_0_1;
+}
+
+} // namespace thunk
+} // namespace ppapi
diff --git a/ppapi/thunk/resource_creation_api.h b/ppapi/thunk/resource_creation_api.h
index 47c1114..377424a 100644
--- a/ppapi/thunk/resource_creation_api.h
+++ b/ppapi/thunk/resource_creation_api.h
@@ -17,6 +17,7 @@
#include "ppapi/c/ppb_input_event.h"
#include "ppapi/c/ppb_websocket.h"
#include "ppapi/c/dev/pp_video_dev.h"
+#include "ppapi/c/dev/ppb_truetype_font_dev.h"
#include "ppapi/c/private/pp_private_font_charset.h"
#include "ppapi/c/private/ppb_network_monitor_private.h"
#include "ppapi/shared_impl/api_id.h"
@@ -80,6 +81,9 @@ class ResourceCreationAPI {
virtual PP_Resource CreateResourceArray(PP_Instance instance,
const PP_Resource elements[],
uint32_t size) = 0;
+ virtual PP_Resource CreateTrueTypeFont(
+ PP_Instance instance,
+ const PP_TrueTypeFontDesc_Dev& desc) = 0;
virtual PP_Resource CreateURLLoader(PP_Instance instance) = 0;
virtual PP_Resource CreateURLRequestInfo(
PP_Instance instance,