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

Side by Side Diff: cc/ipc/cc_param_traits_unittest.cc

Issue 2449853004: Getting rid of DelegatedFrameData (Closed)
Patch Set: nit Created 4 years, 1 month 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
« no previous file with comments | « cc/ipc/cc_param_traits.cc ('k') | cc/ipc/cc_serialization_perftest.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 <stddef.h> 5 #include <stddef.h>
6 #include <string.h> 6 #include <string.h>
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "cc/ipc/cc_param_traits.h" 12 #include "cc/ipc/cc_param_traits.h"
13 #include "cc/output/compositor_frame.h" 13 #include "cc/output/compositor_frame.h"
14 #include "cc/quads/picture_draw_quad.h" 14 #include "cc/quads/picture_draw_quad.h"
15 #include "cc/quads/render_pass_draw_quad.h" 15 #include "cc/quads/render_pass_draw_quad.h"
16 #include "ipc/ipc_message.h" 16 #include "ipc/ipc_message.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "third_party/skia/include/effects/SkBlurImageFilter.h" 18 #include "third_party/skia/include/effects/SkBlurImageFilter.h"
19 19
20 #if defined(OS_POSIX) 20 #if defined(OS_POSIX)
21 #include "base/file_descriptor_posix.h" 21 #include "base/file_descriptor_posix.h"
22 #endif 22 #endif
23 23
24 using cc::DelegatedFrameData; 24 using cc::CompositorFrame;
25 using cc::DebugBorderDrawQuad; 25 using cc::DebugBorderDrawQuad;
26 using cc::DrawQuad; 26 using cc::DrawQuad;
27 using cc::FilterOperation; 27 using cc::FilterOperation;
28 using cc::FilterOperations; 28 using cc::FilterOperations;
29 using cc::PictureDrawQuad; 29 using cc::PictureDrawQuad;
30 using cc::RenderPass; 30 using cc::RenderPass;
31 using cc::RenderPassId; 31 using cc::RenderPassId;
32 using cc::RenderPassDrawQuad; 32 using cc::RenderPassDrawQuad;
33 using cc::ResourceId; 33 using cc::ResourceId;
34 using cc::ResourceProvider; 34 using cc::ResourceProvider;
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 for (size_t i = 1; i < pass_in->quad_list.size(); ++i) { 424 for (size_t i = 1; i < pass_in->quad_list.size(); ++i) {
425 bool same_shared_quad_state_cmp = 425 bool same_shared_quad_state_cmp =
426 pass_cmp->quad_list.ElementAt(i)->shared_quad_state == 426 pass_cmp->quad_list.ElementAt(i)->shared_quad_state ==
427 pass_cmp->quad_list.ElementAt(i - 1)->shared_quad_state; 427 pass_cmp->quad_list.ElementAt(i - 1)->shared_quad_state;
428 bool same_shared_quad_state_in = 428 bool same_shared_quad_state_in =
429 pass_in->quad_list.ElementAt(i)->shared_quad_state == 429 pass_in->quad_list.ElementAt(i)->shared_quad_state ==
430 pass_in->quad_list.ElementAt(i - 1)->shared_quad_state; 430 pass_in->quad_list.ElementAt(i - 1)->shared_quad_state;
431 EXPECT_EQ(same_shared_quad_state_cmp, same_shared_quad_state_in); 431 EXPECT_EQ(same_shared_quad_state_cmp, same_shared_quad_state_in);
432 } 432 }
433 433
434 DelegatedFrameData frame_in; 434 CompositorFrame frame_in;
435 frame_in.render_pass_list.push_back(std::move(child_pass_in)); 435 frame_in.render_pass_list.push_back(std::move(child_pass_in));
436 frame_in.render_pass_list.push_back(std::move(pass_in)); 436 frame_in.render_pass_list.push_back(std::move(pass_in));
437 437
438 IPC::ParamTraits<DelegatedFrameData>::Write(&msg, frame_in); 438 IPC::ParamTraits<CompositorFrame>::Write(&msg, frame_in);
439 439
440 DelegatedFrameData frame_out; 440 CompositorFrame frame_out;
441 base::PickleIterator iter(msg); 441 base::PickleIterator iter(msg);
442 EXPECT_TRUE( 442 EXPECT_TRUE(IPC::ParamTraits<CompositorFrame>::Read(&msg, &iter, &frame_out));
443 IPC::ParamTraits<DelegatedFrameData>::Read(&msg, &iter, &frame_out));
444 443
445 // Make sure the out and cmp RenderPasses match. 444 // Make sure the out and cmp RenderPasses match.
446 std::unique_ptr<RenderPass> child_pass_out = 445 std::unique_ptr<RenderPass> child_pass_out =
447 std::move(frame_out.render_pass_list[0]); 446 std::move(frame_out.render_pass_list[0]);
448 Compare(child_pass_cmp.get(), child_pass_out.get()); 447 Compare(child_pass_cmp.get(), child_pass_out.get());
449 ASSERT_EQ(0u, child_pass_out->shared_quad_state_list.size()); 448 ASSERT_EQ(0u, child_pass_out->shared_quad_state_list.size());
450 ASSERT_EQ(0u, child_pass_out->quad_list.size()); 449 ASSERT_EQ(0u, child_pass_out->quad_list.size());
451 std::unique_ptr<RenderPass> pass_out = 450 std::unique_ptr<RenderPass> pass_out =
452 std::move(frame_out.render_pass_list[1]); 451 std::move(frame_out.render_pass_list[1]);
453 Compare(pass_cmp.get(), pass_out.get()); 452 Compare(pass_cmp.get(), pass_out.get());
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 // The fifth is not used again. 516 // The fifth is not used again.
518 SharedQuadState* shared_state5_in = pass_in->CreateAndAppendSharedQuadState(); 517 SharedQuadState* shared_state5_in = pass_in->CreateAndAppendSharedQuadState();
519 shared_state5_in->SetAll(gfx::Transform(), gfx::Size(5, 5), gfx::Rect(), 518 shared_state5_in->SetAll(gfx::Transform(), gfx::Size(5, 5), gfx::Rect(),
520 gfx::Rect(), false, 1.f, SkXfermode::kSrcOver_Mode, 519 gfx::Rect(), false, 1.f, SkXfermode::kSrcOver_Mode,
521 0); 520 0);
522 521
523 // 5 SharedQuadStates go in. 522 // 5 SharedQuadStates go in.
524 ASSERT_EQ(5u, pass_in->shared_quad_state_list.size()); 523 ASSERT_EQ(5u, pass_in->shared_quad_state_list.size());
525 ASSERT_EQ(2u, pass_in->quad_list.size()); 524 ASSERT_EQ(2u, pass_in->quad_list.size());
526 525
527 DelegatedFrameData frame_in; 526 CompositorFrame frame_in;
528 frame_in.render_pass_list.push_back(std::move(pass_in)); 527 frame_in.render_pass_list.push_back(std::move(pass_in));
529 528
530 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); 529 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
531 IPC::ParamTraits<DelegatedFrameData>::Write(&msg, frame_in); 530 IPC::ParamTraits<CompositorFrame>::Write(&msg, frame_in);
532 531
533 DelegatedFrameData frame_out; 532 CompositorFrame frame_out;
534 base::PickleIterator iter(msg); 533 base::PickleIterator iter(msg);
535 EXPECT_TRUE( 534 EXPECT_TRUE(IPC::ParamTraits<CompositorFrame>::Read(&msg, &iter, &frame_out));
536 IPC::ParamTraits<DelegatedFrameData>::Read(&msg, &iter, &frame_out));
537 535
538 std::unique_ptr<RenderPass> pass_out = 536 std::unique_ptr<RenderPass> pass_out =
539 std::move(frame_out.render_pass_list[0]); 537 std::move(frame_out.render_pass_list[0]);
540 538
541 // 2 SharedQuadStates come out. The first and fourth SharedQuadStates were 539 // 2 SharedQuadStates come out. The first and fourth SharedQuadStates were
542 // used by quads, and so serialized. Others were not. 540 // used by quads, and so serialized. Others were not.
543 ASSERT_EQ(2u, pass_out->shared_quad_state_list.size()); 541 ASSERT_EQ(2u, pass_out->shared_quad_state_list.size());
544 ASSERT_EQ(2u, pass_out->quad_list.size()); 542 ASSERT_EQ(2u, pass_out->quad_list.size());
545 543
546 EXPECT_EQ(gfx::Size(1, 1).ToString(), 544 EXPECT_EQ(gfx::Size(1, 1).ToString(),
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 arbitrary_resource2.size = gfx::Size(89123, 23789); 584 arbitrary_resource2.size = gfx::Size(89123, 23789);
587 arbitrary_resource2.mailbox_holder.mailbox.SetName(arbitrary_mailbox2); 585 arbitrary_resource2.mailbox_holder.mailbox.SetName(arbitrary_mailbox2);
588 arbitrary_resource2.mailbox_holder.texture_target = GL_TEXTURE_EXTERNAL_OES; 586 arbitrary_resource2.mailbox_holder.texture_target = GL_TEXTURE_EXTERNAL_OES;
589 arbitrary_resource2.mailbox_holder.sync_token = arbitrary_token2; 587 arbitrary_resource2.mailbox_holder.sync_token = arbitrary_token2;
590 arbitrary_resource2.is_overlay_candidate = false; 588 arbitrary_resource2.is_overlay_candidate = false;
591 589
592 std::unique_ptr<RenderPass> renderpass_in = RenderPass::Create(); 590 std::unique_ptr<RenderPass> renderpass_in = RenderPass::Create();
593 renderpass_in->SetNew(RenderPassId(1, 1), gfx::Rect(), gfx::Rect(), 591 renderpass_in->SetNew(RenderPassId(1, 1), gfx::Rect(), gfx::Rect(),
594 gfx::Transform()); 592 gfx::Transform());
595 593
596 DelegatedFrameData frame_in; 594 CompositorFrame frame_in;
597 frame_in.resource_list.push_back(arbitrary_resource1); 595 frame_in.resource_list.push_back(arbitrary_resource1);
598 frame_in.resource_list.push_back(arbitrary_resource2); 596 frame_in.resource_list.push_back(arbitrary_resource2);
599 frame_in.render_pass_list.push_back(std::move(renderpass_in)); 597 frame_in.render_pass_list.push_back(std::move(renderpass_in));
600 598
601 IPC::ParamTraits<DelegatedFrameData>::Write(&msg, frame_in); 599 IPC::ParamTraits<CompositorFrame>::Write(&msg, frame_in);
602 600
603 DelegatedFrameData frame_out; 601 CompositorFrame frame_out;
604 base::PickleIterator iter(msg); 602 base::PickleIterator iter(msg);
605 EXPECT_TRUE( 603 EXPECT_TRUE(IPC::ParamTraits<CompositorFrame>::Read(&msg, &iter, &frame_out));
606 IPC::ParamTraits<DelegatedFrameData>::Read(&msg, &iter, &frame_out));
607 604
608 ASSERT_EQ(2u, frame_out.resource_list.size()); 605 ASSERT_EQ(2u, frame_out.resource_list.size());
609 Compare(arbitrary_resource1, frame_out.resource_list[0]); 606 Compare(arbitrary_resource1, frame_out.resource_list[0]);
610 Compare(arbitrary_resource2, frame_out.resource_list[1]); 607 Compare(arbitrary_resource2, frame_out.resource_list[1]);
611 } 608 }
612 609
613 } // namespace 610 } // namespace
614 } // namespace content 611 } // namespace content
OLDNEW
« no previous file with comments | « cc/ipc/cc_param_traits.cc ('k') | cc/ipc/cc_serialization_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698