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_trusted_api.h"
8 #include "ppapi/thunk/resource_creation_api.h"
15 typedef EnterResource
<PPB_BrowserFont_Trusted_API
> EnterBrowserFont
;
17 PP_Var
GetFontFamilies(PP_Instance instance
) {
18 EnterInstance
enter(instance
);
20 return PP_MakeUndefined();
21 return enter
.functions()->GetFontFamilies(instance
);
24 PP_Resource
Create(PP_Instance instance
,
25 const PP_BrowserFont_Trusted_Description
* description
) {
26 EnterResourceCreation
enter(instance
);
29 return enter
.functions()->CreateBrowserFont(instance
, description
);
32 PP_Bool
IsBrowserFont(PP_Resource resource
) {
33 EnterBrowserFont
enter(resource
, false);
34 return enter
.succeeded() ? PP_TRUE
: PP_FALSE
;
37 PP_Bool
Describe(PP_Resource font_id
,
38 PP_BrowserFont_Trusted_Description
* description
,
39 PP_BrowserFont_Trusted_Metrics
* metrics
) {
40 EnterBrowserFont
enter(font_id
, true);
43 return enter
.object()->Describe(description
, metrics
);
46 PP_Bool
DrawTextAt(PP_Resource font_id
,
47 PP_Resource image_data
,
48 const PP_BrowserFont_Trusted_TextRun
* text
,
49 const PP_Point
* position
,
52 PP_Bool image_data_is_opaque
) {
53 EnterBrowserFont
enter(font_id
, true);
56 return enter
.object()->DrawTextAt(image_data
, text
, position
, color
, clip
,
57 image_data_is_opaque
);
60 int32_t MeasureText(PP_Resource font_id
,
61 const PP_BrowserFont_Trusted_TextRun
* text
) {
62 EnterBrowserFont
enter(font_id
, true);
65 return enter
.object()->MeasureText(text
);
68 uint32_t CharacterOffsetForPixel(PP_Resource font_id
,
69 const PP_BrowserFont_Trusted_TextRun
* text
,
70 int32_t pixel_position
) {
71 EnterBrowserFont
enter(font_id
, true);
74 return enter
.object()->CharacterOffsetForPixel(text
, pixel_position
);
77 int32_t PixelOffsetForCharacter(PP_Resource font_id
,
78 const PP_BrowserFont_Trusted_TextRun
* text
,
79 uint32_t char_offset
) {
80 EnterBrowserFont
enter(font_id
, true);
83 return enter
.object()->PixelOffsetForCharacter(text
, char_offset
);
86 const PPB_BrowserFont_Trusted_1_0 g_ppb_browser_font_trusted_thunk
= {
93 &CharacterOffsetForPixel
,
94 &PixelOffsetForCharacter
99 const PPB_BrowserFont_Trusted_1_0
* GetPPB_BrowserFont_Trusted_1_0_Thunk() {
100 return &g_ppb_browser_font_trusted_thunk
;