forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mojom, struct_traits and typemap for AggregatedHitTestRegion.
Used in https://chromium-review.googlesource.com/c/chromium/src/+/1044887. Bug: 803548 Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel Change-Id: If6adbd59ee035b392ea87f3df286bfea569d6950 Reviewed-on: https://chromium-review.googlesource.com/1044783 Reviewed-by: kylechar <kylechar@chromium.org> Reviewed-by: Scott Violet <sky@chromium.org> Reviewed-by: Ken Buchanan <kenrb@chromium.org> Commit-Queue: Ria Jiang <riajiang@chromium.org> Cr-Commit-Position: refs/heads/master@{#556535}
- Loading branch information
Showing
13 changed files
with
191 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
include_rules = [ | ||
"+mojo/public/cpp/bindings", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright 2018 The Chromium Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
source_set("tests") { | ||
testonly = true | ||
|
||
sources = [ | ||
"struct_traits_unittest.cc", | ||
] | ||
|
||
deps = [ | ||
"//base/test:test_support", | ||
"//components/viz/common:common", | ||
"//components/viz/test:test_support", | ||
"//services/viz/public/interfaces", | ||
"//testing/gtest", | ||
"//ui/gfx:test_support", | ||
"//ui/gfx/geometry/mojo:struct_traits", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
include_rules = [ | ||
"+ui/gfx", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
per-file *_struct_traits*.*=set noparent | ||
per-file *_struct_traits*.*=file://ipc/SECURITY_OWNERS | ||
per-file *.typemap=set noparent | ||
per-file *.typemap=file://ipc/SECURITY_OWNERS |
14 changes: 14 additions & 0 deletions
14
services/viz/public/cpp/hit_test/aggregated_hit_test_region.typemap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright 2018 The Chromium Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
mojom = | ||
"//services/viz/public/interfaces/hit_test/aggregated_hit_test_region.mojom" | ||
public_headers = | ||
[ "//components/viz/common/hit_test/aggregated_hit_test_region.h" ] | ||
deps = [ | ||
"//components/viz/common", | ||
] | ||
traits_headers = [ "//services/viz/public/cpp/hit_test/aggregated_hit_test_region_struct_traits.h" ] | ||
type_mappings = | ||
[ "viz.mojom.AggregatedHitTestRegion=viz::AggregatedHitTestRegion" ] |
53 changes: 53 additions & 0 deletions
53
services/viz/public/cpp/hit_test/aggregated_hit_test_region_struct_traits.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright 2018 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef SERVICES_VIZ_PUBLIC_CPP_HIT_TEST_AGGREGATED_HIT_TEST_REGION_STRUCT_TRAITS_H_ | ||
#define SERVICES_VIZ_PUBLIC_CPP_HIT_TEST_AGGREGATED_HIT_TEST_REGION_STRUCT_TRAITS_H_ | ||
|
||
#include "services/viz/public/cpp/compositing/frame_sink_id_struct_traits.h" | ||
#include "services/viz/public/interfaces/hit_test/aggregated_hit_test_region.mojom-shared.h" | ||
#include "ui/gfx/geometry/mojo/geometry_struct_traits.h" | ||
#include "ui/gfx/mojo/transform_struct_traits.h" | ||
|
||
namespace mojo { | ||
|
||
template <> | ||
struct StructTraits<viz::mojom::AggregatedHitTestRegionDataView, | ||
viz::AggregatedHitTestRegion> { | ||
static const viz::FrameSinkId& frame_sink_id( | ||
const viz::AggregatedHitTestRegion& region) { | ||
return region.frame_sink_id; | ||
} | ||
|
||
static uint32_t flags(const viz::AggregatedHitTestRegion& region) { | ||
return region.flags; | ||
} | ||
|
||
static const gfx::Rect& rect(const viz::AggregatedHitTestRegion& region) { | ||
return region.rect; | ||
} | ||
|
||
static uint32_t child_count(const viz::AggregatedHitTestRegion& region) { | ||
return region.child_count; | ||
} | ||
|
||
static gfx::Transform transform(const viz::AggregatedHitTestRegion& region) { | ||
return region.transform(); | ||
} | ||
|
||
static bool Read(viz::mojom::AggregatedHitTestRegionDataView data, | ||
viz::AggregatedHitTestRegion* out) { | ||
if (!data.ReadFrameSinkId(&out->frame_sink_id) || | ||
!data.ReadRect(&out->rect) || !data.ReadTransform(&out->transform_)) { | ||
return false; | ||
} | ||
out->flags = data.flags(); | ||
out->child_count = data.child_count(); | ||
return true; | ||
} | ||
}; | ||
|
||
} // namespace mojo | ||
|
||
#endif // SERVICES_VIZ_PUBLIC_CPP_HIT_TEST_AGGREGATED_HIT_TEST_REGION_STRUCT_TRAITS_H_ |
48 changes: 48 additions & 0 deletions
48
services/viz/public/cpp/hit_test/struct_traits_unittest.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright 2018 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "components/viz/common/hit_test/aggregated_hit_test_region.h" | ||
#include "services/viz/public/cpp/hit_test/aggregated_hit_test_region_struct_traits.h" | ||
#include "services/viz/public/interfaces/hit_test/aggregated_hit_test_region.mojom.h" | ||
#include "services/viz/public/interfaces/hit_test/hit_test_region_list.mojom.h" | ||
#include "testing/gtest/include/gtest/gtest.h" | ||
#include "ui/gfx/geometry/mojo/geometry_struct_traits.h" | ||
#include "ui/gfx/mojo/transform_struct_traits.h" | ||
|
||
namespace viz { | ||
|
||
namespace { | ||
|
||
using StructTraitsTest = testing::Test; | ||
|
||
// Test StructTrait serialization and deserialization for copyable type. |input| | ||
// will be serialized and then deserialized into |output|. | ||
template <class MojomType, class Type> | ||
void SerializeAndDeserialize(const Type& input, Type* output) { | ||
MojomType::DeserializeFromMessage( | ||
mojo::Message(MojomType::SerializeAsMessage(&input).TakeMojoMessage()), | ||
output); | ||
} | ||
|
||
} // namespace | ||
|
||
TEST_F(StructTraitsTest, AggregatedHitTestRegion) { | ||
constexpr FrameSinkId frame_sink_id(1337, 1234); | ||
constexpr uint32_t flags = mojom::kHitTestAsk; | ||
constexpr gfx::Rect rect(1024, 768); | ||
gfx::Transform transform; | ||
transform.Scale(.5f, .7f); | ||
constexpr int32_t child_count = 5; | ||
AggregatedHitTestRegion input(frame_sink_id, flags, rect, transform, | ||
child_count); | ||
AggregatedHitTestRegion output; | ||
SerializeAndDeserialize<mojom::AggregatedHitTestRegion>(input, &output); | ||
EXPECT_EQ(input.frame_sink_id, output.frame_sink_id); | ||
EXPECT_EQ(input.flags, output.flags); | ||
EXPECT_EQ(input.rect, output.rect); | ||
EXPECT_EQ(input.transform(), output.transform()); | ||
EXPECT_EQ(input.child_count, output.child_count); | ||
} | ||
|
||
} // namespace viz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Copyright 2018 The Chromium Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
typemaps = | ||
[ "//services/viz/public/cpp/hit_test/aggregated_hit_test_region.typemap" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
services/viz/public/interfaces/hit_test/aggregated_hit_test_region.mojom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2018 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
module viz.mojom; | ||
|
||
import "services/viz/public/interfaces/compositing/frame_sink_id.mojom"; | ||
import "ui/gfx/geometry/mojo/geometry.mojom"; | ||
import "ui/gfx/mojo/transform.mojom"; | ||
|
||
// Corresponds to viz::AggregatedHitTestRegion. | ||
struct AggregatedHitTestRegion { | ||
FrameSinkId frame_sink_id; | ||
|
||
uint32 flags; | ||
|
||
gfx.mojom.Rect rect; | ||
|
||
uint32 child_count; | ||
|
||
gfx.mojom.Transform transform; | ||
}; |