| 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 graphics_context, |
| 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(graphics_context, 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(graphics_context, |
| 68 true); |
| 69 if (enter_context.failed()) |
| 70 return 0; |
| 71 PPB_Graphics3D_Impl* graphics3d_impl = |
| 72 static_cast<PPB_Graphics3D_Impl*>(enter_context.object()); |
| 73 platform_context = graphics3d_impl->platform_context(); |
| 74 gles2_impl = graphics3d_impl->gles2_impl(); |
| 75 } |
| 62 | 76 |
| 63 scoped_refptr<PPB_VideoDecoder_Impl> decoder( | 77 scoped_refptr<PPB_VideoDecoder_Impl> decoder( |
| 64 new PPB_VideoDecoder_Impl(instance)); | 78 new PPB_VideoDecoder_Impl(instance)); |
| 65 if (decoder->Init(context3d_id, enter_context.object(), config)) | 79 if (decoder->Init(graphics_context, platform_context, gles2_impl, config)) |
| 66 return decoder->GetReference(); | 80 return decoder->GetReference(); |
| 67 return 0; | 81 return 0; |
| 68 } | 82 } |
| 69 | 83 |
| 70 bool PPB_VideoDecoder_Impl::Init(PP_Resource context3d_id, | 84 bool PPB_VideoDecoder_Impl::Init( |
| 71 PPB_Context3D_API* context3d, | 85 PP_Resource graphics_context, |
| 72 const PP_VideoConfigElement* config) { | 86 PluginDelegate::PlatformContext3D* context, |
| 73 if (!::ppapi::VideoDecoderImpl::Init(context3d_id, context3d, config)) | 87 gpu::gles2::GLES2Implementation* gles2_impl, |
| 88 const PP_VideoConfigElement* config) { |
| 89 InitCommon(graphics_context, gles2_impl); |
| 90 |
| 91 int command_buffer_route_id = context->GetCommandBufferRouteId(); |
| 92 if (command_buffer_route_id == 0) |
| 74 return false; | 93 return false; |
| 75 | 94 |
| 76 std::vector<int32> copied; | 95 std::vector<int32> copied; |
| 77 if (!CopyConfigsToVector(config, &copied)) | 96 if (!CopyConfigsToVector(config, &copied)) |
| 78 return false; | 97 return false; |
| 79 | 98 |
| 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); | 99 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); |
| 90 if (!plugin_delegate) | 100 if (!plugin_delegate) |
| 91 return false; | 101 return false; |
| 92 | 102 |
| 93 platform_video_decoder_ = plugin_delegate->CreateVideoDecoder( | 103 platform_video_decoder_ = plugin_delegate->CreateVideoDecoder( |
| 94 this, command_buffer_route_id); | 104 this, command_buffer_route_id); |
| 95 if (!platform_video_decoder_) | 105 if (!platform_video_decoder_) |
| 96 return false; | 106 return false; |
| 97 | 107 |
| 98 FlushCommandBuffer(); | 108 FlushCommandBuffer(); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 void PPB_VideoDecoder_Impl::NotifyFlushDone() { | 253 void PPB_VideoDecoder_Impl::NotifyFlushDone() { |
| 244 RunFlushCallback(PP_OK); | 254 RunFlushCallback(PP_OK); |
| 245 } | 255 } |
| 246 | 256 |
| 247 void PPB_VideoDecoder_Impl::NotifyInitializeDone() { | 257 void PPB_VideoDecoder_Impl::NotifyInitializeDone() { |
| 248 NOTREACHED() << "PlatformVideoDecoder::Initialize() is synchronous!"; | 258 NOTREACHED() << "PlatformVideoDecoder::Initialize() is synchronous!"; |
| 249 } | 259 } |
| 250 | 260 |
| 251 } // namespace ppapi | 261 } // namespace ppapi |
| 252 } // namespace webkit | 262 } // namespace webkit |
| OLD | NEW |