chromium/ui/gfx/mojom/BUILD.gn

# Copyright 2016 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/features.gni")
import("//build/config/ozone.gni")
import("//mojo/public/tools/bindings/mojom.gni")

mojom("mojom") {
  generate_java = true
  sources = [
    "accelerated_widget.mojom",
    "buffer_types.mojom",
    "ca_layer_params.mojom",
    "color_space.mojom",
    "delegated_ink_metadata.mojom",
    "delegated_ink_point.mojom",
    "delegated_ink_point_renderer.mojom",
    "display_color_spaces.mojom",
    "font_render_params.mojom",
    "frame_data.mojom",
    "gpu_extra_info.mojom",
    "gpu_fence_handle.mojom",
    "hdr_static_metadata.mojom",
    "linear_gradient.mojom",
    "mask_filter_info.mojom",
    "overlay_priority_hint.mojom",
    "overlay_transform.mojom",
    "overlay_type.mojom",
    "presentation_feedback.mojom",
    "rrect_f.mojom",
    "selection_bound.mojom",
    "swap_result.mojom",
    "swap_timings.mojom",
    "transform.mojom",
  ]

  if (is_apple) {
    sources += [ "ca_layer_result.mojom" ]
  }

  public_deps = [
    ":hdr_metadata",
    ":native_handle_types",
    "//mojo/public/mojom/base",
    "//skia/public/mojom",
    "//ui/gfx/geometry/mojom",
  ]

  enabled_features = []
  if (ozone_platform_x11) {
    enabled_features += [ "enable_x11_params" ]
  }

  shared_cpp_typemaps = [
    {
      types = [
        {
          mojom = "gfx.mojom.BufferFormat"
          cpp = "::gfx::BufferFormat"
        },
        {
          mojom = "gfx.mojom.BufferUsage"
          cpp = "::gfx::BufferUsage"
        },
        {
          mojom = "gfx.mojom.BufferUsageAndFormat"
          cpp = "::gfx::BufferUsageAndFormat"
        },
        {
          mojom = "gfx.mojom.BufferPlane"
          cpp = "::gfx::BufferPlane"
        },
        {
          mojom = "gfx.mojom.GpuMemoryBufferHandle"
          cpp = "::gfx::GpuMemoryBufferHandle"
          move_only = true
          nullable_is_same_type = true
        },
        {
          mojom = "gfx.mojom.GpuMemoryBufferId"
          cpp = "::gfx::GpuMemoryBufferId"
          copyable_pass_by_value = true
        },
        {
          mojom = "gfx.mojom.GpuMemoryBufferType"
          cpp = "::gfx::GpuMemoryBufferType"
        },
      ]

      traits_headers = [ "buffer_types_mojom_traits.h" ]
      traits_public_deps = [ ":shared_mojom_traits" ]
    },
    {
      types = [
        {
          mojom = "gfx.mojom.ColorSpace"
          cpp = "::gfx::ColorSpace"
        },
      ]
      traits_headers = [ "color_space_mojom_traits.h" ]
      traits_public_deps = [ ":shared_mojom_traits" ]
    },
    {
      types = [
        {
          mojom = "gfx.mojom.ContentColorUsage"
          cpp = "::gfx::ContentColorUsage"
        },
        {
          mojom = "gfx.mojom.DisplayColorSpaces"
          cpp = "::gfx::DisplayColorSpaces"
        },
      ]
      traits_headers = [ "display_color_spaces_mojom_traits.h" ]
      traits_public_deps = [ ":shared_mojom_traits" ]
    },
    {
      types = [
        {
          mojom = "gfx.mojom.GpuExtraInfo"
          cpp = "::gfx::GpuExtraInfo"
        },
        {
          mojom = "gfx.mojom.ANGLEFeature"
          cpp = "::gfx::ANGLEFeature"
        },
      ]
      traits_headers = [ "gpu_extra_info_mojom_traits.h" ]
      traits_public_deps = [ ":shared_mojom_traits" ]
    },
    {
      types = [
        {
          mojom = "gfx.mojom.GpuFenceHandle"
          cpp = "::gfx::GpuFenceHandle"
          move_only = true
          nullable_is_same_type = true
        },
      ]
      traits_headers = [ "gpu_fence_handle_mojom_traits.h" ]
      traits_public_deps = [ ":shared_mojom_traits" ]
    },
    {
      types = [
        {
          mojom = "gfx.mojom.HDRStaticMetadata"
          cpp = "::gfx::HDRStaticMetadata"
        },
      ]
      traits_headers = [ "hdr_static_metadata_mojom_traits.h" ]
      traits_public_deps = [ ":shared_mojom_traits" ]
    },
    {
      types = [
        {
          mojom = "gfx.mojom.PresentationFeedback"
          cpp = "::gfx::PresentationFeedback"
        },
      ]
      traits_headers = [ "presentation_feedback_mojom_traits.h" ]
      traits_public_deps = [ "//ui/gfx" ]
    },
    {
      types = [
        {
          mojom = "gfx.mojom.SelectionBound"
          cpp = "::gfx::SelectionBound"
        },
      ]
      traits_headers = [ "selection_bound_mojom_traits.h" ]
      traits_public_deps = [ "//ui/gfx/geometry/mojom:mojom_traits" ]
    },
    {
      types = [
        {
          mojom = "gfx.mojom.SwapTimings"
          cpp = "::gfx::SwapTimings"
        },
      ]
      traits_headers = [ "swap_timings_mojom_traits.h" ]
      traits_public_deps = [ "//ui/gfx" ]
    },
    {
      types = [
        {
          mojom = "gfx.mojom.Transform"
          cpp = "::gfx::Transform"
        },
      ]
      traits_headers = [ "transform_mojom_traits.h" ]
      traits_public_deps = [ "//ui/gfx" ]
    },
  ]

  cpp_typemaps = [
    {
      types = [
        {
          mojom = "gfx.mojom.AcceleratedWidget"
          cpp = "::gfx::AcceleratedWidget"
          copyable_pass_by_value = true
        },
      ]
      traits_headers = [ "accelerated_widget_mojom_traits.h" ]
      traits_public_deps = [ "//ui/gfx" ]
    },
    {
      types = [
        {
          mojom = "gfx.mojom.CALayerResult"
          cpp = "::gfx::CALayerResult"
        },
      ]
      traits_sources = [ "ca_layer_result_mojom_traits.cc" ]
      traits_headers = [ "ca_layer_result_mojom_traits.h" ]
      traits_public_deps = [ "//ui/gfx" ]
    },
    {
      types = [
        {
          mojom = "gfx.mojom.DelegatedInkMetadata"
          cpp = "::std::unique_ptr<::gfx::DelegatedInkMetadata>"
          move_only = true
          nullable_is_same_type = true
        },
      ]
      traits_sources = [ "delegated_ink_metadata_mojom_traits.cc" ]
      traits_headers = [ "delegated_ink_metadata_mojom_traits.h" ]
      traits_public_deps = [ "//ui/gfx" ]
    },
    {
      types = [
        {
          mojom = "gfx.mojom.DelegatedInkPoint"
          cpp = "::gfx::DelegatedInkPoint"
        },
      ]
      traits_sources = [ "delegated_ink_point_mojom_traits.cc" ]
      traits_headers = [ "delegated_ink_point_mojom_traits.h" ]
      traits_public_deps = [ "//ui/gfx" ]
    },
    {
      types = [
        {
          mojom = "gfx.mojom.Hinting"
          cpp = "::gfx::FontRenderParams::Hinting"
        },
        {
          mojom = "gfx.mojom.SubpixelRendering"
          cpp = "::gfx::FontRenderParams::SubpixelRendering"
        },
      ]
      traits_headers = [ "font_render_params_mojom_traits.h" ]
      traits_public_deps = [ "//ui/gfx" ]
    },
    {
      types = [
        {
          mojom = "gfx.mojom.OverlayTransform"
          cpp = "::gfx::OverlayTransform"
        },
      ]
      traits_headers = [ "overlay_transform_mojom_traits.h" ]
      traits_public_deps = [ "//ui/gfx" ]
    },
    {
      types = [
        {
          mojom = "gfx.mojom.OverlayPriorityHint"
          cpp = "::gfx::OverlayPriorityHint"
        },
      ]
      traits_headers = [ "overlay_priority_hint_mojom_traits.h" ]
      traits_public_deps = [ "//ui/gfx" ]
    },
    {
      types = [
        {
          mojom = "gfx.mojom.RRectF"
          cpp = "::gfx::RRectF"
        },
      ]
      traits_headers = [ "rrect_f_mojom_traits.h" ]
      traits_public_deps = [ "//ui/gfx/geometry/mojom:mojom_traits" ]
    },
    {
      types = [
        {
          mojom = "gfx.mojom.SwapResult"
          cpp = "::gfx::SwapResult"
        },
      ]
      traits_headers = [ "swap_result_mojom_traits.h" ]
      traits_public_deps = [ "//ui/gfx" ]
    },
    {
      types = [
        {
          mojom = "gfx.mojom.MaskFilterInfo"
          cpp = "::gfx::MaskFilterInfo"
        },
      ]
      traits_sources = [ "mask_filter_info_mojom_traits.cc" ]
      traits_headers = [ "mask_filter_info_mojom_traits.h" ]
      traits_public_deps = [ "//ui/gfx/geometry:geometry_skia" ]
    },
    {
      types = [
        {
          mojom = "gfx.mojom.LinearGradient"
          cpp = "::gfx::LinearGradient"
        },
      ]
      traits_sources = [ "linear_gradient_mojom_traits.cc" ]
      traits_headers = [ "linear_gradient_mojom_traits.h" ]
      traits_public_deps = [ "//ui/gfx/geometry:geometry_skia" ]
    },
    {
      types = [
        {
          mojom = "gfx.mojom.FrameData"
          cpp = "::gfx::FrameData"
        },
      ]
      traits_headers = [ "frame_data_mojom_traits.h" ]
      traits_public_deps = [ "//ui/gfx" ]
    },
    {
      types = [
        {
          mojom = "gfx.mojom.OverlayType"
          cpp = "::gfx::OverlayType"
        },
      ]
      traits_headers = [ "overlay_type_mojom_traits.h" ]
      traits_public_deps = [ "//ui/gfx" ]
    },
  ]

  if (use_blink) {
    cpp_typemaps += [
      {
        types = [
          {
            mojom = "gfx.mojom.CALayerParams"
            cpp = "::gfx::CALayerParams"
          },
        ]
        traits_sources = [ "ca_layer_params_mojom_traits.cc" ]
        traits_headers = [ "ca_layer_params_mojom_traits.h" ]
        traits_public_deps = [ "//ui/gfx" ]
      },
    ]
  }

  cpp_typemaps += shared_cpp_typemaps
  blink_cpp_typemaps = shared_cpp_typemaps
  blink_cpp_typemaps += [
    {
      types = [
        {
          mojom = "gfx.mojom.DelegatedInkMetadata"
          cpp = "::std::unique_ptr<::gfx::DelegatedInkMetadata>"
          move_only = true
          nullable_is_same_type = true
        },
      ]
      traits_headers = [ "delegated_ink_metadata_mojom_traits.h" ]
      traits_public_deps = [ "//ui/gfx" ]
    },
  ]
}

