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

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
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 "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"
9 #include "ppapi/proxy/plugin_globals.h" 10 #include "ppapi/proxy/plugin_globals.h"
10 #include "ppapi/proxy/ppapi_messages.h" 11 #include "ppapi/proxy/ppapi_messages.h"
12 #include "ppapi/proxy/serialized_structs.h"
11 #include "ppapi/shared_impl/var.h" 13 #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;
12 18
13 namespace ppapi { 19 namespace ppapi {
14 namespace proxy { 20 namespace proxy {
15 21
16 FlashResource::FlashResource(Connection connection, PP_Instance instance) 22 FlashResource::FlashResource(Connection connection, PP_Instance instance)
17 : PluginResource(connection, instance) { 23 : PluginResource(connection, instance) {
18 SendCreate(RENDERER, PpapiHostMsg_Flash_Create()); 24 SendCreate(RENDERER, PpapiHostMsg_Flash_Create());
19 SendCreate(BROWSER, PpapiHostMsg_Flash_Create()); 25 SendCreate(BROWSER, PpapiHostMsg_Flash_Create());
20 } 26 }
21 27
(...skipping 27 matching lines...) Expand all
49 StringVar* url_string_var(StringVar::FromPPVar(value)); 55 StringVar* url_string_var(StringVar::FromPPVar(value));
50 if (!url_string_var) 56 if (!url_string_var)
51 return PP_FALSE; 57 return PP_FALSE;
52 PluginGlobals::Get()->SetActiveURL(url_string_var->value()); 58 PluginGlobals::Get()->SetActiveURL(url_string_var->value());
53 return PP_TRUE; 59 return PP_TRUE;
54 } 60 }
55 } 61 }
56 return PP_FALSE; 62 return PP_FALSE;
57 } 63 }
58 64
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
59 } // namespace proxy 135 } // namespace proxy
60 } // namespace ppapi 136 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698