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

Side by Side Diff: webkit/plugins/ppapi/ppb_font_impl.cc

Issue 7669055: Remove webkit::ppapi::Resource. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix self-assignment Created 9 years, 4 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 "webkit/plugins/ppapi/ppb_font_impl.h" 5 #include "webkit/plugins/ppapi/ppb_font_impl.h"
6 6
7 #include "ppapi/c/dev/ppb_font_dev.h" 7 #include "ppapi/c/dev/ppb_font_dev.h"
8 #include "ppapi/shared_impl/font_impl.h" 8 #include "ppapi/shared_impl/font_impl.h"
9 #include "ppapi/shared_impl/ppapi_preferences.h" 9 #include "ppapi/shared_impl/ppapi_preferences.h"
10 #include "ppapi/shared_impl/var.h" 10 #include "ppapi/shared_impl/var.h"
11 #include "ppapi/thunk/enter.h" 11 #include "ppapi/thunk/enter.h"
12 #include "ppapi/thunk/thunk.h" 12 #include "ppapi/thunk/thunk.h"
13 #include "webkit/plugins/ppapi/common.h" 13 #include "webkit/plugins/ppapi/common.h"
14 #include "webkit/plugins/ppapi/plugin_module.h" 14 #include "webkit/plugins/ppapi/plugin_module.h"
15 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 15 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
16 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" 16 #include "webkit/plugins/ppapi/ppb_image_data_impl.h"
17 #include "webkit/plugins/ppapi/resource_helper.h"
17 #include "webkit/plugins/ppapi/string.h" 18 #include "webkit/plugins/ppapi/string.h"
18 19
19 using ppapi::StringVar; 20 using ppapi::StringVar;
20 using ppapi::thunk::EnterResource; 21 using ppapi::thunk::EnterResource;
21 using ppapi::thunk::PPB_ImageData_API; 22 using ppapi::thunk::PPB_ImageData_API;
22 using ppapi::WebKitForwarding; 23 using ppapi::WebKitForwarding;
23 24
24 namespace webkit { 25 namespace webkit {
25 namespace ppapi { 26 namespace ppapi {
26 27
27 namespace { 28 namespace {
28 29
29 // Converts the given PP_TextRun to a TextRun, returning true on success. 30 // Converts the given PP_TextRun to a TextRun, returning true on success.
30 // False means the input was invalid. 31 // False means the input was invalid.
31 bool PPTextRunToTextRun(const PP_TextRun_Dev* run, 32 bool PPTextRunToTextRun(const PP_TextRun_Dev* run,
32 WebKitForwarding::Font::TextRun* output) { 33 WebKitForwarding::Font::TextRun* output) {
33 StringVar* text_string = StringVar::FromPPVar(run->text); 34 StringVar* text_string = StringVar::FromPPVar(run->text);
34 if (!text_string) 35 if (!text_string)
35 return false; 36 return false;
36 37
37 output->text = text_string->value(); 38 output->text = text_string->value();
38 output->rtl = PPBoolToBool(run->rtl); 39 output->rtl = PPBoolToBool(run->rtl);
39 output->override_direction = PPBoolToBool(run->override_direction); 40 output->override_direction = PPBoolToBool(run->override_direction);
40 return true; 41 return true;
41 } 42 }
42 43
43 } // namespace 44 } // namespace
44 45
45 PPB_Font_Impl::PPB_Font_Impl(PluginInstance* instance, 46 PPB_Font_Impl::PPB_Font_Impl(PP_Instance pp_instance,
46 const PP_FontDescription_Dev& desc) 47 const PP_FontDescription_Dev& desc)
47 : Resource(instance) { 48 : Resource(pp_instance) {
48 StringVar* face_name = StringVar::FromPPVar(desc.face); 49 StringVar* face_name = StringVar::FromPPVar(desc.face);
49 50
51 PluginInstance* instance = ResourceHelper::GetPluginInstance(this);
50 WebKitForwarding::Font* result = NULL; 52 WebKitForwarding::Font* result = NULL;
51 instance->module()->GetWebKitForwarding()->CreateFontForwarding( 53 instance->module()->GetWebKitForwarding()->CreateFontForwarding(
52 NULL, desc, face_name ? face_name->value() : std::string(), 54 NULL, desc, face_name ? face_name->value() : std::string(),
53 instance->delegate()->GetPreferences(), &result); 55 instance->delegate()->GetPreferences(), &result);
54 font_forwarding_.reset(result); 56 font_forwarding_.reset(result);
55 } 57 }
56 58
57 PPB_Font_Impl::~PPB_Font_Impl() { 59 PPB_Font_Impl::~PPB_Font_Impl() {
58 } 60 }
59 61
60 // static 62 // static
61 PP_Resource PPB_Font_Impl::Create(PluginInstance* instance, 63 PP_Resource PPB_Font_Impl::Create(PP_Instance instance,
62 const PP_FontDescription_Dev& description) { 64 const PP_FontDescription_Dev& description) {
63 if (!::ppapi::FontImpl::IsPPFontDescriptionValid(description)) 65 if (!::ppapi::FontImpl::IsPPFontDescriptionValid(description))
64 return 0; 66 return 0;
65 return (new PPB_Font_Impl(instance, description))->GetReference(); 67 return (new PPB_Font_Impl(instance, description))->GetReference();
66 } 68 }
67 69
68 ::ppapi::thunk::PPB_Font_API* PPB_Font_Impl::AsPPB_Font_API() { 70 ::ppapi::thunk::PPB_Font_API* PPB_Font_Impl::AsPPB_Font_API() {
69 return this; 71 return this;
70 } 72 }
71 73
72 PP_Bool PPB_Font_Impl::Describe(PP_FontDescription_Dev* description, 74 PP_Bool PPB_Font_Impl::Describe(PP_FontDescription_Dev* description,
73 PP_FontMetrics_Dev* metrics) { 75 PP_FontMetrics_Dev* metrics) {
74 std::string face; 76 std::string face;
75 PP_Bool result = PP_FALSE; 77 PP_Bool result = PP_FALSE;
76 font_forwarding_->Describe(NULL, description, &face, metrics, &result); 78 font_forwarding_->Describe(NULL, description, &face, metrics, &result);
77 if (!result) 79 if (!result)
78 return PP_FALSE; 80 return PP_FALSE;
79 81
80 // Convert the string. 82 // Convert the string.
81 description->face = StringVar::StringToPPVar( 83 description->face = StringVar::StringToPPVar(
82 instance()->module()->pp_module(), face); 84 ResourceHelper::GetPluginModule(this)->pp_module(), face);
83 return PP_TRUE; 85 return PP_TRUE;
84 } 86 }
85 87
86 PP_Bool PPB_Font_Impl::DrawTextAt(PP_Resource image_data, 88 PP_Bool PPB_Font_Impl::DrawTextAt(PP_Resource image_data,
87 const PP_TextRun_Dev* text, 89 const PP_TextRun_Dev* text,
88 const PP_Point* position, 90 const PP_Point* position,
89 uint32_t color, 91 uint32_t color,
90 const PP_Rect* clip, 92 const PP_Rect* clip,
91 PP_Bool image_data_is_opaque) { 93 PP_Bool image_data_is_opaque) {
92 // Get and map the image data we're painting to. 94 // Get and map the image data we're painting to.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 return this; 153 return this;
152 } 154 }
153 155
154 PP_Var PPB_Font_FunctionImpl::GetFontFamilies(PP_Instance instance) { 156 PP_Var PPB_Font_FunctionImpl::GetFontFamilies(PP_Instance instance) {
155 return PP_MakeUndefined(); 157 return PP_MakeUndefined();
156 } 158 }
157 159
158 } // namespace ppapi 160 } // namespace ppapi
159 } // namespace webkit 161 } // namespace webkit
160 162
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698