OLD | NEW |
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/proxy/flash_resource.h" | 5 #include "ppapi/proxy/flash_resource.h" |
6 | 6 |
7 #include "ppapi/c/pp_errors.h" | 7 #include "ppapi/c/pp_errors.h" |
8 #include "ppapi/c/private/ppb_flash.h" | 8 #include "ppapi/c/private/ppb_flash.h" |
9 #include "ppapi/c/trusted/ppb_browser_font_trusted.h" | |
10 #include "ppapi/proxy/plugin_globals.h" | 9 #include "ppapi/proxy/plugin_globals.h" |
11 #include "ppapi/proxy/ppapi_messages.h" | 10 #include "ppapi/proxy/ppapi_messages.h" |
12 #include "ppapi/proxy/serialized_structs.h" | |
13 #include "ppapi/shared_impl/var.h" | 11 #include "ppapi/shared_impl/var.h" |
14 #include "ppapi/thunk/enter.h" | |
15 #include "ppapi/thunk/ppb_url_request_info_api.h" | |
16 | |
17 using ppapi::thunk::EnterResourceNoLock; | |
18 | 12 |
19 namespace ppapi { | 13 namespace ppapi { |
20 namespace proxy { | 14 namespace proxy { |
21 | 15 |
22 FlashResource::FlashResource(Connection connection, PP_Instance instance) | 16 FlashResource::FlashResource(Connection connection, PP_Instance instance) |
23 : PluginResource(connection, instance) { | 17 : PluginResource(connection, instance) { |
24 SendCreate(RENDERER, PpapiHostMsg_Flash_Create()); | 18 SendCreate(RENDERER, PpapiHostMsg_Flash_Create()); |
25 SendCreate(BROWSER, PpapiHostMsg_Flash_Create()); | 19 SendCreate(BROWSER, PpapiHostMsg_Flash_Create()); |
26 } | 20 } |
27 | 21 |
(...skipping 27 matching lines...) Expand all Loading... |
55 StringVar* url_string_var(StringVar::FromPPVar(value)); | 49 StringVar* url_string_var(StringVar::FromPPVar(value)); |
56 if (!url_string_var) | 50 if (!url_string_var) |
57 return PP_FALSE; | 51 return PP_FALSE; |
58 PluginGlobals::Get()->SetActiveURL(url_string_var->value()); | 52 PluginGlobals::Get()->SetActiveURL(url_string_var->value()); |
59 return PP_TRUE; | 53 return PP_TRUE; |
60 } | 54 } |
61 } | 55 } |
62 return PP_FALSE; | 56 return PP_FALSE; |
63 } | 57 } |
64 | 58 |
65 void FlashResource::SetInstanceAlwaysOnTop(PP_Instance instance, | |
66 PP_Bool on_top) { | |
67 Post(RENDERER, PpapiHostMsg_Flash_SetInstanceAlwaysOnTop(PP_ToBool(on_top))); | |
68 } | |
69 | |
70 PP_Bool FlashResource::DrawGlyphs( | |
71 PP_Instance instance, | |
72 PP_Resource pp_image_data, | |
73 const PP_BrowserFont_Trusted_Description* font_desc, | |
74 uint32_t color, | |
75 const PP_Point* position, | |
76 const PP_Rect* clip, | |
77 const float transformation[3][3], | |
78 PP_Bool allow_subpixel_aa, | |
79 uint32_t glyph_count, | |
80 const uint16_t glyph_indices[], | |
81 const PP_Point glyph_advances[]) { | |
82 EnterResourceNoLock<thunk::PPB_ImageData_API> enter(pp_image_data, true); | |
83 if (enter.failed()) | |
84 return PP_FALSE; | |
85 // The instance parameter isn't strictly necessary but we check that it | |
86 // matches anyway. | |
87 if (enter.resource()->pp_instance() != instance) | |
88 return PP_FALSE; | |
89 | |
90 PPBFlash_DrawGlyphs_Params params; | |
91 params.image_data = enter.resource()->host_resource(); | |
92 params.font_desc.SetFromPPBrowserFontDescription(*font_desc); | |
93 params.color = color; | |
94 params.position = *position; | |
95 params.clip = *clip; | |
96 for (int i = 0; i < 3; i++) { | |
97 for (int j = 0; j < 3; j++) | |
98 params.transformation[i][j] = transformation[i][j]; | |
99 } | |
100 params.allow_subpixel_aa = allow_subpixel_aa; | |
101 | |
102 params.glyph_indices.insert(params.glyph_indices.begin(), | |
103 &glyph_indices[0], | |
104 &glyph_indices[glyph_count]); | |
105 params.glyph_advances.insert(params.glyph_advances.begin(), | |
106 &glyph_advances[0], | |
107 &glyph_advances[glyph_count]); | |
108 | |
109 // This has to be synchronous because the caller may want to composite on | |
110 // top of the resulting text after the call is complete. | |
111 int32_t result = SyncCall<IPC::Message>(RENDERER, | |
112 PpapiHostMsg_Flash_DrawGlyphs(params)); | |
113 return PP_FromBool(result == PP_OK); | |
114 } | |
115 | |
116 int32_t FlashResource::Navigate(PP_Instance instance, | |
117 PP_Resource request_info, | |
118 const char* target, | |
119 PP_Bool from_user_action) { | |
120 thunk::EnterResourceNoLock<thunk::PPB_URLRequestInfo_API> enter(request_info, | |
121 true); | |
122 if (enter.failed()) | |
123 return PP_ERROR_BADRESOURCE; | |
124 return SyncCall<IPC::Message>(RENDERER, PpapiHostMsg_Flash_Navigate( | |
125 enter.object()->GetData(), target, PP_ToBool(from_user_action))); | |
126 } | |
127 | |
128 PP_Bool FlashResource::IsRectTopmost(PP_Instance instance, | |
129 const PP_Rect* rect) { | |
130 int32_t result = SyncCall<IPC::Message>(RENDERER, | |
131 PpapiHostMsg_Flash_IsRectTopmost(*rect)); | |
132 return PP_FromBool(result == PP_OK); | |
133 } | |
134 | |
135 } // namespace proxy | 59 } // namespace proxy |
136 } // namespace ppapi | 60 } // namespace ppapi |
OLD | NEW |