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

Unified Diff: cc/ipc/struct_traits_unittest.cc

Issue 2174843003: cc mojo: Use ArrayDataViews in RenderPasses (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix RenderPassId Created 4 years, 5 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
« no previous file with comments | « cc/ipc/shared_quad_state_struct_traits.h ('k') | cc/ipc/traits_test_service.mojom » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/ipc/struct_traits_unittest.cc
diff --git a/cc/ipc/struct_traits_unittest.cc b/cc/ipc/struct_traits_unittest.cc
index 7f49066890113247456814e00af77f54399eca57..b0984b1a7076e442cffe3c81c250e22486c6c387 100644
--- a/cc/ipc/struct_traits_unittest.cc
+++ b/cc/ipc/struct_traits_unittest.cc
@@ -63,14 +63,9 @@ class StructTraitsTest : public testing::Test, public mojom::TraitsTestService {
callback.Run(f);
}
- void EchoQuadList(const QuadList& q,
- const EchoQuadListCallback& callback) override {
- callback.Run(q);
- }
-
- void EchoRenderPass(const std::unique_ptr<RenderPass>& r,
+ void EchoRenderPass(std::unique_ptr<RenderPass> r,
const EchoRenderPassCallback& callback) override {
- callback.Run(r);
+ callback.Run(std::move(r));
}
void EchoRenderPassId(const RenderPassId& r,
@@ -414,27 +409,31 @@ TEST_F(StructTraitsTest, FilterOperations) {
}
TEST_F(StructTraitsTest, QuadListBasic) {
- SharedQuadState sqs;
- QuadList input;
+ std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
+ render_pass->SetNew(RenderPassId(1, 1), gfx::Rect(), gfx::Rect(),
+ gfx::Transform());
+
+ SharedQuadState* sqs = render_pass->CreateAndAppendSharedQuadState();
const gfx::Rect rect1(1234, 4321, 1357, 7531);
const SkColor color1 = SK_ColorRED;
const int32_t width1 = 1337;
DebugBorderDrawQuad* debug_quad =
- input.AllocateAndConstruct<DebugBorderDrawQuad>();
- debug_quad->SetNew(&sqs, rect1, rect1, color1, width1);
+ render_pass->CreateAndAppendDrawQuad<DebugBorderDrawQuad>();
+ debug_quad->SetNew(sqs, rect1, rect1, color1, width1);
const gfx::Rect rect2(2468, 8642, 4321, 1234);
const uint32_t color2 = 0xffffffff;
const bool force_anti_aliasing_off = true;
SolidColorDrawQuad* solid_quad =
- input.AllocateAndConstruct<SolidColorDrawQuad>();
- solid_quad->SetNew(&sqs, rect2, rect2, color2, force_anti_aliasing_off);
+ render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
+ solid_quad->SetNew(sqs, rect2, rect2, color2, force_anti_aliasing_off);
const gfx::Rect rect3(1029, 3847, 5610, 2938);
const SurfaceId surface_id(1234, 5678, 2468);
- SurfaceDrawQuad* surface_quad = input.AllocateAndConstruct<SurfaceDrawQuad>();
- surface_quad->SetNew(&sqs, rect3, rect3, surface_id);
+ SurfaceDrawQuad* surface_quad =
+ render_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>();
+ surface_quad->SetNew(sqs, rect3, rect3, surface_id);
const gfx::Rect rect4(1234, 5678, 9101112, 13141516);
const ResourceId resource_id4(1337);
@@ -451,8 +450,8 @@ TEST_F(StructTraitsTest, QuadListBasic) {
background_filters.Append(FilterOperation::CreateSaturateFilter(2.f));
RenderPassDrawQuad* render_pass_quad =
- input.AllocateAndConstruct<RenderPassDrawQuad>();
- render_pass_quad->SetNew(&sqs, rect4, rect4, render_pass_id, resource_id4,
+ render_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>();
+ render_pass_quad->SetNew(sqs, rect4, rect4, render_pass_id, resource_id4,
mask_uv_scale, mask_texture_size, filters,
filters_scale, background_filters);
@@ -467,8 +466,8 @@ TEST_F(StructTraitsTest, QuadListBasic) {
const bool nearest_neighbor = true;
const bool secure_output_only = true;
TextureDrawQuad* texture_draw_quad =
- input.AllocateAndConstruct<TextureDrawQuad>();
- texture_draw_quad->SetNew(&sqs, rect5, rect5, rect5, resource_id5,
+ render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>();
+ texture_draw_quad->SetNew(sqs, rect5, rect5, rect5, resource_id5,
premultiplied_alpha, uv_top_left, uv_bottom_right,
background_color, vertex_opacity, y_flipped,
nearest_neighbor, secure_output_only);
@@ -480,25 +479,25 @@ TEST_F(StructTraitsTest, QuadListBasic) {
9.8f, 8.1f, 7.3f, 6.3f, 5.7f, 4.8f, 3.4f, 2.4f,
1.2f);
StreamVideoDrawQuad* stream_video_draw_quad =
- input.AllocateAndConstruct<StreamVideoDrawQuad>();
- stream_video_draw_quad->SetNew(&sqs, rect6, rect6, rect6, resource_id6,
+ render_pass->CreateAndAppendDrawQuad<StreamVideoDrawQuad>();
+ stream_video_draw_quad->SetNew(sqs, rect6, rect6, rect6, resource_id6,
resource_size_in_pixels, matrix);
mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
- QuadList output;
- proxy->EchoQuadList(input, &output);
+ std::unique_ptr<RenderPass> output;
+ proxy->EchoRenderPass(render_pass->DeepCopy(), &output);
- ASSERT_EQ(input.size(), output.size());
+ ASSERT_EQ(render_pass->quad_list.size(), output->quad_list.size());
const DebugBorderDrawQuad* out_debug_border_draw_quad =
- DebugBorderDrawQuad::MaterialCast(output.ElementAt(0));
+ DebugBorderDrawQuad::MaterialCast(output->quad_list.ElementAt(0));
EXPECT_EQ(rect1, out_debug_border_draw_quad->rect);
EXPECT_EQ(rect1, out_debug_border_draw_quad->visible_rect);
EXPECT_EQ(color1, out_debug_border_draw_quad->color);
EXPECT_EQ(width1, out_debug_border_draw_quad->width);
const SolidColorDrawQuad* out_solid_color_draw_quad =
- SolidColorDrawQuad::MaterialCast(output.ElementAt(1));
+ SolidColorDrawQuad::MaterialCast(output->quad_list.ElementAt(1));
EXPECT_EQ(rect2, out_solid_color_draw_quad->rect);
EXPECT_EQ(rect2, out_solid_color_draw_quad->visible_rect);
EXPECT_EQ(color2, out_solid_color_draw_quad->color);
@@ -506,13 +505,13 @@ TEST_F(StructTraitsTest, QuadListBasic) {
out_solid_color_draw_quad->force_anti_aliasing_off);
const SurfaceDrawQuad* out_surface_draw_quad =
- SurfaceDrawQuad::MaterialCast(output.ElementAt(2));
+ SurfaceDrawQuad::MaterialCast(output->quad_list.ElementAt(2));
EXPECT_EQ(rect3, out_surface_draw_quad->rect);
EXPECT_EQ(rect3, out_surface_draw_quad->visible_rect);
EXPECT_EQ(surface_id, out_surface_draw_quad->surface_id);
const RenderPassDrawQuad* out_render_pass_draw_quad =
- RenderPassDrawQuad::MaterialCast(output.ElementAt(3));
+ RenderPassDrawQuad::MaterialCast(output->quad_list.ElementAt(3));
EXPECT_EQ(rect4, out_render_pass_draw_quad->rect);
EXPECT_EQ(rect4, out_render_pass_draw_quad->visible_rect);
EXPECT_EQ(render_pass_id, out_render_pass_draw_quad->render_pass_id);
@@ -529,7 +528,7 @@ TEST_F(StructTraitsTest, QuadListBasic) {
out_render_pass_draw_quad->background_filters.at(i));
const TextureDrawQuad* out_texture_draw_quad =
- TextureDrawQuad::MaterialCast(output.ElementAt(4));
+ TextureDrawQuad::MaterialCast(output->quad_list.ElementAt(4));
EXPECT_EQ(rect5, out_texture_draw_quad->rect);
EXPECT_EQ(rect5, out_texture_draw_quad->opaque_rect);
EXPECT_EQ(rect5, out_texture_draw_quad->visible_rect);
@@ -547,7 +546,7 @@ TEST_F(StructTraitsTest, QuadListBasic) {
EXPECT_EQ(secure_output_only, out_texture_draw_quad->secure_output_only);
const StreamVideoDrawQuad* out_stream_video_draw_quad =
- StreamVideoDrawQuad::MaterialCast(output.ElementAt(5));
+ StreamVideoDrawQuad::MaterialCast(output->quad_list.ElementAt(5));
EXPECT_EQ(rect6, out_stream_video_draw_quad->rect);
EXPECT_EQ(rect6, out_stream_video_draw_quad->opaque_rect);
EXPECT_EQ(rect6, out_stream_video_draw_quad->visible_rect);
@@ -606,7 +605,7 @@ TEST_F(StructTraitsTest, RenderPass) {
std::unique_ptr<RenderPass> output;
mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
- proxy->EchoRenderPass(input, &output);
+ proxy->EchoRenderPass(input->DeepCopy(), &output);
EXPECT_EQ(input->quad_list.size(), output->quad_list.size());
EXPECT_EQ(input->shared_quad_state_list.size(),
@@ -681,7 +680,7 @@ TEST_F(StructTraitsTest, RenderPassWithEmptySharedQuadStateList) {
// verify that the serialization code can deal with that.
std::unique_ptr<RenderPass> output;
mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
- proxy->EchoRenderPass(input, &output);
+ proxy->EchoRenderPass(input->DeepCopy(), &output);
EXPECT_EQ(input->quad_list.size(), output->quad_list.size());
EXPECT_EQ(input->shared_quad_state_list.size(),
@@ -858,6 +857,10 @@ TEST_F(StructTraitsTest, TransferableResource) {
}
TEST_F(StructTraitsTest, YUVDrawQuad) {
+ std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
+ render_pass->SetNew(RenderPassId(1, 1), gfx::Rect(), gfx::Rect(),
+ gfx::Transform());
+
const DrawQuad::Material material = DrawQuad::YUV_VIDEO_CONTENT;
const gfx::Rect rect(1234, 4321, 1357, 7531);
const gfx::Rect opaque_rect(1357, 8642, 432, 123);
@@ -875,24 +878,24 @@ TEST_F(StructTraitsTest, YUVDrawQuad) {
const float resource_offset = 1337.5f;
const float resource_multiplier = 1234.6f;
- SharedQuadState sqs;
- QuadList input;
- YUVVideoDrawQuad* quad = input.AllocateAndConstruct<YUVVideoDrawQuad>();
- quad->SetAll(&sqs, rect, opaque_rect, visible_rect, needs_blending,
+ SharedQuadState* sqs = render_pass->CreateAndAppendSharedQuadState();
+ YUVVideoDrawQuad* quad =
+ render_pass->CreateAndAppendDrawQuad<YUVVideoDrawQuad>();
+ quad->SetAll(sqs, rect, opaque_rect, visible_rect, needs_blending,
ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, uv_tex_size,
y_plane_resource_id, u_plane_resource_id, v_plane_resource_id,
a_plane_resource_id, color_space, resource_offset,
resource_multiplier);
mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
- QuadList output;
- proxy->EchoQuadList(input, &output);
+ std::unique_ptr<RenderPass> output;
+ proxy->EchoRenderPass(render_pass->DeepCopy(), &output);
- ASSERT_EQ(input.size(), output.size());
+ ASSERT_EQ(render_pass->quad_list.size(), output->quad_list.size());
- ASSERT_EQ(material, output.ElementAt(0)->material);
+ ASSERT_EQ(material, output->quad_list.ElementAt(0)->material);
const YUVVideoDrawQuad* out_quad =
- YUVVideoDrawQuad::MaterialCast(output.ElementAt(0));
+ YUVVideoDrawQuad::MaterialCast(output->quad_list.ElementAt(0));
EXPECT_EQ(rect, out_quad->rect);
EXPECT_EQ(opaque_rect, out_quad->opaque_rect);
EXPECT_EQ(visible_rect, out_quad->visible_rect);
« no previous file with comments | « cc/ipc/shared_quad_state_struct_traits.h ('k') | cc/ipc/traits_test_service.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698