summaryrefslogtreecommitdiffstats
path: root/cc/output/renderer_pixeltest.cc
diff options
context:
space:
mode:
authorvigneshv@chromium.org <vigneshv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-07 21:50:54 +0000
committervigneshv@chromium.org <vigneshv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-07 21:50:54 +0000
commit0402b238e35ca5870036685c05e5b4fd6e870103 (patch)
treed9eb2365dddd50e962e978dadfd0eb8d0750f68e /cc/output/renderer_pixeltest.cc
parent639ac9701e25c6de1696c9b81a4afd9aeb34b57f (diff)
downloadchromium_src-0402b238e35ca5870036685c05e5b4fd6e870103.zip
chromium_src-0402b238e35ca5870036685c05e5b4fd6e870103.tar.gz
chromium_src-0402b238e35ca5870036685c05e5b4fd6e870103.tar.bz2
Adding YUVA support for enabling Alpha Playback
Adding YUVA support for enabling VP8 Alpha Playback. Trying to reland the change that was reverted earlier. Old CL: https://codereview.chromium.org/12157002/ BUG=147355 TBR=jschuh@chromium.org Review URL: https://chromiumcodereview.appspot.com/16580006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204944 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/output/renderer_pixeltest.cc')
-rw-r--r--cc/output/renderer_pixeltest.cc117
1 files changed, 117 insertions, 0 deletions
diff --git a/cc/output/renderer_pixeltest.cc b/cc/output/renderer_pixeltest.cc
index 4b0c194..cb91ca6 100644
--- a/cc/output/renderer_pixeltest.cc
+++ b/cc/output/renderer_pixeltest.cc
@@ -218,6 +218,123 @@ TYPED_TEST(RendererPixelTest, SimpleGreenRect_NonRootRenderPass) {
ExactPixelComparator(true)));
}
+class VideoGLRendererPixelTest : public GLRendererPixelTest {
+ protected:
+ scoped_ptr<YUVVideoDrawQuad> CreateTestYUVVideoDrawQuad(
+ SharedQuadState* shared_state, bool with_alpha) {
+ gfx::Rect rect(this->device_viewport_size_);
+ gfx::Rect opaque_rect(0, 0, 0, 0);
+
+ ResourceProvider::ResourceId y_resource =
+ resource_provider_->CreateResource(
+ this->device_viewport_size_,
+ GL_LUMINANCE,
+ ResourceProvider::TextureUsageAny);
+ ResourceProvider::ResourceId u_resource =
+ resource_provider_->CreateResource(
+ this->device_viewport_size_,
+ GL_LUMINANCE,
+ ResourceProvider::TextureUsageAny);
+ ResourceProvider::ResourceId v_resource =
+ resource_provider_->CreateResource(
+ this->device_viewport_size_,
+ GL_LUMINANCE,
+ ResourceProvider::TextureUsageAny);
+ ResourceProvider::ResourceId a_resource = 0;
+ if (with_alpha) {
+ a_resource = resource_provider_->CreateResource(
+ this->device_viewport_size_,
+ GL_LUMINANCE,
+ ResourceProvider::TextureUsageAny);
+ }
+
+ int w = this->device_viewport_size_.width();
+ int h = this->device_viewport_size_.height();
+ const int y_plane_size = w * h;
+ gfx::Rect uv_rect((w + 1) / 2, (h + 1) / 2);
+ const int uv_plane_size = uv_rect.size().GetArea();
+ scoped_ptr<uint8_t[]> y_plane(new uint8_t[y_plane_size]);
+ scoped_ptr<uint8_t[]> u_plane(new uint8_t[uv_plane_size]);
+ scoped_ptr<uint8_t[]> v_plane(new uint8_t[uv_plane_size]);
+ scoped_ptr<uint8_t[]> a_plane;
+ if (with_alpha)
+ a_plane.reset(new uint8_t[y_plane_size]);
+ // YUV values representing Green.
+ memset(y_plane.get(), 149, y_plane_size);
+ memset(u_plane.get(), 43, uv_plane_size);
+ memset(v_plane.get(), 21, uv_plane_size);
+ if (with_alpha)
+ memset(a_plane.get(), 128, y_plane_size);
+
+ resource_provider_->SetPixels(y_resource, y_plane.get(), rect, rect,
+ gfx::Vector2d());
+ resource_provider_->SetPixels(u_resource, u_plane.get(), uv_rect, uv_rect,
+ gfx::Vector2d());
+ resource_provider_->SetPixels(v_resource, v_plane.get(), uv_rect, uv_rect,
+ gfx::Vector2d());
+ if (with_alpha) {
+ resource_provider_->SetPixels(a_resource, a_plane.get(), rect, rect,
+ gfx::Vector2d());
+ }
+
+ scoped_ptr<YUVVideoDrawQuad> yuv_quad = cc::YUVVideoDrawQuad::Create();
+ yuv_quad->SetNew(shared_state, rect, opaque_rect, gfx::Size(),
+ y_resource, u_resource, v_resource, a_resource);
+ return yuv_quad.Pass();
+ }
+};
+
+TEST_F(VideoGLRendererPixelTest, SimpleYUVRect) {
+ gfx::Rect rect(this->device_viewport_size_);
+
+ RenderPass::Id id(1, 1);
+ scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect);
+
+ scoped_ptr<SharedQuadState> shared_state =
+ CreateTestSharedQuadState(gfx::Transform(), rect);
+
+ scoped_ptr<YUVVideoDrawQuad> yuv_quad =
+ CreateTestYUVVideoDrawQuad(shared_state.get(), false);
+
+ pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>());
+
+ RenderPassList pass_list;
+ pass_list.push_back(pass.Pass());
+
+ EXPECT_TRUE(this->RunPixelTest(
+ &pass_list,
+ base::FilePath(FILE_PATH_LITERAL("green.png")),
+ ExactPixelComparator(true)));
+}
+
+TEST_F(VideoGLRendererPixelTest, SimpleYUVARect) {
+ gfx::Rect rect(this->device_viewport_size_);
+
+ RenderPass::Id id(1, 1);
+ scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect);
+
+ scoped_ptr<SharedQuadState> shared_state =
+ CreateTestSharedQuadState(gfx::Transform(), rect);
+
+ scoped_ptr<YUVVideoDrawQuad> yuv_quad =
+ CreateTestYUVVideoDrawQuad(shared_state.get(), true);
+
+ pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>());
+
+ scoped_ptr<SolidColorDrawQuad> color_quad = SolidColorDrawQuad::Create();
+ color_quad->SetNew(shared_state.get(), rect, SK_ColorWHITE, false);
+
+ pass->quad_list.push_back(color_quad.PassAs<DrawQuad>());
+
+ RenderPassList pass_list;
+ pass_list.push_back(pass.Pass());
+
+ EXPECT_TRUE(this->RunPixelTest(
+ &pass_list,
+ base::FilePath(FILE_PATH_LITERAL("green_alpha.png")),
+ ExactPixelComparator(true)));
+}
+
TYPED_TEST(RendererPixelTest, FastPassColorFilterAlpha) {
gfx::Rect viewport_rect(this->device_viewport_size_);