| OLD | NEW |
| 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/quads/draw_quad.h" | 5 #include "cc/quads/draw_quad.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 CREATE_QUAD_5_NEW(IOSurfaceDrawQuad, | 411 CREATE_QUAD_5_NEW(IOSurfaceDrawQuad, |
| 412 opaque_rect, | 412 opaque_rect, |
| 413 visible_rect, | 413 visible_rect, |
| 414 size, | 414 size, |
| 415 resource_id, | 415 resource_id, |
| 416 orientation); | 416 orientation); |
| 417 EXPECT_EQ(DrawQuad::IO_SURFACE_CONTENT, copy_quad->material); | 417 EXPECT_EQ(DrawQuad::IO_SURFACE_CONTENT, copy_quad->material); |
| 418 EXPECT_EQ(visible_rect, copy_quad->visible_rect); | 418 EXPECT_EQ(visible_rect, copy_quad->visible_rect); |
| 419 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect); | 419 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect); |
| 420 EXPECT_EQ(size, copy_quad->io_surface_size); | 420 EXPECT_EQ(size, copy_quad->io_surface_size); |
| 421 EXPECT_EQ(resource_id, copy_quad->io_surface_resource_id); | 421 EXPECT_EQ(resource_id, copy_quad->io_surface_resource_id()); |
| 422 EXPECT_EQ(orientation, copy_quad->orientation); | 422 EXPECT_EQ(orientation, copy_quad->orientation); |
| 423 | 423 |
| 424 CREATE_QUAD_3_ALL(IOSurfaceDrawQuad, size, resource_id, orientation); | 424 CREATE_QUAD_3_ALL(IOSurfaceDrawQuad, size, resource_id, orientation); |
| 425 EXPECT_EQ(DrawQuad::IO_SURFACE_CONTENT, copy_quad->material); | 425 EXPECT_EQ(DrawQuad::IO_SURFACE_CONTENT, copy_quad->material); |
| 426 EXPECT_EQ(size, copy_quad->io_surface_size); | 426 EXPECT_EQ(size, copy_quad->io_surface_size); |
| 427 EXPECT_EQ(resource_id, copy_quad->io_surface_resource_id); | 427 EXPECT_EQ(resource_id, copy_quad->io_surface_resource_id()); |
| 428 EXPECT_EQ(orientation, copy_quad->orientation); | 428 EXPECT_EQ(orientation, copy_quad->orientation); |
| 429 } | 429 } |
| 430 | 430 |
| 431 TEST(DrawQuadTest, CopyRenderPassDrawQuad) { | 431 TEST(DrawQuadTest, CopyRenderPassDrawQuad) { |
| 432 gfx::Rect visible_rect(40, 50, 30, 20); | 432 gfx::Rect visible_rect(40, 50, 30, 20); |
| 433 RenderPassId render_pass_id(22, 64); | 433 RenderPassId render_pass_id(22, 64); |
| 434 ResourceId mask_resource_id = 78; | 434 ResourceId mask_resource_id = 78; |
| 435 gfx::Vector2dF mask_uv_scale(33.f, 19.f); | 435 gfx::Vector2dF mask_uv_scale(33.f, 19.f); |
| 436 gfx::Size mask_texture_size(128, 134); | 436 gfx::Size mask_texture_size(128, 134); |
| 437 FilterOperations filters; | 437 FilterOperations filters; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 450 mask_resource_id, | 450 mask_resource_id, |
| 451 mask_uv_scale, | 451 mask_uv_scale, |
| 452 mask_texture_size, | 452 mask_texture_size, |
| 453 filters, | 453 filters, |
| 454 filters_scale, | 454 filters_scale, |
| 455 background_filters, | 455 background_filters, |
| 456 copied_render_pass_id); | 456 copied_render_pass_id); |
| 457 EXPECT_EQ(DrawQuad::RENDER_PASS, copy_quad->material); | 457 EXPECT_EQ(DrawQuad::RENDER_PASS, copy_quad->material); |
| 458 EXPECT_EQ(visible_rect, copy_quad->visible_rect); | 458 EXPECT_EQ(visible_rect, copy_quad->visible_rect); |
| 459 EXPECT_EQ(copied_render_pass_id, copy_quad->render_pass_id); | 459 EXPECT_EQ(copied_render_pass_id, copy_quad->render_pass_id); |
| 460 EXPECT_EQ(mask_resource_id, copy_quad->mask_resource_id); | 460 EXPECT_EQ(mask_resource_id, copy_quad->mask_resource_id()); |
| 461 EXPECT_EQ(mask_uv_scale.ToString(), copy_quad->mask_uv_scale.ToString()); | 461 EXPECT_EQ(mask_uv_scale.ToString(), copy_quad->mask_uv_scale.ToString()); |
| 462 EXPECT_EQ(mask_texture_size.ToString(), | 462 EXPECT_EQ(mask_texture_size.ToString(), |
| 463 copy_quad->mask_texture_size.ToString()); | 463 copy_quad->mask_texture_size.ToString()); |
| 464 EXPECT_EQ(filters, copy_quad->filters); | 464 EXPECT_EQ(filters, copy_quad->filters); |
| 465 EXPECT_EQ(filters_scale, copy_quad->filters_scale); | 465 EXPECT_EQ(filters_scale, copy_quad->filters_scale); |
| 466 EXPECT_EQ(background_filters, copy_quad->background_filters); | 466 EXPECT_EQ(background_filters, copy_quad->background_filters); |
| 467 | 467 |
| 468 CREATE_QUAD_ALL_RP(RenderPassDrawQuad, | 468 CREATE_QUAD_ALL_RP(RenderPassDrawQuad, |
| 469 render_pass_id, | 469 render_pass_id, |
| 470 mask_resource_id, | 470 mask_resource_id, |
| 471 mask_uv_scale, | 471 mask_uv_scale, |
| 472 mask_texture_size, | 472 mask_texture_size, |
| 473 filters, | 473 filters, |
| 474 filters_scale, | 474 filters_scale, |
| 475 background_filters, | 475 background_filters, |
| 476 copied_render_pass_id); | 476 copied_render_pass_id); |
| 477 EXPECT_EQ(DrawQuad::RENDER_PASS, copy_quad->material); | 477 EXPECT_EQ(DrawQuad::RENDER_PASS, copy_quad->material); |
| 478 EXPECT_EQ(copied_render_pass_id, copy_quad->render_pass_id); | 478 EXPECT_EQ(copied_render_pass_id, copy_quad->render_pass_id); |
| 479 EXPECT_EQ(mask_resource_id, copy_quad->mask_resource_id); | 479 EXPECT_EQ(mask_resource_id, copy_quad->mask_resource_id()); |
| 480 EXPECT_EQ(mask_uv_scale.ToString(), copy_quad->mask_uv_scale.ToString()); | 480 EXPECT_EQ(mask_uv_scale.ToString(), copy_quad->mask_uv_scale.ToString()); |
| 481 EXPECT_EQ(mask_texture_size.ToString(), | 481 EXPECT_EQ(mask_texture_size.ToString(), |
| 482 copy_quad->mask_texture_size.ToString()); | 482 copy_quad->mask_texture_size.ToString()); |
| 483 EXPECT_EQ(filters, copy_quad->filters); | 483 EXPECT_EQ(filters, copy_quad->filters); |
| 484 EXPECT_EQ(filters_scale, copy_quad->filters_scale); | 484 EXPECT_EQ(filters_scale, copy_quad->filters_scale); |
| 485 EXPECT_EQ(background_filters, copy_quad->background_filters); | 485 EXPECT_EQ(background_filters, copy_quad->background_filters); |
| 486 } | 486 } |
| 487 | 487 |
| 488 TEST(DrawQuadTest, CopySolidColorDrawQuad) { | 488 TEST(DrawQuadTest, CopySolidColorDrawQuad) { |
| 489 gfx::Rect visible_rect(40, 50, 30, 20); | 489 gfx::Rect visible_rect(40, 50, 30, 20); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 509 gfx::Rect visible_rect(40, 50, 30, 20); | 509 gfx::Rect visible_rect(40, 50, 30, 20); |
| 510 ResourceId resource_id = 64; | 510 ResourceId resource_id = 64; |
| 511 gfx::Transform matrix = gfx::Transform(0.5, 0.25, 1, 0.75, 0, 1); | 511 gfx::Transform matrix = gfx::Transform(0.5, 0.25, 1, 0.75, 0, 1); |
| 512 CREATE_SHARED_STATE(); | 512 CREATE_SHARED_STATE(); |
| 513 | 513 |
| 514 CREATE_QUAD_4_NEW( | 514 CREATE_QUAD_4_NEW( |
| 515 StreamVideoDrawQuad, opaque_rect, visible_rect, resource_id, matrix); | 515 StreamVideoDrawQuad, opaque_rect, visible_rect, resource_id, matrix); |
| 516 EXPECT_EQ(DrawQuad::STREAM_VIDEO_CONTENT, copy_quad->material); | 516 EXPECT_EQ(DrawQuad::STREAM_VIDEO_CONTENT, copy_quad->material); |
| 517 EXPECT_EQ(visible_rect, copy_quad->visible_rect); | 517 EXPECT_EQ(visible_rect, copy_quad->visible_rect); |
| 518 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect); | 518 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect); |
| 519 EXPECT_EQ(resource_id, copy_quad->resource_id); | 519 EXPECT_EQ(resource_id, copy_quad->resource_id()); |
| 520 EXPECT_EQ(matrix, copy_quad->matrix); | 520 EXPECT_EQ(matrix, copy_quad->matrix); |
| 521 | 521 |
| 522 CREATE_QUAD_2_ALL(StreamVideoDrawQuad, resource_id, matrix); | 522 CREATE_QUAD_2_ALL(StreamVideoDrawQuad, resource_id, matrix); |
| 523 EXPECT_EQ(DrawQuad::STREAM_VIDEO_CONTENT, copy_quad->material); | 523 EXPECT_EQ(DrawQuad::STREAM_VIDEO_CONTENT, copy_quad->material); |
| 524 EXPECT_EQ(resource_id, copy_quad->resource_id); | 524 EXPECT_EQ(resource_id, copy_quad->resource_id()); |
| 525 EXPECT_EQ(matrix, copy_quad->matrix); | 525 EXPECT_EQ(matrix, copy_quad->matrix); |
| 526 } | 526 } |
| 527 | 527 |
| 528 TEST(DrawQuadTest, CopySurfaceDrawQuad) { | 528 TEST(DrawQuadTest, CopySurfaceDrawQuad) { |
| 529 gfx::Rect visible_rect(40, 50, 30, 20); | 529 gfx::Rect visible_rect(40, 50, 30, 20); |
| 530 SurfaceId surface_id(1234); | 530 SurfaceId surface_id(1234); |
| 531 CREATE_SHARED_STATE(); | 531 CREATE_SHARED_STATE(); |
| 532 | 532 |
| 533 CREATE_QUAD_2_NEW(SurfaceDrawQuad, visible_rect, surface_id); | 533 CREATE_QUAD_2_NEW(SurfaceDrawQuad, visible_rect, surface_id); |
| 534 EXPECT_EQ(DrawQuad::SURFACE_CONTENT, copy_quad->material); | 534 EXPECT_EQ(DrawQuad::SURFACE_CONTENT, copy_quad->material); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 560 premultiplied_alpha, | 560 premultiplied_alpha, |
| 561 uv_top_left, | 561 uv_top_left, |
| 562 uv_bottom_right, | 562 uv_bottom_right, |
| 563 SK_ColorTRANSPARENT, | 563 SK_ColorTRANSPARENT, |
| 564 vertex_opacity, | 564 vertex_opacity, |
| 565 y_flipped, | 565 y_flipped, |
| 566 nearest_neighbor); | 566 nearest_neighbor); |
| 567 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, copy_quad->material); | 567 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, copy_quad->material); |
| 568 EXPECT_EQ(visible_rect, copy_quad->visible_rect); | 568 EXPECT_EQ(visible_rect, copy_quad->visible_rect); |
| 569 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect); | 569 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect); |
| 570 EXPECT_EQ(resource_id, copy_quad->resource_id); | 570 EXPECT_EQ(resource_id, copy_quad->resource_id()); |
| 571 EXPECT_EQ(premultiplied_alpha, copy_quad->premultiplied_alpha); | 571 EXPECT_EQ(premultiplied_alpha, copy_quad->premultiplied_alpha); |
| 572 EXPECT_EQ(uv_top_left, copy_quad->uv_top_left); | 572 EXPECT_EQ(uv_top_left, copy_quad->uv_top_left); |
| 573 EXPECT_EQ(uv_bottom_right, copy_quad->uv_bottom_right); | 573 EXPECT_EQ(uv_bottom_right, copy_quad->uv_bottom_right); |
| 574 EXPECT_FLOAT_ARRAY_EQ(vertex_opacity, copy_quad->vertex_opacity, 4); | 574 EXPECT_FLOAT_ARRAY_EQ(vertex_opacity, copy_quad->vertex_opacity, 4); |
| 575 EXPECT_EQ(y_flipped, copy_quad->y_flipped); | 575 EXPECT_EQ(y_flipped, copy_quad->y_flipped); |
| 576 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor); | 576 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor); |
| 577 | 577 |
| 578 CREATE_QUAD_8_ALL(TextureDrawQuad, | 578 CREATE_QUAD_8_ALL(TextureDrawQuad, |
| 579 resource_id, | 579 resource_id, |
| 580 premultiplied_alpha, | 580 premultiplied_alpha, |
| 581 uv_top_left, | 581 uv_top_left, |
| 582 uv_bottom_right, | 582 uv_bottom_right, |
| 583 SK_ColorTRANSPARENT, | 583 SK_ColorTRANSPARENT, |
| 584 vertex_opacity, | 584 vertex_opacity, |
| 585 y_flipped, | 585 y_flipped, |
| 586 nearest_neighbor); | 586 nearest_neighbor); |
| 587 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, copy_quad->material); | 587 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, copy_quad->material); |
| 588 EXPECT_EQ(resource_id, copy_quad->resource_id); | 588 EXPECT_EQ(resource_id, copy_quad->resource_id()); |
| 589 EXPECT_EQ(premultiplied_alpha, copy_quad->premultiplied_alpha); | 589 EXPECT_EQ(premultiplied_alpha, copy_quad->premultiplied_alpha); |
| 590 EXPECT_EQ(uv_top_left, copy_quad->uv_top_left); | 590 EXPECT_EQ(uv_top_left, copy_quad->uv_top_left); |
| 591 EXPECT_EQ(uv_bottom_right, copy_quad->uv_bottom_right); | 591 EXPECT_EQ(uv_bottom_right, copy_quad->uv_bottom_right); |
| 592 EXPECT_FLOAT_ARRAY_EQ(vertex_opacity, copy_quad->vertex_opacity, 4); | 592 EXPECT_FLOAT_ARRAY_EQ(vertex_opacity, copy_quad->vertex_opacity, 4); |
| 593 EXPECT_EQ(y_flipped, copy_quad->y_flipped); | 593 EXPECT_EQ(y_flipped, copy_quad->y_flipped); |
| 594 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor); | 594 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor); |
| 595 } | 595 } |
| 596 | 596 |
| 597 TEST(DrawQuadTest, CopyTileDrawQuad) { | 597 TEST(DrawQuadTest, CopyTileDrawQuad) { |
| 598 gfx::Rect opaque_rect(33, 44, 22, 33); | 598 gfx::Rect opaque_rect(33, 44, 22, 33); |
| 599 gfx::Rect visible_rect(40, 50, 30, 20); | 599 gfx::Rect visible_rect(40, 50, 30, 20); |
| 600 unsigned resource_id = 104; | 600 unsigned resource_id = 104; |
| 601 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f); | 601 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f); |
| 602 gfx::Size texture_size(85, 32); | 602 gfx::Size texture_size(85, 32); |
| 603 bool swizzle_contents = true; | 603 bool swizzle_contents = true; |
| 604 bool nearest_neighbor = true; | 604 bool nearest_neighbor = true; |
| 605 CREATE_SHARED_STATE(); | 605 CREATE_SHARED_STATE(); |
| 606 | 606 |
| 607 CREATE_QUAD_7_NEW(TileDrawQuad, | 607 CREATE_QUAD_7_NEW(TileDrawQuad, |
| 608 opaque_rect, | 608 opaque_rect, |
| 609 visible_rect, | 609 visible_rect, |
| 610 resource_id, | 610 resource_id, |
| 611 tex_coord_rect, | 611 tex_coord_rect, |
| 612 texture_size, | 612 texture_size, |
| 613 swizzle_contents, | 613 swizzle_contents, |
| 614 nearest_neighbor); | 614 nearest_neighbor); |
| 615 EXPECT_EQ(DrawQuad::TILED_CONTENT, copy_quad->material); | 615 EXPECT_EQ(DrawQuad::TILED_CONTENT, copy_quad->material); |
| 616 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect); | 616 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect); |
| 617 EXPECT_EQ(visible_rect, copy_quad->visible_rect); | 617 EXPECT_EQ(visible_rect, copy_quad->visible_rect); |
| 618 EXPECT_EQ(resource_id, copy_quad->resource_id); | 618 EXPECT_EQ(resource_id, copy_quad->resource_id()); |
| 619 EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect); | 619 EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect); |
| 620 EXPECT_EQ(texture_size, copy_quad->texture_size); | 620 EXPECT_EQ(texture_size, copy_quad->texture_size); |
| 621 EXPECT_EQ(swizzle_contents, copy_quad->swizzle_contents); | 621 EXPECT_EQ(swizzle_contents, copy_quad->swizzle_contents); |
| 622 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor); | 622 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor); |
| 623 | 623 |
| 624 CREATE_QUAD_5_ALL(TileDrawQuad, | 624 CREATE_QUAD_5_ALL(TileDrawQuad, |
| 625 resource_id, | 625 resource_id, |
| 626 tex_coord_rect, | 626 tex_coord_rect, |
| 627 texture_size, | 627 texture_size, |
| 628 swizzle_contents, | 628 swizzle_contents, |
| 629 nearest_neighbor); | 629 nearest_neighbor); |
| 630 EXPECT_EQ(DrawQuad::TILED_CONTENT, copy_quad->material); | 630 EXPECT_EQ(DrawQuad::TILED_CONTENT, copy_quad->material); |
| 631 EXPECT_EQ(resource_id, copy_quad->resource_id); | 631 EXPECT_EQ(resource_id, copy_quad->resource_id()); |
| 632 EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect); | 632 EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect); |
| 633 EXPECT_EQ(texture_size, copy_quad->texture_size); | 633 EXPECT_EQ(texture_size, copy_quad->texture_size); |
| 634 EXPECT_EQ(swizzle_contents, copy_quad->swizzle_contents); | 634 EXPECT_EQ(swizzle_contents, copy_quad->swizzle_contents); |
| 635 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor); | 635 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor); |
| 636 } | 636 } |
| 637 | 637 |
| 638 TEST(DrawQuadTest, CopyYUVVideoDrawQuad) { | 638 TEST(DrawQuadTest, CopyYUVVideoDrawQuad) { |
| 639 gfx::Rect opaque_rect(33, 47, 10, 12); | 639 gfx::Rect opaque_rect(33, 47, 10, 12); |
| 640 gfx::Rect visible_rect(40, 50, 30, 20); | 640 gfx::Rect visible_rect(40, 50, 30, 20); |
| 641 gfx::RectF ya_tex_coord_rect(40, 50, 30, 20); | 641 gfx::RectF ya_tex_coord_rect(40, 50, 30, 20); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 653 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, | 653 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, |
| 654 uv_tex_size, y_plane_resource_id, u_plane_resource_id, | 654 uv_tex_size, y_plane_resource_id, u_plane_resource_id, |
| 655 v_plane_resource_id, a_plane_resource_id, color_space); | 655 v_plane_resource_id, a_plane_resource_id, color_space); |
| 656 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material); | 656 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material); |
| 657 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect); | 657 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect); |
| 658 EXPECT_EQ(visible_rect, copy_quad->visible_rect); | 658 EXPECT_EQ(visible_rect, copy_quad->visible_rect); |
| 659 EXPECT_EQ(ya_tex_coord_rect, copy_quad->ya_tex_coord_rect); | 659 EXPECT_EQ(ya_tex_coord_rect, copy_quad->ya_tex_coord_rect); |
| 660 EXPECT_EQ(uv_tex_coord_rect, copy_quad->uv_tex_coord_rect); | 660 EXPECT_EQ(uv_tex_coord_rect, copy_quad->uv_tex_coord_rect); |
| 661 EXPECT_EQ(ya_tex_size, copy_quad->ya_tex_size); | 661 EXPECT_EQ(ya_tex_size, copy_quad->ya_tex_size); |
| 662 EXPECT_EQ(uv_tex_size, copy_quad->uv_tex_size); | 662 EXPECT_EQ(uv_tex_size, copy_quad->uv_tex_size); |
| 663 EXPECT_EQ(y_plane_resource_id, copy_quad->y_plane_resource_id); | 663 EXPECT_EQ(y_plane_resource_id, copy_quad->y_plane_resource_id()); |
| 664 EXPECT_EQ(u_plane_resource_id, copy_quad->u_plane_resource_id); | 664 EXPECT_EQ(u_plane_resource_id, copy_quad->u_plane_resource_id()); |
| 665 EXPECT_EQ(v_plane_resource_id, copy_quad->v_plane_resource_id); | 665 EXPECT_EQ(v_plane_resource_id, copy_quad->v_plane_resource_id()); |
| 666 EXPECT_EQ(a_plane_resource_id, copy_quad->a_plane_resource_id); | 666 EXPECT_EQ(a_plane_resource_id, copy_quad->a_plane_resource_id()); |
| 667 EXPECT_EQ(color_space, copy_quad->color_space); | 667 EXPECT_EQ(color_space, copy_quad->color_space); |
| 668 | 668 |
| 669 CREATE_QUAD_9_ALL(YUVVideoDrawQuad, ya_tex_coord_rect, uv_tex_coord_rect, | 669 CREATE_QUAD_9_ALL(YUVVideoDrawQuad, ya_tex_coord_rect, uv_tex_coord_rect, |
| 670 ya_tex_size, uv_tex_size, y_plane_resource_id, | 670 ya_tex_size, uv_tex_size, y_plane_resource_id, |
| 671 u_plane_resource_id, v_plane_resource_id, | 671 u_plane_resource_id, v_plane_resource_id, |
| 672 a_plane_resource_id, color_space); | 672 a_plane_resource_id, color_space); |
| 673 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material); | 673 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material); |
| 674 EXPECT_EQ(ya_tex_coord_rect, copy_quad->ya_tex_coord_rect); | 674 EXPECT_EQ(ya_tex_coord_rect, copy_quad->ya_tex_coord_rect); |
| 675 EXPECT_EQ(uv_tex_coord_rect, copy_quad->uv_tex_coord_rect); | 675 EXPECT_EQ(uv_tex_coord_rect, copy_quad->uv_tex_coord_rect); |
| 676 EXPECT_EQ(ya_tex_size, copy_quad->ya_tex_size); | 676 EXPECT_EQ(ya_tex_size, copy_quad->ya_tex_size); |
| 677 EXPECT_EQ(uv_tex_size, copy_quad->uv_tex_size); | 677 EXPECT_EQ(uv_tex_size, copy_quad->uv_tex_size); |
| 678 EXPECT_EQ(y_plane_resource_id, copy_quad->y_plane_resource_id); | 678 EXPECT_EQ(y_plane_resource_id, copy_quad->y_plane_resource_id()); |
| 679 EXPECT_EQ(u_plane_resource_id, copy_quad->u_plane_resource_id); | 679 EXPECT_EQ(u_plane_resource_id, copy_quad->u_plane_resource_id()); |
| 680 EXPECT_EQ(v_plane_resource_id, copy_quad->v_plane_resource_id); | 680 EXPECT_EQ(v_plane_resource_id, copy_quad->v_plane_resource_id()); |
| 681 EXPECT_EQ(a_plane_resource_id, copy_quad->a_plane_resource_id); | 681 EXPECT_EQ(a_plane_resource_id, copy_quad->a_plane_resource_id()); |
| 682 EXPECT_EQ(color_space, copy_quad->color_space); | 682 EXPECT_EQ(color_space, copy_quad->color_space); |
| 683 } | 683 } |
| 684 | 684 |
| 685 TEST(DrawQuadTest, CopyPictureDrawQuad) { | 685 TEST(DrawQuadTest, CopyPictureDrawQuad) { |
| 686 gfx::Rect opaque_rect(33, 44, 22, 33); | 686 gfx::Rect opaque_rect(33, 44, 22, 33); |
| 687 gfx::Rect visible_rect(40, 50, 30, 20); | 687 gfx::Rect visible_rect(40, 50, 30, 20); |
| 688 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f); | 688 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f); |
| 689 gfx::Size texture_size(85, 32); | 689 gfx::Size texture_size(85, 32); |
| 690 bool nearest_neighbor = true; | 690 bool nearest_neighbor = true; |
| 691 ResourceFormat texture_format = RGBA_8888; | 691 ResourceFormat texture_format = RGBA_8888; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 | 725 |
| 726 class DrawQuadIteratorTest : public testing::Test { | 726 class DrawQuadIteratorTest : public testing::Test { |
| 727 protected: | 727 protected: |
| 728 ResourceId IncrementResourceId(ResourceId id) { | 728 ResourceId IncrementResourceId(ResourceId id) { |
| 729 ++num_resources_; | 729 ++num_resources_; |
| 730 return id + 1; | 730 return id + 1; |
| 731 } | 731 } |
| 732 | 732 |
| 733 int IterateAndCount(DrawQuad* quad) { | 733 int IterateAndCount(DrawQuad* quad) { |
| 734 num_resources_ = 0; | 734 num_resources_ = 0; |
| 735 quad->IterateResources(base::Bind( | 735 quad->IterateResources([this](ResourceId resource_id) { |
| 736 &DrawQuadIteratorTest::IncrementResourceId, base::Unretained(this))); | 736 ++num_resources_; |
| 737 return resource_id + 1; |
| 738 }); |
| 737 return num_resources_; | 739 return num_resources_; |
| 738 } | 740 } |
| 739 | 741 |
| 740 private: | 742 private: |
| 741 int num_resources_; | 743 int num_resources_; |
| 742 }; | 744 }; |
| 743 | 745 |
| 744 TEST_F(DrawQuadIteratorTest, CheckerboardDrawQuad) { | 746 TEST_F(DrawQuadIteratorTest, CheckerboardDrawQuad) { |
| 745 gfx::Rect visible_rect(40, 50, 30, 20); | 747 gfx::Rect visible_rect(40, 50, 30, 20); |
| 746 SkColor color = 0xfabb0011; | 748 SkColor color = 0xfabb0011; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 768 ResourceId resource_id = 72; | 770 ResourceId resource_id = 72; |
| 769 IOSurfaceDrawQuad::Orientation orientation = IOSurfaceDrawQuad::UNFLIPPED; | 771 IOSurfaceDrawQuad::Orientation orientation = IOSurfaceDrawQuad::UNFLIPPED; |
| 770 | 772 |
| 771 CREATE_SHARED_STATE(); | 773 CREATE_SHARED_STATE(); |
| 772 CREATE_QUAD_5_NEW(IOSurfaceDrawQuad, | 774 CREATE_QUAD_5_NEW(IOSurfaceDrawQuad, |
| 773 opaque_rect, | 775 opaque_rect, |
| 774 visible_rect, | 776 visible_rect, |
| 775 size, | 777 size, |
| 776 resource_id, | 778 resource_id, |
| 777 orientation); | 779 orientation); |
| 778 EXPECT_EQ(resource_id, quad_new->io_surface_resource_id); | 780 EXPECT_EQ(resource_id, quad_new->io_surface_resource_id()); |
| 779 EXPECT_EQ(1, IterateAndCount(quad_new)); | 781 EXPECT_EQ(1, IterateAndCount(quad_new)); |
| 780 EXPECT_EQ(resource_id + 1, quad_new->io_surface_resource_id); | 782 EXPECT_EQ(resource_id + 1, quad_new->io_surface_resource_id()); |
| 781 } | 783 } |
| 782 | 784 |
| 783 TEST_F(DrawQuadIteratorTest, RenderPassDrawQuad) { | 785 TEST_F(DrawQuadIteratorTest, RenderPassDrawQuad) { |
| 784 gfx::Rect visible_rect(40, 50, 30, 20); | 786 gfx::Rect visible_rect(40, 50, 30, 20); |
| 785 RenderPassId render_pass_id(22, 64); | 787 RenderPassId render_pass_id(22, 64); |
| 786 ResourceId mask_resource_id = 78; | 788 ResourceId mask_resource_id = 78; |
| 787 gfx::Vector2dF mask_uv_scale(33.f, 19.f); | 789 gfx::Vector2dF mask_uv_scale(33.f, 19.f); |
| 788 gfx::Size mask_texture_size(128, 134); | 790 gfx::Size mask_texture_size(128, 134); |
| 789 FilterOperations filters; | 791 FilterOperations filters; |
| 790 filters.Append(FilterOperation::CreateBlurFilter(1.f)); | 792 filters.Append(FilterOperation::CreateBlurFilter(1.f)); |
| 791 gfx::Vector2dF filters_scale(2.f, 3.f); | 793 gfx::Vector2dF filters_scale(2.f, 3.f); |
| 792 FilterOperations background_filters; | 794 FilterOperations background_filters; |
| 793 background_filters.Append( | 795 background_filters.Append( |
| 794 FilterOperation::CreateGrayscaleFilter(1.f)); | 796 FilterOperation::CreateGrayscaleFilter(1.f)); |
| 795 | 797 |
| 796 RenderPassId copied_render_pass_id(235, 11); | 798 RenderPassId copied_render_pass_id(235, 11); |
| 797 | 799 |
| 798 CREATE_SHARED_STATE(); | 800 CREATE_SHARED_STATE(); |
| 799 CREATE_QUAD_NEW_RP(RenderPassDrawQuad, | 801 CREATE_QUAD_NEW_RP(RenderPassDrawQuad, |
| 800 visible_rect, | 802 visible_rect, |
| 801 render_pass_id, | 803 render_pass_id, |
| 802 mask_resource_id, | 804 mask_resource_id, |
| 803 mask_uv_scale, | 805 mask_uv_scale, |
| 804 mask_texture_size, | 806 mask_texture_size, |
| 805 filters, | 807 filters, |
| 806 filters_scale, | 808 filters_scale, |
| 807 background_filters, | 809 background_filters, |
| 808 copied_render_pass_id); | 810 copied_render_pass_id); |
| 809 EXPECT_EQ(mask_resource_id, quad_new->mask_resource_id); | 811 EXPECT_EQ(mask_resource_id, quad_new->mask_resource_id()); |
| 810 EXPECT_EQ(1, IterateAndCount(quad_new)); | 812 EXPECT_EQ(1, IterateAndCount(quad_new)); |
| 811 EXPECT_EQ(mask_resource_id + 1, quad_new->mask_resource_id); | 813 EXPECT_EQ(mask_resource_id + 1, quad_new->mask_resource_id()); |
| 812 quad_new->mask_resource_id = 0; | |
| 813 EXPECT_EQ(0, IterateAndCount(quad_new)); | |
| 814 EXPECT_EQ(0u, quad_new->mask_resource_id); | |
| 815 } | 814 } |
| 816 | 815 |
| 817 TEST_F(DrawQuadIteratorTest, SolidColorDrawQuad) { | 816 TEST_F(DrawQuadIteratorTest, SolidColorDrawQuad) { |
| 818 gfx::Rect visible_rect(40, 50, 30, 20); | 817 gfx::Rect visible_rect(40, 50, 30, 20); |
| 819 SkColor color = 0x49494949; | 818 SkColor color = 0x49494949; |
| 820 bool force_anti_aliasing_off = false; | 819 bool force_anti_aliasing_off = false; |
| 821 | 820 |
| 822 CREATE_SHARED_STATE(); | 821 CREATE_SHARED_STATE(); |
| 823 CREATE_QUAD_3_NEW( | 822 CREATE_QUAD_3_NEW( |
| 824 SolidColorDrawQuad, visible_rect, color, force_anti_aliasing_off); | 823 SolidColorDrawQuad, visible_rect, color, force_anti_aliasing_off); |
| 825 EXPECT_EQ(0, IterateAndCount(quad_new)); | 824 EXPECT_EQ(0, IterateAndCount(quad_new)); |
| 826 } | 825 } |
| 827 | 826 |
| 828 TEST_F(DrawQuadIteratorTest, StreamVideoDrawQuad) { | 827 TEST_F(DrawQuadIteratorTest, StreamVideoDrawQuad) { |
| 829 gfx::Rect opaque_rect(33, 47, 10, 12); | 828 gfx::Rect opaque_rect(33, 47, 10, 12); |
| 830 gfx::Rect visible_rect(40, 50, 30, 20); | 829 gfx::Rect visible_rect(40, 50, 30, 20); |
| 831 ResourceId resource_id = 64; | 830 ResourceId resource_id = 64; |
| 832 gfx::Transform matrix = gfx::Transform(0.5, 0.25, 1, 0.75, 0, 1); | 831 gfx::Transform matrix = gfx::Transform(0.5, 0.25, 1, 0.75, 0, 1); |
| 833 | 832 |
| 834 CREATE_SHARED_STATE(); | 833 CREATE_SHARED_STATE(); |
| 835 CREATE_QUAD_4_NEW( | 834 CREATE_QUAD_4_NEW( |
| 836 StreamVideoDrawQuad, opaque_rect, visible_rect, resource_id, matrix); | 835 StreamVideoDrawQuad, opaque_rect, visible_rect, resource_id, matrix); |
| 837 EXPECT_EQ(resource_id, quad_new->resource_id); | 836 EXPECT_EQ(resource_id, quad_new->resource_id()); |
| 838 EXPECT_EQ(1, IterateAndCount(quad_new)); | 837 EXPECT_EQ(1, IterateAndCount(quad_new)); |
| 839 EXPECT_EQ(resource_id + 1, quad_new->resource_id); | 838 EXPECT_EQ(resource_id + 1, quad_new->resource_id()); |
| 840 } | 839 } |
| 841 | 840 |
| 842 TEST_F(DrawQuadIteratorTest, SurfaceDrawQuad) { | 841 TEST_F(DrawQuadIteratorTest, SurfaceDrawQuad) { |
| 843 gfx::Rect visible_rect(40, 50, 30, 20); | 842 gfx::Rect visible_rect(40, 50, 30, 20); |
| 844 SurfaceId surface_id(4321); | 843 SurfaceId surface_id(4321); |
| 845 | 844 |
| 846 CREATE_SHARED_STATE(); | 845 CREATE_SHARED_STATE(); |
| 847 CREATE_QUAD_2_NEW(SurfaceDrawQuad, visible_rect, surface_id); | 846 CREATE_QUAD_2_NEW(SurfaceDrawQuad, visible_rect, surface_id); |
| 848 EXPECT_EQ(0, IterateAndCount(quad_new)); | 847 EXPECT_EQ(0, IterateAndCount(quad_new)); |
| 849 } | 848 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 864 opaque_rect, | 863 opaque_rect, |
| 865 visible_rect, | 864 visible_rect, |
| 866 resource_id, | 865 resource_id, |
| 867 premultiplied_alpha, | 866 premultiplied_alpha, |
| 868 uv_top_left, | 867 uv_top_left, |
| 869 uv_bottom_right, | 868 uv_bottom_right, |
| 870 SK_ColorTRANSPARENT, | 869 SK_ColorTRANSPARENT, |
| 871 vertex_opacity, | 870 vertex_opacity, |
| 872 y_flipped, | 871 y_flipped, |
| 873 nearest_neighbor); | 872 nearest_neighbor); |
| 874 EXPECT_EQ(resource_id, quad_new->resource_id); | 873 EXPECT_EQ(resource_id, quad_new->resource_id()); |
| 875 EXPECT_EQ(1, IterateAndCount(quad_new)); | 874 EXPECT_EQ(1, IterateAndCount(quad_new)); |
| 876 EXPECT_EQ(resource_id + 1, quad_new->resource_id); | 875 EXPECT_EQ(resource_id + 1, quad_new->resource_id()); |
| 877 } | 876 } |
| 878 | 877 |
| 879 TEST_F(DrawQuadIteratorTest, TileDrawQuad) { | 878 TEST_F(DrawQuadIteratorTest, TileDrawQuad) { |
| 880 gfx::Rect opaque_rect(33, 44, 22, 33); | 879 gfx::Rect opaque_rect(33, 44, 22, 33); |
| 881 gfx::Rect visible_rect(40, 50, 30, 20); | 880 gfx::Rect visible_rect(40, 50, 30, 20); |
| 882 unsigned resource_id = 104; | 881 unsigned resource_id = 104; |
| 883 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f); | 882 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f); |
| 884 gfx::Size texture_size(85, 32); | 883 gfx::Size texture_size(85, 32); |
| 885 bool swizzle_contents = true; | 884 bool swizzle_contents = true; |
| 886 bool nearest_neighbor = true; | 885 bool nearest_neighbor = true; |
| 887 | 886 |
| 888 CREATE_SHARED_STATE(); | 887 CREATE_SHARED_STATE(); |
| 889 CREATE_QUAD_7_NEW(TileDrawQuad, | 888 CREATE_QUAD_7_NEW(TileDrawQuad, |
| 890 opaque_rect, | 889 opaque_rect, |
| 891 visible_rect, | 890 visible_rect, |
| 892 resource_id, | 891 resource_id, |
| 893 tex_coord_rect, | 892 tex_coord_rect, |
| 894 texture_size, | 893 texture_size, |
| 895 swizzle_contents, | 894 swizzle_contents, |
| 896 nearest_neighbor); | 895 nearest_neighbor); |
| 897 EXPECT_EQ(resource_id, quad_new->resource_id); | 896 EXPECT_EQ(resource_id, quad_new->resource_id()); |
| 898 EXPECT_EQ(1, IterateAndCount(quad_new)); | 897 EXPECT_EQ(1, IterateAndCount(quad_new)); |
| 899 EXPECT_EQ(resource_id + 1, quad_new->resource_id); | 898 EXPECT_EQ(resource_id + 1, quad_new->resource_id()); |
| 900 } | 899 } |
| 901 | 900 |
| 902 TEST_F(DrawQuadIteratorTest, YUVVideoDrawQuad) { | 901 TEST_F(DrawQuadIteratorTest, YUVVideoDrawQuad) { |
| 903 gfx::Rect opaque_rect(33, 47, 10, 12); | 902 gfx::Rect opaque_rect(33, 47, 10, 12); |
| 904 gfx::Rect visible_rect(40, 50, 30, 20); | 903 gfx::Rect visible_rect(40, 50, 30, 20); |
| 905 gfx::RectF ya_tex_coord_rect(0.0f, 0.0f, 0.75f, 0.5f); | 904 gfx::RectF ya_tex_coord_rect(0.0f, 0.0f, 0.75f, 0.5f); |
| 906 gfx::RectF uv_tex_coord_rect(0.0f, 0.0f, 0.375f, 0.25f); | 905 gfx::RectF uv_tex_coord_rect(0.0f, 0.0f, 0.375f, 0.25f); |
| 907 gfx::Size ya_tex_size(32, 68); | 906 gfx::Size ya_tex_size(32, 68); |
| 908 gfx::Size uv_tex_size(41, 51); | 907 gfx::Size uv_tex_size(41, 51); |
| 909 ResourceId y_plane_resource_id = 45; | 908 ResourceId y_plane_resource_id = 45; |
| 910 ResourceId u_plane_resource_id = 532; | 909 ResourceId u_plane_resource_id = 532; |
| 911 ResourceId v_plane_resource_id = 4; | 910 ResourceId v_plane_resource_id = 4; |
| 912 ResourceId a_plane_resource_id = 63; | 911 ResourceId a_plane_resource_id = 63; |
| 913 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::JPEG; | 912 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::JPEG; |
| 914 | 913 |
| 915 CREATE_SHARED_STATE(); | 914 CREATE_SHARED_STATE(); |
| 916 CREATE_QUAD_11_NEW(YUVVideoDrawQuad, opaque_rect, visible_rect, | 915 CREATE_QUAD_11_NEW(YUVVideoDrawQuad, opaque_rect, visible_rect, |
| 917 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, | 916 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, |
| 918 uv_tex_size, y_plane_resource_id, u_plane_resource_id, | 917 uv_tex_size, y_plane_resource_id, u_plane_resource_id, |
| 919 v_plane_resource_id, a_plane_resource_id, color_space); | 918 v_plane_resource_id, a_plane_resource_id, color_space); |
| 920 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material); | 919 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material); |
| 921 EXPECT_EQ(y_plane_resource_id, quad_new->y_plane_resource_id); | 920 EXPECT_EQ(y_plane_resource_id, quad_new->y_plane_resource_id()); |
| 922 EXPECT_EQ(u_plane_resource_id, quad_new->u_plane_resource_id); | 921 EXPECT_EQ(u_plane_resource_id, quad_new->u_plane_resource_id()); |
| 923 EXPECT_EQ(v_plane_resource_id, quad_new->v_plane_resource_id); | 922 EXPECT_EQ(v_plane_resource_id, quad_new->v_plane_resource_id()); |
| 924 EXPECT_EQ(a_plane_resource_id, quad_new->a_plane_resource_id); | 923 EXPECT_EQ(a_plane_resource_id, quad_new->a_plane_resource_id()); |
| 925 EXPECT_EQ(color_space, quad_new->color_space); | 924 EXPECT_EQ(color_space, quad_new->color_space); |
| 926 EXPECT_EQ(4, IterateAndCount(quad_new)); | 925 EXPECT_EQ(4, IterateAndCount(quad_new)); |
| 927 EXPECT_EQ(y_plane_resource_id + 1, quad_new->y_plane_resource_id); | 926 EXPECT_EQ(y_plane_resource_id + 1, quad_new->y_plane_resource_id()); |
| 928 EXPECT_EQ(u_plane_resource_id + 1, quad_new->u_plane_resource_id); | 927 EXPECT_EQ(u_plane_resource_id + 1, quad_new->u_plane_resource_id()); |
| 929 EXPECT_EQ(v_plane_resource_id + 1, quad_new->v_plane_resource_id); | 928 EXPECT_EQ(v_plane_resource_id + 1, quad_new->v_plane_resource_id()); |
| 930 EXPECT_EQ(a_plane_resource_id + 1, quad_new->a_plane_resource_id); | 929 EXPECT_EQ(a_plane_resource_id + 1, quad_new->a_plane_resource_id()); |
| 931 } | 930 } |
| 932 | 931 |
| 933 // Disabled until picture draw quad is supported for ubercomp: crbug.com/231715 | 932 // Disabled until picture draw quad is supported for ubercomp: crbug.com/231715 |
| 934 TEST_F(DrawQuadIteratorTest, DISABLED_PictureDrawQuad) { | 933 TEST_F(DrawQuadIteratorTest, DISABLED_PictureDrawQuad) { |
| 935 gfx::Rect opaque_rect(33, 44, 22, 33); | 934 gfx::Rect opaque_rect(33, 44, 22, 33); |
| 936 gfx::Rect visible_rect(40, 50, 30, 20); | 935 gfx::Rect visible_rect(40, 50, 30, 20); |
| 937 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f); | 936 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f); |
| 938 gfx::Size texture_size(85, 32); | 937 gfx::Size texture_size(85, 32); |
| 939 bool nearest_neighbor = true; | 938 bool nearest_neighbor = true; |
| 940 ResourceFormat texture_format = RGBA_8888; | 939 ResourceFormat texture_format = RGBA_8888; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 LOG(ERROR) << "YUVVideoDrawQuad " << sizeof(YUVVideoDrawQuad); | 1036 LOG(ERROR) << "YUVVideoDrawQuad " << sizeof(YUVVideoDrawQuad); |
| 1038 break; | 1037 break; |
| 1039 case DrawQuad::INVALID: | 1038 case DrawQuad::INVALID: |
| 1040 break; | 1039 break; |
| 1041 } | 1040 } |
| 1042 } | 1041 } |
| 1043 } | 1042 } |
| 1044 | 1043 |
| 1045 } // namespace | 1044 } // namespace |
| 1046 } // namespace cc | 1045 } // namespace cc |
| OLD | NEW |