Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Unified Diff: cc/output/renderer_pixeltest.cc

Issue 207233002: cc: Support texcoord offsets in YUVVideoDrawQuad (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 5baa37b0 Initial. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/output/renderer_pixeltest.cc
diff --git a/cc/output/renderer_pixeltest.cc b/cc/output/renderer_pixeltest.cc
index 1165f9a988cdfe6c58e86d82f4a4318f9b255391..48a62ce2e8f4b2f993991a7f1b7893f4fe65c6b8 100644
--- a/cc/output/renderer_pixeltest.cc
+++ b/cc/output/renderer_pixeltest.cc
@@ -403,9 +403,13 @@ 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);
danakj 2014/03/21 18:11:11 a + 1 / 2 == a + (1/2) == a + 0 for integer divis
sheu 2014/03/21 20:44:50 :-( Forgot parentheses. Fixed.
+ const gfx::Rect opaque_rect(0, 0, 0, 0);
ResourceProvider::ResourceId y_resource =
resource_provider_->CreateResource(
@@ -434,10 +438,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 +446,21 @@ 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);
+ // YUV values representing a striped pattern of green.
+ uint8_t luma = 0;
+ for (int i = 0; i < y_plane_size; ++i)
+ y_plane.get()[i] = (luma += 1);
memset(u_plane.get(), 43, uv_plane_size);
memset(v_plane.get(), 21, uv_plane_size);
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(), rect, uv_rect, gfx::Vector2d());
+ resource_provider_->SetPixels(
+ v_resource, v_plane.get(), rect, uv_rect, gfx::Vector2d());
if (with_alpha) {
resource_provider_->SetPixels(a_resource, a_plane.get(), rect, rect,
gfx::Vector2d());
@@ -468,7 +471,7 @@ class VideoGLRendererPixelTest : public GLRendererPixelTest {
rect,
opaque_rect,
rect,
- gfx::Size(),
+ tex_coord_rect,
y_resource,
u_resource,
v_resource,
@@ -486,8 +489,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("green_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 +524,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("green_stripes_offset.png")),
ExactPixelComparator(true)));
}
@@ -510,8 +537,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 +553,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("green_stripes_alpha.png")),
ExactPixelComparator(true)));
}
@@ -539,8 +566,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));
danakj 2014/03/21 18:11:11 nit: gfx::RectF(1.f, 1.f) is much shorter way to s
sheu 2014/03/21 20:44:50 I'm adding offset support to the tests (see: new O
pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>());
« no previous file with comments | « cc/output/gl_renderer.cc ('k') | cc/output/shader.h » ('j') | cc/output/shader.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698