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

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: video-mailbox: virtualandroid Created 7 years, 6 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
« no previous file with comments | « cc/resources/video_resource_updater.h ('k') | cc/trees/layer_tree_host_unittest_context.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/video_resource_updater.cc
diff --git a/cc/resources/video_resource_updater.cc b/cc/resources/video_resource_updater.cc
index 9a72d64171d8a465c1b900f1868dafe5b1414bc3..1b60d0b07497b6a64835c727ac817151f31be2be 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() {}
@@ -42,6 +41,18 @@ void VideoResourceUpdater::DeleteResource(unsigned resource_id) {
resource_id));
}
+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
@@ -108,9 +119,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)
@@ -308,11 +316,15 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes(
return external_resources;
}
+static void ReturnTexture(
+ scoped_refptr<media::VideoFrame::MailboxHolder> mailbox_holder,
+ unsigned sync_point,
+ bool lost_resource) {
+ mailbox_holder->Return(sync_point);
+}
+
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);
@@ -341,33 +353,18 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes(
return VideoFrameExternalResources();
}
- external_resources.hardware_resource =
- resource_provider_->CreateResourceFromExternalTexture(
- video_frame->texture_target(),
- video_frame->texture_id());
- if (external_resources.hardware_resource)
- all_resources_.push_back(external_resources.hardware_resource);
+ scoped_refptr<media::VideoFrame::MailboxHolder> mailbox_holder =
+ video_frame->texture_mailbox();
TextureMailbox::ReleaseCallback callback_to_return_resource =
- base::Bind(&ReturnTexture,
- AsWeakPtr(),
- external_resources.hardware_resource);
- external_resources.hardware_release_callback = callback_to_return_resource;
- return external_resources;
-}
+ base::Bind(&ReturnTexture, mailbox_holder);
-// static
-void VideoResourceUpdater::ReturnTexture(
- base::WeakPtr<VideoResourceUpdater> updater,
- unsigned resource_id,
- unsigned sync_point,
- bool lost_resource) {
- if (!updater.get()) {
- // Resource was already deleted.
- return;
- }
-
- updater->DeleteResource(resource_id);
+ external_resources.mailboxes.push_back(
+ TextureMailbox(mailbox_holder->mailbox(),
+ callback_to_return_resource,
+ video_frame->texture_target(),
+ mailbox_holder->sync_point()));
+ return external_resources;
}
// static
« no previous file with comments | « cc/resources/video_resource_updater.h ('k') | cc/trees/layer_tree_host_unittest_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698