| 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 "ppapi/shared_impl/resource_tracker.h" | 18 #include "ppapi/shared_impl/resource_tracker.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" | |
| 25 #include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h" | 24 #include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h" |
| 26 #include "webkit/plugins/ppapi/resource_helper.h" | 25 #include "webkit/plugins/ppapi/resource_helper.h" |
| 27 | 26 |
| 28 using ppapi::thunk::EnterResourceNoLock; | 27 using ppapi::thunk::EnterResourceNoLock; |
| 29 using ppapi::thunk::PPB_Buffer_API; | 28 using ppapi::thunk::PPB_Buffer_API; |
| 30 using ppapi::thunk::PPB_Context3D_API; | |
| 31 using ppapi::thunk::PPB_Graphics3D_API; | 29 using ppapi::thunk::PPB_Graphics3D_API; |
| 32 using ppapi::thunk::PPB_VideoDecoder_API; | 30 using ppapi::thunk::PPB_VideoDecoder_API; |
| 33 | 31 |
| 34 namespace webkit { | 32 namespace webkit { |
| 35 namespace ppapi { | 33 namespace ppapi { |
| 36 | 34 |
| 37 PPB_VideoDecoder_Impl::PPB_VideoDecoder_Impl(PP_Instance instance) | 35 PPB_VideoDecoder_Impl::PPB_VideoDecoder_Impl(PP_Instance instance) |
| 38 : Resource(instance), | 36 : Resource(instance), |
| 39 ppp_videodecoder_(NULL) { | 37 ppp_videodecoder_(NULL) { |
| 40 PluginModule* plugin_module = ResourceHelper::GetPluginModule(this); | 38 PluginModule* plugin_module = ResourceHelper::GetPluginModule(this); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 57 // TODO(fischman,vrk): this assumes the enum values in the two Profile types | 55 // TODO(fischman,vrk): this assumes the enum values in the two Profile types |
| 58 // match up exactly. Add a COMPILE_ASSERT for this somewhere. | 56 // match up exactly. Add a COMPILE_ASSERT for this somewhere. |
| 59 return static_cast<media::VideoDecodeAccelerator::Profile>(pp_profile); | 57 return static_cast<media::VideoDecodeAccelerator::Profile>(pp_profile); |
| 60 } | 58 } |
| 61 | 59 |
| 62 // static | 60 // static |
| 63 PP_Resource PPB_VideoDecoder_Impl::Create( | 61 PP_Resource PPB_VideoDecoder_Impl::Create( |
| 64 PP_Instance instance, | 62 PP_Instance instance, |
| 65 PP_Resource graphics_context, | 63 PP_Resource graphics_context, |
| 66 PP_VideoDecoder_Profile profile) { | 64 PP_VideoDecoder_Profile profile) { |
| 67 PluginDelegate::PlatformContext3D* platform_context = NULL; | 65 EnterResourceNoLock<PPB_Graphics3D_API> enter_context(graphics_context, true); |
| 68 gpu::gles2::GLES2Implementation* gles2_impl = NULL; | 66 if (enter_context.failed()) |
| 69 EnterResourceNoLock<PPB_Context3D_API> enter_context(graphics_context, false); | 67 return 0; |
| 70 if (enter_context.succeeded()) { | 68 PPB_Graphics3D_Impl* graphics3d_impl = |
| 71 PPB_Context3D_Impl* context3d_impl = | 69 static_cast<PPB_Graphics3D_Impl*>(enter_context.object()); |
| 72 static_cast<PPB_Context3D_Impl*>(enter_context.object()); | |
| 73 platform_context = context3d_impl->platform_context(); | |
| 74 gles2_impl = context3d_impl->gles2_impl(); | |
| 75 } else { | |
| 76 EnterResourceNoLock<PPB_Graphics3D_API> enter_context(graphics_context, | |
| 77 true); | |
| 78 if (enter_context.failed()) | |
| 79 return 0; | |
| 80 PPB_Graphics3D_Impl* graphics3d_impl = | |
| 81 static_cast<PPB_Graphics3D_Impl*>(enter_context.object()); | |
| 82 platform_context = graphics3d_impl->platform_context(); | |
| 83 gles2_impl = graphics3d_impl->gles2_impl(); | |
| 84 } | |
| 85 | 70 |
| 86 scoped_refptr<PPB_VideoDecoder_Impl> decoder( | 71 scoped_refptr<PPB_VideoDecoder_Impl> decoder( |
| 87 new PPB_VideoDecoder_Impl(instance)); | 72 new PPB_VideoDecoder_Impl(instance)); |
| 88 if (decoder->Init(graphics_context, platform_context, gles2_impl, profile)) | 73 if (decoder->Init(graphics_context, graphics3d_impl->platform_context(), |
| 74 graphics3d_impl->gles2_impl(), profile)) |
| 89 return decoder->GetReference(); | 75 return decoder->GetReference(); |
| 90 return 0; | 76 return 0; |
| 91 } | 77 } |
| 92 | 78 |
| 93 bool PPB_VideoDecoder_Impl::Init( | 79 bool PPB_VideoDecoder_Impl::Init( |
| 94 PP_Resource graphics_context, | 80 PP_Resource graphics_context, |
| 95 PluginDelegate::PlatformContext3D* context, | 81 PluginDelegate::PlatformContext3D* context, |
| 96 gpu::gles2::GLES2Implementation* gles2_impl, | 82 gpu::gles2::GLES2Implementation* gles2_impl, |
| 97 PP_VideoDecoder_Profile profile) { | 83 PP_VideoDecoder_Profile profile) { |
| 98 InitCommon(graphics_context, gles2_impl); | 84 InitCommon(graphics_context, gles2_impl); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 void PPB_VideoDecoder_Impl::NotifyFlushDone() { | 253 void PPB_VideoDecoder_Impl::NotifyFlushDone() { |
| 268 RunFlushCallback(PP_OK); | 254 RunFlushCallback(PP_OK); |
| 269 } | 255 } |
| 270 | 256 |
| 271 void PPB_VideoDecoder_Impl::NotifyInitializeDone() { | 257 void PPB_VideoDecoder_Impl::NotifyInitializeDone() { |
| 272 NOTREACHED() << "PlatformVideoDecoder::Initialize() is synchronous!"; | 258 NOTREACHED() << "PlatformVideoDecoder::Initialize() is synchronous!"; |
| 273 } | 259 } |
| 274 | 260 |
| 275 } // namespace ppapi | 261 } // namespace ppapi |
| 276 } // namespace webkit | 262 } // namespace webkit |
| OLD | NEW |