ash: Update app list layout:
[chromium-blink-merge.git] / ppapi / thunk / ppb_browser_font_trusted_thunk.cc
blobbcbc798cee3a1cfff56de1e36e4a1d0dc269985c
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"
10 namespace ppapi {
11 namespace thunk {
13 namespace {
15 typedef EnterResource<PPB_BrowserFont_Trusted_API> EnterBrowserFont;
17 PP_Var GetFontFamilies(PP_Instance instance) {
18 EnterInstance enter(instance);
19 if (enter.failed())
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);
27 if (enter.failed())
28 return 0;
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);
41 if (enter.failed())
42 return PP_FALSE;
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,
50 uint32_t color,
51 const PP_Rect* clip,
52 PP_Bool image_data_is_opaque) {
53 EnterBrowserFont enter(font_id, true);
54 if (enter.failed())
55 return PP_FALSE;
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);
63 if (enter.failed())
64 return -1;
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);
72 if (enter.failed())
73 return -1;
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);
81 if (enter.failed())
82 return -1;
83 return enter.object()->PixelOffsetForCharacter(text, char_offset);
86 const PPB_BrowserFont_Trusted_1_0 g_ppb_browser_font_trusted_thunk = {
87 &GetFontFamilies,
88 &Create,
89 &IsBrowserFont,
90 &Describe,
91 &DrawTextAt,
92 &MeasureText,
93 &CharacterOffsetForPixel,
94 &PixelOffsetForCharacter
97 } // namespace
99 const PPB_BrowserFont_Trusted_1_0* GetPPB_BrowserFont_Trusted_1_0_Thunk() {
100 return &g_ppb_browser_font_trusted_thunk;
103 } // namespace thunk
104 } // namespace ppapi