diff options
author | halliwell <halliwell@chromium.org> | 2015-05-13 09:27:21 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-13 16:27:32 +0000 |
commit | 9e2b43aee24f3a9827e05d34578ba9a747236cd5 (patch) | |
tree | 5e0aebdd03bd476c7f67f98c6b07b96ab6d03a64 /cc | |
parent | 4a44a2b9ce220eb5b7f82018a5d3df06d81807d2 (diff) | |
download | chromium_src-9e2b43aee24f3a9827e05d34578ba9a747236cd5.zip chromium_src-9e2b43aee24f3a9827e05d34578ba9a747236cd5.tar.gz chromium_src-9e2b43aee24f3a9827e05d34578ba9a747236cd5.tar.bz2 |
Add distinction between RGB and RGBA native texture video frame and resources
Currently it's impossible to place a NATIVE_TEXTURE VideoFrame into an
overlay, because:
* NATIVE_TEXTURE VideoFrame turns into RGB_RESOURCE in
VideoResourceUpdater
* RGB_RESOURCE always sets premultipled_alpha flag on its
TextureDrawQuad (see VideoLayerImpl::AppendQuads)
* OverlayStrategyCommon rejects quads with premultiplied alpha
BUG=
Review URL: https://codereview.chromium.org/1134643002
Cr-Commit-Position: refs/heads/master@{#329651}
Diffstat (limited to 'cc')
-rw-r--r-- | cc/layers/video_layer_impl.cc | 4 | ||||
-rw-r--r-- | cc/resources/video_resource_updater.cc | 7 | ||||
-rw-r--r-- | cc/resources/video_resource_updater.h | 1 | ||||
-rw-r--r-- | cc/resources/video_resource_updater_unittest.cc | 5 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_unittest_context.cc | 6 |
5 files changed, 17 insertions, 6 deletions
diff --git a/cc/layers/video_layer_impl.cc b/cc/layers/video_layer_impl.cc index 6f72b01..ae028d5 100644 --- a/cc/layers/video_layer_impl.cc +++ b/cc/layers/video_layer_impl.cc @@ -261,11 +261,13 @@ void VideoLayerImpl::AppendQuads(RenderPass* render_pass, ValidateQuadResources(yuv_video_quad); break; } + case VideoFrameExternalResources::RGBA_RESOURCE: case VideoFrameExternalResources::RGB_RESOURCE: { DCHECK_EQ(frame_resources_.size(), 1u); if (frame_resources_.size() < 1u) break; - bool premultiplied_alpha = true; + bool premultiplied_alpha = + (frame_resource_type_ == VideoFrameExternalResources::RGBA_RESOURCE); gfx::PointF uv_top_left(0.f, 0.f); gfx::PointF uv_bottom_right(tex_width_scale, tex_height_scale); float opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; diff --git a/cc/resources/video_resource_updater.cc b/cc/resources/video_resource_updater.cc index 1cabb97..06fb692 100644 --- a/cc/resources/video_resource_updater.cc +++ b/cc/resources/video_resource_updater.cc @@ -411,10 +411,15 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForHardwarePlanes( VideoFrameExternalResources external_resources; switch (video_frame->texture_format()) { case media::VideoFrame::TEXTURE_RGBA: + case media::VideoFrame::TEXTURE_RGB: DCHECK_EQ(1u, textures); switch (video_frame->mailbox_holder(0).texture_target) { case GL_TEXTURE_2D: - external_resources.type = VideoFrameExternalResources::RGB_RESOURCE; + if (video_frame->texture_format() == media::VideoFrame::TEXTURE_RGB) + external_resources.type = VideoFrameExternalResources::RGB_RESOURCE; + else + external_resources.type = + VideoFrameExternalResources::RGBA_RESOURCE; break; case GL_TEXTURE_EXTERNAL_OES: external_resources.type = diff --git a/cc/resources/video_resource_updater.h b/cc/resources/video_resource_updater.h index df9951a..13f81b8 100644 --- a/cc/resources/video_resource_updater.h +++ b/cc/resources/video_resource_updater.h @@ -35,6 +35,7 @@ class CC_EXPORT VideoFrameExternalResources { NONE, YUV_RESOURCE, RGB_RESOURCE, + RGBA_RESOURCE, STREAM_TEXTURE_RESOURCE, IO_SURFACE, diff --git a/cc/resources/video_resource_updater_unittest.cc b/cc/resources/video_resource_updater_unittest.cc index fa207ab..10f7fbd 100644 --- a/cc/resources/video_resource_updater_unittest.cc +++ b/cc/resources/video_resource_updater_unittest.cc @@ -125,7 +125,8 @@ class VideoResourceUpdaterTest : public testing::Test { gfx::Rect(size), // visible_rect size, // natural_size base::TimeDelta(), // timestamp - false); // allow_overlay + false, // allow_overlay + true); // has_alpha } scoped_refptr<media::VideoFrame> CreateTestYUVHardareVideoFrame() { @@ -308,7 +309,7 @@ TEST_F(VideoResourceUpdaterTest, CreateForHardwarePlanes) { VideoFrameExternalResources resources = updater.CreateExternalResourcesFromVideoFrame(video_frame); - EXPECT_EQ(VideoFrameExternalResources::RGB_RESOURCE, resources.type); + EXPECT_EQ(VideoFrameExternalResources::RGBA_RESOURCE, resources.type); EXPECT_EQ(1u, resources.mailboxes.size()); EXPECT_EQ(1u, resources.release_callbacks.size()); EXPECT_EQ(0u, resources.software_resources.size()); diff --git a/cc/trees/layer_tree_host_unittest_context.cc b/cc/trees/layer_tree_host_unittest_context.cc index c1436e5..71c9ea0 100644 --- a/cc/trees/layer_tree_host_unittest_context.cc +++ b/cc/trees/layer_tree_host_unittest_context.cc @@ -1078,11 +1078,13 @@ class LayerTreeHostContextTestDontUseLostResources hw_video_frame_ = VideoFrame::WrapNativeTexture( gpu::MailboxHolder(mailbox, GL_TEXTURE_2D, sync_point), media::VideoFrame::ReleaseMailboxCB(), gfx::Size(4, 4), - gfx::Rect(0, 0, 4, 4), gfx::Size(4, 4), base::TimeDelta(), false); + gfx::Rect(0, 0, 4, 4), gfx::Size(4, 4), base::TimeDelta(), + false /* allow_overlay */, true /* has_alpha */); scaled_hw_video_frame_ = VideoFrame::WrapNativeTexture( gpu::MailboxHolder(mailbox, GL_TEXTURE_2D, sync_point), media::VideoFrame::ReleaseMailboxCB(), gfx::Size(4, 4), - gfx::Rect(0, 0, 3, 2), gfx::Size(4, 4), base::TimeDelta(), false); + gfx::Rect(0, 0, 3, 2), gfx::Size(4, 4), base::TimeDelta(), + false /* allow_overlay */, true /* has_alpha */); color_frame_provider_.set_frame(color_video_frame_); hw_frame_provider_.set_frame(hw_video_frame_); |