Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: ppapi/thunk/ppb_browser_font_trusted_thunk.cc

Issue 9360045: Rename PPB_Font to PPB_BrowserFont_Trusted. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: REQUIRED CHANGELIST DESCRIPTIONS ARE A WASTE OF TIME Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/thunk/thunk.h" 5 #include "ppapi/thunk/thunk.h"
6 #include "ppapi/thunk/enter.h" 6 #include "ppapi/thunk/enter.h"
7 #include "ppapi/thunk/ppb_font_api.h" 7 #include "ppapi/thunk/ppb_browser_font_trusted_api.h"
8 #include "ppapi/thunk/resource_creation_api.h" 8 #include "ppapi/thunk/resource_creation_api.h"
9 9
10 namespace ppapi { 10 namespace ppapi {
11 namespace thunk { 11 namespace thunk {
12 12
13 namespace { 13 namespace {
14 14
15 typedef EnterResource<PPB_BrowserFont_Trusted_API> EnterBrowserFont;
16
15 PP_Var GetFontFamilies(PP_Instance instance) { 17 PP_Var GetFontFamilies(PP_Instance instance) {
16 EnterFunction<PPB_Font_FunctionAPI> enter(instance, true); 18 EnterInstance enter(instance);
17 if (enter.failed()) 19 if (enter.failed())
18 return PP_MakeUndefined(); 20 return PP_MakeUndefined();
19 return enter.functions()->GetFontFamilies(instance); 21 return enter.functions()->GetFontFamilies(instance);
20 } 22 }
21 23
22 PP_Resource Create(PP_Instance instance, 24 PP_Resource Create(PP_Instance instance,
23 const PP_FontDescription_Dev* description) { 25 const PP_BrowserFont_Trusted_Description* description) {
24 EnterFunction<ResourceCreationAPI> enter(instance, true); 26 EnterResourceCreation enter(instance);
25 if (enter.failed()) 27 if (enter.failed())
26 return 0; 28 return 0;
27 return enter.functions()->CreateFontObject(instance, description); 29 return enter.functions()->CreateBrowserFont(instance, description);
28 } 30 }
29 31
30 PP_Bool IsFont(PP_Resource resource) { 32 PP_Bool IsBrowserFont(PP_Resource resource) {
31 EnterResource<PPB_Font_API> enter(resource, false); 33 EnterBrowserFont enter(resource, false);
32 return enter.succeeded() ? PP_TRUE : PP_FALSE; 34 return enter.succeeded() ? PP_TRUE : PP_FALSE;
33 } 35 }
34 36
35 PP_Bool Describe(PP_Resource font_id, 37 PP_Bool Describe(PP_Resource font_id,
36 PP_FontDescription_Dev* description, 38 PP_BrowserFont_Trusted_Description* description,
37 PP_FontMetrics_Dev* metrics) { 39 PP_BrowserFont_Trusted_Metrics* metrics) {
38 EnterResource<PPB_Font_API> enter(font_id, true); 40 EnterBrowserFont enter(font_id, true);
39 if (enter.failed()) 41 if (enter.failed())
40 return PP_FALSE; 42 return PP_FALSE;
41 return enter.object()->Describe(description, metrics); 43 return enter.object()->Describe(description, metrics);
42 } 44 }
43 45
44 PP_Bool DrawTextAt(PP_Resource font_id, 46 PP_Bool DrawTextAt(PP_Resource font_id,
45 PP_Resource image_data, 47 PP_Resource image_data,
46 const PP_TextRun_Dev* text, 48 const PP_BrowserFont_Trusted_TextRun* text,
47 const PP_Point* position, 49 const PP_Point* position,
48 uint32_t color, 50 uint32_t color,
49 const PP_Rect* clip, 51 const PP_Rect* clip,
50 PP_Bool image_data_is_opaque) { 52 PP_Bool image_data_is_opaque) {
51 EnterResource<PPB_Font_API> enter(font_id, true); 53 EnterBrowserFont enter(font_id, true);
52 if (enter.failed()) 54 if (enter.failed())
53 return PP_FALSE; 55 return PP_FALSE;
54 return enter.object()->DrawTextAt(image_data, text, position, color, clip, 56 return enter.object()->DrawTextAt(image_data, text, position, color, clip,
55 image_data_is_opaque); 57 image_data_is_opaque);
56 } 58 }
57 59
58 int32_t MeasureText(PP_Resource font_id, const PP_TextRun_Dev* text) { 60 int32_t MeasureText(PP_Resource font_id,
59 EnterResource<PPB_Font_API> enter(font_id, true); 61 const PP_BrowserFont_Trusted_TextRun* text) {
62 EnterBrowserFont enter(font_id, true);
60 if (enter.failed()) 63 if (enter.failed())
61 return -1; 64 return -1;
62 return enter.object()->MeasureText(text); 65 return enter.object()->MeasureText(text);
63 } 66 }
64 67
65 uint32_t CharacterOffsetForPixel(PP_Resource font_id, 68 uint32_t CharacterOffsetForPixel(PP_Resource font_id,
66 const PP_TextRun_Dev* text, 69 const PP_BrowserFont_Trusted_TextRun* text,
67 int32_t pixel_position) { 70 int32_t pixel_position) {
68 EnterResource<PPB_Font_API> enter(font_id, true); 71 EnterBrowserFont enter(font_id, true);
69 if (enter.failed()) 72 if (enter.failed())
70 return -1; 73 return -1;
71 return enter.object()->CharacterOffsetForPixel(text, pixel_position); 74 return enter.object()->CharacterOffsetForPixel(text, pixel_position);
72 } 75 }
73 76
74 int32_t PixelOffsetForCharacter(PP_Resource font_id, 77 int32_t PixelOffsetForCharacter(PP_Resource font_id,
75 const PP_TextRun_Dev* text, 78 const PP_BrowserFont_Trusted_TextRun* text,
76 uint32_t char_offset) { 79 uint32_t char_offset) {
77 EnterResource<PPB_Font_API> enter(font_id, true); 80 EnterBrowserFont enter(font_id, true);
78 if (enter.failed()) 81 if (enter.failed())
79 return -1; 82 return -1;
80 return enter.object()->PixelOffsetForCharacter(text, char_offset); 83 return enter.object()->PixelOffsetForCharacter(text, char_offset);
81 } 84 }
82 85
83 const PPB_Font_Dev g_ppb_font_thunk = { 86 const PPB_BrowserFont_Trusted_1_0 g_ppb_browser_font_trusted_thunk = {
84 &GetFontFamilies, 87 &GetFontFamilies,
85 &Create, 88 &Create,
86 &IsFont, 89 &IsBrowserFont,
87 &Describe, 90 &Describe,
88 &DrawTextAt, 91 &DrawTextAt,
89 &MeasureText, 92 &MeasureText,
90 &CharacterOffsetForPixel, 93 &CharacterOffsetForPixel,
91 &PixelOffsetForCharacter 94 &PixelOffsetForCharacter
92 }; 95 };
93 96
94 } // namespace 97 } // namespace
95 98
96 const PPB_Font_Dev_0_6* GetPPB_Font_Dev_0_6_Thunk() { 99 const PPB_BrowserFont_Trusted_1_0* GetPPB_BrowserFont_Trusted_1_0_Thunk() {
97 return &g_ppb_font_thunk; 100 return &g_ppb_browser_font_trusted_thunk;
98 } 101 }
99 102
100 } // namespace thunk 103 } // namespace thunk
101 } // namespace ppapi 104 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698