| 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 "cc/input/selection.h" | 6 #include "cc/input/selection.h" |
| 7 #include "cc/ipc/traits_test_service.mojom.h" | 7 #include "cc/ipc/traits_test_service.mojom.h" |
| 8 #include "cc/quads/debug_border_draw_quad.h" |
| 9 #include "cc/quads/render_pass.h" |
| 10 #include "cc/quads/render_pass_draw_quad.h" |
| 8 #include "cc/quads/render_pass_id.h" | 11 #include "cc/quads/render_pass_id.h" |
| 12 #include "cc/quads/solid_color_draw_quad.h" |
| 13 #include "cc/quads/surface_draw_quad.h" |
| 9 #include "mojo/public/cpp/bindings/binding_set.h" | 14 #include "mojo/public/cpp/bindings/binding_set.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "third_party/skia/include/core/SkString.h" | 16 #include "third_party/skia/include/core/SkString.h" |
| 12 #include "third_party/skia/include/effects/SkDropShadowImageFilter.h" | 17 #include "third_party/skia/include/effects/SkDropShadowImageFilter.h" |
| 13 | 18 |
| 14 namespace cc { | 19 namespace cc { |
| 15 | 20 |
| 16 namespace { | 21 namespace { |
| 17 | 22 |
| 18 class StructTraitsTest : public testing::Test, public mojom::TraitsTestService { | 23 class StructTraitsTest : public testing::Test, public mojom::TraitsTestService { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 42 const EchoFilterOperationCallback& callback) override { | 47 const EchoFilterOperationCallback& callback) override { |
| 43 callback.Run(f); | 48 callback.Run(f); |
| 44 } | 49 } |
| 45 | 50 |
| 46 void EchoFilterOperations( | 51 void EchoFilterOperations( |
| 47 const FilterOperations& f, | 52 const FilterOperations& f, |
| 48 const EchoFilterOperationsCallback& callback) override { | 53 const EchoFilterOperationsCallback& callback) override { |
| 49 callback.Run(f); | 54 callback.Run(f); |
| 50 } | 55 } |
| 51 | 56 |
| 57 void EchoQuadList(const QuadList& q, |
| 58 const EchoQuadListCallback& callback) override { |
| 59 callback.Run(q); |
| 60 } |
| 61 |
| 52 void EchoRenderPassId(const RenderPassId& r, | 62 void EchoRenderPassId(const RenderPassId& r, |
| 53 const EchoRenderPassIdCallback& callback) override { | 63 const EchoRenderPassIdCallback& callback) override { |
| 54 callback.Run(r); | 64 callback.Run(r); |
| 55 } | 65 } |
| 56 | 66 |
| 57 void EchoReturnedResource( | 67 void EchoReturnedResource( |
| 58 const ReturnedResource& r, | 68 const ReturnedResource& r, |
| 59 const EchoReturnedResourceCallback& callback) override { | 69 const EchoReturnedResourceCallback& callback) override { |
| 60 callback.Run(r); | 70 callback.Run(r); |
| 61 } | 71 } |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 input.Append(FilterOperation::CreateZoomFilter(2.0f, 1)); | 270 input.Append(FilterOperation::CreateZoomFilter(2.0f, 1)); |
| 261 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); | 271 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
| 262 FilterOperations output; | 272 FilterOperations output; |
| 263 proxy->EchoFilterOperations(input, &output); | 273 proxy->EchoFilterOperations(input, &output); |
| 264 EXPECT_EQ(input.size(), output.size()); | 274 EXPECT_EQ(input.size(), output.size()); |
| 265 for (size_t i = 0; i < input.size(); ++i) { | 275 for (size_t i = 0; i < input.size(); ++i) { |
| 266 EXPECT_EQ(input.at(i), output.at(i)); | 276 EXPECT_EQ(input.at(i), output.at(i)); |
| 267 } | 277 } |
| 268 } | 278 } |
| 269 | 279 |
| 280 TEST_F(StructTraitsTest, QuadListBasic) { |
| 281 const DrawQuad::Material material1 = DrawQuad::DEBUG_BORDER; |
| 282 const DrawQuad::Material material2 = DrawQuad::SOLID_COLOR; |
| 283 const DrawQuad::Material material3 = DrawQuad::SURFACE_CONTENT; |
| 284 const DrawQuad::Material material4 = DrawQuad::RENDER_PASS; |
| 285 const gfx::Rect rect1(1234, 4321, 1357, 7531); |
| 286 const gfx::Rect rect2(2468, 8642, 4321, 1234); |
| 287 const gfx::Rect rect3(1029, 3847, 5610, 2938); |
| 288 const gfx::Rect rect4(1234, 5678, 9101112, 13141516); |
| 289 const int32_t width1 = 1337; |
| 290 const uint32_t color2 = 0xffffffff; |
| 291 const SurfaceId surface_id(1234, 5678, 2468); |
| 292 const RenderPassId render_pass_id(1234, 5678); |
| 293 |
| 294 QuadList input; |
| 295 DebugBorderDrawQuad* debug_quad = |
| 296 input.AllocateAndConstruct<DebugBorderDrawQuad>(); |
| 297 debug_quad->material = material1; |
| 298 debug_quad->rect = rect1; |
| 299 debug_quad->width = width1; |
| 300 |
| 301 SolidColorDrawQuad* solid_quad = |
| 302 input.AllocateAndConstruct<SolidColorDrawQuad>(); |
| 303 solid_quad->material = material2; |
| 304 solid_quad->rect = rect2; |
| 305 solid_quad->color = color2; |
| 306 |
| 307 SurfaceDrawQuad* surface_quad = input.AllocateAndConstruct<SurfaceDrawQuad>(); |
| 308 surface_quad->material = material3; |
| 309 surface_quad->rect = rect3; |
| 310 surface_quad->surface_id = surface_id; |
| 311 |
| 312 RenderPassDrawQuad* render_pass_quad = |
| 313 input.AllocateAndConstruct<RenderPassDrawQuad>(); |
| 314 render_pass_quad->material = material4; |
| 315 render_pass_quad->rect = rect4; |
| 316 render_pass_quad->render_pass_id = render_pass_id; |
| 317 |
| 318 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
| 319 QuadList output; |
| 320 proxy->EchoQuadList(input, &output); |
| 321 |
| 322 ASSERT_EQ(input.size(), output.size()); |
| 323 |
| 324 ASSERT_EQ(material1, output.ElementAt(0)->material); |
| 325 EXPECT_EQ(rect1, output.ElementAt(0)->rect); |
| 326 EXPECT_EQ(width1, |
| 327 static_cast<DebugBorderDrawQuad*>(output.ElementAt(0))->width); |
| 328 |
| 329 ASSERT_EQ(material2, output.ElementAt(1)->material); |
| 330 EXPECT_EQ(rect2, output.ElementAt(1)->rect); |
| 331 EXPECT_EQ(color2, |
| 332 static_cast<SolidColorDrawQuad*>(output.ElementAt(1))->color); |
| 333 |
| 334 ASSERT_EQ(material3, output.ElementAt(2)->material); |
| 335 EXPECT_EQ(rect3, output.ElementAt(2)->rect); |
| 336 EXPECT_EQ(surface_id, |
| 337 static_cast<SurfaceDrawQuad*>(output.ElementAt(2))->surface_id); |
| 338 |
| 339 ASSERT_EQ(material4, output.ElementAt(3)->material); |
| 340 EXPECT_EQ(rect4, output.ElementAt(3)->rect); |
| 341 EXPECT_EQ( |
| 342 render_pass_id, |
| 343 static_cast<RenderPassDrawQuad*>(output.ElementAt(3))->render_pass_id); |
| 344 } |
| 345 |
| 270 TEST_F(StructTraitsTest, RenderPassId) { | 346 TEST_F(StructTraitsTest, RenderPassId) { |
| 271 const int layer_id = 1337; | 347 const int layer_id = 1337; |
| 272 const uint32_t index = 0xdeadbeef; | 348 const uint32_t index = 0xdeadbeef; |
| 273 RenderPassId input(layer_id, index); | 349 RenderPassId input(layer_id, index); |
| 274 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); | 350 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
| 275 RenderPassId output; | 351 RenderPassId output; |
| 276 proxy->EchoRenderPassId(input, &output); | 352 proxy->EchoRenderPassId(input, &output); |
| 277 EXPECT_EQ(layer_id, output.layer_id); | 353 EXPECT_EQ(layer_id, output.layer_id); |
| 278 EXPECT_EQ(index, output.index); | 354 EXPECT_EQ(index, output.index); |
| 279 } | 355 } |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 EXPECT_EQ(mailbox_holder.sync_token, output.mailbox_holder.sync_token); | 504 EXPECT_EQ(mailbox_holder.sync_token, output.mailbox_holder.sync_token); |
| 429 EXPECT_EQ(mailbox_holder.texture_target, | 505 EXPECT_EQ(mailbox_holder.texture_target, |
| 430 output.mailbox_holder.texture_target); | 506 output.mailbox_holder.texture_target); |
| 431 EXPECT_EQ(read_lock_fences_enabled, output.read_lock_fences_enabled); | 507 EXPECT_EQ(read_lock_fences_enabled, output.read_lock_fences_enabled); |
| 432 EXPECT_EQ(is_software, output.is_software); | 508 EXPECT_EQ(is_software, output.is_software); |
| 433 EXPECT_EQ(gpu_memory_buffer_id, output.gpu_memory_buffer_id.id); | 509 EXPECT_EQ(gpu_memory_buffer_id, output.gpu_memory_buffer_id.id); |
| 434 EXPECT_EQ(is_overlay_candidate, output.is_overlay_candidate); | 510 EXPECT_EQ(is_overlay_candidate, output.is_overlay_candidate); |
| 435 } | 511 } |
| 436 | 512 |
| 437 } // namespace cc | 513 } // namespace cc |
| OLD | NEW |