summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorvigneshv@chromium.org <vigneshv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-28 23:49:10 +0000
committervigneshv@chromium.org <vigneshv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-28 23:49:10 +0000
commit36bf995b022fb03fb59a7353235827bab5328f9c (patch)
treebefb77510bead70f9461f0663b34434465e2cb11 /cc
parent3121bc10e2dd666aa23d0a9921b170cff1e65aeb (diff)
downloadchromium_src-36bf995b022fb03fb59a7353235827bab5328f9c.zip
chromium_src-36bf995b022fb03fb59a7353235827bab5328f9c.tar.gz
chromium_src-36bf995b022fb03fb59a7353235827bab5328f9c.tar.bz2
cc: Pre multiplying alpha value in YUVA Fragment Shader
The alpha value from the video's alpha plane should be pre-multiplied in the YUVA Fragment Shader. This fixes videos not rendering properly when the alpha plane is completely transparent (i.e.) alpha value is zero. Also, adding a pixel test to test the correct behavior. BUG=147355 Review URL: https://chromiumcodereview.appspot.com/18122007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209234 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/output/renderer_pixeltest.cc36
-rw-r--r--cc/output/shader.cc2
2 files changed, 33 insertions, 5 deletions
diff --git a/cc/output/renderer_pixeltest.cc b/cc/output/renderer_pixeltest.cc
index 893e6a1..b559d20 100644
--- a/cc/output/renderer_pixeltest.cc
+++ b/cc/output/renderer_pixeltest.cc
@@ -221,7 +221,7 @@ TYPED_TEST(RendererPixelTest, SimpleGreenRect_NonRootRenderPass) {
class VideoGLRendererPixelTest : public GLRendererPixelTest {
protected:
scoped_ptr<YUVVideoDrawQuad> CreateTestYUVVideoDrawQuad(
- SharedQuadState* shared_state, bool with_alpha) {
+ SharedQuadState* shared_state, bool with_alpha, bool is_transparent) {
gfx::Rect rect(this->device_viewport_size_);
gfx::Rect opaque_rect(0, 0, 0, 0);
@@ -264,7 +264,7 @@ class VideoGLRendererPixelTest : public GLRendererPixelTest {
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);
+ memset(a_plane.get(), is_transparent ? 0 : 128, y_plane_size);
resource_provider_->SetPixels(y_resource, y_plane.get(), rect, rect,
gfx::Vector2d());
@@ -294,7 +294,7 @@ TEST_F(VideoGLRendererPixelTest, SimpleYUVRect) {
CreateTestSharedQuadState(gfx::Transform(), rect);
scoped_ptr<YUVVideoDrawQuad> yuv_quad =
- CreateTestYUVVideoDrawQuad(shared_state.get(), false);
+ CreateTestYUVVideoDrawQuad(shared_state.get(), false, false);
pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>());
@@ -317,7 +317,7 @@ TEST_F(VideoGLRendererPixelTest, SimpleYUVARect) {
CreateTestSharedQuadState(gfx::Transform(), rect);
scoped_ptr<YUVVideoDrawQuad> yuv_quad =
- CreateTestYUVVideoDrawQuad(shared_state.get(), true);
+ CreateTestYUVVideoDrawQuad(shared_state.get(), true, false);
pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>());
@@ -335,6 +335,34 @@ TEST_F(VideoGLRendererPixelTest, SimpleYUVARect) {
ExactPixelComparator(true)));
}
+TEST_F(VideoGLRendererPixelTest, FullyTransparentYUVARect) {
+ 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, 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_ColorBLACK, 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("black.png")),
+ ExactPixelComparator(true)));
+}
+
TYPED_TEST(RendererPixelTest, FastPassColorFilterAlpha) {
gfx::Rect viewport_rect(this->device_viewport_size_);
diff --git a/cc/output/shader.cc b/cc/output/shader.cc
index e08ee8a..385c72d 100644
--- a/cc/output/shader.cc
+++ b/cc/output/shader.cc
@@ -1402,7 +1402,7 @@ std::string FragmentShaderYUVAVideo::GetShaderString(
float a_raw = texture2D(a_texture, v_texCoord).x;
vec3 yuv = vec3(y_raw, u_unsigned, v_unsigned) + yuv_adj;
vec3 rgb = yuv_matrix * yuv;
- gl_FragColor = vec4(rgb, a_raw) * alpha;
+ gl_FragColor = vec4(rgb, float(1)) * (alpha * a_raw);
}
); // NOLINT(whitespace/parens)
}