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/cpp | |
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/cpp')
-rw-r--r-- | ppapi/cpp/video_decoder.cc | 79 | ||||
-rw-r--r-- | ppapi/cpp/video_decoder.h | 2 |
2 files changed, 72 insertions, 9 deletions
diff --git a/ppapi/cpp/video_decoder.cc b/ppapi/cpp/video_decoder.cc index 85654c1..42236e4 100644 --- a/ppapi/cpp/video_decoder.cc +++ b/ppapi/cpp/video_decoder.cc @@ -25,6 +25,44 @@ const char* interface_name<PPB_VideoDecoder_0_2>() { return PPB_VIDEODECODER_INTERFACE_0_2; } +template <> +const char* interface_name<PPB_VideoDecoder_1_0>() { + return PPB_VIDEODECODER_INTERFACE_1_0; +} + +// This struct is used to adapt CompletionCallbackWithOutput<PP_VideoPicture> to +// the pre-1.0 APIs, which return PP_VideoPicture_0_1. This struct is allocated +// on the heap, and deleted in CallbackConverter. +struct CallbackData_0_1 { + explicit CallbackData_0_1( + const CompletionCallbackWithOutput<PP_VideoPicture>& cc) + : original_picture(cc.output()), + original_callback(cc.pp_completion_callback()) {} + PP_VideoPicture_0_1 picture; + PP_VideoPicture* original_picture; + PP_CompletionCallback original_callback; +}; + +// Convert a 1.0 style callback to pre-1.0 callback. +void CallbackConverter(void* user_data, int32_t result) { + CallbackData_0_1* data = static_cast<CallbackData_0_1*>(user_data); + if (result == PP_OK) { + PP_VideoPicture_0_1* picture = &data->picture; + PP_VideoPicture* original_picture = data->original_picture; + original_picture->decode_id = picture->decode_id; + original_picture->texture_id = picture->texture_id; + original_picture->texture_target = picture->texture_target; + original_picture->texture_size = picture->texture_size; + // Set visible_rect to the entire picture. + original_picture->visible_rect = PP_MakeRectFromXYWH( + 0, 0, picture->texture_size.width, picture->texture_size.height); + } + + // Now execute the original callback. + PP_RunCompletionCallback(&data->original_callback, result); + delete data; +} + } // namespace VideoDecoder::VideoDecoder() { @@ -44,12 +82,14 @@ int32_t VideoDecoder::Initialize(const Graphics3D& context, PP_VideoProfile profile, PP_HardwareAcceleration acceleration, const CompletionCallback& cc) { + if (has_interface<PPB_VideoDecoder_1_0>()) { + return get_interface<PPB_VideoDecoder_1_0>()->Initialize( + pp_resource(), context.pp_resource(), profile, acceleration, + cc.pp_completion_callback()); + } if (has_interface<PPB_VideoDecoder_0_2>()) { return get_interface<PPB_VideoDecoder_0_2>()->Initialize( - pp_resource(), - context.pp_resource(), - profile, - acceleration, + pp_resource(), context.pp_resource(), profile, acceleration, cc.pp_completion_callback()); } if (has_interface<PPB_VideoDecoder_0_1>()) { @@ -71,6 +111,10 @@ int32_t VideoDecoder::Decode(uint32_t decode_id, uint32_t size, const void* buffer, const CompletionCallback& cc) { + if (has_interface<PPB_VideoDecoder_1_0>()) { + return get_interface<PPB_VideoDecoder_1_0>()->Decode( + pp_resource(), decode_id, size, buffer, cc.pp_completion_callback()); + } if (has_interface<PPB_VideoDecoder_0_2>()) { return get_interface<PPB_VideoDecoder_0_2>()->Decode( pp_resource(), decode_id, size, buffer, cc.pp_completion_callback()); @@ -84,19 +128,32 @@ int32_t VideoDecoder::Decode(uint32_t decode_id, int32_t VideoDecoder::GetPicture( const CompletionCallbackWithOutput<PP_VideoPicture>& cc) { + if (has_interface<PPB_VideoDecoder_1_0>()) { + return get_interface<PPB_VideoDecoder_1_0>()->GetPicture( + pp_resource(), cc.output(), cc.pp_completion_callback()); + } if (has_interface<PPB_VideoDecoder_0_2>()) { + // Data for our callback wrapper. The callback handler will delete it. + CallbackData_0_1* data = new CallbackData_0_1(cc); return get_interface<PPB_VideoDecoder_0_2>()->GetPicture( - pp_resource(), cc.output(), cc.pp_completion_callback()); + pp_resource(), &data->picture, + PP_MakeCompletionCallback(&CallbackConverter, data)); } if (has_interface<PPB_VideoDecoder_0_1>()) { + // Data for our callback wrapper. The callback handler will delete it. + CallbackData_0_1* data = new CallbackData_0_1(cc); return get_interface<PPB_VideoDecoder_0_1>()->GetPicture( - pp_resource(), cc.output(), cc.pp_completion_callback()); + pp_resource(), &data->picture, + PP_MakeCompletionCallback(&CallbackConverter, data)); } return cc.MayForce(PP_ERROR_NOINTERFACE); } void VideoDecoder::RecyclePicture(const PP_VideoPicture& picture) { - if (has_interface<PPB_VideoDecoder_0_2>()) { + if (has_interface<PPB_VideoDecoder_1_0>()) { + get_interface<PPB_VideoDecoder_1_0>()->RecyclePicture(pp_resource(), + &picture); + } else if (has_interface<PPB_VideoDecoder_0_2>()) { get_interface<PPB_VideoDecoder_0_2>()->RecyclePicture(pp_resource(), &picture); } else if (has_interface<PPB_VideoDecoder_0_1>()) { @@ -106,6 +163,10 @@ void VideoDecoder::RecyclePicture(const PP_VideoPicture& picture) { } int32_t VideoDecoder::Flush(const CompletionCallback& cc) { + if (has_interface<PPB_VideoDecoder_1_0>()) { + return get_interface<PPB_VideoDecoder_1_0>()->Flush( + pp_resource(), cc.pp_completion_callback()); + } if (has_interface<PPB_VideoDecoder_0_2>()) { return get_interface<PPB_VideoDecoder_0_2>()->Flush( pp_resource(), cc.pp_completion_callback()); @@ -118,6 +179,10 @@ int32_t VideoDecoder::Flush(const CompletionCallback& cc) { } int32_t VideoDecoder::Reset(const CompletionCallback& cc) { + if (has_interface<PPB_VideoDecoder_1_0>()) { + return get_interface<PPB_VideoDecoder_1_0>()->Reset( + pp_resource(), cc.pp_completion_callback()); + } if (has_interface<PPB_VideoDecoder_0_2>()) { return get_interface<PPB_VideoDecoder_0_2>()->Reset( pp_resource(), cc.pp_completion_callback()); diff --git a/ppapi/cpp/video_decoder.h b/ppapi/cpp/video_decoder.h index cc7267b..60be572 100644 --- a/ppapi/cpp/video_decoder.h +++ b/ppapi/cpp/video_decoder.h @@ -15,8 +15,6 @@ /// @file /// This file defines the API to create and use a VideoDecoder resource. -struct PP_FileInfo; - namespace pp { class InstanceHandle; |