mojom("native_handle_types") {
  sources = [ "native_handle_types.mojom" ]
  if (is_linux || is_chromeos || use_ozone) {
    enabled_features = [ "supports_native_pixmap" ]
  }
  if (is_linux || is_chromeos) {
    enabled_features += [ "is_linux_or_chromeos" ]
  }
  public_deps = [ "//mojo/public/mojom/base" ]
  generate_java = true

  shared_cpp_typemap = {
    types = [
      {
        mojom = "gfx.mojom.DXGIHandleToken"
        cpp = "::gfx::DXGIHandleToken"
      },
      {
        mojom = "gfx.mojom.NativePixmapHandle"
        cpp = "::gfx::NativePixmapHandle"
        move_only = true
      },
      {
        mojom = "gfx.mojom.NativePixmapPlane"
        cpp = "::gfx::NativePixmapPlane"
        move_only = true
      },
    ]
    traits_headers = [ "native_handle_types_mojom_traits.h" ]
    traits_public_deps = [ ":native_handle_types_mojom_traits" ]
  }
  cpp_typemaps = [ shared_cpp_typemap ]
  blink_cpp_typemaps = [ shared_cpp_typemap ]
}

if (is_win) {
  mojom("dxgi_info") {
    sources = [ "dxgi_info.mojom" ]
    public_deps = [
      "//mojo/public/mojom/base",
      "//skia/public/mojom",
    ]
  }
}

