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

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

Issue 7044012: Support getting the font list in Pepper. This currently only works out of (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_font_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 PP_Var GetFontFamilies(PP_Instance instance) {
16 EnterFunction<PPB_Font_FunctionAPI> enter(instance, true);
17 if (enter.failed())
18 return PP_MakeUndefined();
19 return enter.functions()->GetFontFamilies(instance);
20 }
21
15 PP_Resource Create(PP_Instance instance, 22 PP_Resource Create(PP_Instance instance,
16 const PP_FontDescription_Dev* description) { 23 const PP_FontDescription_Dev* description) {
17 EnterFunction<ResourceCreationAPI> enter(instance, true); 24 EnterFunction<ResourceCreationAPI> enter(instance, true);
18 if (enter.failed()) 25 if (enter.failed())
19 return 0; 26 return 0;
20 return enter.functions()->CreateFontObject(instance, description); 27 return enter.functions()->CreateFontObject(instance, description);
21 } 28 }
22 29
23 PP_Bool IsFont(PP_Resource resource) { 30 PP_Bool IsFont(PP_Resource resource) {
24 EnterResource<PPB_Font_API> enter(resource, false); 31 EnterResource<PPB_Font_API> enter(resource, false);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 int32_t PixelOffsetForCharacter(PP_Resource font_id, 74 int32_t PixelOffsetForCharacter(PP_Resource font_id,
68 const PP_TextRun_Dev* text, 75 const PP_TextRun_Dev* text,
69 uint32_t char_offset) { 76 uint32_t char_offset) {
70 EnterResource<PPB_Font_API> enter(font_id, true); 77 EnterResource<PPB_Font_API> enter(font_id, true);
71 if (enter.failed()) 78 if (enter.failed())
72 return -1; 79 return -1;
73 return enter.object()->PixelOffsetForCharacter(text, char_offset); 80 return enter.object()->PixelOffsetForCharacter(text, char_offset);
74 } 81 }
75 82
76 const PPB_Font_Dev g_ppb_font_thunk = { 83 const PPB_Font_Dev g_ppb_font_thunk = {
84 &GetFontFamilies,
77 &Create, 85 &Create,
78 &IsFont, 86 &IsFont,
79 &Describe, 87 &Describe,
80 &DrawTextAt, 88 &DrawTextAt,
81 &MeasureText, 89 &MeasureText,
82 &CharacterOffsetForPixel, 90 &CharacterOffsetForPixel,
83 &PixelOffsetForCharacter 91 &PixelOffsetForCharacter
84 }; 92 };
85 93
86 } // namespace 94 } // namespace
87 95
88 const PPB_Font_Dev* GetPPB_Font_Thunk() { 96 const PPB_Font_Dev* GetPPB_Font_Thunk() {
89 return &g_ppb_font_thunk; 97 return &g_ppb_font_thunk;
90 } 98 }
91 99
92 } // namespace thunk 100 } // namespace thunk
93 } // namespace ppapi 101 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698