| 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 "webkit/plugins/ppapi/ppb_video_decoder_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_video_decoder_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "gpu/command_buffer/client/gles2_implementation.h" | 11 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 12 #include "media/video/picture.h" | 12 #include "media/video/picture.h" |
| 13 #include "ppapi/c/dev/pp_video_dev.h" | 13 #include "ppapi/c/dev/pp_video_dev.h" |
| 14 #include "ppapi/c/dev/ppb_video_decoder_dev.h" | 14 #include "ppapi/c/dev/ppb_video_decoder_dev.h" |
| 15 #include "ppapi/c/dev/ppp_video_decoder_dev.h" | 15 #include "ppapi/c/dev/ppp_video_decoder_dev.h" |
| 16 #include "ppapi/c/pp_completion_callback.h" | 16 #include "ppapi/c/pp_completion_callback.h" |
| 17 #include "ppapi/c/pp_errors.h" | 17 #include "ppapi/c/pp_errors.h" |
| 18 #include "webkit/plugins/ppapi/resource_helper.h" | 18 #include "webkit/plugins/ppapi/resource_helper.h" |
| 19 #include "ppapi/thunk/enter.h" | 19 #include "ppapi/thunk/enter.h" |
| 20 #include "webkit/plugins/ppapi/common.h" | 20 #include "webkit/plugins/ppapi/common.h" |
| 21 #include "webkit/plugins/ppapi/plugin_module.h" | 21 #include "webkit/plugins/ppapi/plugin_module.h" |
| 22 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 22 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 23 #include "webkit/plugins/ppapi/ppb_buffer_impl.h" | 23 #include "webkit/plugins/ppapi/ppb_buffer_impl.h" |
| 24 #include "webkit/plugins/ppapi/ppb_context_3d_impl.h" | 24 #include "webkit/plugins/ppapi/ppb_context_3d_impl.h" |
| 25 #include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h" |
| 25 #include "webkit/plugins/ppapi/resource_tracker.h" | 26 #include "webkit/plugins/ppapi/resource_tracker.h" |
| 26 | 27 |
| 27 using ppapi::thunk::EnterResourceNoLock; | 28 using ppapi::thunk::EnterResourceNoLock; |
| 28 using ppapi::thunk::PPB_Buffer_API; | 29 using ppapi::thunk::PPB_Buffer_API; |
| 29 using ppapi::thunk::PPB_Context3D_API; | 30 using ppapi::thunk::PPB_Context3D_API; |
| 31 using ppapi::thunk::PPB_Graphics3D_API; |
| 30 using ppapi::thunk::PPB_VideoDecoder_API; | 32 using ppapi::thunk::PPB_VideoDecoder_API; |
| 31 | 33 |
| 32 namespace webkit { | 34 namespace webkit { |
| 33 namespace ppapi { | 35 namespace ppapi { |
| 34 | 36 |
| 35 PPB_VideoDecoder_Impl::PPB_VideoDecoder_Impl(PP_Instance instance) | 37 PPB_VideoDecoder_Impl::PPB_VideoDecoder_Impl(PP_Instance instance) |
| 36 : Resource(instance), | 38 : Resource(instance), |
| 37 ppp_videodecoder_(NULL) { | 39 ppp_videodecoder_(NULL) { |
| 38 PluginModule* plugin_module = ResourceHelper::GetPluginModule(this); | 40 PluginModule* plugin_module = ResourceHelper::GetPluginModule(this); |
| 39 if (plugin_module) { | 41 if (plugin_module) { |
| 40 ppp_videodecoder_ = static_cast<const PPP_VideoDecoder_Dev*>( | 42 ppp_videodecoder_ = static_cast<const PPP_VideoDecoder_Dev*>( |
| 41 plugin_module->GetPluginInterface(PPP_VIDEODECODER_DEV_INTERFACE)); | 43 plugin_module->GetPluginInterface(PPP_VIDEODECODER_DEV_INTERFACE)); |
| 42 } | 44 } |
| 43 } | 45 } |
| 44 | 46 |
| 45 PPB_VideoDecoder_Impl::~PPB_VideoDecoder_Impl() { | 47 PPB_VideoDecoder_Impl::~PPB_VideoDecoder_Impl() { |
| 46 } | 48 } |
| 47 | 49 |
| 48 PPB_VideoDecoder_API* PPB_VideoDecoder_Impl::AsPPB_VideoDecoder_API() { | 50 PPB_VideoDecoder_API* PPB_VideoDecoder_Impl::AsPPB_VideoDecoder_API() { |
| 49 return this; | 51 return this; |
| 50 } | 52 } |
| 51 | 53 |
| 52 // static | 54 // static |
| 53 PP_Resource PPB_VideoDecoder_Impl::Create(PP_Instance instance, | 55 PP_Resource PPB_VideoDecoder_Impl::Create(PP_Instance instance, |
| 54 PP_Resource context3d_id, | 56 PP_Resource context3d_id, |
| 55 const PP_VideoConfigElement* config) { | 57 const PP_VideoConfigElement* config) { |
| 56 if (!context3d_id) | 58 PluginDelegate::PlatformContext3D* platform_context = NULL; |
| 57 return 0; | 59 gpu::gles2::GLES2Implementation* gles2_impl = NULL; |
| 58 | 60 EnterResourceNoLock<PPB_Context3D_API> enter_context(context3d_id, false); |
| 59 EnterResourceNoLock<PPB_Context3D_API> enter_context(context3d_id, true); | 61 if (enter_context.succeeded()) { |
| 60 if (enter_context.failed()) | 62 PPB_Context3D_Impl* context3d_impl = |
| 61 return 0; | 63 static_cast<PPB_Context3D_Impl*>(enter_context.object()); |
| 64 platform_context = context3d_impl->platform_context(); |
| 65 gles2_impl = context3d_impl->gles2_impl(); |
| 66 } else { |
| 67 EnterResourceNoLock<PPB_Graphics3D_API> enter_context(context3d_id, true); |
| 68 if (enter_context.failed()) |
| 69 return 0; |
| 70 PPB_Graphics3D_Impl* graphics3d_impl = |
| 71 static_cast<PPB_Graphics3D_Impl*>(enter_context.object()); |
| 72 platform_context = graphics3d_impl->platform_context(); |
| 73 gles2_impl = graphics3d_impl->gles2_impl(); |
| 74 } |
| 62 | 75 |
| 63 scoped_refptr<PPB_VideoDecoder_Impl> decoder( | 76 scoped_refptr<PPB_VideoDecoder_Impl> decoder( |
| 64 new PPB_VideoDecoder_Impl(instance)); | 77 new PPB_VideoDecoder_Impl(instance)); |
| 65 if (decoder->Init(context3d_id, enter_context.object(), config)) | 78 if (decoder->Init(context3d_id, platform_context, gles2_impl, config)) |
| 66 return decoder->GetReference(); | 79 return decoder->GetReference(); |
| 67 return 0; | 80 return 0; |
| 68 } | 81 } |
| 69 | 82 |
| 70 bool PPB_VideoDecoder_Impl::Init(PP_Resource context3d_id, | 83 bool PPB_VideoDecoder_Impl::Init( |
| 71 PPB_Context3D_API* context3d, | 84 PP_Resource context3d_id, |
| 72 const PP_VideoConfigElement* config) { | 85 PluginDelegate::PlatformContext3D* context, |
| 73 if (!::ppapi::VideoDecoderImpl::Init(context3d_id, context3d, config)) | 86 gpu::gles2::GLES2Implementation* gles2_impl, |
| 87 const PP_VideoConfigElement* config) { |
| 88 InitCommon(context3d_id, gles2_impl); |
| 89 |
| 90 int command_buffer_route_id = context->GetCommandBufferRouteId(); |
| 91 if (command_buffer_route_id == 0) |
| 74 return false; | 92 return false; |
| 75 | 93 |
| 76 std::vector<int32> copied; | 94 std::vector<int32> copied; |
| 77 if (!CopyConfigsToVector(config, &copied)) | 95 if (!CopyConfigsToVector(config, &copied)) |
| 78 return false; | 96 return false; |
| 79 | 97 |
| 80 PPB_Context3D_Impl* context3d_impl = | |
| 81 static_cast<PPB_Context3D_Impl*>(context3d); | |
| 82 | |
| 83 int command_buffer_route_id = | |
| 84 context3d_impl->platform_context()->GetCommandBufferRouteId(); | |
| 85 if (command_buffer_route_id == 0) | |
| 86 return false; | |
| 87 | |
| 88 | |
| 89 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); | 98 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); |
| 90 if (!plugin_delegate) | 99 if (!plugin_delegate) |
| 91 return false; | 100 return false; |
| 92 | 101 |
| 93 platform_video_decoder_ = plugin_delegate->CreateVideoDecoder( | 102 platform_video_decoder_ = plugin_delegate->CreateVideoDecoder( |
| 94 this, command_buffer_route_id); | 103 this, command_buffer_route_id); |
| 95 if (!platform_video_decoder_) | 104 if (!platform_video_decoder_) |
| 96 return false; | 105 return false; |
| 97 | 106 |
| 98 FlushCommandBuffer(); | 107 FlushCommandBuffer(); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 void PPB_VideoDecoder_Impl::NotifyFlushDone() { | 252 void PPB_VideoDecoder_Impl::NotifyFlushDone() { |
| 244 RunFlushCallback(PP_OK); | 253 RunFlushCallback(PP_OK); |
| 245 } | 254 } |
| 246 | 255 |
| 247 void PPB_VideoDecoder_Impl::NotifyInitializeDone() { | 256 void PPB_VideoDecoder_Impl::NotifyInitializeDone() { |
| 248 NOTREACHED() << "PlatformVideoDecoder::Initialize() is synchronous!"; | 257 NOTREACHED() << "PlatformVideoDecoder::Initialize() is synchronous!"; |
| 249 } | 258 } |
| 250 | 259 |
| 251 } // namespace ppapi | 260 } // namespace ppapi |
| 252 } // namespace webkit | 261 } // namespace webkit |
| OLD | NEW |