OLD | NEW |
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 Loading... |
33 const EchoRenderPassIdCallback& callback) override { | 33 const EchoRenderPassIdCallback& callback) override { |
34 callback.Run(r); | 34 callback.Run(r); |
35 } | 35 } |
36 | 36 |
37 void EchoReturnedResource( | 37 void EchoReturnedResource( |
38 const ReturnedResource& r, | 38 const ReturnedResource& r, |
39 const EchoReturnedResourceCallback& callback) override { | 39 const EchoReturnedResourceCallback& callback) override { |
40 callback.Run(r); | 40 callback.Run(r); |
41 } | 41 } |
42 | 42 |
| 43 void EchoSharedQuadState( |
| 44 const std::unique_ptr<SharedQuadState>& s, |
| 45 const EchoSharedQuadStateCallback& callback) override { |
| 46 callback.Run(s); |
| 47 } |
| 48 |
43 void EchoSurfaceId(const SurfaceId& s, | 49 void EchoSurfaceId(const SurfaceId& s, |
44 const EchoSurfaceIdCallback& callback) override { | 50 const EchoSurfaceIdCallback& callback) override { |
45 callback.Run(s); | 51 callback.Run(s); |
46 } | 52 } |
47 | 53 |
48 void EchoTransferableResource( | 54 void EchoTransferableResource( |
49 const TransferableResource& t, | 55 const TransferableResource& t, |
50 const EchoTransferableResourceCallback& callback) override { | 56 const EchoTransferableResourceCallback& callback) override { |
51 callback.Run(t); | 57 callback.Run(t); |
52 } | 58 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 proxy->EchoSurfaceId( | 144 proxy->EchoSurfaceId( |
139 input, [id_namespace, local_id, nonce, &loop](const SurfaceId& pass) { | 145 input, [id_namespace, local_id, nonce, &loop](const SurfaceId& pass) { |
140 EXPECT_EQ(id_namespace, pass.id_namespace()); | 146 EXPECT_EQ(id_namespace, pass.id_namespace()); |
141 EXPECT_EQ(local_id, pass.local_id()); | 147 EXPECT_EQ(local_id, pass.local_id()); |
142 EXPECT_EQ(nonce, pass.nonce()); | 148 EXPECT_EQ(nonce, pass.nonce()); |
143 loop.Quit(); | 149 loop.Quit(); |
144 }); | 150 }); |
145 loop.Run(); | 151 loop.Run(); |
146 } | 152 } |
147 | 153 |
| 154 TEST_F(StructTraitsTest, SharedQuadState) { |
| 155 const gfx::Transform quad_to_target_transform(1.f, 2.f, 3.f, 4.f, 5.f, 6.f, |
| 156 7.f, 8.f, 9.f, 10.f, 11.f, 12.f, |
| 157 13.f, 14.f, 15.f, 16.f); |
| 158 const gfx::Size layer_bounds(1234, 5678); |
| 159 const gfx::Rect visible_layer_rect(12, 34, 56, 78); |
| 160 const gfx::Rect clip_rect(123, 456, 789, 101112); |
| 161 const bool is_clipped = true; |
| 162 const float opacity = 0.9f; |
| 163 const SkXfermode::Mode blend_mode = SkXfermode::kSrcOver_Mode; |
| 164 const int sorting_context_id = 1337; |
| 165 std::unique_ptr<SharedQuadState> input_sqs(new SharedQuadState()); |
| 166 input_sqs->SetAll(quad_to_target_transform, layer_bounds, visible_layer_rect, |
| 167 clip_rect, is_clipped, opacity, blend_mode, |
| 168 sorting_context_id); |
| 169 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
| 170 std::unique_ptr<SharedQuadState> output_sqs; |
| 171 proxy->EchoSharedQuadState(input_sqs, &output_sqs); |
| 172 EXPECT_EQ(quad_to_target_transform, output_sqs->quad_to_target_transform); |
| 173 EXPECT_EQ(layer_bounds, output_sqs->quad_layer_bounds); |
| 174 EXPECT_EQ(visible_layer_rect, output_sqs->visible_quad_layer_rect); |
| 175 EXPECT_EQ(clip_rect, output_sqs->clip_rect); |
| 176 EXPECT_EQ(is_clipped, output_sqs->is_clipped); |
| 177 EXPECT_EQ(opacity, output_sqs->opacity); |
| 178 EXPECT_EQ(blend_mode, output_sqs->blend_mode); |
| 179 EXPECT_EQ(sorting_context_id, output_sqs->sorting_context_id); |
| 180 } |
| 181 |
148 TEST_F(StructTraitsTest, TransferableResource) { | 182 TEST_F(StructTraitsTest, TransferableResource) { |
149 const uint32_t id = 1337; | 183 const uint32_t id = 1337; |
150 const ResourceFormat format = ALPHA_8; | 184 const ResourceFormat format = ALPHA_8; |
151 const uint32_t filter = 1234; | 185 const uint32_t filter = 1234; |
152 const gfx::Size size(1234, 5678); | 186 const gfx::Size size(1234, 5678); |
153 const int8_t mailbox_name[GL_MAILBOX_SIZE_CHROMIUM] = { | 187 const int8_t mailbox_name[GL_MAILBOX_SIZE_CHROMIUM] = { |
154 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, | 188 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, |
155 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7, | 189 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7, |
156 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7}; | 190 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7}; |
157 const gpu::CommandBufferNamespace command_buffer_namespace = gpu::IN_PROCESS; | 191 const gpu::CommandBufferNamespace command_buffer_namespace = gpu::IN_PROCESS; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 EXPECT_EQ(read_lock_fences_enabled, pass.read_lock_fences_enabled); | 232 EXPECT_EQ(read_lock_fences_enabled, pass.read_lock_fences_enabled); |
199 EXPECT_EQ(is_software, pass.is_software); | 233 EXPECT_EQ(is_software, pass.is_software); |
200 EXPECT_EQ(gpu_memory_buffer_id, pass.gpu_memory_buffer_id.id); | 234 EXPECT_EQ(gpu_memory_buffer_id, pass.gpu_memory_buffer_id.id); |
201 EXPECT_EQ(is_overlay_candidate, pass.is_overlay_candidate); | 235 EXPECT_EQ(is_overlay_candidate, pass.is_overlay_candidate); |
202 loop.Quit(); | 236 loop.Quit(); |
203 }); | 237 }); |
204 loop.Run(); | 238 loop.Run(); |
205 } | 239 } |
206 | 240 |
207 } // namespace cc | 241 } // namespace cc |
OLD | NEW |