Index: cc/resources/video_resource_updater.cc |
diff --git a/cc/resources/video_resource_updater.cc b/cc/resources/video_resource_updater.cc |
index a2365ed5aeee38e93f2f1c045c28593ee18a6c2a..5ade8e6db5211b76fac1032a8003960611a1213f 100644 |
--- a/cc/resources/video_resource_updater.cc |
+++ b/cc/resources/video_resource_updater.cc |
@@ -34,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 |
@@ -97,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) |
@@ -289,11 +298,7 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes( |
} |
VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes( |
- const scoped_refptr<media::VideoFrame>& video_frame, |
- const TextureMailbox::ReleaseCallback& release_callback) { |
- if (!VerifyFrame(video_frame)) |
- return VideoFrameExternalResources(); |
- |
+ const scoped_refptr<media::VideoFrame>& video_frame) { |
media::VideoFrame::Format frame_format = video_frame->format(); |
DCHECK_EQ(frame_format, media::VideoFrame::NATIVE_TEXTURE); |
@@ -322,37 +327,33 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes( |
return VideoFrameExternalResources(); |
} |
- gpu::Mailbox mailbox; |
- GLC(context, context->genMailboxCHROMIUM(mailbox.name)); |
- GLC(context, context->bindTexture(GL_TEXTURE_2D, video_frame->texture_id())); |
- GLC(context, context->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name)); |
- GLC(context, context->bindTexture(GL_TEXTURE_2D, 0)); |
- |
+ // 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_), |
- release_callback, |
- video_frame->texture_id(), |
- mailbox); |
+ video_frame); |
external_resources.mailboxes.push_back( |
- TextureMailbox(mailbox, callback_to_return_resource)); |
+ TextureMailbox(video_frame->texture_mailbox(), |
+ callback_to_return_resource)); |
return external_resources; |
} |
// static |
void VideoResourceUpdater::ReturnTexture( |
ResourceProvider* resource_provider, |
- TextureMailbox::ReleaseCallback callback, |
- unsigned texture_id, |
- gpu::Mailbox mailbox, |
+ scoped_refptr<media::VideoFrame> video_frame, |
unsigned sync_point, |
bool lost_resource) { |
- WebKit::WebGraphicsContext3D* context = |
- resource_provider->GraphicsContext3D(); |
- GLC(context, context->bindTexture(GL_TEXTURE_2D, texture_id)); |
- GLC(context, context->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name)); |
- GLC(context, context->bindTexture(GL_TEXTURE_2D, 0)); |
- callback.Run(sync_point, lost_resource); |
+ if (sync_point) { |
+ WebKit::WebGraphicsContext3D* context = |
+ resource_provider->GraphicsContext3D(); |
+ GLC(context, context->waitSyncPoint(sync_point)); |
piman
2013/04/11 22:57:58
You need to (shallow) flush here to ensure the vid
|
+ } |
+ |
+ // Dropping the reference to VideoFrame here releases the texture back to the |
+ // decoder. |
} |
// static |