diff options
Diffstat (limited to 'cc/output/renderer_pixeltest.cc')
-rw-r--r-- | cc/output/renderer_pixeltest.cc | 117 |
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_); |