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

Side by Side Diff: cc/draw_quad_unittest.cc

Issue 11783094: cc: Add point-based UV coordinate on TextureLayer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits and additionnal comments in unittest Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | cc/gl_renderer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/draw_quad.h" 5 #include "cc/draw_quad.h"
6 6
7 #include "cc/checkerboard_draw_quad.h" 7 #include "cc/checkerboard_draw_quad.h"
8 #include "cc/debug_border_draw_quad.h" 8 #include "cc/debug_border_draw_quad.h"
9 #include "cc/io_surface_draw_quad.h" 9 #include "cc/io_surface_draw_quad.h"
10 #include "cc/math_util.h" 10 #include "cc/math_util.h"
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 EXPECT_EQ(DrawQuad::STREAM_VIDEO_CONTENT, copyQuad->material); 355 EXPECT_EQ(DrawQuad::STREAM_VIDEO_CONTENT, copyQuad->material);
356 EXPECT_EQ(textureId, copyQuad->texture_id); 356 EXPECT_EQ(textureId, copyQuad->texture_id);
357 EXPECT_EQ(matrix, copyQuad->matrix); 357 EXPECT_EQ(matrix, copyQuad->matrix);
358 } 358 }
359 359
360 TEST(DrawQuadTest, copyTextureDrawQuad) 360 TEST(DrawQuadTest, copyTextureDrawQuad)
361 { 361 {
362 gfx::Rect opaqueRect(3, 7, 10, 12); 362 gfx::Rect opaqueRect(3, 7, 10, 12);
363 unsigned resourceId = 82; 363 unsigned resourceId = 82;
364 bool premultipliedAlpha = true; 364 bool premultipliedAlpha = true;
365 gfx::RectF uvRect(0.5f, 224.f, 51.f, 36.f); 365 gfx::PointF uvTopLeft(0.5f, 224.f);
366 gfx::PointF uvBottomRight(51.5f, 260.f);
366 const float vertex_opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; 367 const float vertex_opacity[] = {1.0f, 1.0f, 1.0f, 1.0f};
367 bool flipped = true; 368 bool flipped = true;
368 CREATE_SHARED_STATE(); 369 CREATE_SHARED_STATE();
369 370
370 CREATE_QUAD_6_NEW(TextureDrawQuad, opaqueRect, resourceId, premultipliedAlph a, uvRect, vertex_opacity, flipped); 371 CREATE_QUAD_7_NEW(TextureDrawQuad, opaqueRect, resourceId, premultipliedAlph a, uvTopLeft, uvBottomRight, vertex_opacity, flipped);
371 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, copyQuad->material); 372 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, copyQuad->material);
372 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect); 373 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect);
373 EXPECT_EQ(resourceId, copyQuad->resource_id); 374 EXPECT_EQ(resourceId, copyQuad->resource_id);
374 EXPECT_EQ(premultipliedAlpha, copyQuad->premultiplied_alpha); 375 EXPECT_EQ(premultipliedAlpha, copyQuad->premultiplied_alpha);
375 EXPECT_FLOAT_RECT_EQ(uvRect, copyQuad->uv_rect); 376 EXPECT_EQ(uvTopLeft, copyQuad->uv_top_left);
377 EXPECT_EQ(uvBottomRight, copyQuad->uv_bottom_right);
376 EXPECT_FLOAT_ARRAY_EQ(vertex_opacity, copyQuad->vertex_opacity, 4); 378 EXPECT_FLOAT_ARRAY_EQ(vertex_opacity, copyQuad->vertex_opacity, 4);
377 EXPECT_EQ(flipped, copyQuad->flipped); 379 EXPECT_EQ(flipped, copyQuad->flipped);
378 380
379 CREATE_QUAD_5_ALL(TextureDrawQuad, resourceId, premultipliedAlpha, uvRect, v ertex_opacity, flipped); 381 CREATE_QUAD_6_ALL(TextureDrawQuad, resourceId, premultipliedAlpha, uvTopLeft , uvBottomRight, vertex_opacity, flipped);
380 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, copyQuad->material); 382 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, copyQuad->material);
381 EXPECT_EQ(resourceId, copyQuad->resource_id); 383 EXPECT_EQ(resourceId, copyQuad->resource_id);
382 EXPECT_EQ(premultipliedAlpha, copyQuad->premultiplied_alpha); 384 EXPECT_EQ(premultipliedAlpha, copyQuad->premultiplied_alpha);
383 EXPECT_FLOAT_RECT_EQ(uvRect, copyQuad->uv_rect); 385 EXPECT_EQ(uvTopLeft, copyQuad->uv_top_left);
386 EXPECT_EQ(uvBottomRight, copyQuad->uv_bottom_right);
384 EXPECT_FLOAT_ARRAY_EQ(vertex_opacity, copyQuad->vertex_opacity, 4); 387 EXPECT_FLOAT_ARRAY_EQ(vertex_opacity, copyQuad->vertex_opacity, 4);
385 EXPECT_EQ(flipped, copyQuad->flipped); 388 EXPECT_EQ(flipped, copyQuad->flipped);
386 } 389 }
387 390
391 TEST(DrawQuadTest, clipTextureDrawQuad)
392 {
393 gfx::Rect opaqueRect(3, 7, 10, 12);
394 unsigned resourceId = 82;
395 bool premultipliedAlpha = true;
396 bool flipped = true;
397 CREATE_SHARED_STATE();
398 // Original quad is at (30, 40) size 50*60
danakj 2013/01/15 22:39:09 nit: comments are complete sentences including per
Jerome 2013/01/15 23:14:35 Done.
399 sharedState->content_to_target_transform = MathUtil::createGfxTransform(1.f, 0.f, 0.f, 1.f, 10.f, 20.f);
400 // after transform the quad is at (40, 60) size 50*60
danakj 2013/01/15 22:39:09 nit: same thing
Jerome 2013/01/15 23:14:35 Done.
401 sharedState->clip_rect = gfx::Rect(50, 70, 30, 20);
402
403 //40 50 90
404 // B--:-------C 60
405 // | b----c -|-70
406 // | | | |
407 // | a----d -|-90
408 // | |
409 // A----------D 120
410 // UV and vertex opacity are stored per vertex on the parent rectangle 'ABCD '.
411 // The value on the clipped rectangle 'abcd' are interpolated to keep visual appearance.
412
413 // UV value for 'B' vertex
danakj 2013/01/15 22:39:09 nit: complete sentences for all these please.
Jerome 2013/01/15 23:14:35 Done.
414 gfx::PointF uvTopLeft(0.1f, 0.2f);
415 // UV value for 'D' vertex
416 gfx::PointF uvBottomRight(0.9f, 0.8f);
417 // Vertex opacity for 'ABCD'
418 const float vertexOpacity[] = {0.3f, 0.4f, 0.7f, 0.8f};
419
420 {
421 CREATE_QUAD_7_NEW(TextureDrawQuad, opaqueRect, resourceId, premultipliedAl pha, uvTopLeft, uvBottomRight, vertexOpacity, flipped);
422 CREATE_QUAD_6_ALL(TextureDrawQuad, resourceId, premultipliedAlpha, uvTopLe ft, uvBottomRight, vertexOpacity, flipped);
423 EXPECT_TRUE(quadAll->PerformClipping());
424
425 // UV value for vertex 'b'
426 gfx::PointF uvTopLeftClipped(0.26f, 0.3f);
danakj 2013/01/15 22:39:09 I was thinking more about describing these expecte
Jerome 2013/01/15 23:14:35 Done.
427 // UV value for vertex 'd'
428 gfx::PointF uvBottomRightClipped(0.74f, 0.5f);
429 // Vertex opacity for 'abcd'
430 const float vertexOpacityClipped[] = {0.43f, 0.45f, 0.65f, 0.67f};
431
432 EXPECT_EQ(uvTopLeftClipped, quadAll->uv_top_left);
433 EXPECT_EQ(uvBottomRightClipped, quadAll->uv_bottom_right);
434 EXPECT_FLOAT_ARRAY_EQ(vertexOpacityClipped, quadAll->vertex_opacity, 4);
435 }
436
437 uvTopLeft = gfx::PointF(0.8f, 0.7f);
438 uvBottomRight = gfx::PointF(0.2f, 0.1f);
439
440 {
441 CREATE_QUAD_7_NEW(TextureDrawQuad, opaqueRect, resourceId, premultipliedAl pha, uvTopLeft, uvBottomRight, vertexOpacity, flipped);
442 CREATE_QUAD_6_ALL(TextureDrawQuad, resourceId, premultipliedAlpha, uvTopLe ft, uvBottomRight, vertexOpacity, flipped);
443 EXPECT_TRUE(quadAll->PerformClipping());
444
445 // UV value for vertex 'b'
446 gfx::PointF uvTopLeftClipped(0.68f, 0.6f);
447 // UV value for vertex 'd'
448 gfx::PointF uvBottomRightClipped(0.32f, 0.4f);
449
450 EXPECT_EQ(uvTopLeftClipped, quadAll->uv_top_left);
451 EXPECT_EQ(uvBottomRightClipped, quadAll->uv_bottom_right);
452 }
453 }
454
388 TEST(DrawQuadTest, copyTileDrawQuad) 455 TEST(DrawQuadTest, copyTileDrawQuad)
389 { 456 {
390 gfx::Rect opaqueRect(33, 44, 22, 33); 457 gfx::Rect opaqueRect(33, 44, 22, 33);
391 unsigned resourceId = 104; 458 unsigned resourceId = 104;
392 gfx::RectF texCoordRect(31, 12, 54, 20); 459 gfx::RectF texCoordRect(31, 12, 54, 20);
393 gfx::Size textureSize(85, 32); 460 gfx::Size textureSize(85, 32);
394 bool swizzleContents = true; 461 bool swizzleContents = true;
395 bool leftEdgeAA = true; 462 bool leftEdgeAA = true;
396 bool topEdgeAA = true; 463 bool topEdgeAA = true;
397 bool rightEdgeAA = false; 464 bool rightEdgeAA = false;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 EXPECT_EQ(uPlane.resourceId, copyQuad->u_plane.resourceId); 530 EXPECT_EQ(uPlane.resourceId, copyQuad->u_plane.resourceId);
464 EXPECT_EQ(uPlane.size, copyQuad->u_plane.size); 531 EXPECT_EQ(uPlane.size, copyQuad->u_plane.size);
465 EXPECT_EQ(uPlane.format, copyQuad->u_plane.format); 532 EXPECT_EQ(uPlane.format, copyQuad->u_plane.format);
466 EXPECT_EQ(vPlane.resourceId, copyQuad->v_plane.resourceId); 533 EXPECT_EQ(vPlane.resourceId, copyQuad->v_plane.resourceId);
467 EXPECT_EQ(vPlane.size, copyQuad->v_plane.size); 534 EXPECT_EQ(vPlane.size, copyQuad->v_plane.size);
468 EXPECT_EQ(vPlane.format, copyQuad->v_plane.format); 535 EXPECT_EQ(vPlane.format, copyQuad->v_plane.format);
469 } 536 }
470 537
471 } // namespace 538 } // namespace
472 } // namespace cc 539 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/gl_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698