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

Side by Side Diff: ppapi/proxy/flash_resource.cc

Issue 11510008: Refactor 4 PPB_Flash functions to the new PPAPI resource model. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years 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
« no previous file with comments | « ppapi/proxy/flash_resource.h ('k') | ppapi/proxy/ppapi_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/proxy/flash_resource.h" 5 #include "ppapi/proxy/flash_resource.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/containers/mru_cache.h" 9 #include "base/containers/mru_cache.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/time.h" 11 #include "base/time.h"
12 #include "ppapi/c/pp_errors.h" 12 #include "ppapi/c/pp_errors.h"
13 #include "ppapi/c/private/ppb_flash.h" 13 #include "ppapi/c/private/ppb_flash.h"
14 #include "ppapi/c/trusted/ppb_browser_font_trusted.h"
14 #include "ppapi/proxy/plugin_dispatcher.h" 15 #include "ppapi/proxy/plugin_dispatcher.h"
15 #include "ppapi/proxy/plugin_globals.h" 16 #include "ppapi/proxy/plugin_globals.h"
16 #include "ppapi/proxy/ppapi_messages.h" 17 #include "ppapi/proxy/ppapi_messages.h"
18 #include "ppapi/proxy/serialized_structs.h"
17 #include "ppapi/shared_impl/ppapi_preferences.h" 19 #include "ppapi/shared_impl/ppapi_preferences.h"
18 #include "ppapi/shared_impl/scoped_pp_var.h" 20 #include "ppapi/shared_impl/scoped_pp_var.h"
19 #include "ppapi/shared_impl/time_conversion.h" 21 #include "ppapi/shared_impl/time_conversion.h"
20 #include "ppapi/shared_impl/var.h" 22 #include "ppapi/shared_impl/var.h"
21 #include "ppapi/thunk/enter.h" 23 #include "ppapi/thunk/enter.h"
24 #include "ppapi/thunk/ppb_url_request_info_api.h"
25
26 using ppapi::thunk::EnterResourceNoLock;
22 27
23 namespace ppapi { 28 namespace ppapi {
24 namespace proxy { 29 namespace proxy {
25 30
26 namespace { 31 namespace {
27 32
28 struct LocalTimeZoneOffsetEntry { 33 struct LocalTimeZoneOffsetEntry {
29 base::TimeTicks expiration; 34 base::TimeTicks expiration;
30 double offset; 35 double offset;
31 }; 36 };
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 SyncCall<PpapiPluginMsg_Flash_GetLocalDataRestrictionsReply>(BROWSER, 163 SyncCall<PpapiPluginMsg_Flash_GetLocalDataRestrictionsReply>(BROWSER,
159 PpapiHostMsg_Flash_GetLocalDataRestrictions(), &restrictions); 164 PpapiHostMsg_Flash_GetLocalDataRestrictions(), &restrictions);
160 if (result != PP_OK) 165 if (result != PP_OK)
161 return PP_MakeInt32(PP_FLASHLSORESTRICTIONS_NONE); 166 return PP_MakeInt32(PP_FLASHLSORESTRICTIONS_NONE);
162 return PP_MakeInt32(restrictions); 167 return PP_MakeInt32(restrictions);
163 } 168 }
164 } 169 }
165 return PP_MakeUndefined(); 170 return PP_MakeUndefined();
166 } 171 }
167 172
173 void FlashResource::SetInstanceAlwaysOnTop(PP_Instance instance,
174 PP_Bool on_top) {
175 Post(RENDERER, PpapiHostMsg_Flash_SetInstanceAlwaysOnTop(PP_ToBool(on_top)));
176 }
177
178 PP_Bool FlashResource::DrawGlyphs(
179 PP_Instance instance,
180 PP_Resource pp_image_data,
181 const PP_BrowserFont_Trusted_Description* font_desc,
182 uint32_t color,
183 const PP_Point* position,
184 const PP_Rect* clip,
185 const float transformation[3][3],
186 PP_Bool allow_subpixel_aa,
187 uint32_t glyph_count,
188 const uint16_t glyph_indices[],
189 const PP_Point glyph_advances[]) {
190 EnterResourceNoLock<thunk::PPB_ImageData_API> enter(pp_image_data, true);
191 if (enter.failed())
192 return PP_FALSE;
193 // The instance parameter isn't strictly necessary but we check that it
194 // matches anyway.
195 if (enter.resource()->pp_instance() != instance)
196 return PP_FALSE;
197
198 PPBFlash_DrawGlyphs_Params params;
199 params.image_data = enter.resource()->host_resource();
200 params.font_desc.SetFromPPBrowserFontDescription(*font_desc);
201 params.color = color;
202 params.position = *position;
203 params.clip = *clip;
204 for (int i = 0; i < 3; i++) {
205 for (int j = 0; j < 3; j++)
206 params.transformation[i][j] = transformation[i][j];
207 }
208 params.allow_subpixel_aa = allow_subpixel_aa;
209
210 params.glyph_indices.insert(params.glyph_indices.begin(),
211 &glyph_indices[0],
212 &glyph_indices[glyph_count]);
213 params.glyph_advances.insert(params.glyph_advances.begin(),
214 &glyph_advances[0],
215 &glyph_advances[glyph_count]);
216
217 // This has to be synchronous because the caller may want to composite on
218 // top of the resulting text after the call is complete.
219 int32_t result = SyncCall<IPC::Message>(RENDERER,
220 PpapiHostMsg_Flash_DrawGlyphs(params));
221 return PP_FromBool(result == PP_OK);
222 }
223
224 int32_t FlashResource::Navigate(PP_Instance instance,
225 PP_Resource request_info,
226 const char* target,
227 PP_Bool from_user_action) {
228 EnterResourceNoLock<thunk::PPB_URLRequestInfo_API> enter(request_info,
229 true);
230 if (enter.failed())
231 return PP_ERROR_BADRESOURCE;
232 return SyncCall<IPC::Message>(RENDERER, PpapiHostMsg_Flash_Navigate(
233 enter.object()->GetData(), target, PP_ToBool(from_user_action)));
234 }
235
236 PP_Bool FlashResource::IsRectTopmost(PP_Instance instance,
237 const PP_Rect* rect) {
238 int32_t result = SyncCall<IPC::Message>(RENDERER,
239 PpapiHostMsg_Flash_IsRectTopmost(*rect));
240 return PP_FromBool(result == PP_OK);
241 }
242
168 } // namespace proxy 243 } // namespace proxy
169 } // namespace ppapi 244 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/flash_resource.h ('k') | ppapi/proxy/ppapi_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698