| Index: cc/output/renderer_pixeltest.cc
|
| diff --git a/cc/output/renderer_pixeltest.cc b/cc/output/renderer_pixeltest.cc
|
| index d479e5fb2e1c1a5a5e4323935d01cf7549341611..32b7d63af1e000e5725a7126de7cc628edf7b5b5 100644
|
| --- a/cc/output/renderer_pixeltest.cc
|
| +++ b/cc/output/renderer_pixeltest.cc
|
| @@ -207,6 +207,122 @@ 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_RGBA,
|
| + ResourceProvider::TextureUsageAny);
|
| + ResourceProvider::ResourceId u_resource =
|
| + resource_provider_->CreateResource(
|
| + this->device_viewport_size_,
|
| + GL_RGBA,
|
| + ResourceProvider::TextureUsageAny);
|
| + ResourceProvider::ResourceId v_resource =
|
| + resource_provider_->CreateResource(
|
| + this->device_viewport_size_,
|
| + GL_RGBA,
|
| + ResourceProvider::TextureUsageAny);
|
| + ResourceProvider::ResourceId a_resource = 0;
|
| + if (with_alpha) {
|
| + a_resource = resource_provider_->CreateResource(
|
| + this->device_viewport_size_,
|
| + GL_RGBA,
|
| + ResourceProvider::TextureUsageAny);
|
| + }
|
| +
|
| + int w = this->device_viewport_size_.width();
|
| + int h = this->device_viewport_size_.height();
|
| + const int y_plane_size = w * h;
|
| + const int uv_plane_size = ((w + 1) / 2) * ((h + 1) / 2);
|
| + 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(), rect, rect,
|
| + gfx::Vector2d());
|
| + resource_provider_->SetPixels(v_resource, v_plane.get(), rect, 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_);
|
|
|
|
|