Commit 6bc355f1 authored by staraz's avatar staraz Committed by Commit bot

Added typemap for gpu.mojom.GpuInfo, gpu.mojom.GpuDevice and gpu.mojom.CollectInfoResult

BUG=622707
CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:linux_optional_gpu_tests_rel;tryserver.chromium.mac:mac_optional_gpu_tests_rel;tryserver.chromium.win:win_optional_gpu_tests_rel

Review-Url: https://codereview.chromium.org/2133833002
Cr-Commit-Position: refs/heads/master@{#405266}
parent eedcdfa4
...@@ -121,6 +121,7 @@ mojom("interfaces") { ...@@ -121,6 +121,7 @@ mojom("interfaces") {
sources = [ sources = [
"capabilities.mojom", "capabilities.mojom",
"command_buffer.mojom", "command_buffer.mojom",
"gpu_info.mojom",
"mailbox.mojom", "mailbox.mojom",
"mailbox_holder.mojom", "mailbox_holder.mojom",
"sync_token.mojom", "sync_token.mojom",
......
...@@ -6,5 +6,9 @@ file://ipc/SECURITY_OWNERS ...@@ -6,5 +6,9 @@ file://ipc/SECURITY_OWNERS
# The following lines are redundant, they're just to silence the presubmit # The following lines are redundant, they're just to silence the presubmit
per-file *_messages*.h=set noparent per-file *_messages*.h=set noparent
per-file *_messages*.h=file://ipc/SECURITY_OWNERS per-file *_messages*.h=file://ipc/SECURITY_OWNERS
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
per-file *_param_traits*.*=set noparent per-file *_param_traits*.*=set noparent
per-file *_param_traits*.*=file://ipc/SECURITY_OWNERS per-file *_param_traits*.*=file://ipc/SECURITY_OWNERS
per-file *_struct_traits*.*=set noparent
per-file *_struct_traits*.*=file://ipc/SECURITY_OWNERS
// Copyright 2014 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 gpu.mojom;
// gpu::GPUInfo::GPUDevice
struct GpuDevice {
uint32 vendor_id;
uint32 device_id;
bool active;
string vendor_string;
string device_string;
};
enum CollectInfoResult {
kCollectInfoNone = 0,
kCollectInfoSuccess = 1,
kCollectInfoNonFatalFailure = 2,
kCollectInfoFatalFailure = 3
};
# Copyright 2016 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 = "//gpu/ipc/common/gpu_info.mojom"
public_headers = [ "//gpu/config/gpu_info.h" ]
traits_headers = [ "//gpu/ipc/common/gpu_info_struct_traits.h" ]
sources = [
"//gpu/ipc/common/gpu_info_struct_traits.cc",
]
deps = [
"//gpu/config",
]
type_mappings = [
"gpu.mojom.GpuDevice=::gpu::GPUInfo::GPUDevice",
"gpu.mojom.CollectInfoResult=::gpu::CollectInfoResult",
]
// Copyright 2016 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 "gpu/ipc/common/gpu_info_struct_traits.h"
namespace mojo {
// static
bool StructTraits<gpu::mojom::GpuDevice, gpu::GPUInfo::GPUDevice>::Read(
gpu::mojom::GpuDeviceDataView data,
gpu::GPUInfo::GPUDevice* out) {
out->vendor_id = data.vendor_id();
out->device_id = data.device_id();
out->active = data.active();
return data.ReadVendorString(&out->vendor_string) &&
data.ReadDeviceString(&out->device_string);
}
// static
gpu::mojom::CollectInfoResult
EnumTraits<gpu::mojom::CollectInfoResult, gpu::CollectInfoResult>::ToMojom(
gpu::CollectInfoResult collect_info_result) {
switch (collect_info_result) {
case gpu::CollectInfoResult::kCollectInfoNone:
return gpu::mojom::CollectInfoResult::kCollectInfoNone;
case gpu::CollectInfoResult::kCollectInfoSuccess:
return gpu::mojom::CollectInfoResult::kCollectInfoSuccess;
case gpu::CollectInfoResult::kCollectInfoNonFatalFailure:
return gpu::mojom::CollectInfoResult::kCollectInfoNonFatalFailure;
case gpu::CollectInfoResult::kCollectInfoFatalFailure:
return gpu::mojom::CollectInfoResult::kCollectInfoFatalFailure;
}
NOTREACHED() << "Invalid CollectInfoResult value:" << collect_info_result;
return gpu::mojom::CollectInfoResult::kCollectInfoNone;
}
// static
bool EnumTraits<gpu::mojom::CollectInfoResult, gpu::CollectInfoResult>::
FromMojom(gpu::mojom::CollectInfoResult input,
gpu::CollectInfoResult* out) {
switch (input) {
case gpu::mojom::CollectInfoResult::kCollectInfoNone:
*out = gpu::CollectInfoResult::kCollectInfoNone;
return true;
case gpu::mojom::CollectInfoResult::kCollectInfoSuccess:
*out = gpu::CollectInfoResult::kCollectInfoSuccess;
return true;
case gpu::mojom::CollectInfoResult::kCollectInfoNonFatalFailure:
*out = gpu::CollectInfoResult::kCollectInfoNonFatalFailure;
return true;
case gpu::mojom::CollectInfoResult::kCollectInfoFatalFailure:
*out = gpu::CollectInfoResult::kCollectInfoFatalFailure;
return true;
}
NOTREACHED() << "Invalid CollectInfoResult value:" << input;
return false;
}
} // namespace mojo
// Copyright 2016 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 CC_IPC_GPU_STRUCT_TRAITS_H_
#define CC_IPC_GPU_STRUCT_TRAITS_H_
#include "gpu/config/gpu_info.h"
#include "gpu/ipc/common/gpu_info.mojom.h"
namespace mojo {
template <>
struct StructTraits<gpu::mojom::GpuDevice, gpu::GPUInfo::GPUDevice> {
static bool Read(gpu::mojom::GpuDeviceDataView data,
gpu::GPUInfo::GPUDevice* out);
static uint32_t vendor_id(const gpu::GPUInfo::GPUDevice& input) {
return input.vendor_id;
}
static uint32_t device_id(const gpu::GPUInfo::GPUDevice& input) {
return input.device_id;
}
static bool active(const gpu::GPUInfo::GPUDevice& input) {
return input.active;
}
static const std::string& vendor_string(
const gpu::GPUInfo::GPUDevice& input) {
return input.vendor_string;
}
static const std::string& device_string(
const gpu::GPUInfo::GPUDevice& input) {
return input.device_string;
}
};
template <>
struct EnumTraits<gpu::mojom::CollectInfoResult, gpu::CollectInfoResult> {
static gpu::mojom::CollectInfoResult ToMojom(
gpu::CollectInfoResult collect_info_result);
static bool FromMojom(gpu::mojom::CollectInfoResult input,
gpu::CollectInfoResult* out);
};
} // namespace mojo
#endif // CC_IPC_GPU_STRUCT_TRAITS_H_
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
mojom = "//gpu/ipc/common/mailbox.mojom" mojom = "//gpu/ipc/common/mailbox.mojom"
public_headers = [ "//gpu/command_buffer/common/mailbox.h" ] public_headers = [ "//gpu/command_buffer/common/mailbox.h" ]
traits_headers = [ "//gpu/ipc/common/mailbox_struct_traits.h" ] traits_headers = [ "//gpu/ipc/common/mailbox_struct_traits.h" ]
sources = [ "//gpu/ipc/common/mailbox_struct_traits.cc" ] sources = [
"//gpu/ipc/common/mailbox_struct_traits.cc",
]
deps = [ deps = [
"//mojo/public/cpp/bindings", "//mojo/public/cpp/bindings",
] ]
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include <string>
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "gpu/ipc/common/traits_test_service.mojom.h" #include "gpu/ipc/common/traits_test_service.mojom.h"
#include "mojo/public/cpp/bindings/binding_set.h" #include "mojo/public/cpp/bindings/binding_set.h"
...@@ -22,6 +24,11 @@ class StructTraitsTest : public testing::Test, public mojom::TraitsTestService { ...@@ -22,6 +24,11 @@ class StructTraitsTest : public testing::Test, public mojom::TraitsTestService {
private: private:
// TraitsTestService: // TraitsTestService:
void EchoGpuDevice(const GPUInfo::GPUDevice& g,
const EchoGpuDeviceCallback& callback) override {
callback.Run(g);
}
void EchoMailbox(const Mailbox& m, void EchoMailbox(const Mailbox& m,
const EchoMailboxCallback& callback) override { const EchoMailboxCallback& callback) override {
callback.Run(m); callback.Run(m);
...@@ -45,6 +52,30 @@ class StructTraitsTest : public testing::Test, public mojom::TraitsTestService { ...@@ -45,6 +52,30 @@ class StructTraitsTest : public testing::Test, public mojom::TraitsTestService {
} // namespace } // namespace
TEST_F(StructTraitsTest, GPUDevice) {
gpu::GPUInfo::GPUDevice input;
// Using the values from gpu/config/gpu_info_collector_unittest.cc::nvidia_gpu
const uint32_t vendor_id = 0x10de;
const uint32_t device_id = 0x0df8;
const std::string vendor_string = "vendor_string";
const std::string device_string = "device_string";
input.vendor_id = vendor_id;
input.device_id = device_id;
input.vendor_string = vendor_string;
input.device_string = device_string;
input.active = false;
mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
gpu::GPUInfo::GPUDevice output;
proxy->EchoGpuDevice(input, &output);
EXPECT_EQ(vendor_id, output.vendor_id);
EXPECT_EQ(device_id, output.device_id);
EXPECT_FALSE(output.active);
EXPECT_TRUE(vendor_string.compare(output.vendor_string) == 0);
EXPECT_TRUE(device_string.compare(output.device_string) == 0);
}
TEST_F(StructTraitsTest, Mailbox) { TEST_F(StructTraitsTest, Mailbox) {
const int8_t mailbox_name[GL_MAILBOX_SIZE_CHROMIUM] = { const int8_t mailbox_name[GL_MAILBOX_SIZE_CHROMIUM] = {
0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9,
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
module gpu.mojom; module gpu.mojom;
import "gpu/ipc/common/gpu_info.mojom";
import "gpu/ipc/common/mailbox.mojom"; import "gpu/ipc/common/mailbox.mojom";
import "gpu/ipc/common/mailbox_holder.mojom"; import "gpu/ipc/common/mailbox_holder.mojom";
import "gpu/ipc/common/sync_token.mojom"; import "gpu/ipc/common/sync_token.mojom";
...@@ -11,6 +12,10 @@ import "gpu/ipc/common/sync_token.mojom"; ...@@ -11,6 +12,10 @@ import "gpu/ipc/common/sync_token.mojom";
// All functions on this interface echo their arguments to test StructTraits // All functions on this interface echo their arguments to test StructTraits
// serialization and deserialization. // serialization and deserialization.
interface TraitsTestService { interface TraitsTestService {
[Sync]
EchoGpuDevice(GpuDevice g) => (GpuDevice pass);
[Sync] [Sync]
EchoMailbox(Mailbox m) => (Mailbox pass); EchoMailbox(Mailbox m) => (Mailbox pass);
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
typemaps = [ typemaps = [
"//gpu/ipc/common/capabilities.typemap", "//gpu/ipc/common/capabilities.typemap",
"//gpu/ipc/common/command_buffer.typemap", "//gpu/ipc/common/command_buffer.typemap",
"//gpu/ipc/common/gpu_info.typemap",
"//gpu/ipc/common/mailbox.typemap", "//gpu/ipc/common/mailbox.typemap",
"//gpu/ipc/common/mailbox_holder.typemap", "//gpu/ipc/common/mailbox_holder.typemap",
"//gpu/ipc/common/sync_token.typemap", "//gpu/ipc/common/sync_token.typemap",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment