[ppapi] Remove PPB_TrueTypeFont resource.
- UMA shows this interface has no usage. This is a manual reland of: https://chromium-review.googlesource.com/c/chromium/src/+/1546762 That was reverted due to failures on the deterministic build. Let's see if that has been fixed. Change-Id: I4f7409dd0cb76245539d63d61e411bb35c9d1514 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2446369 Reviewed-by: Scott Violet <sky@chromium.org> Reviewed-by: Raymes Khoury <raymes@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Bill Budge <bbudge@chromium.org> Cr-Commit-Position: refs/heads/master@{#814202}
This commit is contained in:
chrome
content
native_client_sdk/src/libraries
ppapi
BUILD.gn
api
c
cpp
native_client
src
untrusted
pnacl_irt_shim
proxy
BUILD.gninterface_list.ccppapi_messages.hppapi_param_traits.ccppapi_param_traits.hppb_instance_proxy.ccresource_creation_proxy.ccresource_creation_proxy.hserialized_structs.ccserialized_structs.htruetype_font_resource.cctruetype_font_resource.htruetype_font_singleton_resource.cctruetype_font_singleton_resource.h
shared_impl
tests
thunk
tools
@ -21,7 +21,6 @@
|
||||
#include "ppapi/c/dev/ppb_printing_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"
|
||||
|
@ -2215,14 +2215,6 @@ TEST_PPAPI_NACL(MouseCursor)
|
||||
|
||||
TEST_PPAPI_NACL(NetworkProxy)
|
||||
|
||||
// TODO(crbug.com/619765): get working on CrOS build.
|
||||
#if defined(OS_CHROMEOS)
|
||||
#define MAYBE_TrueTypeFont DISABLED_TrueTypeFont
|
||||
#else
|
||||
#define MAYBE_TrueTypeFont TrueTypeFont
|
||||
#endif
|
||||
TEST_PPAPI_NACL(MAYBE_TrueTypeFont)
|
||||
|
||||
// TODO(crbug.com/602875), TODO(crbug.com/602876) Flaky on Win and CrOS.
|
||||
#if defined(OS_CHROMEOS) || defined(OS_WIN)
|
||||
#define MAYBE_VideoDecoder DISABLED_VideoDecoder
|
||||
|
@ -2350,17 +2350,6 @@ source_set("browser") {
|
||||
"renderer_host/pepper/pepper_tcp_server_socket_message_filter.h",
|
||||
"renderer_host/pepper/pepper_tcp_socket_message_filter.cc",
|
||||
"renderer_host/pepper/pepper_tcp_socket_message_filter.h",
|
||||
"renderer_host/pepper/pepper_truetype_font.h",
|
||||
"renderer_host/pepper/pepper_truetype_font_host.cc",
|
||||
"renderer_host/pepper/pepper_truetype_font_host.h",
|
||||
"renderer_host/pepper/pepper_truetype_font_linux.cc",
|
||||
"renderer_host/pepper/pepper_truetype_font_list.h",
|
||||
"renderer_host/pepper/pepper_truetype_font_list_host.cc",
|
||||
"renderer_host/pepper/pepper_truetype_font_list_host.h",
|
||||
"renderer_host/pepper/pepper_truetype_font_list_mac.mm",
|
||||
"renderer_host/pepper/pepper_truetype_font_list_win.cc",
|
||||
"renderer_host/pepper/pepper_truetype_font_mac.mm",
|
||||
"renderer_host/pepper/pepper_truetype_font_win.cc",
|
||||
"renderer_host/pepper/pepper_udp_socket_message_filter.cc",
|
||||
"renderer_host/pepper/pepper_udp_socket_message_filter.h",
|
||||
"renderer_host/pepper/pepper_vpn_provider_message_filter_chromeos.cc",
|
||||
@ -2376,20 +2365,6 @@ source_set("browser") {
|
||||
"//ppapi/proxy:ipc",
|
||||
"//ppapi/shared_impl",
|
||||
]
|
||||
|
||||
# TODO(1119772): this makes both use_x11 and use_ozone builds for is_linux use
|
||||
# pangocairo so that PPAPINaClNewlibTest.TrueTypeFont,
|
||||
# PPAPINaClPNaClNonSfiTest.TrueTypeFont, and OutOfProcessPPAPITest.TrueTypeFont
|
||||
# tests continue to run normally on Linux. This also fixes these tests for
|
||||
# Ozone/Linux, but requires to use pangocairo. We probably want to continue
|
||||
# using pango on Linux and switch to something else for other systems that
|
||||
# use Ozone.
|
||||
if (use_ozone && (!is_linux || !use_pangocairo)) {
|
||||
sources += [ "renderer_host/pepper/pepper_truetype_font_list_ozone.cc" ]
|
||||
} else if (use_pangocairo) {
|
||||
sources += [ "renderer_host/pepper/pepper_truetype_font_list_pango.cc" ]
|
||||
}
|
||||
|
||||
if (is_linux || is_chromeos) {
|
||||
deps += [ "//components/services/font:ppapi_fontconfig_matching" ]
|
||||
}
|
||||
|
@ -21,8 +21,6 @@
|
||||
#include "content/browser/renderer_host/pepper/pepper_printing_host.h"
|
||||
#include "content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.h"
|
||||
#include "content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.h"
|
||||
#include "content/browser/renderer_host/pepper/pepper_truetype_font_host.h"
|
||||
#include "content/browser/renderer_host/pepper/pepper_truetype_font_list_host.h"
|
||||
#include "content/browser/renderer_host/pepper/pepper_udp_socket_message_filter.h"
|
||||
#include "ppapi/host/message_filter_host.h"
|
||||
#include "ppapi/host/ppapi_host.h"
|
||||
@ -175,25 +173,6 @@ ContentBrowserPepperHostFactory::CreateResourceHost(
|
||||
new PepperPrintingHost(host_->GetPpapiHost(), instance, resource,
|
||||
std::move(manager)));
|
||||
}
|
||||
case PpapiHostMsg_TrueTypeFont_Create::ID: {
|
||||
ppapi::proxy::SerializedTrueTypeFontDesc desc;
|
||||
if (!ppapi::UnpackMessage<PpapiHostMsg_TrueTypeFont_Create>(message,
|
||||
&desc)) {
|
||||
NOTREACHED();
|
||||
return std::unique_ptr<ppapi::host::ResourceHost>();
|
||||
}
|
||||
// Check that the family name is valid UTF-8 before passing it to the
|
||||
// host OS.
|
||||
if (!base::IsStringUTF8(desc.family))
|
||||
return std::unique_ptr<ppapi::host::ResourceHost>();
|
||||
|
||||
return std::unique_ptr<ppapi::host::ResourceHost>(
|
||||
new PepperTrueTypeFontHost(host_, instance, resource, desc));
|
||||
}
|
||||
case PpapiHostMsg_TrueTypeFontSingleton_Create::ID: {
|
||||
return std::unique_ptr<ppapi::host::ResourceHost>(
|
||||
new PepperTrueTypeFontListHost(host_, instance, resource));
|
||||
}
|
||||
#if defined(OS_CHROMEOS)
|
||||
case PpapiHostMsg_VpnProvider_Create::ID: {
|
||||
scoped_refptr<PepperVpnProviderMessageFilter> vpn_provider(
|
||||
|
@ -1,57 +0,0 @@
|
||||
// Copyright 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.
|
||||
|
||||
#ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_TRUETYPE_FONT_H_
|
||||
#define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_TRUETYPE_FONT_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "ppapi/proxy/serialized_structs.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
class PepperTrueTypeFont
|
||||
: public base::RefCountedThreadSafe<PepperTrueTypeFont> {
|
||||
public:
|
||||
// Factory method to create a font for the current host.
|
||||
static PepperTrueTypeFont* Create();
|
||||
|
||||
// Initializes the font. Updates the descriptor with the actual font's
|
||||
// characteristics. The exact font will depend on the host platform's font
|
||||
// matching and fallback algorithm. On failure, returns NULL and leaves desc
|
||||
// unchanged.
|
||||
// NOTE: This method may perform long blocking file IO.
|
||||
virtual int32_t Initialize(
|
||||
ppapi::proxy::SerializedTrueTypeFontDesc* desc) = 0;
|
||||
|
||||
// Retrieves an array of TrueType table tags contained in this font. Returns
|
||||
// the number of tags on success, a Pepper error code on failure. 'tags' are
|
||||
// written only on success.
|
||||
// NOTE: This method may perform long blocking file IO. It may be called even
|
||||
// though the call to Initialize failed. Implementors must check validity.
|
||||
virtual int32_t GetTableTags(std::vector<uint32_t>* tags) = 0;
|
||||
|
||||
// Gets a TrueType font table corresponding to the given tag. The 'offset' and
|
||||
// 'max_data_length' parameters determine what part of the table is returned.
|
||||
// Returns the data size in bytes on success, a Pepper error code on failure.
|
||||
// 'data' is written only on success.
|
||||
// NOTE: This method may perform long blocking file IO. It may be called even
|
||||
// though the call to Initialize failed. Implementors must check validity.
|
||||
virtual int32_t GetTable(uint32_t table_tag,
|
||||
int32_t offset,
|
||||
int32_t max_data_length,
|
||||
std::string* data) = 0;
|
||||
|
||||
protected:
|
||||
friend class base::RefCountedThreadSafe<PepperTrueTypeFont>;
|
||||
virtual ~PepperTrueTypeFont() {}
|
||||
};
|
||||
|
||||
} // namespace content
|
||||
|
||||
#endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_TRUETYPE_FONT_H_
|
@ -1,158 +0,0 @@
|
||||
// Copyright 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 "content/browser/renderer_host/pepper/pepper_truetype_font.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/files/scoped_file.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/numerics/safe_conversions.h"
|
||||
#include "base/sys_byteorder.h"
|
||||
#include "build/build_config.h"
|
||||
#include "components/services/font/ppapi_fontconfig_matching.h"
|
||||
#include "content/public/common/common_sandbox_support_linux.h"
|
||||
#include "ppapi/buildflags/buildflags.h"
|
||||
#include "ppapi/c/dev/ppb_truetype_font_dev.h"
|
||||
#include "ppapi/c/pp_errors.h"
|
||||
#include "ppapi/c/trusted/ppb_browser_font_trusted.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
namespace {
|
||||
|
||||
class PepperTrueTypeFontLinux : public PepperTrueTypeFont {
|
||||
public:
|
||||
PepperTrueTypeFontLinux();
|
||||
|
||||
// PepperTrueTypeFont implementation.
|
||||
int32_t Initialize(ppapi::proxy::SerializedTrueTypeFontDesc* desc) override;
|
||||
int32_t GetTableTags(std::vector<uint32_t>* tags) override;
|
||||
int32_t GetTable(uint32_t table_tag,
|
||||
int32_t offset,
|
||||
int32_t max_data_length,
|
||||
std::string* data) override;
|
||||
|
||||
private:
|
||||
~PepperTrueTypeFontLinux() override;
|
||||
|
||||
base::ScopedFD fd_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(PepperTrueTypeFontLinux);
|
||||
};
|
||||
|
||||
PepperTrueTypeFontLinux::PepperTrueTypeFontLinux() {
|
||||
}
|
||||
|
||||
PepperTrueTypeFontLinux::~PepperTrueTypeFontLinux() {
|
||||
}
|
||||
|
||||
int32_t PepperTrueTypeFontLinux::Initialize(
|
||||
ppapi::proxy::SerializedTrueTypeFontDesc* desc) {
|
||||
// If no face is provided, convert family to the platform defaults. These
|
||||
// names should be mapped by FontConfig to an appropriate default font.
|
||||
if (desc->family.empty()) {
|
||||
switch (desc->generic_family) {
|
||||
case PP_TRUETYPEFONTFAMILY_SERIF:
|
||||
desc->family = "serif";
|
||||
break;
|
||||
case PP_TRUETYPEFONTFAMILY_SANSSERIF:
|
||||
desc->family = "sans-serif";
|
||||
break;
|
||||
case PP_TRUETYPEFONTFAMILY_CURSIVE:
|
||||
desc->family = "cursive";
|
||||
break;
|
||||
case PP_TRUETYPEFONTFAMILY_FANTASY:
|
||||
desc->family = "fantasy";
|
||||
break;
|
||||
case PP_TRUETYPEFONTFAMILY_MONOSPACE:
|
||||
desc->family = "monospace";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fd_.reset(font_service::MatchFontFaceWithFallback(
|
||||
desc->family, desc->weight >= PP_TRUETYPEFONTWEIGHT_BOLD,
|
||||
desc->style & PP_TRUETYPEFONTSTYLE_ITALIC, desc->charset,
|
||||
PP_BROWSERFONT_TRUSTED_FAMILY_DEFAULT));
|
||||
// TODO(bbudge) Modify content API to return results of font matching and
|
||||
// fallback, so we can update |desc| to reflect that.
|
||||
return fd_.is_valid() ? PP_OK : PP_ERROR_FAILED;
|
||||
}
|
||||
|
||||
int32_t PepperTrueTypeFontLinux::GetTableTags(std::vector<uint32_t>* tags) {
|
||||
if (!fd_.is_valid())
|
||||
return PP_ERROR_FAILED;
|
||||
// Get the 2 byte numTables field at an offset of 4 in the font.
|
||||
uint8_t num_tables_buf[2];
|
||||
size_t output_length = sizeof(num_tables_buf);
|
||||
if (!content::GetFontTable(fd_.get(), 0 /* tag */, 4 /* offset */,
|
||||
reinterpret_cast<uint8_t*>(&num_tables_buf),
|
||||
&output_length))
|
||||
return PP_ERROR_FAILED;
|
||||
DCHECK(output_length == sizeof(num_tables_buf));
|
||||
// Font data is stored in big-endian order.
|
||||
uint16_t num_tables = (num_tables_buf[0] << 8) | num_tables_buf[1];
|
||||
|
||||
// The font has a header, followed by n table entries in its directory.
|
||||
static const size_t kFontHeaderSize = 12;
|
||||
static const size_t kTableEntrySize = 16;
|
||||
output_length = num_tables * kTableEntrySize;
|
||||
std::unique_ptr<uint8_t[]> table_entries(new uint8_t[output_length]);
|
||||
// Get the table directory entries, which follow the font header.
|
||||
if (!content::GetFontTable(fd_.get(), 0 /* tag */,
|
||||
kFontHeaderSize /* offset */, table_entries.get(),
|
||||
&output_length))
|
||||
return PP_ERROR_FAILED;
|
||||
DCHECK(output_length == num_tables * kTableEntrySize);
|
||||
|
||||
tags->resize(num_tables);
|
||||
for (uint16_t i = 0; i < num_tables; i++) {
|
||||
uint8_t* entry = table_entries.get() + i * kTableEntrySize;
|
||||
uint32_t tag = static_cast<uint32_t>(entry[0]) << 24 |
|
||||
static_cast<uint32_t>(entry[1]) << 16 |
|
||||
static_cast<uint32_t>(entry[2]) << 8 |
|
||||
static_cast<uint32_t>(entry[3]);
|
||||
(*tags)[i] = tag;
|
||||
}
|
||||
|
||||
return num_tables;
|
||||
}
|
||||
|
||||
int32_t PepperTrueTypeFontLinux::GetTable(uint32_t table_tag,
|
||||
int32_t offset,
|
||||
int32_t max_data_length,
|
||||
std::string* data) {
|
||||
if (!fd_.is_valid())
|
||||
return PP_ERROR_FAILED;
|
||||
// Get the size of the font data first.
|
||||
size_t table_size = 0;
|
||||
// Tags are byte swapped on Linux.
|
||||
table_tag = base::ByteSwap(table_tag);
|
||||
if (!content::GetFontTable(fd_.get(), table_tag, offset, nullptr,
|
||||
&table_size))
|
||||
return PP_ERROR_FAILED;
|
||||
// Only retrieve as much as the caller requested.
|
||||
table_size = std::min(table_size, static_cast<size_t>(max_data_length));
|
||||
data->resize(table_size);
|
||||
if (!content::GetFontTable(fd_.get(), table_tag, offset,
|
||||
reinterpret_cast<uint8_t*>(&(*data)[0]),
|
||||
&table_size))
|
||||
return PP_ERROR_FAILED;
|
||||
|
||||
return base::checked_cast<int32_t>(table_size);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
PepperTrueTypeFont* PepperTrueTypeFont::Create() {
|
||||
return new PepperTrueTypeFontLinux();
|
||||
}
|
||||
|
||||
} // namespace content
|
@ -1,36 +0,0 @@
|
||||
// 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 CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_TRUETYPE_FONT_LIST_H_
|
||||
#define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_TRUETYPE_FONT_LIST_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace ppapi {
|
||||
namespace proxy {
|
||||
struct SerializedTrueTypeFontDesc;
|
||||
}
|
||||
}
|
||||
|
||||
namespace content {
|
||||
|
||||
// Adds font family names on the host platform to the vector of strings.
|
||||
//
|
||||
// This function is potentially slow (the system may do a bunch of I/O) so be
|
||||
// sure not to call this on a time-critical thread like the UI or I/O threads.
|
||||
void GetFontFamilies_SlowBlocking(std::vector<std::string>* font_families);
|
||||
|
||||
// Adds font descriptors for fonts on the host platform in the given family to
|
||||
// the vector of descriptors.
|
||||
//
|
||||
// This function is potentially slow (the system may do a bunch of I/O) so be
|
||||
// sure not to call this on a time-critical thread like the UI or I/O threads.
|
||||
void GetFontsInFamily_SlowBlocking(
|
||||
const std::string& family,
|
||||
std::vector<ppapi::proxy::SerializedTrueTypeFontDesc>* fonts_in_family);
|
||||
|
||||
} // namespace content
|
||||
|
||||
#endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_TRUETYPE_FONT_LIST_H_
|
@ -1,28 +0,0 @@
|
||||
// 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 CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_TRUETYPE_FONT_LIST_HOST_H_
|
||||
#define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_TRUETYPE_FONT_LIST_HOST_H_
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "ppapi/host/resource_host.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
class BrowserPpapiHost;
|
||||
|
||||
class PepperTrueTypeFontListHost : public ppapi::host::ResourceHost {
|
||||
public:
|
||||
PepperTrueTypeFontListHost(BrowserPpapiHost* host,
|
||||
PP_Instance instance,
|
||||
PP_Resource resource);
|
||||
~PepperTrueTypeFontListHost() override;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(PepperTrueTypeFontListHost);
|
||||
};
|
||||
|
||||
} // namespace content
|
||||
|
||||
#endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_TRUETYPE_FONT_LIST_HOST_H_
|
@ -1,65 +0,0 @@
|
||||
// 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 "content/browser/renderer_host/pepper/pepper_truetype_font_list.h"
|
||||
|
||||
#include <pango/pango.h>
|
||||
#include <pango/pangocairo.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "ppapi/proxy/serialized_structs.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
void GetFontFamilies_SlowBlocking(std::vector<std::string>* font_families) {
|
||||
PangoFontMap* font_map = ::pango_cairo_font_map_get_default();
|
||||
PangoFontFamily** families = nullptr;
|
||||
int num_families = 0;
|
||||
::pango_font_map_list_families(font_map, &families, &num_families);
|
||||
|
||||
for (int i = 0; i < num_families; ++i)
|
||||
font_families->push_back(::pango_font_family_get_name(families[i]));
|
||||
g_free(families);
|
||||
}
|
||||
|
||||
void GetFontsInFamily_SlowBlocking(
|
||||
const std::string& family,
|
||||
std::vector<ppapi::proxy::SerializedTrueTypeFontDesc>* fonts_in_family) {
|
||||
PangoFontMap* font_map = ::pango_cairo_font_map_get_default();
|
||||
PangoFontFamily** font_families = nullptr;
|
||||
int num_families = 0;
|
||||
::pango_font_map_list_families(font_map, &font_families, &num_families);
|
||||
|
||||
for (int i = 0; i < num_families; ++i) {
|
||||
PangoFontFamily* font_family = font_families[i];
|
||||
if (family.compare(::pango_font_family_get_name(font_family)) == 0) {
|
||||
PangoFontFace** font_faces = nullptr;
|
||||
int num_faces = 0;
|
||||
::pango_font_family_list_faces(font_family, &font_faces, &num_faces);
|
||||
|
||||
for (int j = 0; j < num_faces; ++j) {
|
||||
PangoFontFace* font_face = font_faces[j];
|
||||
PangoFontDescription* font_desc = ::pango_font_face_describe(font_face);
|
||||
ppapi::proxy::SerializedTrueTypeFontDesc desc;
|
||||
desc.family = family;
|
||||
if (::pango_font_description_get_style(font_desc) == PANGO_STYLE_ITALIC)
|
||||
desc.style = PP_TRUETYPEFONTSTYLE_ITALIC;
|
||||
desc.weight = static_cast<PP_TrueTypeFontWeight_Dev>(
|
||||
::pango_font_description_get_weight(font_desc));
|
||||
desc.width = static_cast<PP_TrueTypeFontWidth_Dev>(
|
||||
::pango_font_description_get_stretch(font_desc));
|
||||
// Character set is not part of Pango font description.
|
||||
desc.charset = PP_TRUETYPEFONTCHARSET_DEFAULT;
|
||||
|
||||
fonts_in_family->push_back(desc);
|
||||
::pango_font_description_free(font_desc);
|
||||
}
|
||||
g_free(font_faces);
|
||||
}
|
||||
}
|
||||
g_free(font_families);
|
||||
}
|
||||
|
||||
} // namespace content
|
@ -1,91 +0,0 @@
|
||||
// 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 "content/browser/renderer_host/pepper/pepper_truetype_font_list.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/win/scoped_hdc.h"
|
||||
#include "ppapi/c/dev/ppb_truetype_font_dev.h"
|
||||
#include "ppapi/proxy/serialized_structs.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
namespace {
|
||||
|
||||
typedef std::vector<std::string> FontFamilyList;
|
||||
typedef std::vector<ppapi::proxy::SerializedTrueTypeFontDesc> FontDescList;
|
||||
|
||||
static int CALLBACK EnumFontFamiliesProc(ENUMLOGFONTEXW* logical_font,
|
||||
NEWTEXTMETRICEXW* physical_font,
|
||||
DWORD font_type,
|
||||
LPARAM lparam) {
|
||||
FontFamilyList* font_families = reinterpret_cast<FontFamilyList*>(lparam);
|
||||
if (font_families) {
|
||||
const LOGFONTW& lf = logical_font->elfLogFont;
|
||||
if (lf.lfFaceName[0] && lf.lfFaceName[0] != '@' &&
|
||||
lf.lfOutPrecision == OUT_STROKE_PRECIS) { // Outline fonts only.
|
||||
std::string face_name(base::UTF16ToUTF8(lf.lfFaceName));
|
||||
font_families->push_back(face_name);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int CALLBACK EnumFontsInFamilyProc(ENUMLOGFONTEXW* logical_font,
|
||||
NEWTEXTMETRICEXW* physical_font,
|
||||
DWORD font_type,
|
||||
LPARAM lparam) {
|
||||
FontDescList* fonts_in_family = reinterpret_cast<FontDescList*>(lparam);
|
||||
if (fonts_in_family) {
|
||||
const LOGFONTW& lf = logical_font->elfLogFont;
|
||||
if (lf.lfFaceName[0] && lf.lfFaceName[0] != '@' &&
|
||||
lf.lfOutPrecision == OUT_STROKE_PRECIS) { // Outline fonts only.
|
||||
ppapi::proxy::SerializedTrueTypeFontDesc desc;
|
||||
desc.family = base::UTF16ToUTF8(lf.lfFaceName);
|
||||
if (lf.lfItalic)
|
||||
desc.style = PP_TRUETYPEFONTSTYLE_ITALIC;
|
||||
desc.weight = static_cast<PP_TrueTypeFontWeight_Dev>(lf.lfWeight);
|
||||
desc.width = PP_TRUETYPEFONTWIDTH_NORMAL; // TODO(bbudge) support widths.
|
||||
desc.charset = static_cast<PP_TrueTypeFontCharset_Dev>(lf.lfCharSet);
|
||||
fonts_in_family->push_back(desc);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void GetFontFamilies_SlowBlocking(FontFamilyList* font_families) {
|
||||
LOGFONTW logfont;
|
||||
memset(&logfont, 0, sizeof(logfont));
|
||||
logfont.lfCharSet = DEFAULT_CHARSET;
|
||||
base::win::ScopedCreateDC hdc(::CreateCompatibleDC(NULL));
|
||||
::EnumFontFamiliesExW(hdc.Get(),
|
||||
&logfont,
|
||||
(FONTENUMPROCW) & EnumFontFamiliesProc,
|
||||
(LPARAM)font_families,
|
||||
0);
|
||||
}
|
||||
|
||||
void GetFontsInFamily_SlowBlocking(const std::string& family,
|
||||
FontDescList* fonts_in_family) {
|
||||
LOGFONTW logfont;
|
||||
memset(&logfont, 0, sizeof(logfont));
|
||||
logfont.lfCharSet = DEFAULT_CHARSET;
|
||||
base::string16 family16 = base::UTF8ToUTF16(family);
|
||||
// Copy the family name, leaving room for a terminating null (already set
|
||||
// since we zeroed the whole struct above.)
|
||||
family16.copy(logfont.lfFaceName, LF_FACESIZE - 1);
|
||||
base::win::ScopedCreateDC hdc(::CreateCompatibleDC(NULL));
|
||||
::EnumFontFamiliesExW(hdc.Get(),
|
||||
&logfont,
|
||||
(FONTENUMPROCW) & EnumFontsInFamilyProc,
|
||||
(LPARAM)fonts_in_family,
|
||||
0);
|
||||
}
|
||||
|
||||
} // namespace content
|
@ -1,415 +0,0 @@
|
||||
// Copyright 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 "content/browser/renderer_host/pepper/pepper_truetype_font.h"
|
||||
|
||||
#import <ApplicationServices/ApplicationServices.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/mac/foundation_util.h"
|
||||
#include "base/mac/scoped_cftyperef.h"
|
||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/numerics/safe_conversions.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "base/sys_byteorder.h"
|
||||
#include "ppapi/c/dev/ppb_truetype_font_dev.h"
|
||||
#include "ppapi/c/pp_errors.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
namespace {
|
||||
|
||||
static bool FindFloat(CFDictionaryRef dict, CFStringRef name, float* value) {
|
||||
CFNumberRef num;
|
||||
return CFDictionaryGetValueIfPresent(
|
||||
dict, name, reinterpret_cast<const void**>(&num)) &&
|
||||
CFNumberIsFloatType(num) &&
|
||||
CFNumberGetValue(num, kCFNumberFloatType, value);
|
||||
}
|
||||
|
||||
float GetMacWeight(PP_TrueTypeFontWeight_Dev weight) {
|
||||
// Map values from NORMAL (400) to HEAVY (900) to the range [0 .. 1], and
|
||||
// values below NORMAL to the range [-0.6 .. 0]. NORMAL should map to 0.
|
||||
float normal = PP_TRUETYPEFONTWEIGHT_NORMAL;
|
||||
float heavy = PP_TRUETYPEFONTWEIGHT_HEAVY;
|
||||
return (weight - normal) / (heavy - normal);
|
||||
}
|
||||
|
||||
PP_TrueTypeFontWeight_Dev GetPepperWeight(float weight) {
|
||||
// Perform the inverse mapping of GetMacWeight.
|
||||
return static_cast<PP_TrueTypeFontWeight_Dev>(
|
||||
weight * (PP_TRUETYPEFONTWEIGHT_HEAVY - PP_TRUETYPEFONTWEIGHT_NORMAL) +
|
||||
PP_TRUETYPEFONTWEIGHT_NORMAL);
|
||||
}
|
||||
|
||||
float GetMacWidth(PP_TrueTypeFontWidth_Dev width) {
|
||||
// Map values from NORMAL (4) to ULTRA_EXPANDED (8) to the range [0 .. 1],
|
||||
// and values below NORMAL to the range [-1 .. 0]. Normal should map to 0.
|
||||
float normal = PP_TRUETYPEFONTWIDTH_NORMAL;
|
||||
float ultra_expanded = PP_TRUETYPEFONTWIDTH_ULTRAEXPANDED;
|
||||
return (width - normal) / (ultra_expanded - normal);
|
||||
}
|
||||
|
||||
PP_TrueTypeFontWidth_Dev GetPepperWidth(float width) {
|
||||
// Perform the inverse mapping of GetMacWeight.
|
||||
return static_cast<PP_TrueTypeFontWidth_Dev>(
|
||||
width *
|
||||
(PP_TRUETYPEFONTWIDTH_ULTRAEXPANDED - PP_TRUETYPEFONTWIDTH_NORMAL) +
|
||||
PP_TRUETYPEFONTWIDTH_NORMAL);
|
||||
}
|
||||
|
||||
#define MAKE_TABLE_TAG(a, b, c, d) ((a) << 24) + ((b) << 16) + ((c) << 8) + (d)
|
||||
|
||||
// TrueType font header and table entry structs. See
|
||||
// https://developer.apple.com/fonts/TTRefMan/RM06/Chap6.html
|
||||
struct FontHeader {
|
||||
int32_t font_type;
|
||||
uint16_t num_tables;
|
||||
uint16_t search_range;
|
||||
uint16_t entry_selector;
|
||||
uint16_t range_shift;
|
||||
};
|
||||
static_assert(sizeof(FontHeader) == 12, "FontHeader wrong size");
|
||||
|
||||
struct FontDirectoryEntry {
|
||||
uint32_t tag;
|
||||
uint32_t checksum;
|
||||
uint32_t offset;
|
||||
uint32_t logical_length;
|
||||
};
|
||||
static_assert(sizeof(FontDirectoryEntry) == 16,
|
||||
"FontDirectoryEntry wrong size");
|
||||
|
||||
uint32_t CalculateChecksum(char* table, int32_t table_length) {
|
||||
uint32_t sum = 0;
|
||||
uint32_t* current = reinterpret_cast<uint32_t*>(table);
|
||||
uint32_t length = (table_length + 3) / 4;
|
||||
// Raw font data is big-endian.
|
||||
while (length-- > 0)
|
||||
sum += base::NetToHost32(*current++);
|
||||
return sum;
|
||||
}
|
||||
|
||||
class PepperTrueTypeFontMac : public PepperTrueTypeFont {
|
||||
public:
|
||||
PepperTrueTypeFontMac();
|
||||
|
||||
// PepperTrueTypeFont implementation.
|
||||
int32_t Initialize(ppapi::proxy::SerializedTrueTypeFontDesc* desc) override;
|
||||
int32_t GetTableTags(std::vector<uint32_t>* tags) override;
|
||||
int32_t GetTable(uint32_t table_tag,
|
||||
int32_t offset,
|
||||
int32_t max_data_length,
|
||||
std::string* data) override;
|
||||
|
||||
private:
|
||||
~PepperTrueTypeFontMac() override;
|
||||
|
||||
virtual int32_t GetEntireFont(int32_t offset,
|
||||
int32_t max_data_length,
|
||||
std::string* data);
|
||||
|
||||
base::ScopedCFTypeRef<CTFontRef> font_ref_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(PepperTrueTypeFontMac);
|
||||
};
|
||||
|
||||
PepperTrueTypeFontMac::PepperTrueTypeFontMac() {
|
||||
}
|
||||
|
||||
PepperTrueTypeFontMac::~PepperTrueTypeFontMac() {
|
||||
}
|
||||
|
||||
int32_t PepperTrueTypeFontMac::Initialize(
|
||||
ppapi::proxy::SerializedTrueTypeFontDesc* desc) {
|
||||
// Create the font in a nested scope, so we can use the same variable names
|
||||
// when we get the actual font characteristics.
|
||||
{
|
||||
// Create attributes and traits dictionaries.
|
||||
base::ScopedCFTypeRef<CFMutableDictionaryRef> attributes_ref(
|
||||
CFDictionaryCreateMutable(kCFAllocatorDefault,
|
||||
0,
|
||||
&kCFTypeDictionaryKeyCallBacks,
|
||||
&kCFTypeDictionaryValueCallBacks));
|
||||
|
||||
base::ScopedCFTypeRef<CFMutableDictionaryRef> traits_ref(
|
||||
CFDictionaryCreateMutable(kCFAllocatorDefault,
|
||||
0,
|
||||
&kCFTypeDictionaryKeyCallBacks,
|
||||
&kCFTypeDictionaryValueCallBacks));
|
||||
if (!attributes_ref || !traits_ref)
|
||||
return PP_ERROR_FAILED;
|
||||
|
||||
CFDictionaryAddValue(attributes_ref, kCTFontTraitsAttribute, traits_ref);
|
||||
|
||||
// Use symbolic traits to specify traits when possible.
|
||||
CTFontSymbolicTraits symbolic_traits = 0;
|
||||
if (desc->style & PP_TRUETYPEFONTSTYLE_ITALIC)
|
||||
symbolic_traits |= kCTFontItalicTrait;
|
||||
if (desc->weight == PP_TRUETYPEFONTWEIGHT_BOLD)
|
||||
symbolic_traits |= kCTFontBoldTrait;
|
||||
if (desc->width == PP_TRUETYPEFONTWIDTH_CONDENSED)
|
||||
symbolic_traits |= kCTFontCondensedTrait;
|
||||
else if (desc->width == PP_TRUETYPEFONTWIDTH_EXPANDED)
|
||||
symbolic_traits |= kCTFontExpandedTrait;
|
||||
|
||||
base::ScopedCFTypeRef<CFNumberRef> symbolic_traits_ref(CFNumberCreate(
|
||||
kCFAllocatorDefault, kCFNumberSInt32Type, &symbolic_traits));
|
||||
if (!symbolic_traits_ref)
|
||||
return PP_ERROR_FAILED;
|
||||
CFDictionaryAddValue(traits_ref, kCTFontSymbolicTrait, symbolic_traits_ref);
|
||||
|
||||
// Font family matching doesn't work using family classes in symbolic
|
||||
// traits. Instead, map generic_family to font families that are always
|
||||
// available.
|
||||
std::string family(desc->family);
|
||||
if (family.empty()) {
|
||||
switch (desc->generic_family) {
|
||||
case PP_TRUETYPEFONTFAMILY_SERIF:
|
||||
family = "Times";
|
||||
break;
|
||||
case PP_TRUETYPEFONTFAMILY_SANSSERIF:
|
||||
family = "Helvetica";
|
||||
break;
|
||||
case PP_TRUETYPEFONTFAMILY_CURSIVE:
|
||||
family = "Apple Chancery";
|
||||
break;
|
||||
case PP_TRUETYPEFONTFAMILY_FANTASY:
|
||||
family = "Papyrus";
|
||||
break;
|
||||
case PP_TRUETYPEFONTFAMILY_MONOSPACE:
|
||||
family = "Courier";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
base::ScopedCFTypeRef<CFStringRef> name_ref(
|
||||
base::SysUTF8ToCFStringRef(family));
|
||||
if (name_ref)
|
||||
CFDictionaryAddValue(
|
||||
attributes_ref, kCTFontFamilyNameAttribute, name_ref);
|
||||
|
||||
if (desc->weight != PP_TRUETYPEFONTWEIGHT_NORMAL &&
|
||||
desc->weight != PP_TRUETYPEFONTWEIGHT_BOLD) {
|
||||
float weight = GetMacWeight(desc->weight);
|
||||
base::ScopedCFTypeRef<CFNumberRef> weight_trait_ref(
|
||||
CFNumberCreate(kCFAllocatorDefault, kCFNumberFloat32Type, &weight));
|
||||
if (weight_trait_ref)
|
||||
CFDictionaryAddValue(traits_ref, kCTFontWeightTrait, weight_trait_ref);
|
||||
}
|
||||
|
||||
if (desc->width != PP_TRUETYPEFONTWIDTH_NORMAL &&
|
||||
desc->width != PP_TRUETYPEFONTWIDTH_CONDENSED &&
|
||||
desc->width != PP_TRUETYPEFONTWIDTH_EXPANDED) {
|
||||
float width = GetMacWidth(desc->width);
|
||||
base::ScopedCFTypeRef<CFNumberRef> width_trait_ref(
|
||||
CFNumberCreate(kCFAllocatorDefault, kCFNumberFloat32Type, &width));
|
||||
if (width_trait_ref)
|
||||
CFDictionaryAddValue(traits_ref, kCTFontWidthTrait, width_trait_ref);
|
||||
}
|
||||
|
||||
base::ScopedCFTypeRef<CTFontDescriptorRef> desc_ref(
|
||||
CTFontDescriptorCreateWithAttributes(attributes_ref));
|
||||
|
||||
if (desc_ref)
|
||||
font_ref_.reset(CTFontCreateWithFontDescriptor(desc_ref, 0, NULL));
|
||||
|
||||
if (!font_ref_.get())
|
||||
return PP_ERROR_FAILED;
|
||||
}
|
||||
|
||||
// Now query to get the actual font characteristics.
|
||||
base::ScopedCFTypeRef<CTFontDescriptorRef> desc_ref(
|
||||
CTFontCopyFontDescriptor(font_ref_));
|
||||
|
||||
base::ScopedCFTypeRef<CFStringRef> family_name_ref(
|
||||
base::mac::CFCast<CFStringRef>(
|
||||
CTFontDescriptorCopyAttribute(desc_ref, kCTFontFamilyNameAttribute)));
|
||||
desc->family = base::SysCFStringRefToUTF8(family_name_ref);
|
||||
|
||||
base::ScopedCFTypeRef<CFDictionaryRef> traits_ref(
|
||||
base::mac::CFCast<CFDictionaryRef>(
|
||||
CTFontDescriptorCopyAttribute(desc_ref, kCTFontTraitsAttribute)));
|
||||
|
||||
desc->style = PP_TRUETYPEFONTSTYLE_NORMAL;
|
||||
CTFontSymbolicTraits symbolic_traits(CTFontGetSymbolicTraits(font_ref_));
|
||||
if (symbolic_traits & kCTFontItalicTrait)
|
||||
desc->style = static_cast<PP_TrueTypeFontStyle_Dev>(
|
||||
desc->style | PP_TRUETYPEFONTSTYLE_ITALIC);
|
||||
if (symbolic_traits & kCTFontBoldTrait) {
|
||||
desc->weight = PP_TRUETYPEFONTWEIGHT_BOLD;
|
||||
} else {
|
||||
float weight;
|
||||
if (FindFloat(traits_ref, kCTFontWeightTrait, &weight))
|
||||
desc->weight = GetPepperWeight(weight);
|
||||
}
|
||||
if (symbolic_traits & kCTFontCondensedTrait) {
|
||||
desc->width = PP_TRUETYPEFONTWIDTH_CONDENSED;
|
||||
} else if (symbolic_traits & kCTFontExpandedTrait) {
|
||||
desc->width = PP_TRUETYPEFONTWIDTH_EXPANDED;
|
||||
} else {
|
||||
float width;
|
||||
if (FindFloat(traits_ref, kCTFontWidthTrait, &width))
|
||||
desc->width = GetPepperWidth(width);
|
||||
}
|
||||
|
||||
// Character set isn't supported on Mac.
|
||||
desc->charset = PP_TRUETYPEFONTCHARSET_DEFAULT;
|
||||
return PP_OK;
|
||||
}
|
||||
|
||||
int32_t PepperTrueTypeFontMac::GetTableTags(std::vector<uint32_t>* tags) {
|
||||
if (!font_ref_.get())
|
||||
return PP_ERROR_FAILED;
|
||||
base::ScopedCFTypeRef<CFArrayRef> tag_array(
|
||||
CTFontCopyAvailableTables(font_ref_, kCTFontTableOptionNoOptions));
|
||||
if (!tag_array)
|
||||
return PP_ERROR_FAILED;
|
||||
|
||||
// Items returned by CTFontCopyAvailableTables are not boxed. Whose bright
|
||||
// idea was this?
|
||||
CFIndex length = CFArrayGetCount(tag_array);
|
||||
tags->resize(length);
|
||||
for (CFIndex i = 0; i < length; ++i) {
|
||||
(*tags)[i] =
|
||||
reinterpret_cast<uintptr_t>(CFArrayGetValueAtIndex(tag_array, i));
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
int32_t PepperTrueTypeFontMac::GetTable(uint32_t table_tag,
|
||||
int32_t offset,
|
||||
int32_t max_data_length,
|
||||
std::string* data) {
|
||||
if (!font_ref_.get())
|
||||
return PP_ERROR_FAILED;
|
||||
|
||||
if (!table_tag)
|
||||
return GetEntireFont(offset, max_data_length, data);
|
||||
|
||||
base::ScopedCFTypeRef<CFDataRef> table_ref(
|
||||
CTFontCopyTable(font_ref_,
|
||||
static_cast<CTFontTableTag>(table_tag),
|
||||
kCTFontTableOptionNoOptions));
|
||||
if (!table_ref)
|
||||
return PP_ERROR_FAILED;
|
||||
|
||||
CFIndex table_size = CFDataGetLength(table_ref);
|
||||
CFIndex safe_offset =
|
||||
std::min(base::checked_cast<CFIndex>(offset), table_size);
|
||||
CFIndex safe_length = std::min(table_size - safe_offset,
|
||||
base::checked_cast<CFIndex>(max_data_length));
|
||||
data->resize(safe_length);
|
||||
CFDataGetBytes(table_ref,
|
||||
CFRangeMake(safe_offset, safe_length),
|
||||
reinterpret_cast<UInt8*>(&(*data)[0]));
|
||||
|
||||
return safe_length;
|
||||
}
|
||||
|
||||
int32_t PepperTrueTypeFontMac::GetEntireFont(int32_t offset,
|
||||
int32_t max_data_length,
|
||||
std::string* data) {
|
||||
// Reconstruct the font header, table directory, and tables.
|
||||
std::vector<uint32_t> table_tags;
|
||||
int32_t table_count = GetTableTags(&table_tags);
|
||||
if (table_count < 0)
|
||||
return table_count; // PPAPI error code.
|
||||
|
||||
// Allocate enough room for the header and the table directory entries.
|
||||
std::string font(
|
||||
sizeof(FontHeader) + sizeof(FontDirectoryEntry) * table_count, 0);
|
||||
// Map the OS X font type value to a TrueType scalar type.
|
||||
base::ScopedCFTypeRef<CFNumberRef> font_type_ref(
|
||||
base::mac::CFCast<CFNumberRef>(
|
||||
CTFontCopyAttribute(font_ref_, kCTFontFormatAttribute)));
|
||||
int32_t font_type;
|
||||
CFNumberGetValue(font_type_ref, kCFNumberSInt32Type, &font_type);
|
||||
switch (font_type) {
|
||||
case kCTFontFormatOpenTypePostScript:
|
||||
font_type = MAKE_TABLE_TAG('O', 'T', 'T', 'O');
|
||||
break;
|
||||
case kCTFontFormatTrueType:
|
||||
case kCTFontFormatBitmap:
|
||||
font_type = MAKE_TABLE_TAG('t', 'r', 'u', 'e');
|
||||
break;
|
||||
case kCTFontFormatPostScript:
|
||||
font_type = MAKE_TABLE_TAG('t', 'y', 'p', '1');
|
||||
break;
|
||||
case kCTFontFormatOpenTypeTrueType:
|
||||
case kCTFontFormatUnrecognized:
|
||||
default:
|
||||
font_type = MAKE_TABLE_TAG(0, 1, 0, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
// Calculate the rest of the header values.
|
||||
uint16_t num_tables = base::checked_cast<uint16_t>(table_count);
|
||||
uint16_t entry_selector = 0;
|
||||
uint16_t search_range = 1;
|
||||
while (search_range < (num_tables >> 1)) {
|
||||
entry_selector++;
|
||||
search_range <<= 1;
|
||||
}
|
||||
search_range <<= 4;
|
||||
uint16_t range_shift = (num_tables << 4) - search_range;
|
||||
|
||||
// Write the header, with values in big-endian order.
|
||||
FontHeader* font_header = reinterpret_cast<FontHeader*>(&font[0]);
|
||||
font_header->font_type = base::HostToNet32(font_type);
|
||||
font_header->num_tables = base::HostToNet16(num_tables);
|
||||
font_header->search_range = base::HostToNet16(search_range);
|
||||
font_header->entry_selector = base::HostToNet16(entry_selector);
|
||||
font_header->range_shift = base::HostToNet16(range_shift);
|
||||
|
||||
for (int32_t i = 0; i < table_count; i++) {
|
||||
// Get the table data.
|
||||
std::string table;
|
||||
int32_t table_size =
|
||||
GetTable(table_tags[i], 0, std::numeric_limits<int32_t>::max(), &table);
|
||||
if (table_size < 0)
|
||||
return table_size; // PPAPI error code.
|
||||
|
||||
// Append it to the font data so far, and zero pad so tables stay aligned.
|
||||
size_t table_offset = font.size();
|
||||
font.append(table);
|
||||
size_t padding = font.size() & 0x3;
|
||||
font.append(padding, 0);
|
||||
|
||||
// Fill in the directory entry for this table.
|
||||
FontDirectoryEntry* entry = reinterpret_cast<FontDirectoryEntry*>(
|
||||
&font[0] + sizeof(FontHeader) + i * sizeof(FontDirectoryEntry));
|
||||
entry->tag = base::HostToNet32(table_tags[i]);
|
||||
entry->checksum =
|
||||
base::HostToNet32(CalculateChecksum(&font[table_offset], table_size));
|
||||
entry->offset = base::HostToNet32(table_offset);
|
||||
entry->logical_length = base::HostToNet32(table_size);
|
||||
// TODO(bbudge) set the 'head' table checksumAdjustment.
|
||||
}
|
||||
|
||||
// Extract a substring if the caller specified an offset or max data length.
|
||||
int32_t font_size = base::checked_cast<int32_t>(font.size());
|
||||
int32_t safe_offset = std::min(offset, font_size);
|
||||
int32_t safe_length = std::min(font_size - safe_offset, max_data_length);
|
||||
if (safe_offset || safe_length != font_size)
|
||||
font = font.substr(safe_offset, safe_length);
|
||||
|
||||
data->clear();
|
||||
data->swap(font);
|
||||
return safe_length;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
PepperTrueTypeFont* PepperTrueTypeFont::Create() {
|
||||
return new PepperTrueTypeFontMac();
|
||||
}
|
||||
|
||||
} // namespace content
|
@ -1,241 +0,0 @@
|
||||
// Copyright 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 "content/browser/renderer_host/pepper/pepper_truetype_font.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/sys_byteorder.h"
|
||||
#include "base/win/scoped_gdi_object.h"
|
||||
#include "base/win/scoped_hdc.h"
|
||||
#include "base/win/scoped_select_object.h"
|
||||
#include "ppapi/c/dev/ppb_truetype_font_dev.h"
|
||||
#include "ppapi/c/pp_errors.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
namespace {
|
||||
|
||||
class PepperTrueTypeFontWin : public PepperTrueTypeFont {
|
||||
public:
|
||||
PepperTrueTypeFontWin();
|
||||
|
||||
// PepperTrueTypeFont implementation.
|
||||
int32_t Initialize(ppapi::proxy::SerializedTrueTypeFontDesc* desc) override;
|
||||
int32_t GetTableTags(std::vector<uint32_t>* tags) override;
|
||||
int32_t GetTable(uint32_t table_tag,
|
||||
int32_t offset,
|
||||
int32_t max_data_length,
|
||||
std::string* data) override;
|
||||
|
||||
private:
|
||||
~PepperTrueTypeFontWin() override;
|
||||
|
||||
DWORD GetFontData(HDC hdc,
|
||||
DWORD table,
|
||||
DWORD offset,
|
||||
LPVOID buffer,
|
||||
DWORD length);
|
||||
|
||||
base::win::ScopedHFONT font_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(PepperTrueTypeFontWin);
|
||||
};
|
||||
|
||||
PepperTrueTypeFontWin::PepperTrueTypeFontWin() {
|
||||
}
|
||||
|
||||
PepperTrueTypeFontWin::~PepperTrueTypeFontWin() {
|
||||
}
|
||||
|
||||
int32_t PepperTrueTypeFontWin::Initialize(
|
||||
ppapi::proxy::SerializedTrueTypeFontDesc* desc) {
|
||||
DWORD pitch_and_family = DEFAULT_PITCH;
|
||||
switch (desc->generic_family) {
|
||||
case PP_TRUETYPEFONTFAMILY_SERIF:
|
||||
pitch_and_family |= FF_ROMAN;
|
||||
break;
|
||||
case PP_TRUETYPEFONTFAMILY_SANSSERIF:
|
||||
pitch_and_family |= FF_SWISS;
|
||||
break;
|
||||
case PP_TRUETYPEFONTFAMILY_CURSIVE:
|
||||
pitch_and_family |= FF_SCRIPT;
|
||||
break;
|
||||
case PP_TRUETYPEFONTFAMILY_FANTASY:
|
||||
pitch_and_family |= FF_DECORATIVE;
|
||||
break;
|
||||
case PP_TRUETYPEFONTFAMILY_MONOSPACE:
|
||||
pitch_and_family |= FF_MODERN;
|
||||
break;
|
||||
}
|
||||
// TODO(bbudge) support widths (extended, condensed).
|
||||
|
||||
font_.reset(CreateFont(
|
||||
0 /* height */,
|
||||
0 /* width */,
|
||||
0 /* escapement */,
|
||||
0 /* orientation */,
|
||||
desc->weight, // our weight enum matches Windows.
|
||||
(desc->style & PP_TRUETYPEFONTSTYLE_ITALIC) ? 1 : 0,
|
||||
0 /* underline */,
|
||||
0 /* strikeout */,
|
||||
desc->charset, // our charset enum matches Windows.
|
||||
OUT_OUTLINE_PRECIS, // truetype and other outline fonts
|
||||
CLIP_DEFAULT_PRECIS,
|
||||
DEFAULT_QUALITY,
|
||||
pitch_and_family,
|
||||
base::UTF8ToUTF16(desc->family).c_str()));
|
||||
if (!font_.is_valid())
|
||||
return PP_ERROR_FAILED;
|
||||
|
||||
LOGFONT font_desc;
|
||||
if (!::GetObject(font_.get(), sizeof(LOGFONT), &font_desc))
|
||||
return PP_ERROR_FAILED;
|
||||
|
||||
switch (font_desc.lfPitchAndFamily & 0xF0) { // Top 4 bits are family.
|
||||
case FF_ROMAN:
|
||||
desc->generic_family = PP_TRUETYPEFONTFAMILY_SERIF;
|
||||
break;
|
||||
case FF_SWISS:
|
||||
desc->generic_family = PP_TRUETYPEFONTFAMILY_SANSSERIF;
|
||||
break;
|
||||
case FF_SCRIPT:
|
||||
desc->generic_family = PP_TRUETYPEFONTFAMILY_CURSIVE;
|
||||
break;
|
||||
case FF_DECORATIVE:
|
||||
desc->generic_family = PP_TRUETYPEFONTFAMILY_FANTASY;
|
||||
break;
|
||||
case FF_MODERN:
|
||||
desc->generic_family = PP_TRUETYPEFONTFAMILY_MONOSPACE;
|
||||
break;
|
||||
}
|
||||
|
||||
desc->style = font_desc.lfItalic ? PP_TRUETYPEFONTSTYLE_ITALIC
|
||||
: PP_TRUETYPEFONTSTYLE_NORMAL;
|
||||
desc->weight = static_cast<PP_TrueTypeFontWeight_Dev>(font_desc.lfWeight);
|
||||
desc->width = PP_TRUETYPEFONTWIDTH_NORMAL;
|
||||
desc->charset = static_cast<PP_TrueTypeFontCharset_Dev>(font_desc.lfCharSet);
|
||||
|
||||
// To get the face name, select the font and query for the name. GetObject
|
||||
// doesn't fill in the name field of the LOGFONT structure.
|
||||
base::win::ScopedCreateDC hdc(::CreateCompatibleDC(NULL));
|
||||
if (hdc.IsValid()) {
|
||||
base::win::ScopedSelectObject select_object(hdc.Get(), font_.get());
|
||||
WCHAR name[LF_FACESIZE];
|
||||
GetTextFace(hdc.Get(), LF_FACESIZE, name);
|
||||
desc->family = base::UTF16ToUTF8(name);
|
||||
}
|
||||
|
||||
return PP_OK;
|
||||
}
|
||||
|
||||
int32_t PepperTrueTypeFontWin::GetTableTags(std::vector<uint32_t>* tags) {
|
||||
if (!font_.is_valid())
|
||||
return PP_ERROR_FAILED;
|
||||
|
||||
base::win::ScopedCreateDC hdc(::CreateCompatibleDC(NULL));
|
||||
if (!hdc.IsValid())
|
||||
return PP_ERROR_FAILED;
|
||||
|
||||
base::win::ScopedSelectObject select_object(hdc.Get(), font_.get());
|
||||
|
||||
// Get the whole font header.
|
||||
static const DWORD kFontHeaderSize = 12;
|
||||
uint8_t header_buf[kFontHeaderSize];
|
||||
if (GetFontData(hdc.Get(), 0, 0, header_buf, kFontHeaderSize) == GDI_ERROR)
|
||||
return PP_ERROR_FAILED;
|
||||
|
||||
// The numTables follows a 4 byte scalerType tag. Font data is stored in
|
||||
// big-endian order.
|
||||
DWORD num_tables = (header_buf[4] << 8) | header_buf[5];
|
||||
|
||||
// The size in bytes of an entry in the table directory.
|
||||
static const DWORD kDirectoryEntrySize = 16;
|
||||
DWORD directory_size = num_tables * kDirectoryEntrySize;
|
||||
std::unique_ptr<uint8_t[]> directory(new uint8_t[directory_size]);
|
||||
// Get the table directory entries after the font header.
|
||||
if (GetFontData(hdc.Get(), 0 /* tag */, kFontHeaderSize, directory.get(),
|
||||
directory_size) ==
|
||||
GDI_ERROR)
|
||||
return PP_ERROR_FAILED;
|
||||
|
||||
tags->resize(num_tables);
|
||||
for (DWORD i = 0; i < num_tables; i++) {
|
||||
const uint8_t* entry = directory.get() + i * kDirectoryEntrySize;
|
||||
uint32_t tag = static_cast<uint32_t>(entry[0]) << 24 |
|
||||
static_cast<uint32_t>(entry[1]) << 16 |
|
||||
static_cast<uint32_t>(entry[2]) << 8 |
|
||||
static_cast<uint32_t>(entry[3]);
|
||||
(*tags)[i] = tag;
|
||||
}
|
||||
|
||||
return num_tables;
|
||||
}
|
||||
|
||||
int32_t PepperTrueTypeFontWin::GetTable(uint32_t table_tag,
|
||||
int32_t offset,
|
||||
int32_t max_data_length,
|
||||
std::string* data) {
|
||||
if (!font_.is_valid())
|
||||
return PP_ERROR_FAILED;
|
||||
|
||||
base::win::ScopedCreateDC hdc(::CreateCompatibleDC(NULL));
|
||||
if (!hdc.IsValid())
|
||||
return PP_ERROR_FAILED;
|
||||
|
||||
base::win::ScopedSelectObject select_object(hdc.Get(), font_.get());
|
||||
|
||||
// Tags are byte swapped on Windows.
|
||||
table_tag = base::ByteSwap(table_tag);
|
||||
// Get the size of the font table first.
|
||||
DWORD table_size = GetFontData(hdc.Get(), table_tag, 0, NULL, 0);
|
||||
if (table_size == GDI_ERROR)
|
||||
return PP_ERROR_FAILED;
|
||||
|
||||
DWORD safe_offset = std::min(static_cast<DWORD>(offset), table_size);
|
||||
DWORD safe_length =
|
||||
std::min(table_size - safe_offset, static_cast<DWORD>(max_data_length));
|
||||
data->resize(safe_length);
|
||||
if (safe_length == 0) {
|
||||
table_size = 0;
|
||||
} else {
|
||||
table_size = GetFontData(hdc.Get(),
|
||||
table_tag,
|
||||
safe_offset,
|
||||
reinterpret_cast<uint8_t*>(&(*data)[0]),
|
||||
safe_length);
|
||||
if (table_size == GDI_ERROR)
|
||||
return PP_ERROR_FAILED;
|
||||
}
|
||||
return static_cast<int32_t>(table_size);
|
||||
}
|
||||
|
||||
DWORD PepperTrueTypeFontWin::GetFontData(HDC hdc,
|
||||
DWORD table,
|
||||
DWORD offset,
|
||||
void* buffer,
|
||||
DWORD length) {
|
||||
// If this is a zero byte read, return a successful result.
|
||||
if (buffer && !length)
|
||||
return 0;
|
||||
|
||||
return ::GetFontData(hdc, table, offset, buffer, length);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
PepperTrueTypeFont* PepperTrueTypeFont::Create() {
|
||||
return new PepperTrueTypeFontWin();
|
||||
}
|
||||
|
||||
} // namespace content
|
@ -124,13 +124,6 @@ PP_Resource PepperInProcessResourceCreation::CreatePrinting(
|
||||
instance))->GetReference();
|
||||
}
|
||||
|
||||
PP_Resource PepperInProcessResourceCreation::CreateTrueTypeFont(
|
||||
PP_Instance instance,
|
||||
const PP_TrueTypeFontDesc_Dev* desc) {
|
||||
NOTIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
PP_Resource PepperInProcessResourceCreation::CreateURLLoader(
|
||||
PP_Instance instance) {
|
||||
return (new ppapi::proxy::URLLoaderResource(
|
||||
|
@ -58,9 +58,6 @@ class PepperInProcessResourceCreation : public ResourceCreationImpl {
|
||||
const PP_Size* size,
|
||||
PP_Bool is_always_opaque) override;
|
||||
PP_Resource CreatePrinting(PP_Instance instance) override;
|
||||
PP_Resource CreateTrueTypeFont(
|
||||
PP_Instance instance,
|
||||
const struct PP_TrueTypeFontDesc_Dev* desc) override;
|
||||
PP_Resource CreateURLLoader(PP_Instance instance) override;
|
||||
PP_Resource CreateURLRequestInfo(PP_Instance instance) override;
|
||||
PP_Resource CreateWebSocket(PP_Instance instance) override;
|
||||
|
@ -2561,7 +2561,6 @@ ppapi::Resource* PepperPluginInstanceImpl::GetSingletonResource(
|
||||
case ppapi::ISOLATED_FILESYSTEM_SINGLETON_ID:
|
||||
case ppapi::NETWORK_PROXY_SINGLETON_ID:
|
||||
case ppapi::PDF_SINGLETON_ID:
|
||||
case ppapi::TRUETYPE_FONT_SINGLETON_ID:
|
||||
NOTIMPLEMENTED();
|
||||
return nullptr;
|
||||
case ppapi::GAMEPAD_SINGLETON_ID:
|
||||
|
@ -51,7 +51,6 @@
|
||||
#include "ppapi/c/dev/ppb_printing_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"
|
||||
|
@ -133,14 +133,6 @@ TEST_PPAPI_OUT_OF_PROCESS(DISABLED_Scrollbar)
|
||||
TEST_PPAPI_IN_PROCESS(TraceEvent)
|
||||
TEST_PPAPI_OUT_OF_PROCESS(TraceEvent)
|
||||
|
||||
// Doesn't work in CrOS builds, http://crbug.com/619765
|
||||
#if defined(OS_CHROMEOS)
|
||||
#define MAYBE_TrueTypeFont DISABLED_TrueTypeFont
|
||||
#else
|
||||
#define MAYBE_TrueTypeFont TrueTypeFont
|
||||
#endif
|
||||
TEST_PPAPI_OUT_OF_PROCESS(MAYBE_TrueTypeFont)
|
||||
|
||||
TEST_PPAPI_IN_PROCESS(URLUtil)
|
||||
TEST_PPAPI_OUT_OF_PROCESS(URLUtil)
|
||||
|
||||
|
@ -103,7 +103,6 @@
|
||||
'ppb_opengles2ext_dev.h',
|
||||
'ppb_printing_dev.h',
|
||||
'ppb_trace_event_dev.h',
|
||||
'ppb_truetype_font_dev.h',
|
||||
'ppb_var_deprecated.h',
|
||||
'ppb_view_dev.h',
|
||||
'pp_cursor_type_dev.h',
|
||||
|
@ -68,7 +68,6 @@
|
||||
'memory_dev.cc',
|
||||
'printing_dev.cc',
|
||||
'scriptable_object_deprecated.cc',
|
||||
'truetype_font_dev.cc',
|
||||
'view_dev.cc',
|
||||
|
||||
# ppapi/utility/graphics
|
||||
@ -155,7 +154,6 @@
|
||||
'memory_dev.h',
|
||||
'printing_dev.h',
|
||||
'scriptable_object_deprecated.h',
|
||||
'truetype_font_dev.h',
|
||||
'video_capture_client_dev.h',
|
||||
'video_decoder_client_dev.h',
|
||||
'view_dev.h',
|
||||
|
@ -110,8 +110,6 @@ test_common_source_files = [
|
||||
"tests/test_test_internals.h",
|
||||
"tests/test_trace_event.cc",
|
||||
"tests/test_trace_event.h",
|
||||
"tests/test_truetype_font.cc",
|
||||
"tests/test_truetype_font.h",
|
||||
"tests/test_udp_socket.cc",
|
||||
"tests/test_udp_socket.h",
|
||||
"tests/test_udp_socket_private.cc",
|
||||
|
@ -1,276 +0,0 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This file defines the <code>PPB_TrueTypeFont_Dev</code> interface. This
|
||||
* interface exposes font table data for 'sfnt' fonts on the host system. These
|
||||
* include TrueType and OpenType fonts.
|
||||
*/
|
||||
|
||||
[generate_thunk,thunk_include="ppapi/thunk/ppb_truetype_font_singleton_api.h"]
|
||||
|
||||
label Chrome {
|
||||
M26 = 0.1
|
||||
};
|
||||
|
||||
/**
|
||||
* The PP_TrueTypeFontFamily_Dev defines generic font families. These can be
|
||||
* used to create generic fonts consistent with the user's browser settings.
|
||||
*/
|
||||
[assert_size(4)]
|
||||
enum PP_TrueTypeFontFamily_Dev {
|
||||
/**
|
||||
* For a description of these default families, see the
|
||||
* <a href="http://www.w3.org/TR/css3-fonts/#generic-font-families">
|
||||
* 3.1.1 Generic font families</a> documentation.
|
||||
*/
|
||||
PP_TRUETYPEFONTFAMILY_SERIF = 0,
|
||||
PP_TRUETYPEFONTFAMILY_SANSSERIF = 1,
|
||||
PP_TRUETYPEFONTFAMILY_CURSIVE = 2,
|
||||
PP_TRUETYPEFONTFAMILY_FANTASY = 3,
|
||||
PP_TRUETYPEFONTFAMILY_MONOSPACE = 4,
|
||||
PP_TRUETYPEFONTFAMILY_LAST = PP_TRUETYPEFONTFAMILY_MONOSPACE
|
||||
};
|
||||
|
||||
/**
|
||||
* The PP_TrueTypeFontStyle_Dev enum defines font styles.
|
||||
*/
|
||||
[assert_size(4)]
|
||||
enum PP_TrueTypeFontStyle_Dev {
|
||||
PP_TRUETYPEFONTSTYLE_NORMAL = 0,
|
||||
PP_TRUETYPEFONTSTYLE_ITALIC = 1,
|
||||
PP_TRUETYPEFONTSTYLE_LAST = PP_TRUETYPEFONTSTYLE_ITALIC
|
||||
};
|
||||
|
||||
/**
|
||||
* The PP_TrueTypeFontWeight_Dev enum defines font weights.
|
||||
*/
|
||||
[assert_size(4)]
|
||||
enum PP_TrueTypeFontWeight_Dev {
|
||||
PP_TRUETYPEFONTWEIGHT_THIN = 100,
|
||||
PP_TRUETYPEFONTWEIGHT_FIRST = PP_TRUETYPEFONTWEIGHT_THIN,
|
||||
PP_TRUETYPEFONTWEIGHT_ULTRALIGHT = 200,
|
||||
PP_TRUETYPEFONTWEIGHT_LIGHT = 300,
|
||||
PP_TRUETYPEFONTWEIGHT_NORMAL = 400,
|
||||
PP_TRUETYPEFONTWEIGHT_MEDIUM = 500,
|
||||
PP_TRUETYPEFONTWEIGHT_SEMIBOLD = 600,
|
||||
PP_TRUETYPEFONTWEIGHT_BOLD = 700,
|
||||
PP_TRUETYPEFONTWEIGHT_ULTRABOLD = 800,
|
||||
PP_TRUETYPEFONTWEIGHT_HEAVY = 900,
|
||||
PP_TRUETYPEFONTWEIGHT_LAST = PP_TRUETYPEFONTWEIGHT_HEAVY
|
||||
};
|
||||
|
||||
/**
|
||||
* The PP_TrueTypeFontWidth_Dev enum defines font widths.
|
||||
*/
|
||||
[assert_size(4)]
|
||||
enum PP_TrueTypeFontWidth_Dev {
|
||||
PP_TRUETYPEFONTWIDTH_ULTRACONDENSED = 0,
|
||||
PP_TRUETYPEFONTWIDTH_EXTRACONDENSED = 1,
|
||||
PP_TRUETYPEFONTWIDTH_CONDENSED = 2,
|
||||
PP_TRUETYPEFONTWIDTH_SEMICONDENSED = 3,
|
||||
PP_TRUETYPEFONTWIDTH_NORMAL = 4,
|
||||
PP_TRUETYPEFONTWIDTH_SEMIEXPANDED = 5,
|
||||
PP_TRUETYPEFONTWIDTH_EXPANDED = 6,
|
||||
PP_TRUETYPEFONTWIDTH_EXTRAEXPANDED = 7,
|
||||
PP_TRUETYPEFONTWIDTH_ULTRAEXPANDED = 8,
|
||||
PP_TRUETYPEFONTWIDTH_LAST = PP_TRUETYPEFONTWIDTH_ULTRAEXPANDED
|
||||
};
|
||||
|
||||
/**
|
||||
* The PP_TrueTypeFontCharset enum defines font character sets.
|
||||
*/
|
||||
[assert_size(4)]
|
||||
enum PP_TrueTypeFontCharset_Dev {
|
||||
PP_TRUETYPEFONTCHARSET_ANSI = 0,
|
||||
PP_TRUETYPEFONTCHARSET_DEFAULT = 1,
|
||||
PP_TRUETYPEFONTCHARSET_SYMBOL = 2,
|
||||
PP_TRUETYPEFONTCHARSET_MAC = 77,
|
||||
PP_TRUETYPEFONTCHARSET_SHIFTJIS = 128,
|
||||
PP_TRUETYPEFONTCHARSET_HANGUL = 129,
|
||||
PP_TRUETYPEFONTCHARSET_JOHAB = 130,
|
||||
PP_TRUETYPEFONTCHARSET_GB2312 =134,
|
||||
PP_TRUETYPEFONTCHARSET_CHINESEBIG5 = 136,
|
||||
PP_TRUETYPEFONTCHARSET_GREEK = 161,
|
||||
PP_TRUETYPEFONTCHARSET_TURKISH = 162,
|
||||
PP_TRUETYPEFONTCHARSET_VIETNAMESE = 163,
|
||||
PP_TRUETYPEFONTCHARSET_HEBREW = 177,
|
||||
PP_TRUETYPEFONTCHARSET_ARABIC = 178,
|
||||
PP_TRUETYPEFONTCHARSET_BALTIC = 186,
|
||||
PP_TRUETYPEFONTCHARSET_RUSSIAN = 204,
|
||||
PP_TRUETYPEFONTCHARSET_THAI = 222,
|
||||
PP_TRUETYPEFONTCHARSET_EASTEUROPE = 238,
|
||||
PP_TRUETYPEFONTCHARSET_OEM = 255,
|
||||
PP_TRUETYPEFONTCHARSET_LAST = PP_TRUETYPEFONTCHARSET_OEM
|
||||
};
|
||||
|
||||
/**
|
||||
* The <code>PP_TrueTypeFontDesc</code> struct describes a TrueType font. It is
|
||||
* passed to Create(), and returned by Describe().
|
||||
*/
|
||||
[assert_size(40)]
|
||||
struct PP_TrueTypeFontDesc_Dev {
|
||||
/**
|
||||
* Font family name as a string. This can also be an undefined var, in which
|
||||
* case the generic family will be obeyed. If the face is not available on
|
||||
* the system, the browser will attempt to do font fallback or pick a default
|
||||
* font.
|
||||
*/
|
||||
PP_Var family;
|
||||
|
||||
/** This value specifies a generic font family. If a family name string is
|
||||
* provided when creating a font, this is ignored. */
|
||||
PP_TrueTypeFontFamily_Dev generic_family;
|
||||
|
||||
/** This value specifies the font style. */
|
||||
PP_TrueTypeFontStyle_Dev style;
|
||||
|
||||
/** This value specifies the font weight. */
|
||||
PP_TrueTypeFontWeight_Dev weight;
|
||||
|
||||
/** This value specifies the font width, for condensed or expanded fonts */
|
||||
PP_TrueTypeFontWidth_Dev width;
|
||||
|
||||
/** This value specifies a character set. */
|
||||
PP_TrueTypeFontCharset_Dev charset;
|
||||
|
||||
/**
|
||||
* Ensure that this struct is 40-bytes wide by padding the end. In some
|
||||
* compilers, PP_Var is 8-byte aligned, so those compilers align this struct
|
||||
* on 8-byte boundaries as well and pad it to 16 bytes even without this
|
||||
* padding attribute. This padding makes its size consistent across
|
||||
* compilers.
|
||||
*/
|
||||
int32_t padding;
|
||||
};
|
||||
|
||||
interface PPB_TrueTypeFont_Dev {
|
||||
/**
|
||||
* Gets an array of TrueType font family names available on the host.
|
||||
* These names can be used to create a font from a specific family.
|
||||
*
|
||||
* @param[in] instance A <code>PP_Instance</code> requesting the family names.
|
||||
* @param[in] output A <code>PP_ArrayOutput</code> to hold the names.
|
||||
* The output is an array of PP_Vars, each holding a family name.
|
||||
* @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
|
||||
* completion of GetFontFamilies.
|
||||
*
|
||||
* @return If >= 0, the number of family names returned, otherwise an error
|
||||
* code from <code>pp_errors.h</code>.
|
||||
*/
|
||||
[singleton,api=PPB_TrueTypeFont_Singleton_API]
|
||||
int32_t GetFontFamilies([in] PP_Instance instance,
|
||||
[in] PP_ArrayOutput output,
|
||||
[in] PP_CompletionCallback callback);
|
||||
|
||||
/**
|
||||
* Gets an array of TrueType font descriptors for a given font family. These
|
||||
* descriptors can be used to create a font in that family and matching the
|
||||
* descriptor attributes.
|
||||
*
|
||||
* @param[in] instance A <code>PP_Instance</code> requesting the font
|
||||
* descriptors.
|
||||
* @param[in] family A <code>PP_Var</code> holding a string specifying the
|
||||
* font family.
|
||||
* @param[in] output A <code>PP_ArrayOutput</code> to hold the descriptors.
|
||||
* The output is an array of <code>PP_TrueTypeFontDesc</code> structs. Each
|
||||
* desc contains a PP_Var for the family name which must be released.
|
||||
* @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
|
||||
* completion of GetFontsInFamily.
|
||||
*
|
||||
* @return If >= 0, the number of font descriptors returned, otherwise an
|
||||
* error code from <code>pp_errors.h</code>.
|
||||
*/
|
||||
[singleton,api=PPB_TrueTypeFont_Singleton_API]
|
||||
int32_t GetFontsInFamily([in] PP_Instance instance,
|
||||
[in] PP_Var family,
|
||||
[in] PP_ArrayOutput output,
|
||||
[in] PP_CompletionCallback callback);
|
||||
|
||||
/**
|
||||
* Creates a font resource matching the given font characteristics. The
|
||||
* resource id will be non-zero on success, or zero on failure.
|
||||
*
|
||||
* @param[in] instance A <code>PP_Instance</code> to own the font.
|
||||
* @param[in] desc A pointer to a <code>PP_TrueTypeFontDesc</code> describing
|
||||
* the font.
|
||||
*/
|
||||
PP_Resource Create([in] PP_Instance instance,
|
||||
[in] PP_TrueTypeFontDesc_Dev desc);
|
||||
|
||||
/**
|
||||
* Determines if the given resource is a TrueType font.
|
||||
*
|
||||
* @param[in] resource A <code>PP_Resource</code> corresponding to a resource.
|
||||
*
|
||||
* @return <code>PP_TRUE</code> if the resource is a
|
||||
* <code>PPB_TrueTypeFont_Dev</code>, <code>PP_FALSE</code> otherwise.
|
||||
*/
|
||||
PP_Bool IsTrueTypeFont([in] PP_Resource resource);
|
||||
|
||||
/**
|
||||
* Returns a description of the given font resource. This description may
|
||||
* differ from the description passed to Create, reflecting the host's font
|
||||
* matching and fallback algorithm.
|
||||
*
|
||||
* @param[in] font A <code>PP_Resource</code> corresponding to a font.
|
||||
* @param[out] desc A pointer to a <code>PP_TrueTypeFontDesc</code> to hold
|
||||
* the description. The internal 'family' PP_Var should be set to undefined,
|
||||
* since this function overwrites the <code>PP_TrueTypeFontDesc</code>. After
|
||||
* successful completion, the family will be set to a PP_Var with a single
|
||||
* reference, which the caller must release after use.
|
||||
* @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
|
||||
* completion of Describe.
|
||||
*
|
||||
* @return A return code from <code>pp_errors.h</code>. If an error code is
|
||||
* returned, the <code>PP_TrueTypeFontDesc</code> will be unchanged.
|
||||
*/
|
||||
int32_t Describe([in] PP_Resource font,
|
||||
[out] PP_TrueTypeFontDesc_Dev desc,
|
||||
[in] PP_CompletionCallback callback);
|
||||
|
||||
/**
|
||||
* Gets an array of identifying tags for each table in the font. These tags
|
||||
* can be used to request specific tables using GetTable.
|
||||
*
|
||||
* @param[in] font A <code>PP_Resource</code> corresponding to a font.
|
||||
* @param[in] output A <code>PP_ArrayOutput</code> to hold the tags.
|
||||
* The output is an array of 4 byte integers, each representing a table tag.
|
||||
* @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
|
||||
* completion of GetTableTags.
|
||||
*
|
||||
* @return If >= 0, the number of table tags returned, otherwise an error
|
||||
* code from <code>pp_errors.h</code>.
|
||||
*/
|
||||
int32_t GetTableTags([in] PP_Resource font,
|
||||
[in] PP_ArrayOutput output,
|
||||
[in] PP_CompletionCallback callback);
|
||||
|
||||
/**
|
||||
* Copies the given font table into client memory.
|
||||
*
|
||||
* @param[in] font A <code>PP_Resource</code> corresponding to a font.
|
||||
* @param[in] table A 4 byte value indicating which table to copy.
|
||||
* For example, 'glyf' will cause the outline table to be copied into the
|
||||
* output array. A zero tag value will cause the entire font to be copied.
|
||||
* @param[in] offset The offset into the font table. Passing an offset
|
||||
* greater than or equal to the table size will succeed with 0 bytes copied.
|
||||
* @param[in] max_data_length The maximum number of bytes to transfer from
|
||||
* <code>offset</code>.
|
||||
* @param[in] output A <code>PP_ArrayOutput</code> to hold the font data.
|
||||
* The output is an array of bytes.
|
||||
* @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
|
||||
* completion of GetTable.
|
||||
*
|
||||
* @return If >= 0, the table size in bytes, otherwise an error code from
|
||||
* <code>pp_errors.h</code>.
|
||||
*/
|
||||
int32_t GetTable([in] PP_Resource font,
|
||||
[in] uint32_t table,
|
||||
[in] int32_t offset,
|
||||
[in] int32_t max_data_length,
|
||||
[in] PP_ArrayOutput output,
|
||||
[in] PP_CompletionCallback callback);
|
||||
};
|
@ -98,7 +98,6 @@ source_set("c") {
|
||||
"dev/ppb_printing_dev.h",
|
||||
"dev/ppb_text_input_dev.h",
|
||||
"dev/ppb_trace_event_dev.h",
|
||||
"dev/ppb_truetype_font_dev.h",
|
||||
"dev/ppb_url_util_dev.h",
|
||||
"dev/ppb_video_capture_dev.h",
|
||||
"dev/ppb_video_decoder_dev.h",
|
||||
|
@ -1,301 +0,0 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
/* From dev/ppb_truetype_font_dev.idl modified Tue Oct 24 12:47:58 2017. */
|
||||
|
||||
#ifndef PPAPI_C_DEV_PPB_TRUETYPE_FONT_DEV_H_
|
||||
#define PPAPI_C_DEV_PPB_TRUETYPE_FONT_DEV_H_
|
||||
|
||||
#include "ppapi/c/pp_array_output.h"
|
||||
#include "ppapi/c/pp_bool.h"
|
||||
#include "ppapi/c/pp_completion_callback.h"
|
||||
#include "ppapi/c/pp_instance.h"
|
||||
#include "ppapi/c/pp_macros.h"
|
||||
#include "ppapi/c/pp_resource.h"
|
||||
#include "ppapi/c/pp_stdint.h"
|
||||
#include "ppapi/c/pp_var.h"
|
||||
|
||||
#define PPB_TRUETYPEFONT_DEV_INTERFACE_0_1 "PPB_TrueTypeFont(Dev);0.1"
|
||||
#define PPB_TRUETYPEFONT_DEV_INTERFACE PPB_TRUETYPEFONT_DEV_INTERFACE_0_1
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file defines the <code>PPB_TrueTypeFont_Dev</code> interface. This
|
||||
* interface exposes font table data for 'sfnt' fonts on the host system. These
|
||||
* include TrueType and OpenType fonts.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @addtogroup Enums
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* The PP_TrueTypeFontFamily_Dev defines generic font families. These can be
|
||||
* used to create generic fonts consistent with the user's browser settings.
|
||||
*/
|
||||
typedef enum {
|
||||
/**
|
||||
* For a description of these default families, see the
|
||||
* <a href="http://www.w3.org/TR/css3-fonts/#generic-font-families">
|
||||
* 3.1.1 Generic font families</a> documentation.
|
||||
*/
|
||||
PP_TRUETYPEFONTFAMILY_SERIF = 0,
|
||||
PP_TRUETYPEFONTFAMILY_SANSSERIF = 1,
|
||||
PP_TRUETYPEFONTFAMILY_CURSIVE = 2,
|
||||
PP_TRUETYPEFONTFAMILY_FANTASY = 3,
|
||||
PP_TRUETYPEFONTFAMILY_MONOSPACE = 4,
|
||||
PP_TRUETYPEFONTFAMILY_LAST = PP_TRUETYPEFONTFAMILY_MONOSPACE
|
||||
} PP_TrueTypeFontFamily_Dev;
|
||||
PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TrueTypeFontFamily_Dev, 4);
|
||||
|
||||
/**
|
||||
* The PP_TrueTypeFontStyle_Dev enum defines font styles.
|
||||
*/
|
||||
typedef enum {
|
||||
PP_TRUETYPEFONTSTYLE_NORMAL = 0,
|
||||
PP_TRUETYPEFONTSTYLE_ITALIC = 1,
|
||||
PP_TRUETYPEFONTSTYLE_LAST = PP_TRUETYPEFONTSTYLE_ITALIC
|
||||
} PP_TrueTypeFontStyle_Dev;
|
||||
PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TrueTypeFontStyle_Dev, 4);
|
||||
|
||||
/**
|
||||
* The PP_TrueTypeFontWeight_Dev enum defines font weights.
|
||||
*/
|
||||
typedef enum {
|
||||
PP_TRUETYPEFONTWEIGHT_THIN = 100,
|
||||
PP_TRUETYPEFONTWEIGHT_FIRST = PP_TRUETYPEFONTWEIGHT_THIN,
|
||||
PP_TRUETYPEFONTWEIGHT_ULTRALIGHT = 200,
|
||||
PP_TRUETYPEFONTWEIGHT_LIGHT = 300,
|
||||
PP_TRUETYPEFONTWEIGHT_NORMAL = 400,
|
||||
PP_TRUETYPEFONTWEIGHT_MEDIUM = 500,
|
||||
PP_TRUETYPEFONTWEIGHT_SEMIBOLD = 600,
|
||||
PP_TRUETYPEFONTWEIGHT_BOLD = 700,
|
||||
PP_TRUETYPEFONTWEIGHT_ULTRABOLD = 800,
|
||||
PP_TRUETYPEFONTWEIGHT_HEAVY = 900,
|
||||
PP_TRUETYPEFONTWEIGHT_LAST = PP_TRUETYPEFONTWEIGHT_HEAVY
|
||||
} PP_TrueTypeFontWeight_Dev;
|
||||
PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TrueTypeFontWeight_Dev, 4);
|
||||
|
||||
/**
|
||||
* The PP_TrueTypeFontWidth_Dev enum defines font widths.
|
||||
*/
|
||||
typedef enum {
|
||||
PP_TRUETYPEFONTWIDTH_ULTRACONDENSED = 0,
|
||||
PP_TRUETYPEFONTWIDTH_EXTRACONDENSED = 1,
|
||||
PP_TRUETYPEFONTWIDTH_CONDENSED = 2,
|
||||
PP_TRUETYPEFONTWIDTH_SEMICONDENSED = 3,
|
||||
PP_TRUETYPEFONTWIDTH_NORMAL = 4,
|
||||
PP_TRUETYPEFONTWIDTH_SEMIEXPANDED = 5,
|
||||
PP_TRUETYPEFONTWIDTH_EXPANDED = 6,
|
||||
PP_TRUETYPEFONTWIDTH_EXTRAEXPANDED = 7,
|
||||
PP_TRUETYPEFONTWIDTH_ULTRAEXPANDED = 8,
|
||||
PP_TRUETYPEFONTWIDTH_LAST = PP_TRUETYPEFONTWIDTH_ULTRAEXPANDED
|
||||
} PP_TrueTypeFontWidth_Dev;
|
||||
PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TrueTypeFontWidth_Dev, 4);
|
||||
|
||||
/**
|
||||
* The PP_TrueTypeFontCharset enum defines font character sets.
|
||||
*/
|
||||
typedef enum {
|
||||
PP_TRUETYPEFONTCHARSET_ANSI = 0,
|
||||
PP_TRUETYPEFONTCHARSET_DEFAULT = 1,
|
||||
PP_TRUETYPEFONTCHARSET_SYMBOL = 2,
|
||||
PP_TRUETYPEFONTCHARSET_MAC = 77,
|
||||
PP_TRUETYPEFONTCHARSET_SHIFTJIS = 128,
|
||||
PP_TRUETYPEFONTCHARSET_HANGUL = 129,
|
||||
PP_TRUETYPEFONTCHARSET_JOHAB = 130,
|
||||
PP_TRUETYPEFONTCHARSET_GB2312 = 134,
|
||||
PP_TRUETYPEFONTCHARSET_CHINESEBIG5 = 136,
|
||||
PP_TRUETYPEFONTCHARSET_GREEK = 161,
|
||||
PP_TRUETYPEFONTCHARSET_TURKISH = 162,
|
||||
PP_TRUETYPEFONTCHARSET_VIETNAMESE = 163,
|
||||
PP_TRUETYPEFONTCHARSET_HEBREW = 177,
|
||||
PP_TRUETYPEFONTCHARSET_ARABIC = 178,
|
||||
PP_TRUETYPEFONTCHARSET_BALTIC = 186,
|
||||
PP_TRUETYPEFONTCHARSET_RUSSIAN = 204,
|
||||
PP_TRUETYPEFONTCHARSET_THAI = 222,
|
||||
PP_TRUETYPEFONTCHARSET_EASTEUROPE = 238,
|
||||
PP_TRUETYPEFONTCHARSET_OEM = 255,
|
||||
PP_TRUETYPEFONTCHARSET_LAST = PP_TRUETYPEFONTCHARSET_OEM
|
||||
} PP_TrueTypeFontCharset_Dev;
|
||||
PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TrueTypeFontCharset_Dev, 4);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup Structs
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* The <code>PP_TrueTypeFontDesc</code> struct describes a TrueType font. It is
|
||||
* passed to Create(), and returned by Describe().
|
||||
*/
|
||||
struct PP_TrueTypeFontDesc_Dev {
|
||||
/**
|
||||
* Font family name as a string. This can also be an undefined var, in which
|
||||
* case the generic family will be obeyed. If the face is not available on
|
||||
* the system, the browser will attempt to do font fallback or pick a default
|
||||
* font.
|
||||
*/
|
||||
struct PP_Var family;
|
||||
/** This value specifies a generic font family. If a family name string is
|
||||
* provided when creating a font, this is ignored. */
|
||||
PP_TrueTypeFontFamily_Dev generic_family;
|
||||
/** This value specifies the font style. */
|
||||
PP_TrueTypeFontStyle_Dev style;
|
||||
/** This value specifies the font weight. */
|
||||
PP_TrueTypeFontWeight_Dev weight;
|
||||
/** This value specifies the font width, for condensed or expanded fonts */
|
||||
PP_TrueTypeFontWidth_Dev width;
|
||||
/** This value specifies a character set. */
|
||||
PP_TrueTypeFontCharset_Dev charset;
|
||||
/**
|
||||
* Ensure that this struct is 40-bytes wide by padding the end. In some
|
||||
* compilers, PP_Var is 8-byte aligned, so those compilers align this struct
|
||||
* on 8-byte boundaries as well and pad it to 16 bytes even without this
|
||||
* padding attribute. This padding makes its size consistent across
|
||||
* compilers.
|
||||
*/
|
||||
int32_t padding;
|
||||
};
|
||||
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_TrueTypeFontDesc_Dev, 40);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup Interfaces
|
||||
* @{
|
||||
*/
|
||||
struct PPB_TrueTypeFont_Dev_0_1 {
|
||||
/**
|
||||
* Gets an array of TrueType font family names available on the host.
|
||||
* These names can be used to create a font from a specific family.
|
||||
*
|
||||
* @param[in] instance A <code>PP_Instance</code> requesting the family names.
|
||||
* @param[in] output A <code>PP_ArrayOutput</code> to hold the names.
|
||||
* The output is an array of PP_Vars, each holding a family name.
|
||||
* @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
|
||||
* completion of GetFontFamilies.
|
||||
*
|
||||
* @return If >= 0, the number of family names returned, otherwise an error
|
||||
* code from <code>pp_errors.h</code>.
|
||||
*/
|
||||
int32_t (*GetFontFamilies)(PP_Instance instance,
|
||||
struct PP_ArrayOutput output,
|
||||
struct PP_CompletionCallback callback);
|
||||
/**
|
||||
* Gets an array of TrueType font descriptors for a given font family. These
|
||||
* descriptors can be used to create a font in that family and matching the
|
||||
* descriptor attributes.
|
||||
*
|
||||
* @param[in] instance A <code>PP_Instance</code> requesting the font
|
||||
* descriptors.
|
||||
* @param[in] family A <code>PP_Var</code> holding a string specifying the
|
||||
* font family.
|
||||
* @param[in] output A <code>PP_ArrayOutput</code> to hold the descriptors.
|
||||
* The output is an array of <code>PP_TrueTypeFontDesc</code> structs. Each
|
||||
* desc contains a PP_Var for the family name which must be released.
|
||||
* @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
|
||||
* completion of GetFontsInFamily.
|
||||
*
|
||||
* @return If >= 0, the number of font descriptors returned, otherwise an
|
||||
* error code from <code>pp_errors.h</code>.
|
||||
*/
|
||||
int32_t (*GetFontsInFamily)(PP_Instance instance,
|
||||
struct PP_Var family,
|
||||
struct PP_ArrayOutput output,
|
||||
struct PP_CompletionCallback callback);
|
||||
/**
|
||||
* Creates a font resource matching the given font characteristics. The
|
||||
* resource id will be non-zero on success, or zero on failure.
|
||||
*
|
||||
* @param[in] instance A <code>PP_Instance</code> to own the font.
|
||||
* @param[in] desc A pointer to a <code>PP_TrueTypeFontDesc</code> describing
|
||||
* the font.
|
||||
*/
|
||||
PP_Resource (*Create)(PP_Instance instance,
|
||||
const struct PP_TrueTypeFontDesc_Dev* desc);
|
||||
/**
|
||||
* Determines if the given resource is a TrueType font.
|
||||
*
|
||||
* @param[in] resource A <code>PP_Resource</code> corresponding to a resource.
|
||||
*
|
||||
* @return <code>PP_TRUE</code> if the resource is a
|
||||
* <code>PPB_TrueTypeFont_Dev</code>, <code>PP_FALSE</code> otherwise.
|
||||
*/
|
||||
PP_Bool (*IsTrueTypeFont)(PP_Resource resource);
|
||||
/**
|
||||
* Returns a description of the given font resource. This description may
|
||||
* differ from the description passed to Create, reflecting the host's font
|
||||
* matching and fallback algorithm.
|
||||
*
|
||||
* @param[in] font A <code>PP_Resource</code> corresponding to a font.
|
||||
* @param[out] desc A pointer to a <code>PP_TrueTypeFontDesc</code> to hold
|
||||
* the description. The internal 'family' PP_Var should be set to undefined,
|
||||
* since this function overwrites the <code>PP_TrueTypeFontDesc</code>. After
|
||||
* successful completion, the family will be set to a PP_Var with a single
|
||||
* reference, which the caller must release after use.
|
||||
* @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
|
||||
* completion of Describe.
|
||||
*
|
||||
* @return A return code from <code>pp_errors.h</code>. If an error code is
|
||||
* returned, the <code>PP_TrueTypeFontDesc</code> will be unchanged.
|
||||
*/
|
||||
int32_t (*Describe)(PP_Resource font,
|
||||
struct PP_TrueTypeFontDesc_Dev* desc,
|
||||
struct PP_CompletionCallback callback);
|
||||
/**
|
||||
* Gets an array of identifying tags for each table in the font. These tags
|
||||
* can be used to request specific tables using GetTable.
|
||||
*
|
||||
* @param[in] font A <code>PP_Resource</code> corresponding to a font.
|
||||
* @param[in] output A <code>PP_ArrayOutput</code> to hold the tags.
|
||||
* The output is an array of 4 byte integers, each representing a table tag.
|
||||
* @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
|
||||
* completion of GetTableTags.
|
||||
*
|
||||
* @return If >= 0, the number of table tags returned, otherwise an error
|
||||
* code from <code>pp_errors.h</code>.
|
||||
*/
|
||||
int32_t (*GetTableTags)(PP_Resource font,
|
||||
struct PP_ArrayOutput output,
|
||||
struct PP_CompletionCallback callback);
|
||||
/**
|
||||
* Copies the given font table into client memory.
|
||||
*
|
||||
* @param[in] font A <code>PP_Resource</code> corresponding to a font.
|
||||
* @param[in] table A 4 byte value indicating which table to copy.
|
||||
* For example, 'glyf' will cause the outline table to be copied into the
|
||||
* output array. A zero tag value will cause the entire font to be copied.
|
||||
* @param[in] offset The offset into the font table. Passing an offset
|
||||
* greater than or equal to the table size will succeed with 0 bytes copied.
|
||||
* @param[in] max_data_length The maximum number of bytes to transfer from
|
||||
* <code>offset</code>.
|
||||
* @param[in] output A <code>PP_ArrayOutput</code> to hold the font data.
|
||||
* The output is an array of bytes.
|
||||
* @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
|
||||
* completion of GetTable.
|
||||
*
|
||||
* @return If >= 0, the table size in bytes, otherwise an error code from
|
||||
* <code>pp_errors.h</code>.
|
||||
*/
|
||||
int32_t (*GetTable)(PP_Resource font,
|
||||
uint32_t table,
|
||||
int32_t offset,
|
||||
int32_t max_data_length,
|
||||
struct PP_ArrayOutput output,
|
||||
struct PP_CompletionCallback callback);
|
||||
};
|
||||
|
||||
typedef struct PPB_TrueTypeFont_Dev_0_1 PPB_TrueTypeFont_Dev;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* PPAPI_C_DEV_PPB_TRUETYPE_FONT_DEV_H_ */
|
||||
|
@ -179,8 +179,6 @@ source_set("objects") {
|
||||
"dev/printing_dev.h",
|
||||
"dev/text_input_dev.cc",
|
||||
"dev/text_input_dev.h",
|
||||
"dev/truetype_font_dev.cc",
|
||||
"dev/truetype_font_dev.h",
|
||||
"dev/url_util_dev.cc",
|
||||
"dev/url_util_dev.h",
|
||||
"dev/video_capture_client_dev.cc",
|
||||
|
@ -1,156 +0,0 @@
|
||||
// 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/cpp/dev/truetype_font_dev.h"
|
||||
|
||||
#include <string.h> // memcpy
|
||||
|
||||
#include "ppapi/c/dev/ppb_truetype_font_dev.h"
|
||||
#include "ppapi/c/pp_errors.h"
|
||||
#include "ppapi/c/ppb_var.h"
|
||||
#include "ppapi/cpp/completion_callback.h"
|
||||
#include "ppapi/cpp/instance_handle.h"
|
||||
#include "ppapi/cpp/module.h"
|
||||
#include "ppapi/cpp/module_impl.h"
|
||||
#include "ppapi/cpp/var.h"
|
||||
|
||||
namespace pp {
|
||||
|
||||
namespace {
|
||||
|
||||
template <> const char* interface_name<PPB_TrueTypeFont_Dev_0_1>() {
|
||||
return PPB_TRUETYPEFONT_DEV_INTERFACE_0_1;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// TrueTypeFontDesc_Dev --------------------------------------------------------
|
||||
|
||||
TrueTypeFontDesc_Dev::TrueTypeFontDesc_Dev() {
|
||||
desc_.family = family_.pp_var();
|
||||
set_generic_family(PP_TRUETYPEFONTFAMILY_SERIF);
|
||||
set_style(PP_TRUETYPEFONTSTYLE_NORMAL);
|
||||
set_weight(PP_TRUETYPEFONTWEIGHT_NORMAL);
|
||||
set_width(PP_TRUETYPEFONTWIDTH_NORMAL);
|
||||
set_charset(PP_TRUETYPEFONTCHARSET_DEFAULT);
|
||||
}
|
||||
|
||||
TrueTypeFontDesc_Dev::TrueTypeFontDesc_Dev(
|
||||
PassRef,
|
||||
const PP_TrueTypeFontDesc_Dev& pp_desc) {
|
||||
desc_ = pp_desc;
|
||||
set_family(Var(PASS_REF, pp_desc.family));
|
||||
}
|
||||
|
||||
TrueTypeFontDesc_Dev::TrueTypeFontDesc_Dev(const TrueTypeFontDesc_Dev& other) {
|
||||
set_family(other.family());
|
||||
set_generic_family(other.generic_family());
|
||||
set_style(other.style());
|
||||
set_weight(other.weight());
|
||||
set_width(other.width());
|
||||
set_charset(other.charset());
|
||||
}
|
||||
|
||||
TrueTypeFontDesc_Dev::~TrueTypeFontDesc_Dev() {
|
||||
}
|
||||
|
||||
TrueTypeFontDesc_Dev& TrueTypeFontDesc_Dev::operator=(
|
||||
const TrueTypeFontDesc_Dev& other) {
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
set_family(other.family());
|
||||
set_generic_family(other.generic_family());
|
||||
set_style(other.style());
|
||||
set_weight(other.weight());
|
||||
set_width(other.width());
|
||||
set_charset(other.charset());
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// TrueTypeFont_Dev ------------------------------------------------------------
|
||||
|
||||
TrueTypeFont_Dev::TrueTypeFont_Dev() {
|
||||
}
|
||||
|
||||
TrueTypeFont_Dev::TrueTypeFont_Dev(const InstanceHandle& instance,
|
||||
const TrueTypeFontDesc_Dev& desc) {
|
||||
if (!has_interface<PPB_TrueTypeFont_Dev_0_1>())
|
||||
return;
|
||||
PassRefFromConstructor(get_interface<PPB_TrueTypeFont_Dev_0_1>()->Create(
|
||||
instance.pp_instance(), &desc.pp_desc()));
|
||||
}
|
||||
|
||||
TrueTypeFont_Dev::TrueTypeFont_Dev(const TrueTypeFont_Dev& other)
|
||||
: Resource(other) {
|
||||
}
|
||||
|
||||
TrueTypeFont_Dev::TrueTypeFont_Dev(PassRef, PP_Resource resource)
|
||||
: Resource(PASS_REF, resource) {
|
||||
}
|
||||
|
||||
// static
|
||||
int32_t TrueTypeFont_Dev::GetFontFamilies(
|
||||
const InstanceHandle& instance,
|
||||
const CompletionCallbackWithOutput<std::vector<Var> >& cc) {
|
||||
if (has_interface<PPB_TrueTypeFont_Dev_0_1>()) {
|
||||
return get_interface<PPB_TrueTypeFont_Dev_0_1>()->GetFontFamilies(
|
||||
instance.pp_instance(),
|
||||
cc.output(), cc.pp_completion_callback());
|
||||
}
|
||||
return cc.MayForce(PP_ERROR_NOINTERFACE);
|
||||
}
|
||||
|
||||
// static
|
||||
int32_t TrueTypeFont_Dev::GetFontsInFamily(
|
||||
const InstanceHandle& instance,
|
||||
const Var& family,
|
||||
const CompletionCallbackWithOutput<std::vector<TrueTypeFontDesc_Dev> >& cc)
|
||||
{
|
||||
if (has_interface<PPB_TrueTypeFont_Dev_0_1>()) {
|
||||
return get_interface<PPB_TrueTypeFont_Dev_0_1>()->GetFontsInFamily(
|
||||
instance.pp_instance(),
|
||||
family.pp_var(),
|
||||
cc.output(), cc.pp_completion_callback());
|
||||
}
|
||||
return cc.MayForce(PP_ERROR_NOINTERFACE);
|
||||
}
|
||||
|
||||
int32_t TrueTypeFont_Dev::Describe(
|
||||
const CompletionCallbackWithOutput<TrueTypeFontDesc_Dev>& cc) {
|
||||
if (has_interface<PPB_TrueTypeFont_Dev_0_1>()) {
|
||||
int32_t result =
|
||||
get_interface<PPB_TrueTypeFont_Dev_0_1>()->Describe(
|
||||
pp_resource(), cc.output(), cc.pp_completion_callback());
|
||||
return result;
|
||||
}
|
||||
return cc.MayForce(PP_ERROR_NOINTERFACE);
|
||||
}
|
||||
|
||||
int32_t TrueTypeFont_Dev::GetTableTags(
|
||||
const CompletionCallbackWithOutput<std::vector<uint32_t> >& cc) {
|
||||
if (has_interface<PPB_TrueTypeFont_Dev_0_1>()) {
|
||||
return get_interface<PPB_TrueTypeFont_Dev_0_1>()->GetTableTags(
|
||||
pp_resource(),
|
||||
cc.output(), cc.pp_completion_callback());
|
||||
}
|
||||
return cc.MayForce(PP_ERROR_NOINTERFACE);
|
||||
}
|
||||
|
||||
int32_t TrueTypeFont_Dev::GetTable(
|
||||
uint32_t table,
|
||||
int32_t offset,
|
||||
int32_t max_data_length,
|
||||
const CompletionCallbackWithOutput<std::vector<char> >& cc) {
|
||||
if (has_interface<PPB_TrueTypeFont_Dev_0_1>()) {
|
||||
return get_interface<PPB_TrueTypeFont_Dev_0_1>()->GetTable(
|
||||
pp_resource(),
|
||||
table, offset, max_data_length,
|
||||
cc.output(), cc.pp_completion_callback());
|
||||
}
|
||||
return cc.MayForce(PP_ERROR_NOINTERFACE);
|
||||
}
|
||||
|
||||
} // namespace pp
|
@ -1,274 +0,0 @@
|
||||
// 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_CPP_TRUETYPE_FONT_H_
|
||||
#define PPAPI_CPP_TRUETYPE_FONT_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "ppapi/c/dev/ppb_truetype_font_dev.h"
|
||||
#include "ppapi/c/pp_time.h"
|
||||
#include "ppapi/cpp/completion_callback.h"
|
||||
#include "ppapi/cpp/pass_ref.h"
|
||||
#include "ppapi/cpp/resource.h"
|
||||
|
||||
/// @file
|
||||
/// This file defines the API to create a TrueType font object.
|
||||
|
||||
namespace pp {
|
||||
|
||||
class InstanceHandle;
|
||||
|
||||
// TrueTypeFontDesc_Dev --------------------------------------------------------
|
||||
|
||||
/// The <code>TrueTypeFontDesc_Dev</code> class represents a TrueType font
|
||||
/// descriptor, used to Create and Describe fonts.
|
||||
class TrueTypeFontDesc_Dev {
|
||||
public:
|
||||
/// Default constructor for creating a <code>TrueTypeFontDesc_Dev</code>
|
||||
/// object.
|
||||
TrueTypeFontDesc_Dev();
|
||||
|
||||
/// Constructor that takes an existing <code>PP_TrueTypeFontDesc_Dev</code>
|
||||
/// structure. The 'family' PP_Var field in the structure will be managed by
|
||||
/// this instance.
|
||||
TrueTypeFontDesc_Dev(PassRef, const PP_TrueTypeFontDesc_Dev& pp_desc);
|
||||
|
||||
/// The copy constructor for <code>TrueTypeFontDesc_Dev</code>.
|
||||
///
|
||||
/// @param[in] other A reference to a <code>TrueTypeFontDesc_Dev</code>.
|
||||
TrueTypeFontDesc_Dev(const TrueTypeFontDesc_Dev& other);
|
||||
|
||||
~TrueTypeFontDesc_Dev();
|
||||
|
||||
TrueTypeFontDesc_Dev& operator=(const TrueTypeFontDesc_Dev& other);
|
||||
|
||||
const PP_TrueTypeFontDesc_Dev& pp_desc() const {
|
||||
return desc_;
|
||||
}
|
||||
|
||||
Var family() const {
|
||||
return family_;
|
||||
}
|
||||
void set_family(const Var& family) {
|
||||
family_ = family;
|
||||
// The assignment above manages the underlying PP_Vars. Copy the new one
|
||||
// into the wrapped desc struct.
|
||||
desc_.family = family_.pp_var();
|
||||
}
|
||||
|
||||
PP_TrueTypeFontFamily_Dev generic_family() const {
|
||||
return desc_.generic_family;
|
||||
}
|
||||
void set_generic_family(PP_TrueTypeFontFamily_Dev family) {
|
||||
desc_.generic_family = family;
|
||||
}
|
||||
|
||||
PP_TrueTypeFontStyle_Dev style() const { return desc_.style; }
|
||||
void set_style(PP_TrueTypeFontStyle_Dev style) {
|
||||
desc_.style = style;
|
||||
}
|
||||
|
||||
PP_TrueTypeFontWeight_Dev weight() const { return desc_.weight; }
|
||||
void set_weight(PP_TrueTypeFontWeight_Dev weight) {
|
||||
desc_.weight = weight;
|
||||
}
|
||||
|
||||
PP_TrueTypeFontWidth_Dev width() const { return desc_.width; }
|
||||
void set_width(PP_TrueTypeFontWidth_Dev width) {
|
||||
desc_.width = width;
|
||||
}
|
||||
|
||||
PP_TrueTypeFontCharset_Dev charset() const { return desc_.charset; }
|
||||
void set_charset(PP_TrueTypeFontCharset_Dev charset) {
|
||||
desc_.charset = charset;
|
||||
}
|
||||
|
||||
private:
|
||||
pp::Var family_; // This manages the PP_Var embedded in desc_.
|
||||
PP_TrueTypeFontDesc_Dev desc_;
|
||||
};
|
||||
|
||||
// TrueTypeFont_Dev ------------------------------------------------------------
|
||||
|
||||
/// The <code>TrueTypeFont_Dev</code> class represents a TrueType font resource.
|
||||
class TrueTypeFont_Dev : public Resource {
|
||||
public:
|
||||
/// Default constructor for creating a <code>TrueTypeFont_Dev</code> object.
|
||||
TrueTypeFont_Dev();
|
||||
|
||||
/// A constructor used to create a <code>TrueTypeFont_Dev</code> and associate
|
||||
/// it with the provided <code>Instance</code>.
|
||||
///
|
||||
/// @param[in] instance The instance that owns this resource.
|
||||
TrueTypeFont_Dev(const InstanceHandle& instance,
|
||||
const TrueTypeFontDesc_Dev& desc);
|
||||
|
||||
/// The copy constructor for <code>TrueTypeFont_Dev</code>.
|
||||
///
|
||||
/// @param[in] other A reference to a <code>TrueTypeFont_Dev</code>.
|
||||
TrueTypeFont_Dev(const TrueTypeFont_Dev& other);
|
||||
|
||||
/// A constructor used when you have received a PP_Resource as a return
|
||||
/// value that has had its reference count incremented for you.
|
||||
///
|
||||
/// @param[in] resource A PP_Resource corresponding to a TrueType font.
|
||||
TrueTypeFont_Dev(PassRef, PP_Resource resource);
|
||||
|
||||
/// Gets an array of TrueType font family names available on the host.
|
||||
/// These names can be used to create a font from a specific family.
|
||||
///
|
||||
/// @param[in] instance A <code>InstanceHandle</code> requesting the family
|
||||
/// names.
|
||||
/// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be
|
||||
/// called upon completion of GetFontFamilies.
|
||||
///
|
||||
/// @return If >= 0, the number of family names returned, otherwise an error
|
||||
/// code from <code>pp_errors.h</code>.
|
||||
static int32_t GetFontFamilies(
|
||||
const InstanceHandle& instance,
|
||||
const CompletionCallbackWithOutput<std::vector<Var> >& callback);
|
||||
|
||||
/// Gets an array of TrueType font descriptors for a given font family. These
|
||||
/// descriptors can be used to create a font in that family and matching the
|
||||
/// descriptor attributes.
|
||||
///
|
||||
/// @param[in] instance A <code>PP_Instance</code> requesting the font
|
||||
/// descriptors.
|
||||
/// @param[in] family A <code>Var</code> holding a string specifying the font
|
||||
/// family.
|
||||
/// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be
|
||||
/// called upon completion of GetFontsInFamily.
|
||||
///
|
||||
/// @return If >= 0, the number of font descriptors returned, otherwise an
|
||||
/// error code from <code>pp_errors.h</code>.
|
||||
static int32_t GetFontsInFamily(
|
||||
const InstanceHandle& instance,
|
||||
const Var& family,
|
||||
const CompletionCallbackWithOutput<std::vector<TrueTypeFontDesc_Dev> >&
|
||||
callback);
|
||||
|
||||
/// Returns a description of the given font resource. This description may
|
||||
/// differ from the description passed to Create, reflecting the host's font
|
||||
/// matching and fallback algorithm.
|
||||
///
|
||||
/// @param[in] callback A <code>CompletionCallback</code> to be called upon
|
||||
/// completion of Describe.
|
||||
///
|
||||
/// @return A return code from <code>pp_errors.h</code>. If an error code is
|
||||
/// returned, the descriptor will be left unchanged.
|
||||
int32_t Describe(
|
||||
const CompletionCallbackWithOutput<TrueTypeFontDesc_Dev>& callback);
|
||||
|
||||
/// Gets an array of identifying tags for each table in the font.
|
||||
/// These tags can be used to request specific tables using GetTable.
|
||||
///
|
||||
/// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be
|
||||
/// called upon completion of GetTableTags.
|
||||
///
|
||||
/// @return If >= 0, the number of table tags returned, otherwise an error
|
||||
/// code from <code>pp_errors.h</code>.
|
||||
int32_t GetTableTags(
|
||||
const CompletionCallbackWithOutput<std::vector<uint32_t> >& callback);
|
||||
|
||||
/// Copies the given font table into client memory.
|
||||
///
|
||||
/// @param[in] table A 4 byte value indicating which table to copy.
|
||||
/// For example, 'glyf' will cause the outline table to be copied into the
|
||||
/// output array. A zero tag value will cause the entire font to be copied.
|
||||
/// @param[in] offset The offset into the font table.
|
||||
/// @param[in] max_data_length The maximum number of bytes to transfer from
|
||||
/// <code>offset</code>.
|
||||
/// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be
|
||||
/// called upon completion of GetTable.
|
||||
///
|
||||
/// @return If >= 0, the table size in bytes, otherwise an error code from
|
||||
/// <code>pp_errors.h</code>.
|
||||
int32_t GetTable(
|
||||
uint32_t table,
|
||||
int32_t offset,
|
||||
int32_t max_data_length,
|
||||
const CompletionCallbackWithOutput<std::vector<char> >& callback);
|
||||
};
|
||||
|
||||
namespace internal {
|
||||
|
||||
// A specialization of CallbackOutputTraits to provide the callback system the
|
||||
// information on how to handle pp::TrueTypeFontDesc_Dev. This converts
|
||||
// PP_TrueTypeFontDesc_Dev to pp::TrueTypeFontDesc_Dev when passing to the
|
||||
// plugin, and specifically manages the PP_Var embedded in the desc_ field.
|
||||
template<>
|
||||
struct CallbackOutputTraits<TrueTypeFontDesc_Dev> {
|
||||
typedef PP_TrueTypeFontDesc_Dev* APIArgType;
|
||||
typedef PP_TrueTypeFontDesc_Dev StorageType;
|
||||
|
||||
static inline APIArgType StorageToAPIArg(StorageType& t) {
|
||||
return &t;
|
||||
}
|
||||
|
||||
static inline TrueTypeFontDesc_Dev StorageToPluginArg(StorageType& t) {
|
||||
return TrueTypeFontDesc_Dev(PASS_REF, t);
|
||||
}
|
||||
|
||||
static inline void Initialize(StorageType* t) {
|
||||
// Use the same defaults as TrueTypeFontDesc_Dev does.
|
||||
TrueTypeFontDesc_Dev dummy;
|
||||
*t = dummy.pp_desc();
|
||||
}
|
||||
};
|
||||
|
||||
class TrueTypeFontDescArrayOutputAdapterWithStorage
|
||||
: public ArrayOutputAdapter<PP_TrueTypeFontDesc_Dev> {
|
||||
public:
|
||||
TrueTypeFontDescArrayOutputAdapterWithStorage() {
|
||||
set_output(&temp_storage_);
|
||||
}
|
||||
|
||||
virtual ~TrueTypeFontDescArrayOutputAdapterWithStorage() {
|
||||
if (!temp_storage_.empty()) {
|
||||
// An easy way to release the resource references held by |temp_storage_|.
|
||||
output();
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<TrueTypeFontDesc_Dev>& output() {
|
||||
PP_DCHECK(output_storage_.empty());
|
||||
typedef std::vector<PP_TrueTypeFontDesc_Dev> Entries;
|
||||
for (Entries::iterator it = temp_storage_.begin();
|
||||
it != temp_storage_.end(); ++it)
|
||||
output_storage_.push_back(TrueTypeFontDesc_Dev(PASS_REF, *it));
|
||||
temp_storage_.clear();
|
||||
return output_storage_;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<PP_TrueTypeFontDesc_Dev> temp_storage_;
|
||||
std::vector<TrueTypeFontDesc_Dev> output_storage_;
|
||||
};
|
||||
|
||||
// A specialization of CallbackOutputTraits to provide the callback system the
|
||||
// information on how to handle vectors of TrueTypeFontDesc_Dev. This converts
|
||||
// PP_TrueTypeFontDesc_Dev to TrueTypeFontDesc_Dev when passing to the plugin.
|
||||
template<>
|
||||
struct CallbackOutputTraits< std::vector<TrueTypeFontDesc_Dev> > {
|
||||
typedef PP_ArrayOutput APIArgType;
|
||||
typedef TrueTypeFontDescArrayOutputAdapterWithStorage StorageType;
|
||||
|
||||
static inline APIArgType StorageToAPIArg(StorageType& t) {
|
||||
return t.pp_array_output();
|
||||
}
|
||||
|
||||
static inline std::vector<TrueTypeFontDesc_Dev>& StorageToPluginArg(
|
||||
StorageType& t) {
|
||||
return t.output();
|
||||
}
|
||||
|
||||
static inline void Initialize(StorageType* /* t */) {}
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
} // namespace pp
|
||||
|
||||
#endif // PPAPI_CPP_TRUETYPE_FONT_H_
|
@ -13,7 +13,6 @@
|
||||
#include "ppapi/c/dev/ppb_file_chooser_dev.h"
|
||||
#include "ppapi/c/dev/ppb_ime_input_event_dev.h"
|
||||
#include "ppapi/c/dev/ppb_printing_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_video_capture_dev.h"
|
||||
#include "ppapi/c/dev/ppb_video_decoder_dev.h"
|
||||
@ -153,7 +152,6 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileChooser_Dev_0_6;
|
||||
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_IMEInputEvent_Dev_0_1;
|
||||
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_IMEInputEvent_Dev_0_2;
|
||||
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Printing_Dev_0_7;
|
||||
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TrueTypeFont_Dev_0_1;
|
||||
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_6;
|
||||
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_7;
|
||||
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoCapture_Dev_0_3;
|
||||
@ -2857,45 +2855,6 @@ static int32_t Pnacl_M23_PPB_Printing_Dev_GetDefaultPrintSettings(PP_Resource re
|
||||
|
||||
/* Not generating wrapper methods for PPB_Trace_Event_Dev_0_2 */
|
||||
|
||||
/* Begin wrapper methods for PPB_TrueTypeFont_Dev_0_1 */
|
||||
|
||||
static int32_t Pnacl_M26_PPB_TrueTypeFont_Dev_GetFontFamilies(PP_Instance instance, struct PP_ArrayOutput* output, struct PP_CompletionCallback* callback) {
|
||||
const struct PPB_TrueTypeFont_Dev_0_1 *iface = Pnacl_WrapperInfo_PPB_TrueTypeFont_Dev_0_1.real_iface;
|
||||
return iface->GetFontFamilies(instance, *output, *callback);
|
||||
}
|
||||
|
||||
static int32_t Pnacl_M26_PPB_TrueTypeFont_Dev_GetFontsInFamily(PP_Instance instance, struct PP_Var* family, struct PP_ArrayOutput* output, struct PP_CompletionCallback* callback) {
|
||||
const struct PPB_TrueTypeFont_Dev_0_1 *iface = Pnacl_WrapperInfo_PPB_TrueTypeFont_Dev_0_1.real_iface;
|
||||
return iface->GetFontsInFamily(instance, *family, *output, *callback);
|
||||
}
|
||||
|
||||
static PP_Resource Pnacl_M26_PPB_TrueTypeFont_Dev_Create(PP_Instance instance, const struct PP_TrueTypeFontDesc_Dev* desc) {
|
||||
const struct PPB_TrueTypeFont_Dev_0_1 *iface = Pnacl_WrapperInfo_PPB_TrueTypeFont_Dev_0_1.real_iface;
|
||||
return iface->Create(instance, desc);
|
||||
}
|
||||
|
||||
static PP_Bool Pnacl_M26_PPB_TrueTypeFont_Dev_IsTrueTypeFont(PP_Resource resource) {
|
||||
const struct PPB_TrueTypeFont_Dev_0_1 *iface = Pnacl_WrapperInfo_PPB_TrueTypeFont_Dev_0_1.real_iface;
|
||||
return iface->IsTrueTypeFont(resource);
|
||||
}
|
||||
|
||||
static int32_t Pnacl_M26_PPB_TrueTypeFont_Dev_Describe(PP_Resource font, struct PP_TrueTypeFontDesc_Dev* desc, struct PP_CompletionCallback* callback) {
|
||||
const struct PPB_TrueTypeFont_Dev_0_1 *iface = Pnacl_WrapperInfo_PPB_TrueTypeFont_Dev_0_1.real_iface;
|
||||
return iface->Describe(font, desc, *callback);
|
||||
}
|
||||
|
||||
static int32_t Pnacl_M26_PPB_TrueTypeFont_Dev_GetTableTags(PP_Resource font, struct PP_ArrayOutput* output, struct PP_CompletionCallback* callback) {
|
||||
const struct PPB_TrueTypeFont_Dev_0_1 *iface = Pnacl_WrapperInfo_PPB_TrueTypeFont_Dev_0_1.real_iface;
|
||||
return iface->GetTableTags(font, *output, *callback);
|
||||
}
|
||||
|
||||
static int32_t Pnacl_M26_PPB_TrueTypeFont_Dev_GetTable(PP_Resource font, uint32_t table, int32_t offset, int32_t max_data_length, struct PP_ArrayOutput* output, struct PP_CompletionCallback* callback) {
|
||||
const struct PPB_TrueTypeFont_Dev_0_1 *iface = Pnacl_WrapperInfo_PPB_TrueTypeFont_Dev_0_1.real_iface;
|
||||
return iface->GetTable(font, table, offset, max_data_length, *output, *callback);
|
||||
}
|
||||
|
||||
/* End wrapper methods for PPB_TrueTypeFont_Dev_0_1 */
|
||||
|
||||
/* Begin wrapper methods for PPB_URLUtil_Dev_0_6 */
|
||||
|
||||
static void Pnacl_M17_PPB_URLUtil_Dev_Canonicalize(struct PP_Var* _struct_result, struct PP_Var* url, struct PP_URLComponents_Dev* components) {
|
||||
@ -5087,16 +5046,6 @@ static const struct PPB_Printing_Dev_0_7 Pnacl_Wrappers_PPB_Printing_Dev_0_7 = {
|
||||
|
||||
/* Not generating wrapper interface for PPB_Trace_Event_Dev_0_2 */
|
||||
|
||||
static const struct PPB_TrueTypeFont_Dev_0_1 Pnacl_Wrappers_PPB_TrueTypeFont_Dev_0_1 = {
|
||||
.GetFontFamilies = (int32_t (*)(PP_Instance instance, struct PP_ArrayOutput output, struct PP_CompletionCallback callback))&Pnacl_M26_PPB_TrueTypeFont_Dev_GetFontFamilies,
|
||||
.GetFontsInFamily = (int32_t (*)(PP_Instance instance, struct PP_Var family, struct PP_ArrayOutput output, struct PP_CompletionCallback callback))&Pnacl_M26_PPB_TrueTypeFont_Dev_GetFontsInFamily,
|
||||
.Create = (PP_Resource (*)(PP_Instance instance, const struct PP_TrueTypeFontDesc_Dev* desc))&Pnacl_M26_PPB_TrueTypeFont_Dev_Create,
|
||||
.IsTrueTypeFont = (PP_Bool (*)(PP_Resource resource))&Pnacl_M26_PPB_TrueTypeFont_Dev_IsTrueTypeFont,
|
||||
.Describe = (int32_t (*)(PP_Resource font, struct PP_TrueTypeFontDesc_Dev* desc, struct PP_CompletionCallback callback))&Pnacl_M26_PPB_TrueTypeFont_Dev_Describe,
|
||||
.GetTableTags = (int32_t (*)(PP_Resource font, struct PP_ArrayOutput output, struct PP_CompletionCallback callback))&Pnacl_M26_PPB_TrueTypeFont_Dev_GetTableTags,
|
||||
.GetTable = (int32_t (*)(PP_Resource font, uint32_t table, int32_t offset, int32_t max_data_length, struct PP_ArrayOutput output, struct PP_CompletionCallback callback))&Pnacl_M26_PPB_TrueTypeFont_Dev_GetTable
|
||||
};
|
||||
|
||||
static const struct PPB_URLUtil_Dev_0_6 Pnacl_Wrappers_PPB_URLUtil_Dev_0_6 = {
|
||||
.Canonicalize = (struct PP_Var (*)(struct PP_Var url, struct PP_URLComponents_Dev* components))&Pnacl_M17_PPB_URLUtil_Dev_Canonicalize,
|
||||
.ResolveRelativeToURL = (struct PP_Var (*)(struct PP_Var base_url, struct PP_Var relative_string, struct PP_URLComponents_Dev* components))&Pnacl_M17_PPB_URLUtil_Dev_ResolveRelativeToURL,
|
||||
@ -5894,12 +5843,6 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Printing_Dev_0_7 = {
|
||||
.real_iface = NULL
|
||||
};
|
||||
|
||||
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TrueTypeFont_Dev_0_1 = {
|
||||
.iface_macro = PPB_TRUETYPEFONT_DEV_INTERFACE_0_1,
|
||||
.wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_TrueTypeFont_Dev_0_1,
|
||||
.real_iface = NULL
|
||||
};
|
||||
|
||||
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_6 = {
|
||||
.iface_macro = PPB_URLUTIL_DEV_INTERFACE_0_6,
|
||||
.wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_URLUtil_Dev_0_6,
|
||||
@ -6183,7 +6126,6 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = {
|
||||
&Pnacl_WrapperInfo_PPB_IMEInputEvent_Dev_0_1,
|
||||
&Pnacl_WrapperInfo_PPB_IMEInputEvent_Dev_0_2,
|
||||
&Pnacl_WrapperInfo_PPB_Printing_Dev_0_7,
|
||||
&Pnacl_WrapperInfo_PPB_TrueTypeFont_Dev_0_1,
|
||||
&Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_6,
|
||||
&Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_7,
|
||||
&Pnacl_WrapperInfo_PPB_VideoCapture_Dev_0_3,
|
||||
|
@ -156,10 +156,6 @@ component("proxy") {
|
||||
"tcp_socket_resource.h",
|
||||
"tcp_socket_resource_base.cc",
|
||||
"tcp_socket_resource_base.h",
|
||||
"truetype_font_resource.cc",
|
||||
"truetype_font_resource.h",
|
||||
"truetype_font_singleton_resource.cc",
|
||||
"truetype_font_singleton_resource.h",
|
||||
"udp_socket_filter.cc",
|
||||
"udp_socket_filter.h",
|
||||
"udp_socket_private_resource.cc",
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "ppapi/c/dev/ppb_printing_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"
|
||||
|
@ -35,7 +35,6 @@
|
||||
#include "ipc/ipc_platform_file.h"
|
||||
#include "ppapi/c/dev/pp_video_capture_dev.h"
|
||||
#include "ppapi/c/dev/pp_video_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"
|
||||
@ -131,14 +130,6 @@ IPC_ENUM_TRAITS_MAX_VALUE(PP_PrivateFontCharset, PP_PRIVATEFONTCHARSET_LAST)
|
||||
IPC_ENUM_TRAITS_MAX_VALUE(PP_TCPSocket_Option,
|
||||
PP_TCPSOCKET_OPTION_RECV_BUFFER_SIZE)
|
||||
IPC_ENUM_TRAITS_MAX_VALUE(PP_TextInput_Type, PP_TEXTINPUT_TYPE_LAST)
|
||||
IPC_ENUM_TRAITS_MAX_VALUE(PP_TrueTypeFontFamily_Dev, PP_TRUETYPEFONTFAMILY_LAST)
|
||||
IPC_ENUM_TRAITS_MAX_VALUE(PP_TrueTypeFontStyle_Dev, PP_TRUETYPEFONTSTYLE_LAST)
|
||||
IPC_ENUM_TRAITS_MIN_MAX_VALUE(PP_TrueTypeFontWeight_Dev,
|
||||
PP_TRUETYPEFONTWEIGHT_FIRST,
|
||||
PP_TRUETYPEFONTWEIGHT_LAST)
|
||||
IPC_ENUM_TRAITS_MAX_VALUE(PP_TrueTypeFontWidth_Dev, PP_TRUETYPEFONTWIDTH_LAST)
|
||||
IPC_ENUM_TRAITS_MAX_VALUE(PP_TrueTypeFontCharset_Dev,
|
||||
PP_TRUETYPEFONTCHARSET_LAST)
|
||||
IPC_ENUM_TRAITS_MAX_VALUE(PP_UDPSocket_Option,
|
||||
PP_UDPSOCKET_OPTION_MULTICAST_TTL)
|
||||
IPC_ENUM_TRAITS_MIN_MAX_VALUE(PP_VideoDecodeError_Dev,
|
||||
@ -1782,32 +1773,6 @@ IPC_MESSAGE_CONTROL1(PpapiHostMsg_NetworkProxy_GetProxyForURL,
|
||||
IPC_MESSAGE_CONTROL1(PpapiPluginMsg_NetworkProxy_GetProxyForURLReply,
|
||||
std::string /* proxy */)
|
||||
|
||||
// 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_TrueTypeFontSingleton_GetFontsInFamily,
|
||||
std::string /* family */)
|
||||
IPC_MESSAGE_CONTROL1(PpapiPluginMsg_TrueTypeFontSingleton_GetFontsInFamilyReply,
|
||||
std::vector<ppapi::proxy::SerializedTrueTypeFontDesc>
|
||||
/* fonts */)
|
||||
IPC_MESSAGE_CONTROL1(PpapiHostMsg_TrueTypeFont_Create,
|
||||
ppapi::proxy::SerializedTrueTypeFontDesc /* desc */)
|
||||
// Unsolicited reply to return the actual font's desc to the plugin.
|
||||
IPC_MESSAGE_CONTROL2(PpapiPluginMsg_TrueTypeFont_CreateReply,
|
||||
ppapi::proxy::SerializedTrueTypeFontDesc /* desc */,
|
||||
int32_t /* result */)
|
||||
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 */)
|
||||
|
||||
// Host Resolver ---------------------------------------------------------------
|
||||
// Creates a PPB_HostResolver resource.
|
||||
IPC_MESSAGE_CONTROL0(PpapiHostMsg_HostResolver_Create)
|
||||
|
@ -435,37 +435,6 @@ void ParamTraits<ppapi::proxy::SerializedFontDescription>::Log(
|
||||
}
|
||||
#endif // !defined(OS_NACL) && !defined(NACL_WIN64)
|
||||
|
||||
// ppapi::proxy::SerializedTrueTypeFontDesc ------------------------------------
|
||||
|
||||
// static
|
||||
void ParamTraits<ppapi::proxy::SerializedTrueTypeFontDesc>::Write(
|
||||
base::Pickle* m,
|
||||
const param_type& p) {
|
||||
WriteParam(m, p.family);
|
||||
WriteParam(m, p.generic_family);
|
||||
WriteParam(m, p.style);
|
||||
WriteParam(m, p.weight);
|
||||
WriteParam(m, p.width);
|
||||
WriteParam(m, p.charset);
|
||||
}
|
||||
|
||||
// static
|
||||
bool ParamTraits<ppapi::proxy::SerializedTrueTypeFontDesc>::Read(
|
||||
const base::Pickle* m,
|
||||
base::PickleIterator* iter,
|
||||
param_type* r) {
|
||||
return ReadParam(m, iter, &r->family) &&
|
||||
ReadParam(m, iter, &r->generic_family) &&
|
||||
ReadParam(m, iter, &r->style) && ReadParam(m, iter, &r->weight) &&
|
||||
ReadParam(m, iter, &r->width) && ReadParam(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 -------------------------------------------------------
|
||||
|
||||
|
@ -34,7 +34,6 @@ struct PPBFlash_DrawGlyphs_Params;
|
||||
struct PPBURLLoader_UpdateProgress_Params;
|
||||
struct SerializedDirEntry;
|
||||
struct SerializedFontDescription;
|
||||
struct SerializedTrueTypeFontDesc;
|
||||
class SerializedFlashMenu;
|
||||
class SerializedHandle;
|
||||
class SerializedVar;
|
||||
@ -106,17 +105,6 @@ struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::proxy::SerializedFontDescription> {
|
||||
static void Log(const param_type& p, std::string* l);
|
||||
};
|
||||
|
||||
template<>
|
||||
struct PPAPI_PROXY_EXPORT
|
||||
ParamTraits<ppapi::proxy::SerializedTrueTypeFontDesc> {
|
||||
typedef ppapi::proxy::SerializedTrueTypeFontDesc param_type;
|
||||
static void Write(base::Pickle* m, const param_type& p);
|
||||
static bool Read(const base::Pickle* m,
|
||||
base::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;
|
||||
|
@ -34,7 +34,6 @@
|
||||
#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/proxy/uma_private_resource.h"
|
||||
#include "ppapi/shared_impl/array_var.h"
|
||||
#include "ppapi/shared_impl/ppapi_globals.h"
|
||||
@ -362,9 +361,6 @@ Resource* PPB_Instance_Proxy::GetSingletonResource(PP_Instance instance,
|
||||
case NETWORK_PROXY_SINGLETON_ID:
|
||||
new_singleton = new NetworkProxyResource(connection, instance);
|
||||
break;
|
||||
case TRUETYPE_FONT_SINGLETON_ID:
|
||||
new_singleton = new TrueTypeFontSingletonResource(connection, instance);
|
||||
break;
|
||||
case UMA_SINGLETON_ID:
|
||||
new_singleton = new UMAPrivateResource(connection, instance);
|
||||
break;
|
||||
|
@ -41,7 +41,6 @@
|
||||
#include "ppapi/proxy/tcp_server_socket_private_resource.h"
|
||||
#include "ppapi/proxy/tcp_socket_private_resource.h"
|
||||
#include "ppapi/proxy/tcp_socket_resource.h"
|
||||
#include "ppapi/proxy/truetype_font_resource.h"
|
||||
#include "ppapi/proxy/udp_socket_private_resource.h"
|
||||
#include "ppapi/proxy/udp_socket_resource.h"
|
||||
#include "ppapi/proxy/url_loader_resource.h"
|
||||
@ -159,14 +158,6 @@ PP_Resource ResourceCreationProxy::CreateTouchInputEvent(
|
||||
OBJECT_IS_PROXY, instance, type, time_stamp, modifiers);
|
||||
}
|
||||
|
||||
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 (new URLLoaderResource(GetConnection(), instance))->GetReference();
|
||||
}
|
||||
|
@ -82,9 +82,6 @@ class ResourceCreationProxy : public InterfaceProxy,
|
||||
PP_InputEvent_Type type,
|
||||
PP_TimeTicks time_stamp,
|
||||
uint32_t modifiers) override;
|
||||
PP_Resource CreateTrueTypeFont(
|
||||
PP_Instance instance,
|
||||
const PP_TrueTypeFontDesc_Dev* desc) override;
|
||||
PP_Resource CreateURLLoader(PP_Instance instance) override;
|
||||
PP_Resource CreateURLRequestInfo(PP_Instance instance) override;
|
||||
PP_Resource CreateWheelInputEvent(
|
||||
|
@ -61,40 +61,6 @@ SerializedNetworkInfo::SerializedNetworkInfo()
|
||||
|
||||
SerializedNetworkInfo::~SerializedNetworkInfo() {}
|
||||
|
||||
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(),
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "build/build_config.h"
|
||||
#include "ppapi/c/dev/ppb_truetype_font_dev.h"
|
||||
#include "ppapi/c/pp_bool.h"
|
||||
#include "ppapi/c/pp_codecs.h"
|
||||
#include "ppapi/c/pp_instance.h"
|
||||
@ -62,30 +61,6 @@ struct PPAPI_PROXY_EXPORT SerializedNetworkInfo {
|
||||
};
|
||||
typedef std::vector<SerializedNetworkInfo> SerializedNetworkList;
|
||||
|
||||
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_TrueTypeFontDesc_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;
|
||||
|
@ -1,164 +0,0 @@
|
||||
// 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),
|
||||
create_result_(PP_OK_COMPLETIONPENDING),
|
||||
describe_desc_(NULL) {
|
||||
SerializedTrueTypeFontDesc serialized_desc;
|
||||
serialized_desc.SetFromPPTrueTypeFontDesc(desc);
|
||||
SendCreate(BROWSER, 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) {
|
||||
if (describe_callback_.get())
|
||||
return PP_ERROR_INPROGRESS;
|
||||
|
||||
if (create_result_ == PP_OK) {
|
||||
desc_.CopyToPPTrueTypeFontDesc(desc);
|
||||
} else if (create_result_ == PP_OK_COMPLETIONPENDING) {
|
||||
describe_desc_ = desc;
|
||||
describe_callback_ = callback;
|
||||
}
|
||||
|
||||
return create_result_;
|
||||
}
|
||||
|
||||
int32_t TrueTypeFontResource::GetTableTags(
|
||||
const PP_ArrayOutput& output,
|
||||
scoped_refptr<TrackedCallback> callback) {
|
||||
Call<PpapiPluginMsg_TrueTypeFont_GetTableTagsReply>(
|
||||
BROWSER,
|
||||
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>(
|
||||
BROWSER,
|
||||
PpapiHostMsg_TrueTypeFont_GetTable(table, offset, max_data_length),
|
||||
base::Bind(&TrueTypeFontResource::OnPluginMsgGetTableComplete,
|
||||
this,
|
||||
callback,
|
||||
output));
|
||||
|
||||
return PP_OK_COMPLETIONPENDING;
|
||||
}
|
||||
|
||||
void TrueTypeFontResource::OnReplyReceived(
|
||||
const ResourceMessageReplyParams& params,
|
||||
const IPC::Message& msg) {
|
||||
PPAPI_BEGIN_MESSAGE_MAP(TrueTypeFontResource, msg)
|
||||
PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(PpapiPluginMsg_TrueTypeFont_CreateReply,
|
||||
OnPluginMsgCreateComplete)
|
||||
PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED(
|
||||
PluginResource::OnReplyReceived(params, msg))
|
||||
PPAPI_END_MESSAGE_MAP()
|
||||
}
|
||||
|
||||
void TrueTypeFontResource::OnPluginMsgCreateComplete(
|
||||
const ResourceMessageReplyParams& params,
|
||||
const ppapi::proxy::SerializedTrueTypeFontDesc& desc,
|
||||
int32_t result) {
|
||||
DCHECK(result != PP_OK_COMPLETIONPENDING);
|
||||
DCHECK(create_result_ == PP_OK_COMPLETIONPENDING);
|
||||
create_result_ = result;
|
||||
if (create_result_ == PP_OK)
|
||||
desc_ = desc;
|
||||
|
||||
// Now complete any pending Describe operation.
|
||||
if (TrackedCallback::IsPending(describe_callback_)) {
|
||||
desc_.CopyToPPTrueTypeFontDesc(describe_desc_);
|
||||
describe_desc_ = NULL;
|
||||
scoped_refptr<TrackedCallback> callback;
|
||||
callback.swap(describe_callback_);
|
||||
callback->Run(create_result_ == PP_OK ? PP_OK : PP_ERROR_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
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
|
@ -1,89 +0,0 @@
|
||||
// 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 <stdint.h>
|
||||
|
||||
#include <queue>
|
||||
#include <string>
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "ppapi/proxy/connection.h"
|
||||
#include "ppapi/proxy/plugin_resource.h"
|
||||
#include "ppapi/proxy/ppapi_proxy_export.h"
|
||||
#include "ppapi/proxy/serialized_structs.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);
|
||||
~TrueTypeFontResource() override;
|
||||
|
||||
// Resource implementation.
|
||||
thunk::PPB_TrueTypeFont_API* AsPPB_TrueTypeFont_API() override;
|
||||
|
||||
// PPB_TrueTypeFont_API implementation.
|
||||
int32_t Describe(
|
||||
PP_TrueTypeFontDesc_Dev* desc,
|
||||
scoped_refptr<TrackedCallback> callback) override;
|
||||
int32_t GetTableTags(
|
||||
const PP_ArrayOutput& output,
|
||||
scoped_refptr<TrackedCallback> callback) override;
|
||||
int32_t GetTable(
|
||||
uint32_t table,
|
||||
int32_t offset,
|
||||
int32_t max_data_length,
|
||||
const PP_ArrayOutput& output,
|
||||
scoped_refptr<TrackedCallback> callback) override;
|
||||
|
||||
// PluginResource implementation.
|
||||
void OnReplyReceived(const ResourceMessageReplyParams& params,
|
||||
const IPC::Message& msg) override;
|
||||
|
||||
private:
|
||||
void OnPluginMsgCreateComplete(
|
||||
const ResourceMessageReplyParams& params,
|
||||
const ppapi::proxy::SerializedTrueTypeFontDesc& desc,
|
||||
int32_t result);
|
||||
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);
|
||||
|
||||
int32_t create_result_;
|
||||
// Valid only when create_result_ == PP_OK.
|
||||
ppapi::proxy::SerializedTrueTypeFontDesc desc_;
|
||||
|
||||
// Params for pending Describe call.
|
||||
PP_TrueTypeFontDesc_Dev* describe_desc_;
|
||||
scoped_refptr<TrackedCallback> describe_callback_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(TrueTypeFontResource);
|
||||
};
|
||||
|
||||
} // namespace proxy
|
||||
} // namespace ppapi
|
||||
|
||||
#endif // PPAPI_PROXY_TRUETYPE_FONT_RESOURCE_H_
|
@ -1,124 +0,0 @@
|
||||
// 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 <stddef.h>
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "ppapi/proxy/ppapi_messages.h"
|
||||
#include "ppapi/proxy/serialized_structs.h"
|
||||
#include "ppapi/shared_impl/array_writer.h"
|
||||
#include "ppapi/shared_impl/ppapi_globals.h"
|
||||
#include "ppapi/shared_impl/tracked_callback.h"
|
||||
#include "ppapi/shared_impl/var.h"
|
||||
#include "ppapi/shared_impl/var_tracker.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;
|
||||
}
|
||||
|
||||
int32_t TrueTypeFontSingletonResource::GetFontsInFamily(
|
||||
PP_Instance instance,
|
||||
PP_Var family,
|
||||
const PP_ArrayOutput& output,
|
||||
const scoped_refptr<TrackedCallback>& callback) {
|
||||
scoped_refptr<StringVar> family_var = StringVar::FromPPVar(family);
|
||||
const uint32_t kMaxFamilySizeInBytes = 1024;
|
||||
if (!family_var.get() || family_var->value().size() > kMaxFamilySizeInBytes)
|
||||
return PP_ERROR_BADARGUMENT;
|
||||
Call<PpapiPluginMsg_TrueTypeFontSingleton_GetFontsInFamilyReply>(BROWSER,
|
||||
PpapiHostMsg_TrueTypeFontSingleton_GetFontsInFamily(family_var->value()),
|
||||
base::Bind(
|
||||
&TrueTypeFontSingletonResource::OnPluginMsgGetFontsInFamilyComplete,
|
||||
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) {
|
||||
if (!TrackedCallback::IsPending(callback))
|
||||
return;
|
||||
// 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);
|
||||
}
|
||||
|
||||
void TrueTypeFontSingletonResource::OnPluginMsgGetFontsInFamilyComplete(
|
||||
scoped_refptr<TrackedCallback> callback,
|
||||
PP_ArrayOutput array_output,
|
||||
const ResourceMessageReplyParams& params,
|
||||
const std::vector<SerializedTrueTypeFontDesc>& fonts) {
|
||||
if (!TrackedCallback::IsPending(callback))
|
||||
return;
|
||||
// The result code should contain the data size if it's positive.
|
||||
int32_t result = params.result();
|
||||
DCHECK((result < 0 && fonts.size() == 0) ||
|
||||
result == static_cast<int32_t>(fonts.size()));
|
||||
ArrayWriter output;
|
||||
output.set_pp_array_output(array_output);
|
||||
if (output.is_valid()) {
|
||||
// Convert the message data to an array of PP_TrueTypeFontDesc_Dev structs.
|
||||
// Each desc has an embedded PP_Var containing the family name.
|
||||
std::vector<PP_TrueTypeFontDesc_Dev> pp_fonts(fonts.size());
|
||||
for (size_t i = 0; i < fonts.size(); i++)
|
||||
fonts[i].CopyToPPTrueTypeFontDesc(&pp_fonts[i]);
|
||||
|
||||
if (!output.StoreVector(pp_fonts)) {
|
||||
for (size_t i = 0; i < pp_fonts.size(); i++)
|
||||
PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(pp_fonts[i].family);
|
||||
}
|
||||
} else {
|
||||
result = PP_ERROR_FAILED;
|
||||
}
|
||||
|
||||
callback->Run(result);
|
||||
}
|
||||
|
||||
} // namespace proxy
|
||||
} // namespace ppapi
|
@ -1,68 +0,0 @@
|
||||
// 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 <stdint.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "base/macros.h"
|
||||
#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 SerializedTrueTypeFontDesc;
|
||||
|
||||
// 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);
|
||||
~TrueTypeFontSingletonResource() override;
|
||||
|
||||
// Resource override.
|
||||
thunk::PPB_TrueTypeFont_Singleton_API* AsPPB_TrueTypeFont_Singleton_API()
|
||||
override;
|
||||
|
||||
// thunk::PPB_TrueTypeFont_Singleton_API implementation.
|
||||
int32_t GetFontFamilies(
|
||||
PP_Instance instance,
|
||||
const PP_ArrayOutput& output,
|
||||
const scoped_refptr<TrackedCallback>& callback) override;
|
||||
int32_t GetFontsInFamily(
|
||||
PP_Instance instance,
|
||||
PP_Var family,
|
||||
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);
|
||||
void OnPluginMsgGetFontsInFamilyComplete(
|
||||
scoped_refptr<TrackedCallback> callback,
|
||||
PP_ArrayOutput array_output,
|
||||
const ResourceMessageReplyParams& params,
|
||||
const std::vector<SerializedTrueTypeFontDesc>& fonts);
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(TrueTypeFontSingletonResource);
|
||||
};
|
||||
|
||||
} // namespace proxy
|
||||
} // namespace ppapi
|
||||
|
||||
#endif // PPAPI_PROXY_TRUETYPE_FONT_SINGLETON_RESOURCE_H_
|
@ -66,8 +66,6 @@
|
||||
F(PPB_PDF_API) \
|
||||
F(PPB_Printing_API) \
|
||||
F(PPB_Scrollbar_API) \
|
||||
F(PPB_TrueTypeFont_API) \
|
||||
F(PPB_TrueTypeFont_Singleton_API) \
|
||||
F(PPB_TCPServerSocket_Private_API) \
|
||||
F(PPB_TCPSocket_API) \
|
||||
F(PPB_TCPSocket_Private_API) \
|
||||
|
@ -23,7 +23,6 @@ enum SingletonResourceID {
|
||||
ISOLATED_FILESYSTEM_SINGLETON_ID,
|
||||
NETWORK_PROXY_SINGLETON_ID,
|
||||
PDF_SINGLETON_ID,
|
||||
TRUETYPE_FONT_SINGLETON_ID,
|
||||
UMA_SINGLETON_ID,
|
||||
};
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "ppapi/c/dev/ppb_printing_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"
|
||||
|
@ -1,436 +0,0 @@
|
||||
// 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.
|
||||
//
|
||||
// Tests PPB_TrueTypeFont interface.
|
||||
|
||||
#include "ppapi/tests/test_truetype_font.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
|
||||
#include "ppapi/c/private/ppb_testing_private.h"
|
||||
#include "ppapi/cpp/completion_callback.h"
|
||||
#include "ppapi/cpp/dev/truetype_font_dev.h"
|
||||
#include "ppapi/cpp/instance.h"
|
||||
#include "ppapi/cpp/var.h"
|
||||
#include "ppapi/tests/test_utils.h"
|
||||
#include "ppapi/tests/testing_instance.h"
|
||||
|
||||
REGISTER_TEST_CASE(TrueTypeFont);
|
||||
|
||||
#define MAKE_TABLE_TAG(a, b, c, d) ((a) << 24) + ((b) << 16) + ((c) << 8) + (d)
|
||||
|
||||
namespace {
|
||||
|
||||
const PP_Resource kInvalidResource = 0;
|
||||
const PP_Instance kInvalidInstance = 0;
|
||||
|
||||
// TrueType font header and table entry structs. See
|
||||
// https://developer.apple.com/fonts/TTRefMan/RM06/Chap6.html
|
||||
struct FontHeader {
|
||||
int32_t font_type;
|
||||
uint16_t num_tables;
|
||||
uint16_t search_range;
|
||||
uint16_t entry_selector;
|
||||
uint16_t range_shift;
|
||||
};
|
||||
|
||||
struct FontDirectoryEntry {
|
||||
uint32_t tag;
|
||||
uint32_t checksum;
|
||||
uint32_t offset;
|
||||
uint32_t logical_length;
|
||||
};
|
||||
|
||||
uint32_t ReadBigEndian32(const void* ptr) {
|
||||
const uint8_t* data = reinterpret_cast<const uint8_t*>(ptr);
|
||||
return (data[3] << 0) | (data[2] << 8) | (data[1] << 16) | (data[0] << 24);
|
||||
}
|
||||
|
||||
uint16_t ReadBigEndian16(const void* ptr) {
|
||||
const uint8_t* data = reinterpret_cast<const uint8_t*>(ptr);
|
||||
return (data[1] << 0) | (data[0] << 8);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TestTrueTypeFont::TestTrueTypeFont(TestingInstance* instance)
|
||||
: TestCase(instance),
|
||||
ppb_truetype_font_interface_(NULL),
|
||||
ppb_core_interface_(NULL),
|
||||
ppb_var_interface_(NULL) {
|
||||
}
|
||||
|
||||
bool TestTrueTypeFont::Init() {
|
||||
ppb_truetype_font_interface_ = static_cast<const PPB_TrueTypeFont_Dev*>(
|
||||
pp::Module::Get()->GetBrowserInterface(PPB_TRUETYPEFONT_DEV_INTERFACE));
|
||||
if (!ppb_truetype_font_interface_)
|
||||
instance_->AppendError("PPB_TrueTypeFont_Dev interface not available");
|
||||
|
||||
ppb_core_interface_ = static_cast<const PPB_Core*>(
|
||||
pp::Module::Get()->GetBrowserInterface(PPB_CORE_INTERFACE));
|
||||
if (!ppb_core_interface_)
|
||||
instance_->AppendError("PPB_Core interface not available");
|
||||
|
||||
ppb_var_interface_ = static_cast<const PPB_Var*>(
|
||||
pp::Module::Get()->GetBrowserInterface(PPB_VAR_INTERFACE));
|
||||
if (!ppb_var_interface_)
|
||||
instance_->AppendError("PPB_Var interface not available");
|
||||
|
||||
return
|
||||
ppb_truetype_font_interface_ &&
|
||||
ppb_core_interface_ &&
|
||||
ppb_var_interface_;
|
||||
}
|
||||
|
||||
TestTrueTypeFont::~TestTrueTypeFont() {
|
||||
}
|
||||
|
||||
void TestTrueTypeFont::RunTests(const std::string& filter) {
|
||||
RUN_TEST(GetFontFamilies, filter);
|
||||
RUN_TEST(GetFontsInFamily, filter);
|
||||
RUN_TEST(Create, filter);
|
||||
RUN_TEST(Describe, filter);
|
||||
RUN_TEST(GetTableTags, filter);
|
||||
RUN_TEST(GetTable, filter);
|
||||
}
|
||||
|
||||
std::string TestTrueTypeFont::TestGetFontFamilies() {
|
||||
{
|
||||
// A valid instance should be able to enumerate fonts.
|
||||
TestCompletionCallbackWithOutput< std::vector<pp::Var> > cc(
|
||||
instance_->pp_instance(), false);
|
||||
cc.WaitForResult(pp::TrueTypeFont_Dev::GetFontFamilies(instance_,
|
||||
cc.GetCallback()));
|
||||
const std::vector<pp::Var> font_families = cc.output();
|
||||
// We should get some font families on any platform.
|
||||
ASSERT_NE(0, font_families.size());
|
||||
ASSERT_EQ(static_cast<int32_t>(font_families.size()), cc.result());
|
||||
// Make sure at least one family is a non-empty string.
|
||||
ASSERT_NE(0, font_families[0].AsString().size());
|
||||
}
|
||||
{
|
||||
// Using an invalid instance should fail.
|
||||
TestCompletionCallbackWithOutput< std::vector<pp::Var> > cc(
|
||||
instance_->pp_instance(), false);
|
||||
cc.WaitForResult(
|
||||
ppb_truetype_font_interface_->GetFontFamilies(
|
||||
kInvalidInstance,
|
||||
cc.GetCallback().output(),
|
||||
cc.GetCallback().pp_completion_callback()));
|
||||
ASSERT_TRUE(cc.result() == PP_ERROR_FAILED ||
|
||||
cc.result() == PP_ERROR_BADARGUMENT);
|
||||
ASSERT_EQ(0, cc.output().size());
|
||||
}
|
||||
|
||||
PASS();
|
||||
}
|
||||
|
||||
std::string TestTrueTypeFont::TestGetFontsInFamily() {
|
||||
{
|
||||
// Get the list of all font families.
|
||||
TestCompletionCallbackWithOutput< std::vector<pp::Var> > cc(
|
||||
instance_->pp_instance(), false);
|
||||
cc.WaitForResult(pp::TrueTypeFont_Dev::GetFontFamilies(instance_,
|
||||
cc.GetCallback()));
|
||||
// Try to use a common family that is likely to have multiple variations.
|
||||
const std::vector<pp::Var> families = cc.output();
|
||||
pp::Var family("Arial");
|
||||
if (std::find(families.begin(), families.end(), family) == families.end()) {
|
||||
family = pp::Var("Times");
|
||||
if (std::find(families.begin(), families.end(), family) == families.end())
|
||||
family = families[0]; // Just use the first family.
|
||||
}
|
||||
|
||||
// GetFontsInFamily: A valid instance should be able to enumerate fonts
|
||||
// in a given family.
|
||||
TestCompletionCallbackWithOutput< std::vector<pp::TrueTypeFontDesc_Dev> >
|
||||
cc2(instance_->pp_instance(), false);
|
||||
cc2.WaitForResult(pp::TrueTypeFont_Dev::GetFontsInFamily(
|
||||
instance_,
|
||||
family,
|
||||
cc2.GetCallback()));
|
||||
std::vector<pp::TrueTypeFontDesc_Dev> fonts_in_family = cc2.output();
|
||||
ASSERT_NE(0, fonts_in_family.size());
|
||||
ASSERT_EQ(static_cast<int32_t>(fonts_in_family.size()), cc2.result());
|
||||
|
||||
// We should be able to create any of the returned fonts without fallback.
|
||||
for (size_t i = 0; i < fonts_in_family.size(); ++i) {
|
||||
pp::TrueTypeFontDesc_Dev& font_in_family = fonts_in_family[i];
|
||||
pp::TrueTypeFont_Dev font(instance_, font_in_family);
|
||||
TestCompletionCallbackWithOutput<pp::TrueTypeFontDesc_Dev> cc(
|
||||
instance_->pp_instance(), false);
|
||||
cc.WaitForResult(font.Describe(cc.GetCallback()));
|
||||
const pp::TrueTypeFontDesc_Dev desc = cc.output();
|
||||
|
||||
ASSERT_EQ(family, desc.family());
|
||||
ASSERT_EQ(font_in_family.style(), desc.style());
|
||||
ASSERT_EQ(font_in_family.weight(), desc.weight());
|
||||
}
|
||||
}
|
||||
{
|
||||
// Using an invalid instance should fail.
|
||||
TestCompletionCallbackWithOutput< std::vector<pp::TrueTypeFontDesc_Dev> >
|
||||
cc(instance_->pp_instance(), false);
|
||||
pp::Var family("Times");
|
||||
cc.WaitForResult(
|
||||
ppb_truetype_font_interface_->GetFontsInFamily(
|
||||
kInvalidInstance,
|
||||
family.pp_var(),
|
||||
cc.GetCallback().output(),
|
||||
cc.GetCallback().pp_completion_callback()));
|
||||
ASSERT_TRUE(cc.result() == PP_ERROR_FAILED ||
|
||||
cc.result() == PP_ERROR_BADARGUMENT);
|
||||
ASSERT_EQ(0, cc.output().size());
|
||||
}
|
||||
|
||||
PASS();
|
||||
}
|
||||
|
||||
std::string TestTrueTypeFont::TestCreate() {
|
||||
PP_Resource font;
|
||||
PP_TrueTypeFontDesc_Dev desc = {
|
||||
PP_MakeUndefined(),
|
||||
PP_TRUETYPEFONTFAMILY_SERIF,
|
||||
PP_TRUETYPEFONTSTYLE_NORMAL,
|
||||
PP_TRUETYPEFONTWEIGHT_NORMAL,
|
||||
PP_TRUETYPEFONTWIDTH_NORMAL,
|
||||
PP_TRUETYPEFONTCHARSET_DEFAULT
|
||||
};
|
||||
// Creating a font from an invalid instance returns an invalid resource.
|
||||
font = ppb_truetype_font_interface_->Create(kInvalidInstance, &desc);
|
||||
ASSERT_EQ(kInvalidResource, font);
|
||||
ASSERT_NE(PP_TRUE, ppb_truetype_font_interface_->IsTrueTypeFont(font));
|
||||
|
||||
// Creating a font from a valid instance returns a font resource.
|
||||
font = ppb_truetype_font_interface_->Create(instance_->pp_instance(), &desc);
|
||||
ASSERT_NE(kInvalidResource, font);
|
||||
ASSERT_EQ(PP_TRUE, ppb_truetype_font_interface_->IsTrueTypeFont(font));
|
||||
|
||||
ppb_core_interface_->ReleaseResource(font);
|
||||
// Once released, the resource shouldn't be a font.
|
||||
ASSERT_NE(PP_TRUE, ppb_truetype_font_interface_->IsTrueTypeFont(font));
|
||||
|
||||
PASS();
|
||||
}
|
||||
|
||||
std::string TestTrueTypeFont::TestDescribe() {
|
||||
pp::TrueTypeFontDesc_Dev create_desc;
|
||||
create_desc.set_generic_family(PP_TRUETYPEFONTFAMILY_SERIF);
|
||||
create_desc.set_style(PP_TRUETYPEFONTSTYLE_NORMAL);
|
||||
create_desc.set_weight(PP_TRUETYPEFONTWEIGHT_NORMAL);
|
||||
pp::TrueTypeFont_Dev font(instance_, create_desc);
|
||||
// Describe: See what font-matching did with a generic font. We should always
|
||||
// be able to Create a generic Serif font.
|
||||
TestCompletionCallbackWithOutput<pp::TrueTypeFontDesc_Dev> cc(
|
||||
instance_->pp_instance(), false);
|
||||
cc.WaitForResult(font.Describe(cc.GetCallback()));
|
||||
const pp::TrueTypeFontDesc_Dev desc = cc.output();
|
||||
ASSERT_NE(0, desc.family().AsString().size());
|
||||
ASSERT_EQ(PP_TRUETYPEFONTFAMILY_SERIF, desc.generic_family());
|
||||
ASSERT_EQ(PP_TRUETYPEFONTSTYLE_NORMAL, desc.style());
|
||||
ASSERT_EQ(PP_TRUETYPEFONTWEIGHT_NORMAL, desc.weight());
|
||||
|
||||
// Describe an invalid resource should fail.
|
||||
PP_TrueTypeFontDesc_Dev fail_desc;
|
||||
memset(&fail_desc, 0, sizeof(fail_desc));
|
||||
fail_desc.family = PP_MakeUndefined();
|
||||
// Create a shallow copy to check that no data is changed.
|
||||
PP_TrueTypeFontDesc_Dev fail_desc_copy;
|
||||
memcpy(&fail_desc_copy, &fail_desc, sizeof(fail_desc));
|
||||
|
||||
cc.WaitForResult(
|
||||
ppb_truetype_font_interface_->Describe(
|
||||
kInvalidResource,
|
||||
&fail_desc,
|
||||
cc.GetCallback().pp_completion_callback()));
|
||||
ASSERT_EQ(PP_ERROR_BADRESOURCE, cc.result());
|
||||
ASSERT_EQ(PP_VARTYPE_UNDEFINED, fail_desc.family.type);
|
||||
ASSERT_EQ(0, memcmp(&fail_desc, &fail_desc_copy, sizeof(fail_desc)));
|
||||
|
||||
PASS();
|
||||
}
|
||||
|
||||
std::string TestTrueTypeFont::TestGetTableTags() {
|
||||
pp::TrueTypeFontDesc_Dev desc;
|
||||
pp::TrueTypeFont_Dev font(instance_, desc);
|
||||
{
|
||||
TestCompletionCallbackWithOutput< std::vector<uint32_t> > cc(
|
||||
instance_->pp_instance(), false);
|
||||
cc.WaitForResult(font.GetTableTags(cc.GetCallback()));
|
||||
std::vector<uint32_t> tags = cc.output();
|
||||
ASSERT_NE(0, tags.size());
|
||||
ASSERT_EQ(static_cast<int32_t>(tags.size()), cc.result());
|
||||
// Tags will vary depending on the actual font that the host platform
|
||||
// chooses. Check that all required TrueType tags are present.
|
||||
const int required_tag_count = 9;
|
||||
uint32_t required_tags[required_tag_count] = {
|
||||
// Note: these must be sorted for std::includes below.
|
||||
MAKE_TABLE_TAG('c', 'm', 'a', 'p'),
|
||||
MAKE_TABLE_TAG('g', 'l', 'y', 'f'),
|
||||
MAKE_TABLE_TAG('h', 'e', 'a', 'd'),
|
||||
MAKE_TABLE_TAG('h', 'h', 'e', 'a'),
|
||||
MAKE_TABLE_TAG('h', 'm', 't', 'x'),
|
||||
MAKE_TABLE_TAG('l', 'o', 'c', 'a'),
|
||||
MAKE_TABLE_TAG('m', 'a', 'x', 'p'),
|
||||
MAKE_TABLE_TAG('n', 'a', 'm', 'e'),
|
||||
MAKE_TABLE_TAG('p', 'o', 's', 't')
|
||||
};
|
||||
std::sort(tags.begin(), tags.end());
|
||||
ASSERT_TRUE(std::includes(tags.begin(),
|
||||
tags.end(),
|
||||
required_tags,
|
||||
required_tags + required_tag_count));
|
||||
}
|
||||
{
|
||||
// Invalid resource should fail and write no data.
|
||||
TestCompletionCallbackWithOutput< std::vector<uint32_t> > cc(
|
||||
instance_->pp_instance(), false);
|
||||
cc.WaitForResult(
|
||||
ppb_truetype_font_interface_->GetTableTags(
|
||||
kInvalidResource,
|
||||
cc.GetCallback().output(),
|
||||
cc.GetCallback().pp_completion_callback()));
|
||||
ASSERT_EQ(PP_ERROR_BADRESOURCE, cc.result());
|
||||
ASSERT_EQ(0, cc.output().size());
|
||||
}
|
||||
|
||||
PASS();
|
||||
}
|
||||
|
||||
std::string TestTrueTypeFont::TestGetTable() {
|
||||
pp::TrueTypeFontDesc_Dev desc;
|
||||
pp::TrueTypeFont_Dev font(instance_, desc);
|
||||
|
||||
{
|
||||
// Getting a required table from a valid font should succeed.
|
||||
TestCompletionCallbackWithOutput< std::vector<char> > cc1(
|
||||
instance_->pp_instance(), false);
|
||||
cc1.WaitForResult(font.GetTable(MAKE_TABLE_TAG('c', 'm', 'a', 'p'),
|
||||
0, std::numeric_limits<int32_t>::max(),
|
||||
cc1.GetCallback()));
|
||||
const std::vector<char> cmap_data = cc1.output();
|
||||
ASSERT_NE(0, cmap_data.size());
|
||||
ASSERT_EQ(static_cast<int32_t>(cmap_data.size()), cc1.result());
|
||||
|
||||
// Passing 0 for the table tag should return the entire font.
|
||||
TestCompletionCallbackWithOutput< std::vector<char> > cc2(
|
||||
instance_->pp_instance(), false);
|
||||
cc2.WaitForResult(font.GetTable(0 /* table_tag */,
|
||||
0, std::numeric_limits<int32_t>::max(),
|
||||
cc2.GetCallback()));
|
||||
const std::vector<char> entire_font = cc2.output();
|
||||
ASSERT_NE(0, entire_font.size());
|
||||
ASSERT_EQ(static_cast<int32_t>(entire_font.size()), cc2.result());
|
||||
|
||||
// Verify that the CMAP table is in entire_font, and that it's identical
|
||||
// to the one we retrieved above. Note that since the font header and table
|
||||
// directory are in file (big-endian) order, we need to byte swap tags and
|
||||
// numbers.
|
||||
const size_t kHeaderSize = sizeof(FontHeader);
|
||||
const size_t kEntrySize = sizeof(FontDirectoryEntry);
|
||||
ASSERT_TRUE(kHeaderSize < entire_font.size());
|
||||
FontHeader header;
|
||||
memcpy(&header, &entire_font[0], kHeaderSize);
|
||||
uint16_t num_tables = ReadBigEndian16(&header.num_tables);
|
||||
std::vector<FontDirectoryEntry> directory(num_tables);
|
||||
size_t directory_size = kEntrySize * num_tables;
|
||||
ASSERT_TRUE(kHeaderSize + directory_size < entire_font.size());
|
||||
memcpy(&directory[0], &entire_font[kHeaderSize], directory_size);
|
||||
const FontDirectoryEntry* cmap_entry = NULL;
|
||||
for (uint16_t i = 0; i < num_tables; i++) {
|
||||
if (ReadBigEndian32(&directory[i].tag) ==
|
||||
MAKE_TABLE_TAG('c', 'm', 'a', 'p')) {
|
||||
cmap_entry = &directory[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
ASSERT_NE(NULL, cmap_entry);
|
||||
|
||||
uint32_t logical_length = ReadBigEndian32(&cmap_entry->logical_length);
|
||||
uint32_t table_offset = ReadBigEndian32(&cmap_entry->offset);
|
||||
ASSERT_EQ(static_cast<size_t>(logical_length), cmap_data.size());
|
||||
ASSERT_TRUE(static_cast<size_t>(table_offset + logical_length) <
|
||||
entire_font.size());
|
||||
const char* cmap_table = &entire_font[0] + table_offset;
|
||||
ASSERT_EQ(0, memcmp(cmap_table, &cmap_data[0], cmap_data.size()));
|
||||
|
||||
// Use offset and max_data_length to restrict the data. Read a part of
|
||||
// the 'CMAP' table.
|
||||
TestCompletionCallbackWithOutput< std::vector<char> > cc3(
|
||||
instance_->pp_instance(), false);
|
||||
const int32_t kOffset = 4;
|
||||
int32_t partial_cmap_size = static_cast<int32_t>(cmap_data.size() - 64);
|
||||
cc3.WaitForResult(font.GetTable(MAKE_TABLE_TAG('c', 'm', 'a', 'p'),
|
||||
kOffset,
|
||||
partial_cmap_size,
|
||||
cc3.GetCallback()));
|
||||
const std::vector<char> partial_cmap_data = cc3.output();
|
||||
ASSERT_EQ(partial_cmap_data.size(), static_cast<size_t>(cc3.result()));
|
||||
ASSERT_EQ(partial_cmap_data.size(), static_cast<size_t>(partial_cmap_size));
|
||||
ASSERT_EQ(0, memcmp(cmap_table + kOffset, &partial_cmap_data[0],
|
||||
partial_cmap_size));
|
||||
}
|
||||
{
|
||||
// Getting an invalid table should fail ('zzzz' should be safely invalid).
|
||||
TestCompletionCallbackWithOutput< std::vector<char> > cc(
|
||||
instance_->pp_instance(), false);
|
||||
cc.WaitForResult(font.GetTable(MAKE_TABLE_TAG('z', 'z', 'z', 'z'),
|
||||
0, std::numeric_limits<int32_t>::max(),
|
||||
cc.GetCallback()));
|
||||
ASSERT_EQ(0, cc.output().size());
|
||||
ASSERT_EQ(PP_ERROR_FAILED, cc.result());
|
||||
}
|
||||
{
|
||||
// GetTable on an invalid resource should fail with a bad resource error
|
||||
// and write no data.
|
||||
TestCompletionCallbackWithOutput< std::vector<char> > cc(
|
||||
instance_->pp_instance(), false);
|
||||
cc.WaitForResult(
|
||||
ppb_truetype_font_interface_->GetTable(
|
||||
kInvalidResource,
|
||||
MAKE_TABLE_TAG('c', 'm', 'a', 'p'),
|
||||
0, std::numeric_limits<int32_t>::max(),
|
||||
cc.GetCallback().output(),
|
||||
cc.GetCallback().pp_completion_callback()));
|
||||
ASSERT_EQ(PP_ERROR_BADRESOURCE, cc.result());
|
||||
ASSERT_EQ(0, cc.output().size());
|
||||
}
|
||||
{
|
||||
// Negative offset should fail with a bad argument error and write no data.
|
||||
TestCompletionCallbackWithOutput< std::vector<char> > cc(
|
||||
instance_->pp_instance(), false);
|
||||
cc.WaitForResult(font.GetTable(MAKE_TABLE_TAG('c', 'm', 'a', 'p'),
|
||||
-100, 0,
|
||||
cc.GetCallback()));
|
||||
ASSERT_EQ(PP_ERROR_BADARGUMENT, cc.result());
|
||||
ASSERT_EQ(0, cc.output().size());
|
||||
}
|
||||
{
|
||||
// Offset larger than file size succeeds but returns no data.
|
||||
TestCompletionCallbackWithOutput< std::vector<char> > cc(
|
||||
instance_->pp_instance(), false);
|
||||
cc.WaitForResult(font.GetTable(MAKE_TABLE_TAG('c', 'm', 'a', 'p'),
|
||||
1 << 28, 0,
|
||||
cc.GetCallback()));
|
||||
ASSERT_EQ(PP_OK, cc.result());
|
||||
ASSERT_EQ(0, cc.output().size());
|
||||
}
|
||||
{
|
||||
// Negative max_data_length should fail with a bad argument error and write
|
||||
// no data.
|
||||
TestCompletionCallbackWithOutput< std::vector<char> > cc(
|
||||
instance_->pp_instance(), false);
|
||||
cc.WaitForResult(font.GetTable(MAKE_TABLE_TAG('c', 'm', 'a', 'p'),
|
||||
0, -100,
|
||||
cc.GetCallback()));
|
||||
ASSERT_EQ(PP_ERROR_BADARGUMENT, cc.result());
|
||||
ASSERT_EQ(0, cc.output().size());
|
||||
}
|
||||
|
||||
PASS();
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
// 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 PAPPI_TESTS_TEST_TRUETYPE_FONT_H_
|
||||
#define PAPPI_TESTS_TEST_TRUETYPE_FONT_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "ppapi/c/dev/ppb_truetype_font_dev.h"
|
||||
#include "ppapi/c/ppb_core.h"
|
||||
#include "ppapi/c/ppb_var.h"
|
||||
#include "ppapi/tests/test_case.h"
|
||||
|
||||
class TestTrueTypeFont : public TestCase {
|
||||
public:
|
||||
explicit TestTrueTypeFont(TestingInstance* instance);
|
||||
virtual ~TestTrueTypeFont();
|
||||
|
||||
private:
|
||||
// TestCase implementation.
|
||||
virtual bool Init();
|
||||
virtual void RunTests(const std::string& filter);
|
||||
|
||||
std::string TestGetFontFamilies();
|
||||
std::string TestGetFontsInFamily();
|
||||
std::string TestCreate();
|
||||
std::string TestDescribe();
|
||||
std::string TestGetTableTags();
|
||||
std::string TestGetTable();
|
||||
|
||||
const PPB_TrueTypeFont_Dev* ppb_truetype_font_interface_;
|
||||
const PPB_Core* ppb_core_interface_;
|
||||
const PPB_Var* ppb_var_interface_;
|
||||
};
|
||||
|
||||
#endif // PAPPI_TESTS_TEST_TRUETYPE_FONT_H_
|
@ -112,9 +112,6 @@ source_set("thunk") {
|
||||
"ppb_tcp_socket_private_thunk.cc",
|
||||
"ppb_tcp_socket_thunk.cc",
|
||||
"ppb_text_input_thunk.cc",
|
||||
"ppb_truetype_font_api.h",
|
||||
"ppb_truetype_font_dev_thunk.cc",
|
||||
"ppb_truetype_font_singleton_api.h",
|
||||
"ppb_udp_socket_api.h",
|
||||
"ppb_udp_socket_private_api.h",
|
||||
"ppb_udp_socket_private_thunk.cc",
|
||||
|
@ -5,6 +5,9 @@
|
||||
// Please see inteface_ppb_public_stable for the documentation on the format of
|
||||
// this file.
|
||||
|
||||
// no-include-guard-because-multiply-included
|
||||
// NOLINT(build/header_guard)
|
||||
|
||||
#include "ppapi/thunk/interfaces_preamble.h"
|
||||
|
||||
// Map the old dev console interface to the stable one (which is the same) to
|
||||
@ -17,7 +20,6 @@ PROXIED_IFACE(PPB_IME_INPUT_EVENT_DEV_INTERFACE_0_2, PPB_IMEInputEvent_Dev_0_2)
|
||||
PROXIED_IFACE(PPB_MEMORY_DEV_INTERFACE_0_1, PPB_Memory_Dev_0_1)
|
||||
PROXIED_IFACE(PPB_PRINTING_DEV_INTERFACE_0_7, PPB_Printing_Dev_0_7)
|
||||
PROXIED_IFACE(PPB_TEXTINPUT_DEV_INTERFACE_0_2, PPB_TextInput_Dev_0_2)
|
||||
PROXIED_IFACE(PPB_TRUETYPEFONT_DEV_INTERFACE_0_1, PPB_TrueTypeFont_Dev_0_1)
|
||||
PROXIED_IFACE(PPB_VIEW_DEV_INTERFACE_0_1, PPB_View_Dev_0_1)
|
||||
|
||||
#if !defined(OS_NACL)
|
||||
|
@ -22,7 +22,7 @@ PP_Resource GetFontFileWithFallback(
|
||||
const PP_BrowserFont_Trusted_Description* description,
|
||||
PP_PrivateFontCharset charset) {
|
||||
// TODO(raymes): Eventually we should replace the use of this function with
|
||||
// either PPB_Flash_Font_File or PPB_TrueType_Font directly in the PDF code.
|
||||
// PPB_Flash_Font_File directly in the PDF code.
|
||||
// For now just call into PPB_Flash_Font_File which has the exact same API.
|
||||
EnterResourceCreation enter(instance);
|
||||
if (enter.failed())
|
||||
@ -35,7 +35,7 @@ bool GetFontTableForPrivateFontFile(PP_Resource font_file,
|
||||
void* output,
|
||||
uint32_t* output_length) {
|
||||
// TODO(raymes): Eventually we should replace the use of this function with
|
||||
// either PPB_Flash_Font_File or PPB_TrueType_Font directly in the PDF code.
|
||||
// PPB_Flash_Font_File directly in the PDF code.
|
||||
// For now just call into PPB_Flash_Font_File which has the exact same API.
|
||||
EnterResource<PPB_Flash_FontFile_API> enter(font_file, true);
|
||||
if (enter.failed())
|
||||
|
@ -1,38 +0,0 @@
|
||||
// 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 <stdint.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_
|
@ -1,42 +0,0 @@
|
||||
// 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 <stdint.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;
|
||||
|
||||
virtual int32_t GetFontsInFamily(
|
||||
PP_Instance instance,
|
||||
PP_Var family,
|
||||
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_
|
@ -12,7 +12,6 @@
|
||||
#include "gpu/command_buffer/common/command_buffer_id.h"
|
||||
#include "ppapi/c/dev/pp_video_dev.h"
|
||||
#include "ppapi/c/dev/ppb_file_chooser_dev.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_resource.h"
|
||||
@ -104,9 +103,6 @@ class ResourceCreationAPI {
|
||||
PP_InputEvent_Type type,
|
||||
PP_TimeTicks time_stamp,
|
||||
uint32_t modifiers) = 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) = 0;
|
||||
|
@ -1716,15 +1716,6 @@ struct FuzzTraits<ppapi::proxy::SerializedFontDescription> {
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct FuzzTraits<ppapi::proxy::SerializedTrueTypeFontDesc> {
|
||||
static bool Fuzz(ppapi::proxy::SerializedTrueTypeFontDesc* p,
|
||||
Fuzzer* fuzzer) {
|
||||
// TODO(mbarbella): This should actually do something.
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct FuzzTraits<ppapi::proxy::SerializedVar> {
|
||||
static bool Fuzz(ppapi::proxy::SerializedVar* p, Fuzzer* fuzzer) {
|
||||
|
@ -56989,7 +56989,7 @@ Called by update_net_trust_anchors.py.-->
|
||||
<int value="36133501" label="PPB_MediaStreamVideoTrack;1.0"/>
|
||||
<int value="37307420" label="PPB_Scrollbar(Dev);0.5"/>
|
||||
<int value="59327104" label="PPB_Messaging;1.2"/>
|
||||
<int value="62905097" label="PPB_TrueTypeFont(Dev);0.1"/>
|
||||
<int value="62905097" label="PPB_TrueTypeFont(Removed);0.1"/>
|
||||
<int value="79708274" label="PPB_TCPSocket;1.1"/>
|
||||
<int value="110360074" label="PPB_Var;1.1"/>
|
||||
<int value="125017713" label="PPB_CameraCapabilities_Private;0.1"/>
|
||||
|
Reference in New Issue
Block a user