diff options
author | Bill Budge <bbudge@google.com> | 2014-11-06 14:31:21 -0800 |
---|---|---|
committer | Bill Budge <bbudge@google.com> | 2014-11-06 22:33:05 +0000 |
commit | 2d4bf3a9f724cfc78d43b6b247397ca76d39b3f4 (patch) | |
tree | cc1a0628d5b00476df5bb8a25cca91ce5df3710a /ppapi/proxy | |
parent | 0270f3e42d769d55807d925daaacf7cb4f60e807 (diff) | |
download | chromium_src-2d4bf3a9f724cfc78d43b6b247397ca76d39b3f4.zip chromium_src-2d4bf3a9f724cfc78d43b6b247397ca76d39b3f4.tar.gz chromium_src-2d4bf3a9f724cfc78d43b6b247397ca76d39b3f4.tar.bz2 |
Pepper: Expose visible_rect to PPB_VideoDecoder.GetPicture.
Adds an out parameter to GetPicture to return the subrectangle of
the picture texture that contains the picture.
Adds a new 0.3 version of PPB_VideoDecoder.
BUG=429071
NOPRESUBMIT=true
R=binji@chromium.org, dmichael@chromium.org, mpearson@chromium.org, tsepez@chromium.org
Review URL: https://codereview.chromium.org/703753002
Cr-Commit-Position: refs/heads/master@{#303102}
Diffstat (limited to 'ppapi/proxy')
-rw-r--r-- | ppapi/proxy/ppapi_messages.h | 5 | ||||
-rw-r--r-- | ppapi/proxy/video_decoder_resource.cc | 60 | ||||
-rw-r--r-- | ppapi/proxy/video_decoder_resource.h | 20 | ||||
-rw-r--r-- | ppapi/proxy/video_decoder_resource_unittest.cc | 13 |
4 files changed, 66 insertions, 32 deletions
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index de7caf3..caf8287 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -1950,9 +1950,10 @@ IPC_MESSAGE_CONTROL4(PpapiPluginMsg_VideoDecoder_RequestTextures, IPC_MESSAGE_CONTROL2(PpapiHostMsg_VideoDecoder_AssignTextures, PP_Size /* size */, std::vector<uint32_t> /* texture_ids */) -IPC_MESSAGE_CONTROL2(PpapiPluginMsg_VideoDecoder_PictureReady, +IPC_MESSAGE_CONTROL3(PpapiPluginMsg_VideoDecoder_PictureReady, int32_t /* decode_id */, - uint32_t /* texture_id */) + uint32_t /* texture_id */, + PP_Rect /* visible_rect */) IPC_MESSAGE_CONTROL1(PpapiHostMsg_VideoDecoder_RecyclePicture, uint32_t /* texture_id */) IPC_MESSAGE_CONTROL1(PpapiPluginMsg_VideoDecoder_DismissPicture, diff --git a/ppapi/proxy/video_decoder_resource.cc b/ppapi/proxy/video_decoder_resource.cc index 733e6f8..2dbe60e 100644 --- a/ppapi/proxy/video_decoder_resource.cc +++ b/ppapi/proxy/video_decoder_resource.cc @@ -49,8 +49,10 @@ VideoDecoderResource::Texture::Texture(uint32_t texture_target, VideoDecoderResource::Texture::~Texture() { } -VideoDecoderResource::Picture::Picture(int32_t decode_id, uint32_t texture_id) - : decode_id(decode_id), texture_id(texture_id) { +VideoDecoderResource::Picture::Picture(int32_t decode_id, + uint32_t texture_id, + const PP_Rect& visible_rect) + : decode_id(decode_id), texture_id(texture_id), visible_rect(visible_rect) { } VideoDecoderResource::Picture::~Picture() { @@ -61,6 +63,7 @@ VideoDecoderResource::VideoDecoderResource(Connection connection, : PluginResource(connection, instance), num_decodes_(0), get_picture_(NULL), + get_picture_0_1_(NULL), gles2_impl_(NULL), initialized_(false), testing_(false), @@ -249,6 +252,13 @@ int32_t VideoDecoderResource::Decode(uint32_t decode_id, return PP_OK_COMPLETIONPENDING; } +int32_t VideoDecoderResource::GetPicture0_1( + PP_VideoPicture_0_1* picture, + scoped_refptr<TrackedCallback> callback) { + get_picture_0_1_ = picture; + return GetPicture(NULL, callback); +} + int32_t VideoDecoderResource::GetPicture( PP_VideoPicture* picture, scoped_refptr<TrackedCallback> callback) { @@ -259,14 +269,16 @@ int32_t VideoDecoderResource::GetPicture( if (get_picture_callback_.get()) return PP_ERROR_INPROGRESS; + get_picture_ = picture; + // If the next picture is ready, return it synchronously. if (!received_pictures_.empty()) { - WriteNextPicture(picture); + WriteNextPicture(); return PP_OK; } get_picture_callback_ = callback; - get_picture_ = picture; + return PP_OK_COMPLETIONPENDING; } @@ -399,16 +411,15 @@ void VideoDecoderResource::OnPluginMsgRequestTextures( void VideoDecoderResource::OnPluginMsgPictureReady( const ResourceMessageReplyParams& params, int32_t decode_id, - uint32_t texture_id) { - received_pictures_.push(Picture(decode_id, texture_id)); + uint32_t texture_id, + const PP_Rect& visible_rect) { + received_pictures_.push(Picture(decode_id, texture_id, visible_rect)); if (TrackedCallback::IsPending(get_picture_callback_)) { // The plugin may call GetPicture in its callback. scoped_refptr<TrackedCallback> callback; callback.swap(get_picture_callback_); - PP_VideoPicture* picture = get_picture_; - get_picture_ = NULL; - WriteNextPicture(picture); + WriteNextPicture(); callback->Run(PP_OK); } } @@ -510,20 +521,41 @@ void VideoDecoderResource::DeleteGLTexture(uint32_t id) { } } -void VideoDecoderResource::WriteNextPicture(PP_VideoPicture* pp_picture) { +void VideoDecoderResource::WriteNextPicture() { DCHECK(!received_pictures_.empty()); Picture& picture = received_pictures_.front(); + // Internally, we identify decodes by a unique id, which the host returns // to us in the picture. Use this to get the plugin's decode_id. - pp_picture->decode_id = decode_ids_[picture.decode_id % kMaximumPictureDelay]; - pp_picture->texture_id = picture.texture_id; + uint32_t decode_id = decode_ids_[picture.decode_id % kMaximumPictureDelay]; + uint32_t texture_id = picture.texture_id; + uint32_t texture_target = 0; + PP_Size texture_size = PP_MakeSize(0, 0); TextureMap::iterator it = textures_.find(picture.texture_id); if (it != textures_.end()) { - pp_picture->texture_target = it->second.texture_target; - pp_picture->texture_size = it->second.size; + texture_target = it->second.texture_target; + texture_size = it->second.size; } else { NOTREACHED(); } + + if (get_picture_) { + DCHECK(!get_picture_0_1_); + get_picture_->decode_id = decode_id; + get_picture_->texture_id = texture_id; + get_picture_->texture_target = texture_target; + get_picture_->texture_size = texture_size; + get_picture_->visible_rect = picture.visible_rect; + get_picture_ = NULL; + } else { + DCHECK(get_picture_0_1_); + get_picture_0_1_->decode_id = decode_id; + get_picture_0_1_->texture_id = texture_id; + get_picture_0_1_->texture_target = texture_target; + get_picture_0_1_->texture_size = texture_size; + get_picture_0_1_ = NULL; + } + received_pictures_.pop(); } diff --git a/ppapi/proxy/video_decoder_resource.h b/ppapi/proxy/video_decoder_resource.h index 2e4ea6d..bcc8906 100644 --- a/ppapi/proxy/video_decoder_resource.h +++ b/ppapi/proxy/video_decoder_resource.h @@ -56,6 +56,9 @@ class PPAPI_PROXY_EXPORT VideoDecoderResource uint32_t size, const void* buffer, scoped_refptr<TrackedCallback> callback) override; + virtual int32_t GetPicture0_1( + PP_VideoPicture_0_1* picture, + scoped_refptr<TrackedCallback> callback) override; virtual int32_t GetPicture(PP_VideoPicture* picture, scoped_refptr<TrackedCallback> callback) override; virtual void RecyclePicture(const PP_VideoPicture* picture) override; @@ -96,19 +99,16 @@ class PPAPI_PROXY_EXPORT VideoDecoderResource // Struct to hold a picture received from the decoder. struct Picture { - Picture(int32_t decode_id, uint32_t texture_id); + Picture(int32_t decode_id, + uint32_t texture_id, + const PP_Rect& visible_rect); ~Picture(); int32_t decode_id; uint32_t texture_id; + PP_Rect visible_rect; }; - int32_t InitializeInternal(PP_Resource graphics_context, - PP_VideoProfile profile, - PP_Bool allow_software_fallback, - scoped_refptr<TrackedCallback> callback, - bool testing); - // Unsolicited reply message handlers. void OnPluginMsgRequestTextures(const ResourceMessageReplyParams& params, uint32_t num_textures, @@ -117,7 +117,8 @@ class PPAPI_PROXY_EXPORT VideoDecoderResource const std::vector<gpu::Mailbox>& mailboxes); void OnPluginMsgPictureReady(const ResourceMessageReplyParams& params, int32_t decode_id, - uint32_t texture_id); + uint32_t texture_id, + const PP_Rect& visible_rect); void OnPluginMsgDismissPicture(const ResourceMessageReplyParams& params, uint32_t texture_id); void OnPluginMsgNotifyError(const ResourceMessageReplyParams& params, @@ -132,7 +133,7 @@ class PPAPI_PROXY_EXPORT VideoDecoderResource void RunCallbackWithError(scoped_refptr<TrackedCallback>* callback); void DeleteGLTexture(uint32_t texture_id); - void WriteNextPicture(PP_VideoPicture* picture); + void WriteNextPicture(); // ScopedVector to own the shared memory buffers. ScopedVector<ShmBuffer> shm_buffers_; @@ -169,6 +170,7 @@ class PPAPI_PROXY_EXPORT VideoDecoderResource // State for pending get_picture_callback_. PP_VideoPicture* get_picture_; + PP_VideoPicture_0_1* get_picture_0_1_; ScopedPPResource graphics3d_; gpu::gles2::GLES2Implementation* gles2_impl_; diff --git a/ppapi/proxy/video_decoder_resource_unittest.cc b/ppapi/proxy/video_decoder_resource_unittest.cc index fa6e89f..7716940 100644 --- a/ppapi/proxy/video_decoder_resource_unittest.cc +++ b/ppapi/proxy/video_decoder_resource_unittest.cc @@ -58,9 +58,9 @@ class MockCompletionCallback { class VideoDecoderResourceTest : public PluginProxyTest { public: VideoDecoderResourceTest() - : decoder_iface_(thunk::GetPPB_VideoDecoder_0_2_Thunk()) {} + : decoder_iface_(thunk::GetPPB_VideoDecoder_1_0_Thunk()) {} - const PPB_VideoDecoder_0_2* decoder_iface() const { return decoder_iface_; } + const PPB_VideoDecoder_1_0* decoder_iface() const { return decoder_iface_; } void SendReply(const ResourceMessageCallParams& params, int32_t result, @@ -217,10 +217,9 @@ class VideoDecoderResourceTest : public PluginProxyTest { void SendPictureReady(const ResourceMessageCallParams& params, uint32_t decode_count, uint32_t texture_id) { - SendReply( - params, - PP_OK, - PpapiPluginMsg_VideoDecoder_PictureReady(decode_count, texture_id)); + PP_Rect visible_rect = PP_MakeRectFromXYWH(0, 0, 640, 480); + SendReply(params, PP_OK, PpapiPluginMsg_VideoDecoder_PictureReady( + decode_count, texture_id, visible_rect)); } void SendFlushReply(const ResourceMessageCallParams& params) { @@ -298,7 +297,7 @@ class VideoDecoderResourceTest : public PluginProxyTest { return true; } - const PPB_VideoDecoder_0_2* decoder_iface_; + const PPB_VideoDecoder_1_0* decoder_iface_; char decode_buffer_[kDecodeBufferSize]; }; |