From 08bab53f31485b4644a6a318fa5eb606c667ec1b Mon Sep 17 00:00:00 2001 From: "sail@chromium.org" Date: Fri, 8 Jun 2012 19:39:45 +0000 Subject: Plumb texture target to VideoDecodeAccelerator::Client Currently all VideoDecodeAccelerator::Clients use GL_TEXTURE_2D as their texture target. Unfortunately the Mac decoder only supports GL_TEXTURE_RECTANGLE_ARB texture targets. This CL allows decoders to choose which texture target they want. BUG=127414 TEST= Review URL: https://chromiumcodereview.appspot.com/10392141 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141258 0039d316-1c4b-4281-b951-d872f2087c98 --- ppapi/api/dev/ppp_video_decoder_dev.idl | 27 ++++++++++++++++++++++++++- ppapi/c/dev/ppp_video_decoder_dev.h | 29 ++++++++++++++++++++++++----- ppapi/cpp/dev/video_decoder_client_dev.cc | 5 +++-- ppapi/cpp/dev/video_decoder_client_dev.h | 3 ++- ppapi/examples/video_decode/video_decode.cc | 28 +++++++++++++++++++--------- ppapi/proxy/ppapi_messages.h | 5 +++-- ppapi/proxy/ppp_video_decoder_proxy.cc | 14 +++++++++----- ppapi/proxy/ppp_video_decoder_proxy.h | 3 ++- 8 files changed, 88 insertions(+), 26 deletions(-) (limited to 'ppapi') diff --git a/ppapi/api/dev/ppp_video_decoder_dev.idl b/ppapi/api/dev/ppp_video_decoder_dev.idl index 2a6e419..1f6d8c6 100644 --- a/ppapi/api/dev/ppp_video_decoder_dev.idl +++ b/ppapi/api/dev/ppp_video_decoder_dev.idl @@ -8,7 +8,8 @@ */ label Chrome { M14 = 0.9, - M18 = 0.10 + M18 = 0.10, + M21 = 0.11 }; /** @@ -33,6 +34,7 @@ interface PPP_VideoDecoder_Dev { * |req_num_of_bufs| tells how many buffers are needed by the decoder. * |dimensions| tells the dimensions of the buffer to allocate. */ + [deprecate=0.11] void ProvidePictureBuffers( [in] PP_Instance instance, [in] PP_Resource decoder, @@ -40,6 +42,29 @@ interface PPP_VideoDecoder_Dev { [in] PP_Size dimensions); /** + * Callback function to provide buffers for the decoded output pictures. If + * succeeds plugin must provide buffers through AssignPictureBuffers function + * to the API. If |req_num_of_bufs| matching exactly the specification + * given in the parameters cannot be allocated decoder should be destroyed. + * + * Decoding will not proceed until buffers have been provided. + * + * Parameters: + * |instance| the plugin instance to which the callback is responding. + * |decoder| the PPB_VideoDecoder_Dev resource. + * |req_num_of_bufs| tells how many buffers are needed by the decoder. + * |dimensions| tells the dimensions of the buffer to allocate. + * |texture_target| the type of texture used. + */ + [version=0.11] + void ProvidePictureBuffers( + [in] PP_Instance instance, + [in] PP_Resource decoder, + [in] uint32_t req_num_of_bufs, + [in] PP_Size dimensions, + [in] uint32_t texture_target); + + /** * Callback function for decoder to deliver unneeded picture buffers back to * the plugin. * diff --git a/ppapi/c/dev/ppp_video_decoder_dev.h b/ppapi/c/dev/ppp_video_decoder_dev.h index a06b582..20c4e8c 100644 --- a/ppapi/c/dev/ppp_video_decoder_dev.h +++ b/ppapi/c/dev/ppp_video_decoder_dev.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* From dev/ppp_video_decoder_dev.idl modified Wed Jan 11 14:58:58 2012. */ +/* From dev/ppp_video_decoder_dev.idl modified Tue May 29 10:59:23 2012. */ #ifndef PPAPI_C_DEV_PPP_VIDEO_DECODER_DEV_H_ #define PPAPI_C_DEV_PPP_VIDEO_DECODER_DEV_H_ @@ -17,7 +17,8 @@ #define PPP_VIDEODECODER_DEV_INTERFACE_0_9 "PPP_VideoDecoder(Dev);0.9" #define PPP_VIDEODECODER_DEV_INTERFACE_0_10 "PPP_VideoDecoder(Dev);0.10" -#define PPP_VIDEODECODER_DEV_INTERFACE PPP_VIDEODECODER_DEV_INTERFACE_0_10 +#define PPP_VIDEODECODER_DEV_INTERFACE_0_11 "PPP_VideoDecoder(Dev);0.11" +#define PPP_VIDEODECODER_DEV_INTERFACE PPP_VIDEODECODER_DEV_INTERFACE_0_11 /** * @file @@ -36,7 +37,7 @@ * * See PPB_VideoDecoder_Dev for general usage tips. */ -struct PPP_VideoDecoder_Dev_0_10 { +struct PPP_VideoDecoder_Dev_0_11 { /** * Callback function to provide buffers for the decoded output pictures. If * succeeds plugin must provide buffers through AssignPictureBuffers function @@ -50,11 +51,13 @@ struct PPP_VideoDecoder_Dev_0_10 { * |decoder| the PPB_VideoDecoder_Dev resource. * |req_num_of_bufs| tells how many buffers are needed by the decoder. * |dimensions| tells the dimensions of the buffer to allocate. + * |texture_target| the type of texture used. */ void (*ProvidePictureBuffers)(PP_Instance instance, PP_Resource decoder, uint32_t req_num_of_bufs, - const struct PP_Size* dimensions); + const struct PP_Size* dimensions, + uint32_t texture_target); /** * Callback function for decoder to deliver unneeded picture buffers back to * the plugin. @@ -94,7 +97,7 @@ struct PPP_VideoDecoder_Dev_0_10 { PP_VideoDecodeError_Dev error); }; -typedef struct PPP_VideoDecoder_Dev_0_10 PPP_VideoDecoder_Dev; +typedef struct PPP_VideoDecoder_Dev_0_11 PPP_VideoDecoder_Dev; struct PPP_VideoDecoder_Dev_0_9 { void (*ProvidePictureBuffers)(PP_Instance instance, @@ -112,6 +115,22 @@ struct PPP_VideoDecoder_Dev_0_9 { PP_Resource decoder, PP_VideoDecodeError_Dev error); }; + +struct PPP_VideoDecoder_Dev_0_10 { + void (*ProvidePictureBuffers)(PP_Instance instance, + PP_Resource decoder, + uint32_t req_num_of_bufs, + const struct PP_Size* dimensions); + void (*DismissPictureBuffer)(PP_Instance instance, + PP_Resource decoder, + int32_t picture_buffer_id); + void (*PictureReady)(PP_Instance instance, + PP_Resource decoder, + const struct PP_Picture_Dev* picture); + void (*NotifyError)(PP_Instance instance, + PP_Resource decoder, + PP_VideoDecodeError_Dev error); +}; /** * @} */ diff --git a/ppapi/cpp/dev/video_decoder_client_dev.cc b/ppapi/cpp/dev/video_decoder_client_dev.cc index eaab575..10c2619 100644 --- a/ppapi/cpp/dev/video_decoder_client_dev.cc +++ b/ppapi/cpp/dev/video_decoder_client_dev.cc @@ -21,13 +21,14 @@ const char kPPPVideoDecoderInterface[] = PPP_VIDEODECODER_DEV_INTERFACE; void ProvidePictureBuffers(PP_Instance instance, PP_Resource decoder, uint32_t req_num_of_bufs, - const PP_Size* dimensions) { + const PP_Size* dimensions, + uint32_t texture_target) { void* object = Instance::GetPerInstanceObject(instance, kPPPVideoDecoderInterface); if (!object) return; static_cast(object)->ProvidePictureBuffers( - decoder, req_num_of_bufs, *dimensions); + decoder, req_num_of_bufs, *dimensions, texture_target); } void DismissPictureBuffer(PP_Instance instance, diff --git a/ppapi/cpp/dev/video_decoder_client_dev.h b/ppapi/cpp/dev/video_decoder_client_dev.h index d598b40..a6e2bb5 100644 --- a/ppapi/cpp/dev/video_decoder_client_dev.h +++ b/ppapi/cpp/dev/video_decoder_client_dev.h @@ -26,7 +26,8 @@ class VideoDecoderClient_Dev { // Callback to provide buffers for the decoded output pictures. virtual void ProvidePictureBuffers(PP_Resource decoder, uint32_t req_num_of_bufs, - const PP_Size& dimensions) = 0; + const PP_Size& dimensions, + uint32_t texture_target) = 0; // Callback for decoder to deliver unneeded picture buffers back to the // plugin. diff --git a/ppapi/examples/video_decode/video_decode.cc b/ppapi/examples/video_decode/video_decode.cc index dd0c08f..6e4f4e1 100644 --- a/ppapi/examples/video_decode/video_decode.cc +++ b/ppapi/examples/video_decode/video_decode.cc @@ -60,9 +60,11 @@ class VideoDecodeDemoInstance : public pp::Instance, } // pp::VideoDecoderClient_Dev implementation. - virtual void ProvidePictureBuffers(PP_Resource decoder, - uint32_t req_num_of_bufs, - const PP_Size& dimensions); + virtual void ProvidePictureBuffers( + PP_Resource decoder, + uint32_t req_num_of_bufs, + const PP_Size& dimensions, + uint32_t texture_target); virtual void DismissPictureBuffer(PP_Resource decoder, int32_t picture_buffer_id); virtual void PictureReady(PP_Resource decoder, const PP_Picture_Dev& picture); @@ -82,8 +84,10 @@ class VideoDecodeDemoInstance : public pp::Instance, void DecodeNextNALUs(); // Per-decoder implementation of part of pp::VideoDecoderClient_Dev. - void ProvidePictureBuffers(uint32_t req_num_of_bufs, - PP_Size dimensions); + void ProvidePictureBuffers( + uint32_t req_num_of_bufs, + PP_Size dimensions, + uint32_t texture_target); void DismissPictureBuffer(int32_t picture_buffer_id); const PP_PictureBuffer_Dev& GetPictureBufferById(int id); @@ -320,15 +324,21 @@ void VideoDecodeDemoInstance::DecoderClient::DecodeNextNALU() { decoder_->Decode(bitstream_buffer, cb); } -void VideoDecodeDemoInstance::ProvidePictureBuffers( - PP_Resource decoder, uint32_t req_num_of_bufs, const PP_Size& dimensions) { +void VideoDecodeDemoInstance::ProvidePictureBuffers(PP_Resource decoder, + uint32_t req_num_of_bufs, + const PP_Size& dimensions, + uint32_t texture_target) { DecoderClient* client = video_decoders_[decoder]; assert(client); - client->ProvidePictureBuffers(req_num_of_bufs, dimensions); + client->ProvidePictureBuffers(req_num_of_bufs, dimensions, texture_target); } void VideoDecodeDemoInstance::DecoderClient::ProvidePictureBuffers( - uint32_t req_num_of_bufs, PP_Size dimensions) { + uint32_t req_num_of_bufs, + PP_Size dimensions, + uint32_t texture_target) { + // TODO(sail): Add support for GL_TEXTURE_RECTANGLE_ARB. + assert(texture_target == GL_TEXTURE_2D); std::vector buffers; for (uint32_t i = 0; i < req_num_of_bufs; ++i) { PP_PictureBuffer_Dev buffer; diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index b2787a9..16c57c1 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -626,10 +626,11 @@ IPC_MESSAGE_ROUTED2(PpapiMsg_PPBVideoDecoder_ResetACK, int32_t /* PP_CompletionCallback result */) // PPP_VideoDecoder_Dev. -IPC_MESSAGE_ROUTED3(PpapiMsg_PPPVideoDecoder_ProvidePictureBuffers, +IPC_MESSAGE_ROUTED4(PpapiMsg_PPPVideoDecoder_ProvidePictureBuffers, ppapi::HostResource /* video_decoder */, uint32_t /* requested number of buffers */, - PP_Size /* dimensions of buffers */) + PP_Size /* dimensions of buffers */, + uint32_t /* texture_target */) IPC_MESSAGE_ROUTED2(PpapiMsg_PPPVideoDecoder_DismissPictureBuffer, ppapi::HostResource /* video_decoder */, int32_t /* picture buffer id */) diff --git a/ppapi/proxy/ppp_video_decoder_proxy.cc b/ppapi/proxy/ppp_video_decoder_proxy.cc index 1ebf20a..7648b7f 100644 --- a/ppapi/proxy/ppp_video_decoder_proxy.cc +++ b/ppapi/proxy/ppp_video_decoder_proxy.cc @@ -22,14 +22,15 @@ namespace { void ProvidePictureBuffers(PP_Instance instance, PP_Resource decoder, uint32_t req_num_of_bufs, - const PP_Size* dimensions) { + const PP_Size* dimensions, + uint32_t texture_target) { HostResource decoder_resource; decoder_resource.SetHostResource(instance, decoder); HostDispatcher::GetForInstance(instance)->Send( new PpapiMsg_PPPVideoDecoder_ProvidePictureBuffers( API_ID_PPP_VIDEO_DECODER_DEV, - decoder_resource, req_num_of_bufs, *dimensions)); + decoder_resource, req_num_of_bufs, *dimensions, texture_target)); } void DismissPictureBuffer(PP_Instance instance, PP_Resource decoder, @@ -118,15 +119,18 @@ bool PPP_VideoDecoder_Proxy::OnMessageReceived(const IPC::Message& msg) { } void PPP_VideoDecoder_Proxy::OnMsgProvidePictureBuffers( - const HostResource& decoder, uint32_t req_num_of_bufs, - const PP_Size& dimensions) { + const HostResource& decoder, + uint32_t req_num_of_bufs, + const PP_Size& dimensions, + uint32_t texture_target) { PP_Resource plugin_decoder = PluginGlobals::Get()->plugin_resource_tracker()-> PluginResourceForHostResource(decoder); CallWhileUnlocked(ppp_video_decoder_impl_->ProvidePictureBuffers, decoder.instance(), plugin_decoder, req_num_of_bufs, - &dimensions); + &dimensions, + texture_target); } void PPP_VideoDecoder_Proxy::OnMsgDismissPictureBuffer( diff --git a/ppapi/proxy/ppp_video_decoder_proxy.h b/ppapi/proxy/ppp_video_decoder_proxy.h index c4ff4c3..84d83a5 100644 --- a/ppapi/proxy/ppp_video_decoder_proxy.h +++ b/ppapi/proxy/ppp_video_decoder_proxy.h @@ -30,7 +30,8 @@ class PPP_VideoDecoder_Proxy : public InterfaceProxy { // Message handlers. void OnMsgProvidePictureBuffers(const ppapi::HostResource& decoder, uint32_t req_num_of_buffers, - const PP_Size& dimensions); + const PP_Size& dimensions, + uint32_t texture_target); void OnMsgDismissPictureBuffer(const ppapi::HostResource& decoder, int32_t picture_id); void OnMsgPictureReady(const ppapi::HostResource& decoder, -- cgit v1.1