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

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: Use the texture target in the hardware video frame 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 a50e4c8b03b5722fc77b14247f6e1c8d5b8f1193..fbe668b58fe1d1c43cef15593b7bc79c75d6d9fc 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,26 +327,29 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes(
return VideoFrameExternalResources();
}
- external_resources.hardware_resource =
- resource_provider_->CreateResourceFromExternalTexture(
- video_frame->texture_target(),
- 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_target(),
danakj 2013/04/19 21:39:43 Woops, I hadn't hooked the VideoFrame::texture_tar
+ 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

Powered by Google App Engine
This is Rietveld 408576698