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

Side by Side Diff: ppapi/cpp/private/flash.cc

Issue 9381010: Convert resources to take an instance key instead of an Instance*. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: USELESS PATCH TITLE Created 8 years, 9 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
« no previous file with comments | « ppapi/cpp/private/flash.h ('k') | ppapi/cpp/private/flash_clipboard.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/cpp/private/flash.h" 5 #include "ppapi/cpp/private/flash.h"
6 6
7 #include "ppapi/c/pp_bool.h" 7 #include "ppapi/c/pp_bool.h"
8 #include "ppapi/c/pp_errors.h" 8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/cpp/dev/font_dev.h" 9 #include "ppapi/cpp/dev/font_dev.h"
10 #include "ppapi/cpp/image_data.h" 10 #include "ppapi/cpp/image_data.h"
11 #include "ppapi/cpp/instance.h" 11 #include "ppapi/cpp/instance_handle.h"
12 #include "ppapi/cpp/module.h" 12 #include "ppapi/cpp/module.h"
13 #include "ppapi/cpp/module_impl.h" 13 #include "ppapi/cpp/module_impl.h"
14 #include "ppapi/cpp/point.h" 14 #include "ppapi/cpp/point.h"
15 #include "ppapi/cpp/rect.h" 15 #include "ppapi/cpp/rect.h"
16 #include "ppapi/cpp/url_request_info.h" 16 #include "ppapi/cpp/url_request_info.h"
17 #include "ppapi/cpp/var.h" 17 #include "ppapi/cpp/var.h"
18 #include "ppapi/c/private/ppb_flash.h" 18 #include "ppapi/c/private/ppb_flash.h"
19 19
20 namespace pp { 20 namespace pp {
21 21
(...skipping 16 matching lines...) Expand all
38 namespace flash { 38 namespace flash {
39 39
40 // static 40 // static
41 bool Flash::IsAvailable() { 41 bool Flash::IsAvailable() {
42 return has_interface<PPB_Flash>() || 42 return has_interface<PPB_Flash>() ||
43 has_interface<PPB_Flash_12_0>() || 43 has_interface<PPB_Flash_12_0>() ||
44 has_interface<PPB_Flash_11>(); 44 has_interface<PPB_Flash_11>();
45 } 45 }
46 46
47 // static 47 // static
48 void Flash::SetInstanceAlwaysOnTop(Instance* instance, bool on_top) { 48 void Flash::SetInstanceAlwaysOnTop(const InstanceHandle& instance,
49 bool on_top) {
49 if (has_interface<PPB_Flash>()) { 50 if (has_interface<PPB_Flash>()) {
50 get_interface<PPB_Flash>()->SetInstanceAlwaysOnTop(instance->pp_instance(), 51 get_interface<PPB_Flash>()->SetInstanceAlwaysOnTop(instance.pp_instance(),
51 PP_FromBool(on_top)); 52 PP_FromBool(on_top));
52 } else if (has_interface<PPB_Flash_12_0>()) { 53 } else if (has_interface<PPB_Flash_12_0>()) {
53 get_interface<PPB_Flash_12_0>()->SetInstanceAlwaysOnTop( 54 get_interface<PPB_Flash_12_0>()->SetInstanceAlwaysOnTop(
54 instance->pp_instance(), PP_FromBool(on_top)); 55 instance.pp_instance(), PP_FromBool(on_top));
55 } else if (has_interface<PPB_Flash_11>()) { 56 } else if (has_interface<PPB_Flash_11>()) {
56 get_interface<PPB_Flash_11>()->SetInstanceAlwaysOnTop( 57 get_interface<PPB_Flash_11>()->SetInstanceAlwaysOnTop(
57 instance->pp_instance(), PP_FromBool(on_top)); 58 instance.pp_instance(), PP_FromBool(on_top));
58 } 59 }
59 } 60 }
60 61
61 // static 62 // static
62 bool Flash::DrawGlyphs(Instance* instance, 63 bool Flash::DrawGlyphs(const InstanceHandle& instance,
63 ImageData* image, 64 ImageData* image,
64 const FontDescription_Dev& font_desc, 65 const FontDescription_Dev& font_desc,
65 uint32_t color, 66 uint32_t color,
66 const Point& position, 67 const Point& position,
67 const Rect& clip, 68 const Rect& clip,
68 const float transformation[3][3], 69 const float transformation[3][3],
69 bool allow_subpixel_aa, 70 bool allow_subpixel_aa,
70 uint32_t glyph_count, 71 uint32_t glyph_count,
71 const uint16_t glyph_indices[], 72 const uint16_t glyph_indices[],
72 const PP_Point glyph_advances[]) { 73 const PP_Point glyph_advances[]) {
73 bool rv = false; 74 bool rv = false;
74 if (has_interface<PPB_Flash>()) { 75 if (has_interface<PPB_Flash>()) {
75 rv = PP_ToBool(get_interface<PPB_Flash>()->DrawGlyphs( 76 rv = PP_ToBool(get_interface<PPB_Flash>()->DrawGlyphs(
76 instance->pp_instance(), 77 instance.pp_instance(),
77 image->pp_resource(), 78 image->pp_resource(),
78 &font_desc.pp_font_description(), 79 &font_desc.pp_font_description(),
79 color, 80 color,
80 &position.pp_point(), 81 &position.pp_point(),
81 &clip.pp_rect(), 82 &clip.pp_rect(),
82 transformation, 83 transformation,
83 PP_FromBool(allow_subpixel_aa), 84 PP_FromBool(allow_subpixel_aa),
84 glyph_count, 85 glyph_count,
85 glyph_indices, 86 glyph_indices,
86 glyph_advances)); 87 glyph_advances));
87 } else if (has_interface<PPB_Flash_12_0>()) { 88 } else if (has_interface<PPB_Flash_12_0>()) {
88 rv = PP_ToBool(get_interface<PPB_Flash_12_0>()->DrawGlyphs( 89 rv = PP_ToBool(get_interface<PPB_Flash_12_0>()->DrawGlyphs(
89 instance->pp_instance(), 90 instance.pp_instance(),
90 image->pp_resource(), 91 image->pp_resource(),
91 &font_desc.pp_font_description(), 92 &font_desc.pp_font_description(),
92 color, 93 color,
93 &position.pp_point(), 94 &position.pp_point(),
94 &clip.pp_rect(), 95 &clip.pp_rect(),
95 transformation, 96 transformation,
96 PP_FromBool(allow_subpixel_aa), 97 PP_FromBool(allow_subpixel_aa),
97 glyph_count, 98 glyph_count,
98 glyph_indices, 99 glyph_indices,
99 glyph_advances)); 100 glyph_advances));
100 } else if (has_interface<PPB_Flash_11>()) { 101 } else if (has_interface<PPB_Flash_11>()) {
101 rv = PP_ToBool(get_interface<PPB_Flash_11>()->DrawGlyphs( 102 rv = PP_ToBool(get_interface<PPB_Flash_11>()->DrawGlyphs(
102 instance->pp_instance(), 103 instance.pp_instance(),
103 image->pp_resource(), 104 image->pp_resource(),
104 &font_desc.pp_font_description(), 105 &font_desc.pp_font_description(),
105 color, 106 color,
106 position.pp_point(), 107 position.pp_point(),
107 clip.pp_rect(), 108 clip.pp_rect(),
108 transformation, 109 transformation,
109 glyph_count, 110 glyph_count,
110 glyph_indices, 111 glyph_indices,
111 glyph_advances)); 112 glyph_advances));
112 } 113 }
113 return rv; 114 return rv;
114 } 115 }
115 116
116 // static 117 // static
117 Var Flash::GetProxyForURL(Instance* instance, const std::string& url) { 118 Var Flash::GetProxyForURL(const InstanceHandle& instance,
119 const std::string& url) {
118 Var rv; 120 Var rv;
119 if (has_interface<PPB_Flash>()) { 121 if (has_interface<PPB_Flash>()) {
120 rv = Var(Var::PassRef(), 122 rv = Var(PASS_REF,
121 get_interface<PPB_Flash>()->GetProxyForURL(instance->pp_instance(), 123 get_interface<PPB_Flash>()->GetProxyForURL(instance.pp_instance(),
122 url.c_str())); 124 url.c_str()));
123 } else if (has_interface<PPB_Flash_12_0>()) { 125 } else if (has_interface<PPB_Flash_12_0>()) {
124 rv = Var(Var::PassRef(), 126 rv = Var(PASS_REF,
125 get_interface<PPB_Flash_12_0>()->GetProxyForURL( 127 get_interface<PPB_Flash_12_0>()->GetProxyForURL(
126 instance->pp_instance(), url.c_str())); 128 instance.pp_instance(), url.c_str()));
127 } else if (has_interface<PPB_Flash_11>()) { 129 } else if (has_interface<PPB_Flash_11>()) {
128 rv = Var(Var::PassRef(), 130 rv = Var(PASS_REF,
129 get_interface<PPB_Flash_11>()->GetProxyForURL( 131 get_interface<PPB_Flash_11>()->GetProxyForURL(
130 instance->pp_instance(), url.c_str())); 132 instance.pp_instance(), url.c_str()));
131 } 133 }
132 return rv; 134 return rv;
133 } 135 }
134 136
135 // static 137 // static
136 int32_t Flash::Navigate(const URLRequestInfo& request_info, 138 int32_t Flash::Navigate(const URLRequestInfo& request_info,
137 const std::string& target, 139 const std::string& target,
138 bool from_user_action) { 140 bool from_user_action) {
139 int32_t rv = PP_ERROR_FAILED; 141 int32_t rv = PP_ERROR_FAILED;
140 if (has_interface<PPB_Flash>()) { 142 if (has_interface<PPB_Flash>()) {
141 rv = get_interface<PPB_Flash>()->Navigate(request_info.pp_resource(), 143 rv = get_interface<PPB_Flash>()->Navigate(request_info.pp_resource(),
142 target.c_str(), 144 target.c_str(),
143 PP_FromBool(from_user_action)); 145 PP_FromBool(from_user_action));
144 } else if (has_interface<PPB_Flash_12_0>()) { 146 } else if (has_interface<PPB_Flash_12_0>()) {
145 rv = get_interface<PPB_Flash_12_0>()->Navigate( 147 rv = get_interface<PPB_Flash_12_0>()->Navigate(
146 request_info.pp_resource(), 148 request_info.pp_resource(),
147 target.c_str(), 149 target.c_str(),
148 PP_FromBool(from_user_action)); 150 PP_FromBool(from_user_action));
149 } else if (has_interface<PPB_Flash_11>()) { 151 } else if (has_interface<PPB_Flash_11>()) {
150 rv = get_interface<PPB_Flash_11>()->Navigate(request_info.pp_resource(), 152 rv = get_interface<PPB_Flash_11>()->Navigate(request_info.pp_resource(),
151 target.c_str(), 153 target.c_str(),
152 from_user_action); 154 from_user_action);
153 } 155 }
154 return rv; 156 return rv;
155 } 157 }
156 158
157 // static 159 // static
158 void Flash::RunMessageLoop(Instance* instance) { 160 void Flash::RunMessageLoop(const InstanceHandle& instance) {
159 if (has_interface<PPB_Flash>()) 161 if (has_interface<PPB_Flash>())
160 get_interface<PPB_Flash>()->RunMessageLoop(instance->pp_instance()); 162 get_interface<PPB_Flash>()->RunMessageLoop(instance.pp_instance());
161 else if (has_interface<PPB_Flash_12_0>()) 163 else if (has_interface<PPB_Flash_12_0>())
162 get_interface<PPB_Flash_12_0>()->RunMessageLoop(instance->pp_instance()); 164 get_interface<PPB_Flash_12_0>()->RunMessageLoop(instance.pp_instance());
163 else if (has_interface<PPB_Flash_11>()) 165 else if (has_interface<PPB_Flash_11>())
164 get_interface<PPB_Flash_11>()->RunMessageLoop(instance->pp_instance()); 166 get_interface<PPB_Flash_11>()->RunMessageLoop(instance.pp_instance());
165 } 167 }
166 168
167 // static 169 // static
168 void Flash::QuitMessageLoop(Instance* instance) { 170 void Flash::QuitMessageLoop(const InstanceHandle& instance) {
169 if (has_interface<PPB_Flash>()) 171 if (has_interface<PPB_Flash>())
170 get_interface<PPB_Flash>()->QuitMessageLoop(instance->pp_instance()); 172 get_interface<PPB_Flash>()->QuitMessageLoop(instance.pp_instance());
171 else if (has_interface<PPB_Flash_12_0>()) 173 else if (has_interface<PPB_Flash_12_0>())
172 get_interface<PPB_Flash_12_0>()->QuitMessageLoop(instance->pp_instance()); 174 get_interface<PPB_Flash_12_0>()->QuitMessageLoop(instance.pp_instance());
173 else if (has_interface<PPB_Flash_11>()) 175 else if (has_interface<PPB_Flash_11>())
174 get_interface<PPB_Flash_11>()->QuitMessageLoop(instance->pp_instance()); 176 get_interface<PPB_Flash_11>()->QuitMessageLoop(instance.pp_instance());
175 } 177 }
176 178
177 // static 179 // static
178 double Flash::GetLocalTimeZoneOffset(Instance* instance, PP_Time t) { 180 double Flash::GetLocalTimeZoneOffset(const InstanceHandle& instance,
181 PP_Time t) {
179 double rv = 0; 182 double rv = 0;
180 if (has_interface<PPB_Flash>()) { 183 if (has_interface<PPB_Flash>()) {
181 rv = get_interface<PPB_Flash>()->GetLocalTimeZoneOffset( 184 rv = get_interface<PPB_Flash>()->GetLocalTimeZoneOffset(
182 instance->pp_instance(), t); 185 instance.pp_instance(), t);
183 } else if (has_interface<PPB_Flash_12_0>()) { 186 } else if (has_interface<PPB_Flash_12_0>()) {
184 rv = get_interface<PPB_Flash_12_0>()->GetLocalTimeZoneOffset( 187 rv = get_interface<PPB_Flash_12_0>()->GetLocalTimeZoneOffset(
185 instance->pp_instance(), t); 188 instance.pp_instance(), t);
186 } else if (has_interface<PPB_Flash_11>()) { 189 } else if (has_interface<PPB_Flash_11>()) {
187 rv = get_interface<PPB_Flash_11>()->GetLocalTimeZoneOffset( 190 rv = get_interface<PPB_Flash_11>()->GetLocalTimeZoneOffset(
188 instance->pp_instance(), t); 191 instance.pp_instance(), t);
189 } 192 }
190 return rv; 193 return rv;
191 } 194 }
192 195
193 // static 196 // static
194 Var Flash::GetCommandLineArgs(Module* module) { 197 Var Flash::GetCommandLineArgs(Module* module) {
195 Var rv; 198 Var rv;
196 if (has_interface<PPB_Flash>()) { 199 if (has_interface<PPB_Flash>()) {
197 rv = Var(Var::PassRef(), 200 rv = Var(PASS_REF,
198 get_interface<PPB_Flash>()->GetCommandLineArgs( 201 get_interface<PPB_Flash>()->GetCommandLineArgs(
199 module->pp_module())); 202 module->pp_module()));
200 } else if (has_interface<PPB_Flash_12_0>()) { 203 } else if (has_interface<PPB_Flash_12_0>()) {
201 rv = Var(Var::PassRef(), 204 rv = Var(PASS_REF,
202 get_interface<PPB_Flash_12_0>()->GetCommandLineArgs( 205 get_interface<PPB_Flash_12_0>()->GetCommandLineArgs(
203 module->pp_module())); 206 module->pp_module()));
204 } else if (has_interface<PPB_Flash_11>()) { 207 } else if (has_interface<PPB_Flash_11>()) {
205 rv = Var(Var::PassRef(), 208 rv = Var(PASS_REF,
206 get_interface<PPB_Flash_11>()->GetCommandLineArgs( 209 get_interface<PPB_Flash_11>()->GetCommandLineArgs(
207 module->pp_module())); 210 module->pp_module()));
208 } 211 }
209 return rv; 212 return rv;
210 } 213 }
211 214
212 // static 215 // static
213 void Flash::PreloadFontWin(const void* logfontw) { 216 void Flash::PreloadFontWin(const void* logfontw) {
214 if (has_interface<PPB_Flash>()) 217 if (has_interface<PPB_Flash>())
215 get_interface<PPB_Flash>()->PreloadFontWin(logfontw); 218 get_interface<PPB_Flash>()->PreloadFontWin(logfontw);
216 else if (has_interface<PPB_Flash_12_0>()) 219 else if (has_interface<PPB_Flash_12_0>())
217 get_interface<PPB_Flash_12_0>()->PreloadFontWin(logfontw); 220 get_interface<PPB_Flash_12_0>()->PreloadFontWin(logfontw);
218 } 221 }
219 222
220 // static 223 // static
221 bool Flash::IsRectTopmost(Instance* instance, const Rect& rect) { 224 bool Flash::IsRectTopmost(const InstanceHandle& instance, const Rect& rect) {
222 bool rv = false; 225 bool rv = false;
223 if (has_interface<PPB_Flash>()) { 226 if (has_interface<PPB_Flash>()) {
224 rv = PP_ToBool(get_interface<PPB_Flash>()->IsRectTopmost( 227 rv = PP_ToBool(get_interface<PPB_Flash>()->IsRectTopmost(
225 instance->pp_instance(), &rect.pp_rect())); 228 instance.pp_instance(), &rect.pp_rect()));
226 } 229 }
227 return rv; 230 return rv;
228 } 231 }
229 232
230 // static 233 // static
231 int32_t Flash::InvokePrinting(Instance* instance) { 234 int32_t Flash::InvokePrinting(const InstanceHandle& instance) {
232 int32_t rv = PP_ERROR_NOTSUPPORTED; 235 int32_t rv = PP_ERROR_NOTSUPPORTED;
233 if (has_interface<PPB_Flash>()) 236 if (has_interface<PPB_Flash>())
234 rv = get_interface<PPB_Flash>()->InvokePrinting(instance->pp_instance()); 237 rv = get_interface<PPB_Flash>()->InvokePrinting(instance.pp_instance());
235 return rv; 238 return rv;
236 } 239 }
237 240
238 // static 241 // static
239 void Flash::UpdateActivity(Instance* instance) { 242 void Flash::UpdateActivity(const InstanceHandle& instance) {
240 if (has_interface<PPB_Flash>()) 243 if (has_interface<PPB_Flash>())
241 get_interface<PPB_Flash>()->UpdateActivity(instance->pp_instance()); 244 get_interface<PPB_Flash>()->UpdateActivity(instance.pp_instance());
242 } 245 }
243 246
244 } // namespace flash 247 } // namespace flash
245 } // namespace pp 248 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/cpp/private/flash.h ('k') | ppapi/cpp/private/flash_clipboard.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698