Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Unified Diff: cc/resources/video_resource_updater.cc

Issue 14199002: Send hardware video frames with mailboxes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ifdefed Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..06ccde2d6ea3fe69aecc68d233d7f1f4ce946759 100644
--- a/cc/resources/video_resource_updater.cc
+++ b/cc/resources/video_resource_updater.cc
@@ -19,7 +19,13 @@ const unsigned kRGBResourceFormat = GL_RGBA;
namespace cc {
-VideoFrameExternalResources::VideoFrameExternalResources() : type(NONE) {}
+VideoFrameExternalResources::VideoFrameExternalResources()
+#ifdef VIDEO_FRAME_MAILBOX
+ : type(NONE) {}
+#else
+ : type(NONE),
+ hardware_resource(0) {}
+#endif
VideoFrameExternalResources::~VideoFrameExternalResources() {}
@@ -34,6 +40,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 +115,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 +304,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 +333,54 @@ 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));
+#ifndef VIDEO_FRAME_MAILBOX
+ ResourceProvider::ResourceId hardware_resource = 0;
+ hardware_resource = resource_provider_->CreateResourceFromExternalTexture(
+ video_frame->texture_id());
+#endif
+ // 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 =
+#ifdef VIDEO_FRAME_MAILBOX
+ base::Bind(&ReturnTexture, video_frame);
+#else
base::Bind(&ReturnTexture,
+ video_frame,
base::Unretained(resource_provider_),
- release_callback,
- video_frame->texture_id(),
- mailbox);
- external_resources.mailboxes.push_back(
- TextureMailbox(mailbox, callback_to_return_resource));
+ hardware_resource);
+#endif
+
+#ifdef VIDEO_FRAME_MAILBOX
+ external_resources.mailboxes.push_back(
+ TextureMailbox(video_frame->texture_mailbox(),
+ callback_to_return_resource,
+ video_frame->texture_mailbox_sync_point()));
+#else
+ external_resources.hardware_resource = hardware_resource;
+ external_resources.hardware_release_callback = callback_to_return_resource;
+#endif
return external_resources;
}
// static
void VideoResourceUpdater::ReturnTexture(
+ scoped_refptr<media::VideoFrame> video_frame,
+#ifndef VIDEO_FRAME_MAILBOX
ResourceProvider* resource_provider,
- TextureMailbox::ReleaseCallback callback,
- unsigned texture_id,
- gpu::Mailbox mailbox,
+ unsigned resource_id,
+#endif
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);
+#ifndef VIDEO_FRAME_MAILBOX
+ resource_provider->DeleteResource(resource_id);
+#else
+ video_frame->set_texture_mailbox_sync_point(sync_point);
+#endif
+
+ // Dropping the reference to VideoFrame here releases the texture back to the
+ // decoder.
}
// static

Powered by Google App Engine
This is Rietveld 408576698