1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ppapi/thunk/thunk.h"
6 #include "ppapi/thunk/enter.h"
7 #include "ppapi/thunk/ppb_browser_font_singleton_api.h"
8 #include "ppapi/thunk/ppb_browser_font_trusted_api.h"
9 #include "ppapi/thunk/resource_creation_api.h"
16 typedef EnterResource
<PPB_BrowserFont_Trusted_API
> EnterBrowserFont
;
18 PP_Var
GetFontFamilies(PP_Instance instance
) {
19 EnterInstanceAPI
<PPB_BrowserFont_Singleton_API
> enter(instance
);
21 return PP_MakeUndefined();
22 return enter
.functions()->GetFontFamilies(instance
);
25 PP_Resource
Create(PP_Instance instance
,
26 const PP_BrowserFont_Trusted_Description
* description
) {
27 EnterResourceCreation
enter(instance
);
30 return enter
.functions()->CreateBrowserFont(instance
, description
);
33 PP_Bool
IsBrowserFont(PP_Resource resource
) {
34 EnterBrowserFont
enter(resource
, false);
35 return enter
.succeeded() ? PP_TRUE
: PP_FALSE
;
38 PP_Bool
Describe(PP_Resource font_id
,
39 PP_BrowserFont_Trusted_Description
* description
,
40 PP_BrowserFont_Trusted_Metrics
* metrics
) {
41 EnterBrowserFont
enter(font_id
, true);
44 return enter
.object()->Describe(description
, metrics
);
47 PP_Bool
DrawTextAt(PP_Resource font_id
,
48 PP_Resource image_data
,
49 const PP_BrowserFont_Trusted_TextRun
* text
,
50 const PP_Point
* position
,
53 PP_Bool image_data_is_opaque
) {
54 EnterBrowserFont
enter(font_id
, true);
57 return enter
.object()->DrawTextAt(image_data
, text
, position
, color
, clip
,
58 image_data_is_opaque
);
61 int32_t MeasureText(PP_Resource font_id
,
62 const PP_BrowserFont_Trusted_TextRun
* text
) {
63 EnterBrowserFont
enter(font_id
, true);
66 return enter
.object()->MeasureText(text
);
69 uint32_t CharacterOffsetForPixel(PP_Resource font_id
,
70 const PP_BrowserFont_Trusted_TextRun
* text
,
71 int32_t pixel_position
) {
72 EnterBrowserFont
enter(font_id
, true);
75 return enter
.object()->CharacterOffsetForPixel(text
, pixel_position
);
78 int32_t PixelOffsetForCharacter(PP_Resource font_id
,
79 const PP_BrowserFont_Trusted_TextRun
* text
,
80 uint32_t char_offset
) {
81 EnterBrowserFont
enter(font_id
, true);
84 return enter
.object()->PixelOffsetForCharacter(text
, char_offset
);
87 const PPB_BrowserFont_Trusted_1_0 g_ppb_browser_font_trusted_thunk
= {
94 &CharacterOffsetForPixel
,
95 &PixelOffsetForCharacter
100 const PPB_BrowserFont_Trusted_1_0
* GetPPB_BrowserFont_Trusted_1_0_Thunk() {
101 return &g_ppb_browser_font_trusted_thunk
;