diff options
author | fischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-29 17:47:01 +0000 |
---|---|---|
committer | fischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-29 17:47:01 +0000 |
commit | 890e8966414165e59418b7886778cbd16cc194ac (patch) | |
tree | 3e0de593dd21b86879bd09d228a090f8af105564 /webkit | |
parent | 32fcb896c5d34a483c3adbdec90badbddd54d7d8 (diff) | |
download | chromium_src-890e8966414165e59418b7886778cbd16cc194ac.zip chromium_src-890e8966414165e59418b7886778cbd16cc194ac.tar.gz chromium_src-890e8966414165e59418b7886778cbd16cc194ac.tar.bz2 |
Implement proper synchronization between HW video decode IPC and CommandBuffer.
This is done by inserting tokens into the command-buffer stream
when synchronization is needed, and adding a
last-read/last-written token pair to each IPC message. This
allowed me to remove the bogus FinishGL() calls from the gles2
sample pepper plugin.
As part of this CL, the return value for VideoDecodeAccelerator::{Decode,Flush,Abort} changed from bool to void. These are all async methods so errors ought to be signaled using callbacks.
BUG=none
TEST=gles2 works, no crashes; trybots
Review URL: http://codereview.chromium.org/7260008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90971 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/plugins/ppapi/mock_plugin_delegate.cc | 3 | ||||
-rw-r--r-- | webkit/plugins/ppapi/mock_plugin_delegate.h | 7 | ||||
-rw-r--r-- | webkit/plugins/ppapi/plugin_delegate.h | 4 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_video_decoder_impl.cc | 26 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_video_decoder_impl.h | 4 | ||||
-rw-r--r-- | webkit/plugins/ppapi/resource_tracker.h | 9 |
6 files changed, 33 insertions, 20 deletions
diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.cc b/webkit/plugins/ppapi/mock_plugin_delegate.cc index 476d4c9..1270504 100644 --- a/webkit/plugins/ppapi/mock_plugin_delegate.cc +++ b/webkit/plugins/ppapi/mock_plugin_delegate.cc @@ -46,7 +46,8 @@ MockPluginDelegate::PlatformContext3D* MockPluginDelegate::CreateContext3D() { MockPluginDelegate::PlatformVideoDecoder* MockPluginDelegate::CreateVideoDecoder( media::VideoDecodeAccelerator::Client* client, - int command_buffer_route_id) { + int32 command_buffer_route_id, + gpu::CommandBufferHelper* cmd_buffer_helper) { return NULL; } diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.h b/webkit/plugins/ppapi/mock_plugin_delegate.h index 0b91348..c58d4fd 100644 --- a/webkit/plugins/ppapi/mock_plugin_delegate.h +++ b/webkit/plugins/ppapi/mock_plugin_delegate.h @@ -7,6 +7,10 @@ #include "webkit/plugins/ppapi/plugin_delegate.h" +namespace gpu { +class CommandBufferHelper; +} + namespace webkit { namespace ppapi { @@ -24,7 +28,8 @@ class MockPluginDelegate : public PluginDelegate { virtual PlatformContext3D* CreateContext3D(); virtual PlatformVideoDecoder* CreateVideoDecoder( media::VideoDecodeAccelerator::Client* client, - int command_buffer_route_id); + int32 command_buffer_route_id, + gpu::CommandBufferHelper* cmd_buffer_helper); virtual PlatformAudio* CreateAudio(uint32_t sample_rate, uint32_t sample_count, PlatformAudio::Client* client); diff --git a/webkit/plugins/ppapi/plugin_delegate.h b/webkit/plugins/ppapi/plugin_delegate.h index c72eaaa..dae68a8 100644 --- a/webkit/plugins/ppapi/plugin_delegate.h +++ b/webkit/plugins/ppapi/plugin_delegate.h @@ -46,6 +46,7 @@ class Rect; namespace gpu { class CommandBuffer; +class CommandBufferHelper; } namespace ppapi { @@ -263,7 +264,8 @@ class PluginDelegate { // The caller will own the pointer returned from this. virtual PlatformVideoDecoder* CreateVideoDecoder( media::VideoDecodeAccelerator::Client* client, - int command_buffer_route_id) = 0; + int32 command_buffer_route_id, + gpu::CommandBufferHelper* cmd_buffer_helper) = 0; // The caller is responsible for calling Shutdown() on the returned pointer // to clean up the corresponding resources allocated during this call. diff --git a/webkit/plugins/ppapi/ppb_video_decoder_impl.cc b/webkit/plugins/ppapi/ppb_video_decoder_impl.cc index d1e41d4..f5f6126 100644 --- a/webkit/plugins/ppapi/ppb_video_decoder_impl.cc +++ b/webkit/plugins/ppapi/ppb_video_decoder_impl.cc @@ -8,6 +8,7 @@ #include "base/logging.h" #include "base/message_loop.h" +#include "gpu/command_buffer/client/gles2_implementation.h" #include "media/video/picture.h" #include "ppapi/c/dev/pp_video_dev.h" #include "ppapi/c/dev/ppb_video_decoder_dev.h" @@ -65,6 +66,7 @@ void CopyToConfigList( PPB_VideoDecoder_Impl::PPB_VideoDecoder_Impl(PluginInstance* instance) : Resource(instance), callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), + context3d_id_(0), abort_callback_(PP_BlockUntilComplete()), flush_callback_(PP_BlockUntilComplete()) { ppp_videodecoder_ = @@ -73,6 +75,8 @@ PPB_VideoDecoder_Impl::PPB_VideoDecoder_Impl(PluginInstance* instance) } PPB_VideoDecoder_Impl::~PPB_VideoDecoder_Impl() { + if (context3d_id_) + ResourceTracker::Get()->UnrefResource(context3d_id_); } PPB_VideoDecoder_API* PPB_VideoDecoder_Impl::AsPPB_VideoDecoder_API() { @@ -120,6 +124,8 @@ int32_t PPB_VideoDecoder_Impl::Initialize( PPB_Context3D_Impl* context3d = static_cast<PPB_Context3D_Impl*>(enter.object()); + context3d_id_ = context_id; + ResourceTracker::Get()->AddRefResource(context3d_id_); int command_buffer_route_id = context3d->platform_context()->GetCommandBufferRouteId(); if (command_buffer_route_id == 0) @@ -127,7 +133,7 @@ int32_t PPB_VideoDecoder_Impl::Initialize( platform_video_decoder_.reset( instance()->delegate()->CreateVideoDecoder( - this, command_buffer_route_id)); + this, command_buffer_route_id, context3d->gles2_impl()->helper())); if (!platform_video_decoder_.get()) return PP_ERROR_FAILED; @@ -160,10 +166,8 @@ int32_t PPB_VideoDecoder_Impl::Decode( CHECK(bitstream_buffer_callbacks_.insert(std::make_pair( bitstream_buffer->id, callback)).second); - if (platform_video_decoder_->Decode(decode_buffer)) - return PP_OK_COMPLETIONPENDING; - else - return PP_ERROR_FAILED; + platform_video_decoder_->Decode(decode_buffer); + return PP_OK_COMPLETIONPENDING; } void PPB_VideoDecoder_Impl::AssignGLESBuffers( @@ -223,10 +227,8 @@ int32_t PPB_VideoDecoder_Impl::Flush(PP_CompletionCallback callback) { // TODO(vmr): Check for current flush/abort operations. flush_callback_ = callback; - if (platform_video_decoder_->Flush()) - return PP_OK_COMPLETIONPENDING; - else - return PP_ERROR_FAILED; + platform_video_decoder_->Flush(); + return PP_OK_COMPLETIONPENDING; } int32_t PPB_VideoDecoder_Impl::Abort(PP_CompletionCallback callback) { @@ -237,10 +239,8 @@ int32_t PPB_VideoDecoder_Impl::Abort(PP_CompletionCallback callback) { // TODO(vmr): Check for current flush/abort operations. abort_callback_ = callback; - if (platform_video_decoder_->Abort()) - return PP_OK_COMPLETIONPENDING; - else - return PP_ERROR_FAILED; + platform_video_decoder_->Abort(); + return PP_OK_COMPLETIONPENDING; } void PPB_VideoDecoder_Impl::ProvidePictureBuffers( diff --git a/webkit/plugins/ppapi/ppb_video_decoder_impl.h b/webkit/plugins/ppapi/ppb_video_decoder_impl.h index 5b4a326..75db896 100644 --- a/webkit/plugins/ppapi/ppb_video_decoder_impl.h +++ b/webkit/plugins/ppapi/ppb_video_decoder_impl.h @@ -84,6 +84,10 @@ class PPB_VideoDecoder_Impl : public Resource, // Factory to produce our callbacks. base::ScopedCallbackFactory<PPB_VideoDecoder_Impl> callback_factory_; + // The resource ID of the underlying Context3d object being used. Used only + // for reference counting to keep it alive for the lifetime of |*this|. + PP_Resource context3d_id_; + PP_CompletionCallback initialization_callback_; PP_CompletionCallback abort_callback_; PP_CompletionCallback flush_callback_; diff --git a/webkit/plugins/ppapi/resource_tracker.h b/webkit/plugins/ppapi/resource_tracker.h index b728895..84669e1 100644 --- a/webkit/plugins/ppapi/resource_tracker.h +++ b/webkit/plugins/ppapi/resource_tracker.h @@ -175,10 +175,11 @@ class ResourceTracker : public ::ppapi::TrackerBase { // For each PP_Resource, keep the Resource* (as refptr) and plugin use count. // This use count is different then Resource's RefCount, and is manipulated - // using this RefResource/UnrefResource. When it drops to zero, we just remove - // the resource from this resource tracker, but the resource object will be - // alive so long as some scoped_refptr still holds it's reference. This - // prevents plugins from forcing destruction of Resource objects. + // using this AddRefResource/UnrefResource. When it drops to zero, we just + // remove the resource from this resource tracker, but the resource object + // will be alive so long as some scoped_refptr still holds it's + // reference. This prevents plugins from forcing destruction of Resource + // objects. typedef std::pair<scoped_refptr<Resource>, size_t> ResourceAndRefCount; typedef base::hash_map<PP_Resource, ResourceAndRefCount> ResourceMap; ResourceMap live_resources_; |