Chromium Code Reviews| 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" | 13 #include "ppapi/proxy/ppb_context_3d_proxy.h" |
| 14 #include "ppapi/proxy/ppb_graphics_3d_proxy.h" | |
| 14 #include "ppapi/thunk/enter.h" | 15 #include "ppapi/thunk/enter.h" |
| 15 #include "ppapi/thunk/resource_creation_api.h" | 16 #include "ppapi/thunk/resource_creation_api.h" |
| 16 #include "ppapi/thunk/thunk.h" | 17 #include "ppapi/thunk/thunk.h" |
| 17 | 18 |
| 18 using ppapi::thunk::EnterResourceNoLock; | 19 using ppapi::thunk::EnterResourceNoLock; |
| 19 using ppapi::thunk::PPB_Buffer_API; | 20 using ppapi::thunk::PPB_Buffer_API; |
| 20 using ppapi::thunk::PPB_Context3D_API; | 21 using ppapi::thunk::PPB_Context3D_API; |
| 22 using ppapi::thunk::PPB_Graphics3D_API; | |
| 21 using ppapi::thunk::PPB_VideoDecoder_API; | 23 using ppapi::thunk::PPB_VideoDecoder_API; |
| 22 | 24 |
| 23 namespace ppapi { | 25 namespace ppapi { |
| 24 namespace proxy { | 26 namespace proxy { |
| 25 | 27 |
| 26 class VideoDecoder : public Resource, public VideoDecoderImpl { | 28 class VideoDecoder : public Resource, public VideoDecoderImpl { |
| 27 public: | 29 public: |
| 28 // You must call Init() before using this class. | 30 // You must call Init() before using this class. |
| 29 explicit VideoDecoder(const HostResource& resource); | 31 explicit VideoDecoder(const HostResource& resource); |
| 30 virtual ~VideoDecoder(); | 32 virtual ~VideoDecoder(); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 213 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
| 212 // Dispatcher is null if it cannot find the instance passed to it (i.e. if the | 214 // Dispatcher is null if it cannot find the instance passed to it (i.e. if the |
| 213 // client passes in an invalid instance). | 215 // client passes in an invalid instance). |
| 214 if (!dispatcher) | 216 if (!dispatcher) |
| 215 return 0; | 217 return 0; |
| 216 | 218 |
| 217 std::vector<PP_VideoConfigElement> copied; | 219 std::vector<PP_VideoConfigElement> copied; |
| 218 if (!VideoDecoderImpl::CopyConfigsToVector(config, &copied)) | 220 if (!VideoDecoderImpl::CopyConfigsToVector(config, &copied)) |
| 219 return 0; | 221 return 0; |
| 220 | 222 |
| 221 EnterResourceNoLock<PPB_Context3D_API> enter_context(context3d_id, true); | 223 HostResource host_context; |
| 222 if (enter_context.failed()) | 224 gpu::gles2::GLES2Implementation* gles2_impl = NULL; |
| 223 return 0; | 225 |
| 224 Context3D* ppb_context = | 226 EnterResourceNoLock<PPB_Context3D_API> enter_context(context3d_id, false); |
| 225 static_cast<Context3D*>(enter_context.object()); | 227 if (enter_context.succeeded()) { |
| 226 HostResource host_context = ppb_context->host_resource(); | 228 Context3D* context = static_cast<Context3D*>(enter_context.object()); |
| 229 host_context = context->host_resource(); | |
| 230 gles2_impl = context->gles2_impl(); | |
| 231 } else { | |
| 232 EnterResourceNoLock<PPB_Graphics3D_API> enter_context(context3d_id, true); | |
|
vrk (LEFT CHROMIUM)
2011/08/29 16:56:41
nit: "context3d_id" is a bit of a misleading name
piman
2011/08/29 19:58:57
I renamed to graphics_context. I really want to na
| |
| 233 if (enter_context.failed()) | |
| 234 return 0; | |
| 235 Graphics3D* context = static_cast<Graphics3D*>(enter_context.object()); | |
| 236 host_context = context->host_resource(); | |
| 237 gles2_impl = context->gles2_impl(); | |
| 238 } | |
| 227 | 239 |
| 228 HostResource result; | 240 HostResource result; |
| 229 dispatcher->Send(new PpapiHostMsg_PPBVideoDecoder_Create( | 241 dispatcher->Send(new PpapiHostMsg_PPBVideoDecoder_Create( |
| 230 INTERFACE_ID_PPB_VIDEO_DECODER_DEV, instance, | 242 INTERFACE_ID_PPB_VIDEO_DECODER_DEV, instance, |
| 231 host_context, copied, &result)); | 243 host_context, copied, &result)); |
| 232 if (result.is_null()) | 244 if (result.is_null()) |
| 233 return 0; | 245 return 0; |
| 234 | 246 |
| 235 // Need a scoped_refptr to keep the object alive during the Init call. | 247 // Need a scoped_refptr to keep the object alive during the Init call. |
| 236 scoped_refptr<VideoDecoder> decoder(new VideoDecoder(result)); | 248 scoped_refptr<VideoDecoder> decoder(new VideoDecoder(result)); |
| 237 if (!decoder->Init(context3d_id, enter_context.object(), config)) | 249 decoder->InitCommon(context3d_id, gles2_impl); |
| 238 return 0; | |
| 239 return decoder->GetReference(); | 250 return decoder->GetReference(); |
| 240 } | 251 } |
| 241 | 252 |
| 242 void PPB_VideoDecoder_Proxy::OnMsgCreate( | 253 void PPB_VideoDecoder_Proxy::OnMsgCreate( |
| 243 PP_Instance instance, const HostResource& context3d_id, | 254 PP_Instance instance, const HostResource& context3d_id, |
| 244 const std::vector<PP_VideoConfigElement>& config, | 255 const std::vector<PP_VideoConfigElement>& config, |
| 245 HostResource* result) { | 256 HostResource* result) { |
| 246 thunk::EnterFunction<thunk::ResourceCreationAPI> resource_creation(instance, | 257 thunk::EnterFunction<thunk::ResourceCreationAPI> resource_creation(instance, |
| 247 true); | 258 true); |
| 248 if (resource_creation.failed()) | 259 if (resource_creation.failed()) |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 336 | 347 |
| 337 void PPB_VideoDecoder_Proxy::OnMsgResetACK( | 348 void PPB_VideoDecoder_Proxy::OnMsgResetACK( |
| 338 const HostResource& decoder, int32_t result) { | 349 const HostResource& decoder, int32_t result) { |
| 339 EnterPluginFromHostResource<PPB_VideoDecoder_API> enter(decoder); | 350 EnterPluginFromHostResource<PPB_VideoDecoder_API> enter(decoder); |
| 340 if (enter.succeeded()) | 351 if (enter.succeeded()) |
| 341 static_cast<VideoDecoder*>(enter.object())->ResetACK(result); | 352 static_cast<VideoDecoder*>(enter.object())->ResetACK(result); |
| 342 } | 353 } |
| 343 | 354 |
| 344 } // namespace proxy | 355 } // namespace proxy |
| 345 } // namespace ppapi | 356 } // namespace ppapi |
| OLD | NEW |