mojom("test_interfaces") {
  sources = [ "traits_test_service.mojom" ]

  public_deps = [ ":mojom" ]
}

component("native_handle_types_mojom_traits") {
  output_name = "gfx_native_types_shared_mojom_traits"
  defines = [ "IS_GFX_NATIVE_HANDLE_TYPES_SHARED_MOJOM_TRAITS_IMPL" ]
  sources = [
    "native_handle_types_mojom_traits.cc",
    "native_handle_types_mojom_traits.h",
  ]

  public_deps = [
    ":native_handle_types_shared",
    "//base",
    "//mojo/public/mojom/base",
    "//ui/gfx",
  ]
}

mojom("hdr_metadata") {
  generate_java = true

  sources = [ "hdr_metadata.mojom" ]

  public_deps = [
    "//mojo/public/mojom/base",
    "//skia/public/mojom",
  ]

  cpp_typemaps = [
    {
      types = [
        {
          mojom = "gfx.mojom.HdrMetadataCta861_3"
          cpp = "::gfx::HdrMetadataCta861_3"
        },
        {
          mojom = "gfx.mojom.HdrMetadataSmpteSt2086"
          cpp = "::gfx::HdrMetadataSmpteSt2086"
        },
        {
          mojom = "gfx.mojom.HdrMetadataNdwl"
          cpp = "::gfx::HdrMetadataNdwl"
        },
        {
          mojom = "gfx.mojom.HdrMetadataExtendedRange"
          cpp = "::gfx::HdrMetadataExtendedRange"
        },
        {
          mojom = "gfx.mojom.HDRMetadata"
          cpp = "::gfx::HDRMetadata"
        },
      ]
      traits_headers = [ "hdr_metadata_mojom_traits.h" ]
      traits_sources = [ "hdr_metadata_mojom_traits.cc" ]
    },
  ]
}

component("shared_mojom_traits") {
  output_name = "gfx_shared_mojom_traits"
  defines = [ "IS_GFX_SHARED_MOJOM_TRAITS_IMPL" ]
  sources = [
    "buffer_types_mojom_traits.cc",
    "buffer_types_mojom_traits.h",
    "color_space_mojom_traits.cc",
    "color_space_mojom_traits.h",
    "display_color_spaces_mojom_traits.cc",
    "display_color_spaces_mojom_traits.h",
    "gpu_extra_info_mojom_traits.cc",
    "gpu_extra_info_mojom_traits.h",
    "gpu_fence_handle_mojom_traits.cc",
    "gpu_fence_handle_mojom_traits.h",
    "hdr_static_metadata_mojom_traits.cc",
    "hdr_static_metadata_mojom_traits.h",
  ]
  public_deps = [
    ":mojom_shared",
    ":native_handle_types",
    "//ui/gfx",
  ]
  deps = [
    "//skia/public/mojom",
    "//ui/base:ozone_buildflags",
  ]
  frameworks = [
    "CoreFoundation.framework",
    "IOSurface.framework",
  ]
}