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

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: Created 8 years, 10 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) 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, bool on_top) {
49 if (has_interface<PPB_Flash>()) { 49 if (has_interface<PPB_Flash>()) {
50 get_interface<PPB_Flash>()->SetInstanceAlwaysOnTop(instance->pp_instance(), 50 get_interface<PPB_Flash>()->SetInstanceAlwaysOnTop(instance.pp_instance(),
51 PP_FromBool(on_top)); 51 PP_FromBool(on_top));
52 } else if (has_interface<PPB_Flash_12_0>()) { 52 } else if (has_interface<PPB_Flash_12_0>()) {
53 get_interface<PPB_Flash_12_0>()->SetInstanceAlwaysOnTop( 53 get_interface<PPB_Flash_12_0>()->SetInstanceAlwaysOnTop(
54 instance->pp_instance(), PP_FromBool(on_top)); 54 instance.pp_instance(), PP_FromBool(on_top));
55 } else if (has_interface<PPB_Flash_11>()) { 55 } else if (has_interface<PPB_Flash_11>()) {
56 get_interface<PPB_Flash_11>()->SetInstanceAlwaysOnTop( 56 get_interface<PPB_Flash_11>()->SetInstanceAlwaysOnTop(
57 instance->pp_instance(), PP_FromBool(on_top)); 57 instance.pp_instance(), PP_FromBool(on_top));
58 } 58 }
59 } 59 }
60 60
61 // static 61 // static
62 bool Flash::DrawGlyphs(Instance* instance, 62 bool Flash::DrawGlyphs(const InstanceHandle& instance,
63 ImageData* image, 63 ImageData* image,
64 const FontDescription_Dev& font_desc, 64 const FontDescription_Dev& font_desc,
65 uint32_t color, 65 uint32_t color,
66 const Point& position, 66 const Point& position,
67 const Rect& clip, 67 const Rect& clip,
68 const float transformation[3][3], 68 const float transformation[3][3],
69 bool allow_subpixel_aa, 69 bool allow_subpixel_aa,
70 uint32_t glyph_count, 70 uint32_t glyph_count,
71 const uint16_t glyph_indices[], 71 const uint16_t glyph_indices[],
72 const PP_Point glyph_advances[]) { 72 const PP_Point glyph_advances[]) {
73 bool rv = false; 73 bool rv = false;
74 if (has_interface<PPB_Flash>()) { 74 if (has_interface<PPB_Flash>()) {
75 rv = PP_ToBool(get_interface<PPB_Flash>()->DrawGlyphs( 75 rv = PP_ToBool(get_interface<PPB_Flash>()->DrawGlyphs(
76 instance->pp_instance(), 76 instance.pp_instance(),
77 image->pp_resource(), 77 image->pp_resource(),
78 &font_desc.pp_font_description(), 78 &font_desc.pp_font_description(),
79 color, 79 color,
80 &position.pp_point(), 80 &position.pp_point(),
81 &clip.pp_rect(), 81 &clip.pp_rect(),
82 transformation, 82 transformation,
83 PP_FromBool(allow_subpixel_aa), 83 PP_FromBool(allow_subpixel_aa),
84 glyph_count, 84 glyph_count,
85 glyph_indices, 85 glyph_indices,
86 glyph_advances)); 86 glyph_advances));
87 } else if (has_interface<PPB_Flash_12_0>()) { 87 } else if (has_interface<PPB_Flash_12_0>()) {
88 rv = PP_ToBool(get_interface<PPB_Flash_12_0>()->DrawGlyphs( 88 rv = PP_ToBool(get_interface<PPB_Flash_12_0>()->DrawGlyphs(
89 instance->pp_instance(), 89 instance.pp_instance(),
90 image->pp_resource(), 90 image->pp_resource(),
91 &font_desc.pp_font_description(), 91 &font_desc.pp_font_description(),
92 color, 92 color,
93 &position.pp_point(), 93 &position.pp_point(),
94 &clip.pp_rect(), 94 &clip.pp_rect(),
95 transformation, 95 transformation,
96 PP_FromBool(allow_subpixel_aa), 96 PP_FromBool(allow_subpixel_aa),
97 glyph_count, 97 glyph_count,
98 glyph_indices, 98 glyph_indices,
99 glyph_advances)); 99 glyph_advances));
100 } else if (has_interface<PPB_Flash_11>()) { 100 } else if (has_interface<PPB_Flash_11>()) {
101 rv = PP_ToBool(get_interface<PPB_Flash_11>()->DrawGlyphs( 101 rv = PP_ToBool(get_interface<PPB_Flash_11>()->DrawGlyphs(
102 instance->pp_instance(), 102 instance.pp_instance(),
103 image->pp_resource(), 103 image->pp_resource(),
104 &font_desc.pp_font_description(), 104 &font_desc.pp_font_description(),
105 color, 105 color,
106 position.pp_point(), 106 position.pp_point(),
107 clip.pp_rect(), 107 clip.pp_rect(),
108 transformation, 108 transformation,
109 glyph_count, 109 glyph_count,
110 glyph_indices, 110 glyph_indices,
111 glyph_advances)); 111 glyph_advances));
112 } 112 }
113 return rv; 113 return rv;
114 } 114 }
115 115
116 // static 116 // static
117 Var Flash::GetProxyForURL(Instance* instance, const std::string& url) { 117 Var Flash::GetProxyForURL(const InstanceHandle& instance,
118 const std::string& url) {
118 Var rv; 119 Var rv;
119 if (has_interface<PPB_Flash>()) { 120 if (has_interface<PPB_Flash>()) {
120 rv = Var(Var::PassRef(), 121 rv = Var(PASS_REF,
121 get_interface<PPB_Flash>()->GetProxyForURL(instance->pp_instance(), 122 get_interface<PPB_Flash>()->GetProxyForURL(instance.pp_instance(),
122 url.c_str())); 123 url.c_str()));
123 } else if (has_interface<PPB_Flash_12_0>()) { 124 } else if (has_interface<PPB_Flash_12_0>()) {
124 rv = Var(Var::PassRef(), 125 rv = Var(PASS_REF,
125 get_interface<PPB_Flash_12_0>()->GetProxyForURL( 126 get_interface<PPB_Flash_12_0>()->GetProxyForURL(
126 instance->pp_instance(), url.c_str())); 127 instance.pp_instance(), url.c_str()));
127 } else if (has_interface<PPB_Flash_11>()) { 128 } else if (has_interface<PPB_Flash_11>()) {
128 rv = Var(Var::PassRef(), 129 rv = Var(PASS_REF,
129 get_interface<PPB_Flash_11>()->GetProxyForURL( 130 get_interface<PPB_Flash_11>()->GetProxyForURL(
130 instance->pp_instance(), url.c_str())); 131 instance.pp_instance(), url.c_str()));
131 } 132 }
132 return rv; 133 return rv;
133 } 134 }
134 135
135 // static 136 // static
136 int32_t Flash::Navigate(const URLRequestInfo& request_info, 137 int32_t Flash::Navigate(const URLRequestInfo& request_info,
137 const std::string& target, 138 const std::string& target,
138 bool from_user_action) { 139 bool from_user_action) {
139 int32_t rv = PP_ERROR_FAILED; 140 int32_t rv = PP_ERROR_FAILED;
140 if (has_interface<PPB_Flash>()) { 141 if (has_interface<PPB_Flash>()) {
141 rv = get_interface<PPB_Flash>()->Navigate(request_info.pp_resource(), 142 rv = get_interface<PPB_Flash>()->Navigate(request_info.pp_resource(),
142 target.c_str(), 143 target.c_str(),
143 PP_FromBool(from_user_action)); 144 PP_FromBool(from_user_action));
144 } else if (has_interface<PPB_Flash_12_0>()) { 145 } else if (has_interface<PPB_Flash_12_0>()) {
145 rv = get_interface<PPB_Flash_12_0>()->Navigate( 146 rv = get_interface<PPB_Flash_12_0>()->Navigate(
146 request_info.pp_resource(), 147 request_info.pp_resource(),
147 target.c_str(), 148 target.c_str(),
148 PP_FromBool(from_user_action)); 149 PP_FromBool(from_user_action));
149 } else if (has_interface<PPB_Flash_11>()) { 150 } else if (has_interface<PPB_Flash_11>()) {
150 rv = get_interface<PPB_Flash_11>()->Navigate(request_info.pp_resource(), 151 rv = get_interface<PPB_Flash_11>()->Navigate(request_info.pp_resource(),
151 target.c_str(), 152 target.c_str(),
152 from_user_action); 153 from_user_action);
153 } 154 }
154 return rv; 155 return rv;
155 } 156 }
156 157
157 // static 158 // static
158 void Flash::RunMessageLoop(Instance* instance) { 159 void Flash::RunMessageLoop(const InstanceHandle& instance) {
159 if (has_interface<PPB_Flash>()) 160 if (has_interface<PPB_Flash>())
160 get_interface<PPB_Flash>()->RunMessageLoop(instance->pp_instance()); 161 get_interface<PPB_Flash>()->RunMessageLoop(instance.pp_instance());
161 else if (has_interface<PPB_Flash_12_0>()) 162 else if (has_interface<PPB_Flash_12_0>())
162 get_interface<PPB_Flash_12_0>()->RunMessageLoop(instance->pp_instance()); 163 get_interface<PPB_Flash_12_0>()->RunMessageLoop(instance.pp_instance());
163 else if (has_interface<PPB_Flash_11>()) 164 else if (has_interface<PPB_Flash_11>())
164 get_interface<PPB_Flash_11>()->RunMessageLoop(instance->pp_instance()); 165 get_interface<PPB_Flash_11>()->RunMessageLoop(instance.pp_instance());
165 } 166 }
166 167
167 // static 168 // static
168 void Flash::QuitMessageLoop(Instance* instance) { 169 void Flash::QuitMessageLoop(const InstanceHandle& instance) {
169 if (has_interface<PPB_Flash>()) 170 if (has_interface<PPB_Flash>())
170 get_interface<PPB_Flash>()->QuitMessageLoop(instance->pp_instance()); 171 get_interface<PPB_Flash>()->QuitMessageLoop(instance.pp_instance());
171 else if (has_interface<PPB_Flash_12_0>()) 172 else if (has_interface<PPB_Flash_12_0>())
172 get_interface<PPB_Flash_12_0>()->QuitMessageLoop(instance->pp_instance()); 173 get_interface<PPB_Flash_12_0>()->QuitMessageLoop(instance.pp_instance());
173 else if (has_interface<PPB_Flash_11>()) 174 else if (has_interface<PPB_Flash_11>())
174 get_interface<PPB_Flash_11>()->QuitMessageLoop(instance->pp_instance()); 175 get_interface<PPB_Flash_11>()->QuitMessageLoop(instance.pp_instance());
175 } 176 }
176 177
177 // static 178 // static
178 double Flash::GetLocalTimeZoneOffset(Instance* instance, PP_Time t) { 179 double Flash::GetLocalTimeZoneOffset(const InstanceHandle& instance, PP_Time t) {
179 double rv = 0; 180 double rv = 0;
180 if (has_interface<PPB_Flash>()) { 181 if (has_interface<PPB_Flash>()) {
181 rv = get_interface<PPB_Flash>()->GetLocalTimeZoneOffset( 182 rv = get_interface<PPB_Flash>()->GetLocalTimeZoneOffset(
182 instance->pp_instance(), t); 183 instance.pp_instance(), t);
183 } else if (has_interface<PPB_Flash_12_0>()) { 184 } else if (has_interface<PPB_Flash_12_0>()) {
184 rv = get_interface<PPB_Flash_12_0>()->GetLocalTimeZoneOffset( 185 rv = get_interface<PPB_Flash_12_0>()->GetLocalTimeZoneOffset(
185 instance->pp_instance(), t); 186 instance.pp_instance(), t);
186 } else if (has_interface<PPB_Flash_11>()) { 187 } else if (has_interface<PPB_Flash_11>()) {
187 rv = get_interface<PPB_Flash_11>()->GetLocalTimeZoneOffset( 188 rv = get_interface<PPB_Flash_11>()->GetLocalTimeZoneOffset(
188 instance->pp_instance(), t); 189 instance.pp_instance(), t);
189 } 190 }
190 return rv; 191 return rv;
191 } 192 }
192 193
193 // static 194 // static
194 Var Flash::GetCommandLineArgs(Module* module) { 195 Var Flash::GetCommandLineArgs(Module* module) {
195 Var rv; 196 Var rv;
196 if (has_interface<PPB_Flash>()) { 197 if (has_interface<PPB_Flash>()) {
197 rv = Var(Var::PassRef(), 198 rv = Var(PASS_REF,
198 get_interface<PPB_Flash>()->GetCommandLineArgs( 199 get_interface<PPB_Flash>()->GetCommandLineArgs(
199 module->pp_module())); 200 module->pp_module()));
200 } else if (has_interface<PPB_Flash_12_0>()) { 201 } else if (has_interface<PPB_Flash_12_0>()) {
201 rv = Var(Var::PassRef(), 202 rv = Var(PASS_REF,
202 get_interface<PPB_Flash_12_0>()->GetCommandLineArgs( 203 get_interface<PPB_Flash_12_0>()->GetCommandLineArgs(
203 module->pp_module())); 204 module->pp_module()));
204 } else if (has_interface<PPB_Flash_11>()) { 205 } else if (has_interface<PPB_Flash_11>()) {
205 rv = Var(Var::PassRef(), 206 rv = Var(PASS_REF,
206 get_interface<PPB_Flash_11>()->GetCommandLineArgs( 207 get_interface<PPB_Flash_11>()->GetCommandLineArgs(
207 module->pp_module())); 208 module->pp_module()));
208 } 209 }
209 return rv; 210 return rv;
210 } 211 }
211 212
212 // static 213 // static
213 void Flash::PreloadFontWin(const void* logfontw) { 214 void Flash::PreloadFontWin(const void* logfontw) {
214 if (has_interface<PPB_Flash>()) 215 if (has_interface<PPB_Flash>())
215 get_interface<PPB_Flash>()->PreloadFontWin(logfontw); 216 get_interface<PPB_Flash>()->PreloadFontWin(logfontw);
216 else if (has_interface<PPB_Flash_12_0>()) 217 else if (has_interface<PPB_Flash_12_0>())
217 get_interface<PPB_Flash_12_0>()->PreloadFontWin(logfontw); 218 get_interface<PPB_Flash_12_0>()->PreloadFontWin(logfontw);
218 } 219 }
219 220
220 // static 221 // static
221 bool Flash::IsRectTopmost(Instance* instance, const Rect& rect) { 222 bool Flash::IsRectTopmost(const InstanceHandle& instance, const Rect& rect) {
222 bool rv = false; 223 bool rv = false;
223 if (has_interface<PPB_Flash>()) { 224 if (has_interface<PPB_Flash>()) {
224 rv = PP_ToBool(get_interface<PPB_Flash>()->IsRectTopmost( 225 rv = PP_ToBool(get_interface<PPB_Flash>()->IsRectTopmost(
225 instance->pp_instance(), &rect.pp_rect())); 226 instance.pp_instance(), &rect.pp_rect()));
226 } 227 }
227 return rv; 228 return rv;
228 } 229 }
229 230
230 // static 231 // static
231 int32_t Flash::InvokePrinting(Instance* instance) { 232 int32_t Flash::InvokePrinting(const InstanceHandle& instance) {
232 int32_t rv = PP_ERROR_NOTSUPPORTED; 233 int32_t rv = PP_ERROR_NOTSUPPORTED;
233 if (has_interface<PPB_Flash>()) 234 if (has_interface<PPB_Flash>())
234 rv = get_interface<PPB_Flash>()->InvokePrinting(instance->pp_instance()); 235 rv = get_interface<PPB_Flash>()->InvokePrinting(instance.pp_instance());
235 return rv; 236 return rv;
236 } 237 }
237 238
238 // static 239 // static
239 void Flash::UpdateActivity(Instance* instance) { 240 void Flash::UpdateActivity(const InstanceHandle& instance) {
240 if (has_interface<PPB_Flash>()) 241 if (has_interface<PPB_Flash>())
241 get_interface<PPB_Flash>()->UpdateActivity(instance->pp_instance()); 242 get_interface<PPB_Flash>()->UpdateActivity(instance.pp_instance());
242 } 243 }
243 244
244 } // namespace flash 245 } // namespace flash
245 } // namespace pp 246 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698