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

Side by Side Diff: mojo/converters/surfaces/tests/surface_unittest.cc

Issue 1548443002: Introducing gpu::CommandBufferId as a distinct, IdType<...>-based type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@type-safe-save-package-id-self-contained
Patch Set: Created 4 years, 10 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stdint.h> 6 #include <stdint.h>
7 7
8 #include <utility> 8 #include <utility>
9 9
10 #include "cc/quads/debug_border_draw_quad.h" 10 #include "cc/quads/debug_border_draw_quad.h"
11 #include "cc/quads/render_pass.h" 11 #include "cc/quads/render_pass.h"
12 #include "cc/quads/solid_color_draw_quad.h" 12 #include "cc/quads/solid_color_draw_quad.h"
13 #include "cc/quads/surface_draw_quad.h" 13 #include "cc/quads/surface_draw_quad.h"
14 #include "cc/quads/texture_draw_quad.h" 14 #include "cc/quads/texture_draw_quad.h"
15 #include "cc/resources/resource_provider.h" 15 #include "cc/resources/resource_provider.h"
16 #include "gpu/command_buffer/common/mailbox.h" 16 #include "gpu/command_buffer/common/mailbox.h"
17 #include "gpu/command_buffer/common/mailbox_holder.h" 17 #include "gpu/command_buffer/common/mailbox_holder.h"
18 #include "gpu/command_buffer/common/sync_token.h"
18 #include "mojo/converters/geometry/geometry_type_converters.h" 19 #include "mojo/converters/geometry/geometry_type_converters.h"
19 #include "mojo/converters/surfaces/surfaces_type_converters.h" 20 #include "mojo/converters/surfaces/surfaces_type_converters.h"
20 #include "mojo/converters/transform/transform_type_converters.h" 21 #include "mojo/converters/transform/transform_type_converters.h"
21 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
22 #include "third_party/skia/include/core/SkColor.h" 23 #include "third_party/skia/include/core/SkColor.h"
23 #include "third_party/skia/include/core/SkXfermode.h" 24 #include "third_party/skia/include/core/SkXfermode.h"
24 25
25 using mus::mojom::Color; 26 using mus::mojom::Color;
26 using mus::mojom::ColorPtr; 27 using mus::mojom::ColorPtr;
27 using mus::mojom::CompositorFrame; 28 using mus::mojom::CompositorFrame;
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 MailboxPtr mus_mailbox = Mailbox::New(); 401 MailboxPtr mus_mailbox = Mailbox::New();
401 402
402 gpu::Mailbox converted_mailbox = mus_mailbox.To<gpu::Mailbox>(); 403 gpu::Mailbox converted_mailbox = mus_mailbox.To<gpu::Mailbox>();
403 EXPECT_TRUE(converted_mailbox.IsZero()); 404 EXPECT_TRUE(converted_mailbox.IsZero());
404 } 405 }
405 406
406 TEST(SurfaceLibTest, MailboxHolder) { 407 TEST(SurfaceLibTest, MailboxHolder) {
407 gpu::Mailbox mailbox; 408 gpu::Mailbox mailbox;
408 mailbox.Generate(); 409 mailbox.Generate();
409 uint32_t texture_target = GL_TEXTURE_2D; 410 uint32_t texture_target = GL_TEXTURE_2D;
410 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, 1, 7u); 411 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0,
412 gpu::CommandBufferId::FromUnsafeValue(1), 7u);
411 sync_token.SetVerifyFlush(); 413 sync_token.SetVerifyFlush();
412 gpu::MailboxHolder holder(mailbox, sync_token, texture_target); 414 gpu::MailboxHolder holder(mailbox, sync_token, texture_target);
413 415
414 MailboxHolderPtr mus_holder = MailboxHolder::From(holder); 416 MailboxHolderPtr mus_holder = MailboxHolder::From(holder);
415 EXPECT_EQ(texture_target, mus_holder->texture_target); 417 EXPECT_EQ(texture_target, mus_holder->texture_target);
416 EXPECT_EQ(sync_token, mus_holder->sync_token.To<gpu::SyncToken>()); 418 EXPECT_EQ(sync_token, mus_holder->sync_token.To<gpu::SyncToken>());
417 419
418 gpu::MailboxHolder round_trip_holder = mus_holder.To<gpu::MailboxHolder>(); 420 gpu::MailboxHolder round_trip_holder = mus_holder.To<gpu::MailboxHolder>();
419 EXPECT_EQ(mailbox, round_trip_holder.mailbox); 421 EXPECT_EQ(mailbox, round_trip_holder.mailbox);
420 EXPECT_EQ(texture_target, round_trip_holder.texture_target); 422 EXPECT_EQ(texture_target, round_trip_holder.texture_target);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 EXPECT_EQ(mailbox_holder.mailbox, round_trip_resource.mailbox_holder.mailbox); 454 EXPECT_EQ(mailbox_holder.mailbox, round_trip_resource.mailbox_holder.mailbox);
453 EXPECT_EQ(mailbox_holder.texture_target, 455 EXPECT_EQ(mailbox_holder.texture_target,
454 round_trip_resource.mailbox_holder.texture_target); 456 round_trip_resource.mailbox_holder.texture_target);
455 EXPECT_EQ(mailbox_holder.sync_token, 457 EXPECT_EQ(mailbox_holder.sync_token,
456 round_trip_resource.mailbox_holder.sync_token); 458 round_trip_resource.mailbox_holder.sync_token);
457 EXPECT_EQ(is_software, round_trip_resource.is_software); 459 EXPECT_EQ(is_software, round_trip_resource.is_software);
458 } 460 }
459 461
460 TEST(SurfaceLibTest, ReturnedResource) { 462 TEST(SurfaceLibTest, ReturnedResource) {
461 uint32_t id = 5u; 463 uint32_t id = 5u;
462 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, 1, 24u); 464 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0,
465 gpu::CommandBufferId::FromUnsafeValue(1), 24u);
463 sync_token.SetVerifyFlush(); 466 sync_token.SetVerifyFlush();
464 int count = 2; 467 int count = 2;
465 bool lost = false; 468 bool lost = false;
466 cc::ReturnedResource resource; 469 cc::ReturnedResource resource;
467 resource.id = id; 470 resource.id = id;
468 resource.sync_token = sync_token; 471 resource.sync_token = sync_token;
469 resource.count = count; 472 resource.count = count;
470 resource.lost = lost; 473 resource.lost = lost;
471 474
472 ReturnedResourcePtr mus_resource = ReturnedResource::From(resource); 475 ReturnedResourcePtr mus_resource = ReturnedResource::From(resource);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 ASSERT_TRUE(mus_quad->debug_border_quad_state); 509 ASSERT_TRUE(mus_quad->debug_border_quad_state);
507 DebugBorderQuadStatePtr& mus_debug_border_state = 510 DebugBorderQuadStatePtr& mus_debug_border_state =
508 mus_quad->debug_border_quad_state; 511 mus_quad->debug_border_quad_state;
509 EXPECT_TRUE( 512 EXPECT_TRUE(
510 Color::From(arbitrary_color).Equals(mus_debug_border_state->color)); 513 Color::From(arbitrary_color).Equals(mus_debug_border_state->color));
511 EXPECT_EQ(width, mus_debug_border_state->width); 514 EXPECT_EQ(width, mus_debug_border_state->width);
512 } 515 }
513 516
514 } // namespace 517 } // namespace
515 } // namespace mojo 518 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698