Chromium Code Reviews| Index: cc/output/renderer_pixeltest.cc |
| diff --git a/cc/output/renderer_pixeltest.cc b/cc/output/renderer_pixeltest.cc |
| index 1165f9a988cdfe6c58e86d82f4a4318f9b255391..d20ba4c28921dd59bb0c0cd302f625447f771c97 100644 |
| --- a/cc/output/renderer_pixeltest.cc |
| +++ b/cc/output/renderer_pixeltest.cc |
| @@ -403,25 +403,30 @@ TEST_F(GLRendererPixelTest, NonPremultipliedTextureWithBackground) { |
| class VideoGLRendererPixelTest : public GLRendererPixelTest { |
| protected: |
| scoped_ptr<YUVVideoDrawQuad> CreateTestYUVVideoDrawQuad( |
| - SharedQuadState* shared_state, bool with_alpha, bool is_transparent) { |
| - gfx::Rect rect(this->device_viewport_size_); |
| - gfx::Rect opaque_rect(0, 0, 0, 0); |
| + SharedQuadState* shared_state, |
| + bool with_alpha, |
| + bool is_transparent, |
| + const gfx::RectF& tex_coord_rect) { |
| + const gfx::Rect rect(this->device_viewport_size_); |
| + const gfx::Rect uv_rect( |
| + 0, 0, (rect.width() + 1) / 2, (rect.height() + 1) / 2); |
| + const gfx::Rect opaque_rect(0, 0, 0, 0); |
| ResourceProvider::ResourceId y_resource = |
| resource_provider_->CreateResource( |
| - this->device_viewport_size_, |
| + rect.size(), |
| GL_CLAMP_TO_EDGE, |
| ResourceProvider::TextureUsageAny, |
| LUMINANCE_8); |
| ResourceProvider::ResourceId u_resource = |
| resource_provider_->CreateResource( |
| - this->device_viewport_size_, |
| + uv_rect.size(), |
| GL_CLAMP_TO_EDGE, |
| ResourceProvider::TextureUsageAny, |
| LUMINANCE_8); |
| ResourceProvider::ResourceId v_resource = |
| resource_provider_->CreateResource( |
| - this->device_viewport_size_, |
| + uv_rect.size(), |
| GL_CLAMP_TO_EDGE, |
| ResourceProvider::TextureUsageAny, |
| LUMINANCE_8); |
| @@ -434,10 +439,7 @@ class VideoGLRendererPixelTest : public GLRendererPixelTest { |
| LUMINANCE_8); |
| } |
| - 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 y_plane_size = rect.size().GetArea(); |
| 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]); |
| @@ -445,19 +447,25 @@ class VideoGLRendererPixelTest : public GLRendererPixelTest { |
| 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); |
| + // YUV values representing a striped pattern of green. |
|
danakj
2014/03/21 21:44:55
Update this comment please
|
| + uint8_t y_value = 0; |
| + uint8_t u_value = 0; |
| + uint8_t v_value = 0; |
| + for (int i = 0; i < y_plane_size; ++i) |
| + y_plane.get()[i] = (y_value += 1); |
| + for (int i = 0; i < uv_plane_size; ++i) { |
| + u_plane.get()[i] = (u_value += 3); |
| + v_plane.get()[i] = (v_value += 5); |
| + } |
| if (with_alpha) |
| memset(a_plane.get(), is_transparent ? 0 : 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()); |
| + 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()); |
| @@ -468,7 +476,7 @@ class VideoGLRendererPixelTest : public GLRendererPixelTest { |
| rect, |
| opaque_rect, |
| rect, |
| - gfx::Size(), |
| + tex_coord_rect, |
| y_resource, |
| u_resource, |
| v_resource, |
| @@ -486,8 +494,32 @@ TEST_F(VideoGLRendererPixelTest, SimpleYUVRect) { |
| scoped_ptr<SharedQuadState> shared_state = |
| CreateTestSharedQuadState(gfx::Transform(), rect); |
| - scoped_ptr<YUVVideoDrawQuad> yuv_quad = |
| - CreateTestYUVVideoDrawQuad(shared_state.get(), false, false); |
| + scoped_ptr<YUVVideoDrawQuad> yuv_quad = CreateTestYUVVideoDrawQuad( |
| + shared_state.get(), false, false, gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f)); |
| + |
| + pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); |
| + |
| + RenderPassList pass_list; |
| + pass_list.push_back(pass.Pass()); |
| + |
| + EXPECT_TRUE( |
| + this->RunPixelTest(&pass_list, |
| + PixelTest::NoOffscreenContext, |
| + base::FilePath(FILE_PATH_LITERAL("yuv_stripes.png")), |
| + ExactPixelComparator(true))); |
| +} |
| + |
| +TEST_F(VideoGLRendererPixelTest, OffsetYUVRect) { |
| + 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, false, gfx::RectF(0.125f, 0.25f, 0.75f, 0.5f)); |
| pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); |
| @@ -497,7 +529,7 @@ TEST_F(VideoGLRendererPixelTest, SimpleYUVRect) { |
| EXPECT_TRUE(this->RunPixelTest( |
| &pass_list, |
| PixelTest::NoOffscreenContext, |
| - base::FilePath(FILE_PATH_LITERAL("green.png")), |
| + base::FilePath(FILE_PATH_LITERAL("yuv_stripes_offset.png")), |
| ExactPixelComparator(true))); |
| } |
| @@ -510,8 +542,8 @@ TEST_F(VideoGLRendererPixelTest, SimpleYUVARect) { |
| scoped_ptr<SharedQuadState> shared_state = |
| CreateTestSharedQuadState(gfx::Transform(), rect); |
| - scoped_ptr<YUVVideoDrawQuad> yuv_quad = |
| - CreateTestYUVVideoDrawQuad(shared_state.get(), true, false); |
| + scoped_ptr<YUVVideoDrawQuad> yuv_quad = CreateTestYUVVideoDrawQuad( |
| + shared_state.get(), true, false, gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f)); |
| pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); |
| @@ -526,7 +558,7 @@ TEST_F(VideoGLRendererPixelTest, SimpleYUVARect) { |
| EXPECT_TRUE(this->RunPixelTest( |
| &pass_list, |
| PixelTest::NoOffscreenContext, |
| - base::FilePath(FILE_PATH_LITERAL("green_alpha.png")), |
| + base::FilePath(FILE_PATH_LITERAL("yuv_stripes_alpha.png")), |
| ExactPixelComparator(true))); |
| } |
| @@ -539,8 +571,8 @@ TEST_F(VideoGLRendererPixelTest, FullyTransparentYUVARect) { |
| scoped_ptr<SharedQuadState> shared_state = |
| CreateTestSharedQuadState(gfx::Transform(), rect); |
| - scoped_ptr<YUVVideoDrawQuad> yuv_quad = |
| - CreateTestYUVVideoDrawQuad(shared_state.get(), true, true); |
| + scoped_ptr<YUVVideoDrawQuad> yuv_quad = CreateTestYUVVideoDrawQuad( |
| + shared_state.get(), true, true, gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f)); |
| pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); |