OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ppb_video_decoder_proxy.h" | 5 #include "ppapi/proxy/ppb_video_decoder_proxy.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "gpu/command_buffer/client/gles2_implementation.h" | 8 #include "gpu/command_buffer/client/gles2_implementation.h" |
9 #include "ppapi/proxy/enter_proxy.h" | 9 #include "ppapi/proxy/enter_proxy.h" |
10 #include "ppapi/proxy/plugin_dispatcher.h" | 10 #include "ppapi/proxy/plugin_dispatcher.h" |
11 #include "ppapi/proxy/ppapi_messages.h" | 11 #include "ppapi/proxy/ppapi_messages.h" |
12 #include "ppapi/proxy/ppb_buffer_proxy.h" | 12 #include "ppapi/proxy/ppb_buffer_proxy.h" |
13 #include "ppapi/proxy/ppb_context_3d_proxy.h" | |
14 #include "ppapi/proxy/ppb_graphics_3d_proxy.h" | 13 #include "ppapi/proxy/ppb_graphics_3d_proxy.h" |
15 #include "ppapi/thunk/enter.h" | 14 #include "ppapi/thunk/enter.h" |
16 #include "ppapi/thunk/resource_creation_api.h" | 15 #include "ppapi/thunk/resource_creation_api.h" |
17 #include "ppapi/thunk/thunk.h" | 16 #include "ppapi/thunk/thunk.h" |
18 | 17 |
19 using ppapi::thunk::EnterResourceNoLock; | 18 using ppapi::thunk::EnterResourceNoLock; |
20 using ppapi::thunk::PPB_Buffer_API; | 19 using ppapi::thunk::PPB_Buffer_API; |
21 using ppapi::thunk::PPB_Context3D_API; | |
22 using ppapi::thunk::PPB_Graphics3D_API; | 20 using ppapi::thunk::PPB_Graphics3D_API; |
23 using ppapi::thunk::PPB_VideoDecoder_API; | 21 using ppapi::thunk::PPB_VideoDecoder_API; |
24 | 22 |
25 namespace ppapi { | 23 namespace ppapi { |
26 namespace proxy { | 24 namespace proxy { |
27 | 25 |
28 class VideoDecoder : public Resource, public VideoDecoderImpl { | 26 class VideoDecoder : public Resource, public VideoDecoderImpl { |
29 public: | 27 public: |
30 // You must call Init() before using this class. | 28 // You must call Init() before using this class. |
31 explicit VideoDecoder(const HostResource& resource); | 29 explicit VideoDecoder(const HostResource& resource); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 PP_Resource PPB_VideoDecoder_Proxy::CreateProxyResource( | 186 PP_Resource PPB_VideoDecoder_Proxy::CreateProxyResource( |
189 PP_Instance instance, | 187 PP_Instance instance, |
190 PP_Resource graphics_context, | 188 PP_Resource graphics_context, |
191 PP_VideoDecoder_Profile profile) { | 189 PP_VideoDecoder_Profile profile) { |
192 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 190 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
193 // Dispatcher is null if it cannot find the instance passed to it (i.e. if the | 191 // Dispatcher is null if it cannot find the instance passed to it (i.e. if the |
194 // client passes in an invalid instance). | 192 // client passes in an invalid instance). |
195 if (!dispatcher) | 193 if (!dispatcher) |
196 return 0; | 194 return 0; |
197 | 195 |
198 HostResource host_context; | 196 EnterResourceNoLock<PPB_Graphics3D_API> enter_context(graphics_context, |
199 gpu::gles2::GLES2Implementation* gles2_impl = NULL; | 197 true); |
| 198 if (enter_context.failed()) |
| 199 return 0; |
200 | 200 |
201 EnterResourceNoLock<PPB_Context3D_API> enter_context(graphics_context, false); | 201 Graphics3D* context = static_cast<Graphics3D*>(enter_context.object()); |
202 if (enter_context.succeeded()) { | |
203 Context3D* context = static_cast<Context3D*>(enter_context.object()); | |
204 host_context = context->host_resource(); | |
205 gles2_impl = context->gles2_impl(); | |
206 } else { | |
207 EnterResourceNoLock<PPB_Graphics3D_API> enter_context(graphics_context, | |
208 true); | |
209 if (enter_context.failed()) | |
210 return 0; | |
211 Graphics3D* context = static_cast<Graphics3D*>(enter_context.object()); | |
212 host_context = context->host_resource(); | |
213 gles2_impl = context->gles2_impl(); | |
214 } | |
215 | 202 |
216 HostResource result; | 203 HostResource result; |
217 dispatcher->Send(new PpapiHostMsg_PPBVideoDecoder_Create( | 204 dispatcher->Send(new PpapiHostMsg_PPBVideoDecoder_Create( |
218 API_ID_PPB_VIDEO_DECODER_DEV, instance, | 205 API_ID_PPB_VIDEO_DECODER_DEV, instance, |
219 host_context, profile, &result)); | 206 context->host_resource(), profile, &result)); |
220 if (result.is_null()) | 207 if (result.is_null()) |
221 return 0; | 208 return 0; |
222 | 209 |
223 // Need a scoped_refptr to keep the object alive during the Init call. | 210 // Need a scoped_refptr to keep the object alive during the Init call. |
224 scoped_refptr<VideoDecoder> decoder(new VideoDecoder(result)); | 211 scoped_refptr<VideoDecoder> decoder(new VideoDecoder(result)); |
225 decoder->InitCommon(graphics_context, gles2_impl); | 212 decoder->InitCommon(graphics_context, context->gles2_impl()); |
226 return decoder->GetReference(); | 213 return decoder->GetReference(); |
227 } | 214 } |
228 | 215 |
229 void PPB_VideoDecoder_Proxy::OnMsgCreate( | 216 void PPB_VideoDecoder_Proxy::OnMsgCreate( |
230 PP_Instance instance, const HostResource& graphics_context, | 217 PP_Instance instance, const HostResource& graphics_context, |
231 PP_VideoDecoder_Profile profile, | 218 PP_VideoDecoder_Profile profile, |
232 HostResource* result) { | 219 HostResource* result) { |
233 thunk::EnterResourceCreation resource_creation(instance); | 220 thunk::EnterResourceCreation resource_creation(instance); |
234 if (resource_creation.failed()) | 221 if (resource_creation.failed()) |
235 return; | 222 return; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 | 312 |
326 void PPB_VideoDecoder_Proxy::OnMsgResetACK( | 313 void PPB_VideoDecoder_Proxy::OnMsgResetACK( |
327 const HostResource& decoder, int32_t result) { | 314 const HostResource& decoder, int32_t result) { |
328 EnterPluginFromHostResource<PPB_VideoDecoder_API> enter(decoder); | 315 EnterPluginFromHostResource<PPB_VideoDecoder_API> enter(decoder); |
329 if (enter.succeeded()) | 316 if (enter.succeeded()) |
330 static_cast<VideoDecoder*>(enter.object())->ResetACK(result); | 317 static_cast<VideoDecoder*>(enter.object())->ResetACK(result); |
331 } | 318 } |
332 | 319 |
333 } // namespace proxy | 320 } // namespace proxy |
334 } // namespace ppapi | 321 } // namespace ppapi |
OLD | NEW |