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

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

Issue 2020993004: Implement TransferableResource StructTraits (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 6 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
« no previous file with comments | « cc/ipc/BUILD.gn ('k') | cc/ipc/traits_test_service.mojom » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "cc/ipc/traits_test_service.mojom.h" 7 #include "cc/ipc/traits_test_service.mojom.h"
8 #include "cc/quads/render_pass_id.h" 8 #include "cc/quads/render_pass_id.h"
9 #include "mojo/public/cpp/bindings/binding_set.h" 9 #include "mojo/public/cpp/bindings/binding_set.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 22 matching lines...) Expand all
33 const ReturnedResource& r, 33 const ReturnedResource& r,
34 const EchoReturnedResourceCallback& callback) override { 34 const EchoReturnedResourceCallback& callback) override {
35 callback.Run(r); 35 callback.Run(r);
36 } 36 }
37 37
38 void EchoSurfaceId(const SurfaceId& s, 38 void EchoSurfaceId(const SurfaceId& s,
39 const EchoSurfaceIdCallback& callback) override { 39 const EchoSurfaceIdCallback& callback) override {
40 callback.Run(s); 40 callback.Run(s);
41 } 41 }
42 42
43 void EchoTransferableResource(
44 const TransferableResource& t,
45 const EchoTransferableResourceCallback& callback) override {
46 callback.Run(t);
47 }
48
43 mojo::BindingSet<TraitsTestService> traits_test_bindings_; 49 mojo::BindingSet<TraitsTestService> traits_test_bindings_;
44 }; 50 };
45 51
46 } // namespace 52 } // namespace
47 53
48 TEST_F(StructTraitsTest, RenderPassId) { 54 TEST_F(StructTraitsTest, RenderPassId) {
49 const int layer_id = 1337; 55 const int layer_id = 1337;
50 const uint32_t index = 0xdeadbeef; 56 const uint32_t index = 0xdeadbeef;
51 RenderPassId input(layer_id, index); 57 RenderPassId input(layer_id, index);
52 base::RunLoop loop; 58 base::RunLoop loop;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 proxy->EchoSurfaceId( 106 proxy->EchoSurfaceId(
101 input, [id_namespace, local_id, nonce, &loop](const SurfaceId& pass) { 107 input, [id_namespace, local_id, nonce, &loop](const SurfaceId& pass) {
102 EXPECT_EQ(id_namespace, pass.id_namespace()); 108 EXPECT_EQ(id_namespace, pass.id_namespace());
103 EXPECT_EQ(local_id, pass.local_id()); 109 EXPECT_EQ(local_id, pass.local_id());
104 EXPECT_EQ(nonce, pass.nonce()); 110 EXPECT_EQ(nonce, pass.nonce());
105 loop.Quit(); 111 loop.Quit();
106 }); 112 });
107 loop.Run(); 113 loop.Run();
108 } 114 }
109 115
116 TEST_F(StructTraitsTest, TransferableResource) {
117 const uint32_t id = 1337;
118 const ResourceFormat format = ALPHA_8;
119 const uint32_t filter = 1234;
120 const gfx::Size size(1234, 5678);
121 const int8_t mailbox_name[GL_MAILBOX_SIZE_CHROMIUM] = {
122 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9,
123 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7,
124 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7};
125 const gpu::CommandBufferNamespace command_buffer_namespace = gpu::IN_PROCESS;
126 const int32_t extra_data_field = 0xbeefbeef;
127 const gpu::CommandBufferId command_buffer_id(
128 gpu::CommandBufferId::FromUnsafeValue(0xdeadbeef));
129 const uint64_t release_count = 0xdeadbeefdeadL;
130 const uint32_t texture_target = 1337;
131 const bool read_lock_fences_enabled = true;
132 const bool is_software = false;
133 const int gpu_memory_buffer_id = 0xdeadbeef;
134 const bool is_overlay_candidate = true;
135
136 gpu::MailboxHolder mailbox_holder;
137 mailbox_holder.mailbox.SetName(mailbox_name);
138 mailbox_holder.sync_token =
139 gpu::SyncToken(command_buffer_namespace, extra_data_field,
140 command_buffer_id, release_count);
141 mailbox_holder.texture_target = texture_target;
142 TransferableResource input;
143 input.id = id;
144 input.format = format;
145 input.filter = filter;
146 input.size = size;
147 input.mailbox_holder = mailbox_holder;
148 input.read_lock_fences_enabled = read_lock_fences_enabled;
149 input.is_software = is_software;
150 input.gpu_memory_buffer_id.id = gpu_memory_buffer_id;
151 input.is_overlay_candidate = is_overlay_candidate;
152 base::RunLoop loop;
153 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
154 proxy->EchoTransferableResource(
155 input, [id, format, filter, size, mailbox_holder,
156 read_lock_fences_enabled, is_software, gpu_memory_buffer_id,
157 is_overlay_candidate, &loop](const TransferableResource& pass) {
158 EXPECT_EQ(id, pass.id);
159 EXPECT_EQ(format, pass.format);
160 EXPECT_EQ(filter, pass.filter);
161 EXPECT_EQ(size, pass.size);
162 EXPECT_EQ(mailbox_holder.mailbox, pass.mailbox_holder.mailbox);
163 EXPECT_EQ(mailbox_holder.sync_token, pass.mailbox_holder.sync_token);
164 EXPECT_EQ(mailbox_holder.texture_target,
165 pass.mailbox_holder.texture_target);
166 EXPECT_EQ(read_lock_fences_enabled, pass.read_lock_fences_enabled);
167 EXPECT_EQ(is_software, pass.is_software);
168 EXPECT_EQ(gpu_memory_buffer_id, pass.gpu_memory_buffer_id.id);
169 EXPECT_EQ(is_overlay_candidate, pass.is_overlay_candidate);
170 loop.Quit();
171 });
172 loop.Run();
173 }
174
110 } // namespace cc 175 } // namespace cc
OLDNEW
« no previous file with comments | « cc/ipc/BUILD.gn ('k') | cc/ipc/traits_test_service.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698