| Index: cc/resources/video_resource_updater.cc
|
| diff --git a/cc/resources/video_resource_updater.cc b/cc/resources/video_resource_updater.cc
|
| index 11bfc314d1160604a7a6f4d6f0d1cac5b6b865e5..73cde2373644b4d5f98166cec18cb6d606887697 100644
|
| --- a/cc/resources/video_resource_updater.cc
|
| +++ b/cc/resources/video_resource_updater.cc
|
| @@ -19,8 +19,7 @@ const unsigned kRGBResourceFormat = GL_RGBA;
|
|
|
| namespace cc {
|
|
|
| -VideoFrameExternalResources::VideoFrameExternalResources()
|
| - : type(NONE), hardware_resource(0) {}
|
| +VideoFrameExternalResources::VideoFrameExternalResources() : type(NONE) {}
|
|
|
| VideoFrameExternalResources::~VideoFrameExternalResources() {}
|
|
|
| @@ -35,6 +34,18 @@ VideoResourceUpdater::~VideoResourceUpdater() {
|
| }
|
| }
|
|
|
| +VideoFrameExternalResources VideoResourceUpdater::
|
| + CreateExternalResourcesFromVideoFrame(
|
| + const scoped_refptr<media::VideoFrame>& video_frame) {
|
| + if (!VerifyFrame(video_frame))
|
| + return VideoFrameExternalResources();
|
| +
|
| + if (video_frame->format() == media::VideoFrame::NATIVE_TEXTURE)
|
| + return CreateForHardwarePlanes(video_frame);
|
| + else
|
| + return CreateForSoftwarePlanes(video_frame);
|
| +}
|
| +
|
| bool VideoResourceUpdater::VerifyFrame(
|
| const scoped_refptr<media::VideoFrame>& video_frame) {
|
| // If these fail, we'll have to add logic that handles offset bitmap/texture
|
| @@ -98,9 +109,6 @@ static gfx::Size SoftwarePlaneDimension(
|
|
|
| VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes(
|
| const scoped_refptr<media::VideoFrame>& video_frame) {
|
| - if (!VerifyFrame(video_frame))
|
| - return VideoFrameExternalResources();
|
| -
|
| media::VideoFrame::Format input_frame_format = video_frame->format();
|
|
|
| #if defined(GOOGLE_TV)
|
| @@ -291,9 +299,6 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes(
|
|
|
| VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes(
|
| const scoped_refptr<media::VideoFrame>& video_frame) {
|
| - if (!VerifyFrame(video_frame))
|
| - return VideoFrameExternalResources();
|
| -
|
| media::VideoFrame::Format frame_format = video_frame->format();
|
|
|
| DCHECK_EQ(frame_format, media::VideoFrame::NATIVE_TEXTURE);
|
| @@ -322,25 +327,28 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes(
|
| return VideoFrameExternalResources();
|
| }
|
|
|
| - external_resources.hardware_resource =
|
| - resource_provider_->CreateResourceFromExternalTexture(
|
| - video_frame->texture_id());
|
| -
|
| + // Hold a reference to the VideoFrame in the callback, so the frame stays
|
| + // alive while the texture is in use. As long as the frame is alive, the
|
| + // texture inside it will not be reused by the decoder.
|
| TextureMailbox::ReleaseCallback callback_to_return_resource =
|
| - base::Bind(&ReturnTexture,
|
| - base::Unretained(resource_provider_),
|
| - external_resources.hardware_resource);
|
| - external_resources.hardware_release_callback = callback_to_return_resource;
|
| + base::Bind(&ReturnTexture, video_frame);
|
| +
|
| + external_resources.mailboxes.push_back(
|
| + TextureMailbox(video_frame->texture_mailbox(),
|
| + callback_to_return_resource,
|
| + video_frame->texture_mailbox_sync_point()));
|
| return external_resources;
|
| }
|
|
|
| // static
|
| void VideoResourceUpdater::ReturnTexture(
|
| - ResourceProvider* resource_provider,
|
| - unsigned resource_id,
|
| + scoped_refptr<media::VideoFrame> video_frame,
|
| unsigned sync_point,
|
| bool lost_resource) {
|
| - resource_provider->DeleteResource(resource_id);
|
| + video_frame->set_texture_mailbox_sync_point(sync_point);
|
| +
|
| + // Dropping the reference to VideoFrame here releases the texture back to the
|
| + // decoder.
|
| }
|
|
|
| // static
|
|
|