Index: cc/output/renderer_pixeltest.cc |
diff --git a/cc/output/renderer_pixeltest.cc b/cc/output/renderer_pixeltest.cc |
index d479e5fb2e1c1a5a5e4323935d01cf7549341611..de0c12ac3d093f4d87481eeb0d8c4188111ca1ac 100644 |
--- a/cc/output/renderer_pixeltest.cc |
+++ b/cc/output/renderer_pixeltest.cc |
@@ -207,6 +207,145 @@ TYPED_TEST(RendererPixelTest, SimpleGreenRect_NonRootRenderPass) { |
ExactPixelComparator(true))); |
} |
+TEST_F(GLRendererPixelTest, SimpleYUVRect) { |
+ gfx::Rect rect(this->device_viewport_size_); |
+ gfx::Rect opaque_rect(0, 0, 0, 0); |
+ |
+ RenderPass::Id id(1, 1); |
+ scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); |
+ |
+ scoped_ptr<SharedQuadState> shared_state = |
+ CreateTestSharedQuadState(gfx::Transform(), rect); |
+ |
+ ResourceProvider::ResourceId y_resource = |
+ cc::PixelTest::resource_provider_->CreateResource( |
enne (OOO)
2013/05/30 23:52:54
cc::PixelTest::resource_provider_ => this->resourc
vignesh
2013/05/31 19:49:37
Done.
|
+ this->device_viewport_size_, |
+ GL_RGBA, |
+ ResourceProvider::TextureUsageAny); |
+ ResourceProvider::ResourceId u_resource = |
+ cc::PixelTest::resource_provider_->CreateResource( |
+ this->device_viewport_size_, |
+ GL_RGBA, |
+ ResourceProvider::TextureUsageAny); |
+ ResourceProvider::ResourceId v_resource = |
+ cc::PixelTest::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(); |
+ uint8_t* y_plane = new uint8_t[w * h]; |
enne (OOO)
2013/05/30 23:52:54
Please use a scoped_ptr for any memory ownership:
vignesh
2013/05/31 19:49:37
Done.
|
+ uint8_t* u_plane = new uint8_t[(w / 2) * (h / 2)]; |
enne (OOO)
2013/05/30 23:52:54
Can you put this repeated expression in a temporar
vignesh
2013/05/31 19:49:37
Done.
|
+ uint8_t* v_plane = new uint8_t[(w / 2) * (h / 2)]; |
+ // YUV values representing Green. |
+ memset(y_plane, 149, w * h); |
+ memset(u_plane, 43, (w / 2) * (h / 2)); |
+ memset(v_plane, 21, (w / 2) * (h / 2)); |
+ |
+ cc::PixelTest::resource_provider_->SetPixels(y_resource, y_plane, rect, rect, |
+ gfx::Vector2d()); |
+ cc::PixelTest::resource_provider_->SetPixels(u_resource, u_plane, rect, rect, |
+ gfx::Vector2d()); |
+ cc::PixelTest::resource_provider_->SetPixels(v_resource, v_plane, rect, rect, |
+ gfx::Vector2d()); |
+ |
+ scoped_ptr<cc::YUVVideoDrawQuad> yuv_quad = cc::YUVVideoDrawQuad::Create(); |
+ yuv_quad->SetNew(shared_state.get(), rect, opaque_rect, gfx::Size(0, 0), |
enne (OOO)
2013/05/30 23:52:54
style nit: gfx::Size(), here and elsewhere
vignesh
2013/05/31 19:49:37
Done.
|
+ y_resource, u_resource, v_resource, 0); |
+ |
+ pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); |
+ |
+ RenderPassList pass_list; |
+ pass_list.push_back(pass.Pass()); |
+ |
+ delete[] y_plane; |
+ delete[] u_plane; |
+ delete[] v_plane; |
+ |
+ EXPECT_TRUE(this->RunPixelTest( |
+ &pass_list, |
+ base::FilePath(FILE_PATH_LITERAL("green.png")), |
+ ExactPixelComparator(true))); |
+} |
+ |
+TEST_F(GLRendererPixelTest, SimpleYUVARect) { |
+ gfx::Rect rect(this->device_viewport_size_); |
+ gfx::Rect opaque_rect(0, 0, 0, 0); |
+ |
+ RenderPass::Id id(1, 1); |
+ scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); |
+ |
+ scoped_ptr<SharedQuadState> shared_state = |
+ CreateTestSharedQuadState(gfx::Transform(), rect); |
+ |
+ ResourceProvider::ResourceId y_resource = |
enne (OOO)
2013/05/30 23:52:54
There's a lot of repeated code between these two t
vignesh
2013/05/31 19:49:37
Done.
|
+ cc::PixelTest::resource_provider_->CreateResource( |
+ this->device_viewport_size_, |
+ GL_RGBA, |
+ ResourceProvider::TextureUsageAny); |
+ ResourceProvider::ResourceId u_resource = |
+ cc::PixelTest::resource_provider_->CreateResource( |
+ this->device_viewport_size_, |
+ GL_RGBA, |
+ ResourceProvider::TextureUsageAny); |
+ ResourceProvider::ResourceId v_resource = |
+ cc::PixelTest::resource_provider_->CreateResource( |
+ this->device_viewport_size_, |
+ GL_RGBA, |
+ ResourceProvider::TextureUsageAny); |
+ ResourceProvider::ResourceId a_resource = |
+ cc::PixelTest::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(); |
+ uint8_t* y_plane = new uint8_t[w * h]; |
+ uint8_t* u_plane = new uint8_t[(w / 2) * (h / 2)]; |
+ uint8_t* v_plane = new uint8_t[(w / 2) * (h / 2)]; |
+ uint8_t* a_plane = new uint8_t[w * h]; |
+ // YUV values representing Green. |
+ memset(y_plane, 149, w * h); |
+ memset(u_plane, 43, (w / 2) * (h / 2)); |
+ memset(v_plane, 21, (w / 2) * (h / 2)); |
+ memset(a_plane, 128, (w / 2) * (h / 2)); |
+ |
+ cc::PixelTest::resource_provider_->SetPixels(y_resource, y_plane, rect, rect, |
+ gfx::Vector2d()); |
+ cc::PixelTest::resource_provider_->SetPixels(u_resource, u_plane, rect, rect, |
+ gfx::Vector2d()); |
+ cc::PixelTest::resource_provider_->SetPixels(v_resource, v_plane, rect, rect, |
+ gfx::Vector2d()); |
+ cc::PixelTest::resource_provider_->SetPixels(a_resource, a_plane, rect, rect, |
+ gfx::Vector2d()); |
+ |
+ scoped_ptr<cc::YUVVideoDrawQuad> yuv_quad = cc::YUVVideoDrawQuad::Create(); |
+ yuv_quad->SetNew(shared_state.get(), rect, opaque_rect, gfx::Size(0, 0), |
+ y_resource, u_resource, v_resource, a_resource); |
+ |
+ 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()); |
+ |
+ delete[] y_plane; |
+ delete[] u_plane; |
+ delete[] v_plane; |
+ delete[] a_plane; |
+ |
+ 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_); |