Skip to content

Commit

Permalink
Struct traits used by GpuInfo
Browse files Browse the repository at this point in the history
This CL contains struct traits of the structs used by gpu::GPUInfo

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

Review-Url: https://codereview.chromium.org/2147693002
Cr-Commit-Position: refs/heads/master@{#410053}
  • Loading branch information
staraz authored and Commit bot committed Aug 5, 2016
1 parent 7731769 commit a639771
Show file tree
Hide file tree
Showing 21 changed files with 614 additions and 6 deletions.
5 changes: 5 additions & 0 deletions gpu/ipc/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,16 @@ mojom("interfaces") {
sources = [
"capabilities.mojom",
"command_buffer.mojom",
"dx_diag_node.mojom",
"gpu_info.mojom",
"mailbox.mojom",
"mailbox_holder.mojom",
"sync_token.mojom",
]

public_deps = [
"//ui/gfx/geometry/mojo",
]
}

mojom("test_interfaces") {
Expand Down
12 changes: 12 additions & 0 deletions gpu/ipc/common/dx_diag_node.mojom
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// 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/config/dx_diag_node.h
// gpu::DxDiagNode
struct DxDiagNode {
map<string, string> values;
map<string, DxDiagNode> children;
};
11 changes: 11 additions & 0 deletions gpu/ipc/common/dx_diag_node.typemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 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/dx_diag_node.mojom"
public_headers = [ "//gpu/config/dx_diag_node.h" ]
traits_headers = [ "//gpu/ipc/common/dx_diag_node_struct_traits.h" ]
sources = [
"//gpu/ipc/common/dx_diag_node_struct_traits.cc",
]
type_mappings = [ "gpu.mojom.DxDiagNode=gpu::DxDiagNode" ]
16 changes: 16 additions & 0 deletions gpu/ipc/common/dx_diag_node_struct_traits.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 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/dx_diag_node_struct_traits.h"

namespace mojo {

// static
bool StructTraits<gpu::mojom::DxDiagNode, gpu::DxDiagNode>::Read(
gpu::mojom::DxDiagNodeDataView data,
gpu::DxDiagNode* out) {
return data.ReadValues(&out->values) && data.ReadChildren(&out->children);
}

} // namespace mojo
29 changes: 29 additions & 0 deletions gpu/ipc/common/dx_diag_node_struct_traits.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// 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 GPU_IPC_COMMON_DX_DIAG_NODE_STRUCT_TRAITS_H_
#define GPU_IPC_COMMON_DX_DIAG_NODE_STRUCT_TRAITS_H_

#include "gpu/ipc/common/dx_diag_node.mojom.h"

namespace mojo {

template <>
struct StructTraits<gpu::mojom::DxDiagNode, gpu::DxDiagNode> {
static bool Read(gpu::mojom::DxDiagNodeDataView data, gpu::DxDiagNode* out);

static const std::map<std::string, std::string>& values(
const gpu::DxDiagNode& node) {
return node.values;
}

static const std::map<std::string, gpu::DxDiagNode>& children(
const gpu::DxDiagNode& node) {
return node.children;
}
};

} // namespace mojo

#endif // GPU_IPC_COMMON_DX_DIAG_NODE_STRUCT_TRAITS_H_
51 changes: 50 additions & 1 deletion gpu/ipc/common/gpu_info.mojom
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// Copyright 2014 The Chromium Authors. All rights reserved.
// 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.

// gpu/config/gpu_info.h
module gpu.mojom;

import "ui/gfx/geometry/mojo/geometry.mojom";

// gpu::GPUInfo::GPUDevice
struct GpuDevice {
uint32 vendor_id;
Expand All @@ -13,9 +16,55 @@ struct GpuDevice {
string device_string;
};

// gpu::CollectInfoResult
enum CollectInfoResult {
kCollectInfoNone = 0,
kCollectInfoSuccess = 1,
kCollectInfoNonFatalFailure = 2,
kCollectInfoFatalFailure = 3
};

// gpu::VideoCodecProfile
enum VideoCodecProfile {
VIDEO_CODEC_PROFILE_UNKNOWN = -1,
H264PROFILE_BASELINE = 0,
H264PROFILE_MAIN,
H264PROFILE_EXTENDED,
H264PROFILE_HIGH,
H264PROFILE_HIGH10PROFILE,
H264PROFILE_HIGH422PROFILE,
H264PROFILE_HIGH444PREDICTIVEPROFILE,
H264PROFILE_SCALABLEBASELINE,
H264PROFILE_SCALABLEHIGH,
H264PROFILE_STEREOHIGH,
H264PROFILE_MULTIVIEWHIGH,
VP8PROFILE_ANY,
VP9PROFILE_PROFILE0,
VP9PROFILE_PROFILE1,
VP9PROFILE_PROFILE2,
VP9PROFILE_PROFILE3,
HEVCPROFILE_MAIN,
HEVCPROFILE_MAIN10,
HEVCPROFILE_MAIN_STILL_PICTURE,
};

// gpu::VideoDecodeAcceleratorSupportedProfile
struct VideoDecodeAcceleratorSupportedProfile {
VideoCodecProfile profile;
gfx.mojom.Size max_resolution;
gfx.mojom.Size min_resolution;
bool encrypted_only;
};

// gpu::VideoDecodeAcceleratorCapabilities
struct VideoDecodeAcceleratorCapabilities {
uint32 flags;
};

// gpu::VideoEncodeAcceleratorSupportedProfile
struct VideoEncodeAcceleratorSupportedProfile {
VideoCodecProfile profile;
gfx.mojom.Size max_resolution;
uint32 max_framerate_numerator;
uint32 max_framerate_denominator;
};
9 changes: 7 additions & 2 deletions gpu/ipc/common/gpu_info.typemap
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ sources = [
]
deps = [
"//gpu/config",
"//ui/gfx/geometry/mojo",
]
type_mappings = [
"gpu.mojom.GpuDevice=::gpu::GPUInfo::GPUDevice",
"gpu.mojom.CollectInfoResult=::gpu::CollectInfoResult",
"gpu.mojom.GpuDevice=gpu::GPUInfo::GPUDevice",
"gpu.mojom.CollectInfoResult=gpu::CollectInfoResult",
"gpu.mojom.VideoCodecProfile=gpu::VideoCodecProfile",
"gpu.mojom.VideoDecodeAcceleratorSupportedProfile=gpu::VideoDecodeAcceleratorSupportedProfile",
"gpu.mojom.VideoDecodeAcceleratorCapabilities=gpu::VideoDecodeAcceleratorCapabilities",
"gpu.mojom.VideoEncodeAcceleratorSupportedProfile=gpu::VideoEncodeAcceleratorSupportedProfile",
]
152 changes: 152 additions & 0 deletions gpu/ipc/common/gpu_info_struct_traits.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,156 @@ bool EnumTraits<gpu::mojom::CollectInfoResult, gpu::CollectInfoResult>::
return false;
}

// static
gpu::mojom::VideoCodecProfile
EnumTraits<gpu::mojom::VideoCodecProfile, gpu::VideoCodecProfile>::ToMojom(
gpu::VideoCodecProfile video_codec_profile) {
switch (video_codec_profile) {
case gpu::VideoCodecProfile::VIDEO_CODEC_PROFILE_UNKNOWN:
return gpu::mojom::VideoCodecProfile::VIDEO_CODEC_PROFILE_UNKNOWN;
case gpu::VideoCodecProfile::H264PROFILE_BASELINE:
return gpu::mojom::VideoCodecProfile::H264PROFILE_BASELINE;
case gpu::VideoCodecProfile::H264PROFILE_MAIN:
return gpu::mojom::VideoCodecProfile::H264PROFILE_MAIN;
case gpu::VideoCodecProfile::H264PROFILE_EXTENDED:
return gpu::mojom::VideoCodecProfile::H264PROFILE_EXTENDED;
case gpu::VideoCodecProfile::H264PROFILE_HIGH:
return gpu::mojom::VideoCodecProfile::H264PROFILE_HIGH;
case gpu::VideoCodecProfile::H264PROFILE_HIGH10PROFILE:
return gpu::mojom::VideoCodecProfile::H264PROFILE_HIGH10PROFILE;
case gpu::VideoCodecProfile::H264PROFILE_HIGH422PROFILE:
return gpu::mojom::VideoCodecProfile::H264PROFILE_HIGH422PROFILE;
case gpu::VideoCodecProfile::H264PROFILE_HIGH444PREDICTIVEPROFILE:
return gpu::mojom::VideoCodecProfile::
H264PROFILE_HIGH444PREDICTIVEPROFILE;
case gpu::VideoCodecProfile::H264PROFILE_SCALABLEBASELINE:
return gpu::mojom::VideoCodecProfile::H264PROFILE_SCALABLEBASELINE;
case gpu::VideoCodecProfile::H264PROFILE_SCALABLEHIGH:
return gpu::mojom::VideoCodecProfile::H264PROFILE_SCALABLEHIGH;
case gpu::VideoCodecProfile::H264PROFILE_STEREOHIGH:
return gpu::mojom::VideoCodecProfile::H264PROFILE_STEREOHIGH;
case gpu::VideoCodecProfile::H264PROFILE_MULTIVIEWHIGH:
return gpu::mojom::VideoCodecProfile::H264PROFILE_MULTIVIEWHIGH;
case gpu::VideoCodecProfile::VP8PROFILE_ANY:
return gpu::mojom::VideoCodecProfile::VP8PROFILE_ANY;
case gpu::VideoCodecProfile::VP9PROFILE_PROFILE0:
return gpu::mojom::VideoCodecProfile::VP9PROFILE_PROFILE0;
case gpu::VideoCodecProfile::VP9PROFILE_PROFILE1:
return gpu::mojom::VideoCodecProfile::VP9PROFILE_PROFILE1;
case gpu::VideoCodecProfile::VP9PROFILE_PROFILE2:
return gpu::mojom::VideoCodecProfile::VP9PROFILE_PROFILE2;
case gpu::VideoCodecProfile::VP9PROFILE_PROFILE3:
return gpu::mojom::VideoCodecProfile::VP9PROFILE_PROFILE3;
case gpu::VideoCodecProfile::HEVCPROFILE_MAIN:
return gpu::mojom::VideoCodecProfile::HEVCPROFILE_MAIN;
case gpu::VideoCodecProfile::HEVCPROFILE_MAIN10:
return gpu::mojom::VideoCodecProfile::HEVCPROFILE_MAIN10;
case gpu::VideoCodecProfile::HEVCPROFILE_MAIN_STILL_PICTURE:
return gpu::mojom::VideoCodecProfile::HEVCPROFILE_MAIN_STILL_PICTURE;
}
NOTREACHED() << "Invalid VideoCodecProfile:" << video_codec_profile;
return gpu::mojom::VideoCodecProfile::VIDEO_CODEC_PROFILE_UNKNOWN;
}

// static
bool EnumTraits<gpu::mojom::VideoCodecProfile, gpu::VideoCodecProfile>::
FromMojom(gpu::mojom::VideoCodecProfile input,
gpu::VideoCodecProfile* out) {
switch (input) {
case gpu::mojom::VideoCodecProfile::VIDEO_CODEC_PROFILE_UNKNOWN:
*out = gpu::VideoCodecProfile::VIDEO_CODEC_PROFILE_UNKNOWN;
return true;
case gpu::mojom::VideoCodecProfile::H264PROFILE_BASELINE:
*out = gpu::VideoCodecProfile::H264PROFILE_BASELINE;
return true;
case gpu::mojom::VideoCodecProfile::H264PROFILE_MAIN:
*out = gpu::VideoCodecProfile::H264PROFILE_MAIN;
return true;
case gpu::mojom::VideoCodecProfile::H264PROFILE_EXTENDED:
*out = gpu::VideoCodecProfile::H264PROFILE_EXTENDED;
return true;
case gpu::mojom::VideoCodecProfile::H264PROFILE_HIGH:
*out = gpu::VideoCodecProfile::H264PROFILE_HIGH;
return true;
case gpu::mojom::VideoCodecProfile::H264PROFILE_HIGH10PROFILE:
*out = gpu::VideoCodecProfile::H264PROFILE_HIGH10PROFILE;
return true;
case gpu::mojom::VideoCodecProfile::H264PROFILE_HIGH422PROFILE:
*out = gpu::VideoCodecProfile::H264PROFILE_HIGH422PROFILE;
return true;
case gpu::mojom::VideoCodecProfile::H264PROFILE_HIGH444PREDICTIVEPROFILE:
*out = gpu::VideoCodecProfile::H264PROFILE_HIGH444PREDICTIVEPROFILE;
return true;
case gpu::mojom::VideoCodecProfile::H264PROFILE_SCALABLEBASELINE:
*out = gpu::VideoCodecProfile::H264PROFILE_SCALABLEBASELINE;
return true;
case gpu::mojom::VideoCodecProfile::H264PROFILE_SCALABLEHIGH:
*out = gpu::VideoCodecProfile::H264PROFILE_SCALABLEHIGH;
return true;
case gpu::mojom::VideoCodecProfile::H264PROFILE_STEREOHIGH:
*out = gpu::VideoCodecProfile::H264PROFILE_STEREOHIGH;
return true;
case gpu::mojom::VideoCodecProfile::H264PROFILE_MULTIVIEWHIGH:
*out = gpu::VideoCodecProfile::H264PROFILE_MULTIVIEWHIGH;
return true;
case gpu::mojom::VideoCodecProfile::VP8PROFILE_ANY:
*out = gpu::VideoCodecProfile::VP8PROFILE_ANY;
return true;
case gpu::mojom::VideoCodecProfile::VP9PROFILE_PROFILE0:
*out = gpu::VideoCodecProfile::VP9PROFILE_PROFILE0;
return true;
case gpu::mojom::VideoCodecProfile::VP9PROFILE_PROFILE1:
*out = gpu::VideoCodecProfile::VP9PROFILE_PROFILE1;
return true;
case gpu::mojom::VideoCodecProfile::VP9PROFILE_PROFILE2:
*out = gpu::VideoCodecProfile::VP9PROFILE_PROFILE2;
return true;
case gpu::mojom::VideoCodecProfile::VP9PROFILE_PROFILE3:
*out = gpu::VideoCodecProfile::VP9PROFILE_PROFILE3;
return true;
case gpu::mojom::VideoCodecProfile::HEVCPROFILE_MAIN:
*out = gpu::VideoCodecProfile::HEVCPROFILE_MAIN;
return true;
case gpu::mojom::VideoCodecProfile::HEVCPROFILE_MAIN10:
*out = gpu::VideoCodecProfile::HEVCPROFILE_MAIN10;
return true;
case gpu::mojom::VideoCodecProfile::HEVCPROFILE_MAIN_STILL_PICTURE:
*out = gpu::VideoCodecProfile::HEVCPROFILE_MAIN_STILL_PICTURE;
return true;
}
NOTREACHED() << "Invalid VideoCodecProfile: " << input;
return false;
}

// static
bool StructTraits<gpu::mojom::VideoDecodeAcceleratorSupportedProfile,
gpu::VideoDecodeAcceleratorSupportedProfile>::
Read(gpu::mojom::VideoDecodeAcceleratorSupportedProfileDataView data,
gpu::VideoDecodeAcceleratorSupportedProfile* out) {
out->encrypted_only = data.encrypted_only();
return data.ReadProfile(&out->profile) &&
data.ReadMaxResolution(&out->max_resolution) &&
data.ReadMinResolution(&out->min_resolution);
}

// static
bool StructTraits<gpu::mojom::VideoDecodeAcceleratorCapabilities,
gpu::VideoDecodeAcceleratorCapabilities>::
Read(gpu::mojom::VideoDecodeAcceleratorCapabilitiesDataView data,
gpu::VideoDecodeAcceleratorCapabilities* out) {
out->flags = data.flags();
return true;
}

// static
bool StructTraits<gpu::mojom::VideoEncodeAcceleratorSupportedProfile,
gpu::VideoEncodeAcceleratorSupportedProfile>::
Read(gpu::mojom::VideoEncodeAcceleratorSupportedProfileDataView data,
gpu::VideoEncodeAcceleratorSupportedProfile* out) {
out->max_framerate_numerator = data.max_framerate_numerator();
out->max_framerate_denominator = data.max_framerate_denominator();
return data.ReadProfile(&out->profile) &&
data.ReadMaxResolution(&out->max_resolution);
}

} // namespace mojo
Loading

0 comments on commit a639771

Please sign in to comment.