# 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. 

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",
    "display_color_spaces.mojom",
    "font_render_params.mojom",
    "gpu_fence_handle.mojom",
    "overlay_transform.mojom",
    "presentation_feedback.mojom",
    "rrect_f.mojom",
    "selection_bound.mojom",
    "swap_result.mojom",
    "swap_timings.mojom",
    "transform.mojom",
  ]

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

  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. 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 = [ ":color_space_mojom_support" ]
    },
    {
      types = [
        {
          mojom = "gfx.mojom. GpuFenceHandle"
          cpp = "::gfx::GpuFenceHandle"
        },
      ]
      traits_headers = [ "gpu_fence_handle_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. 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. 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" ]
    },
    {
      types = [
        {
          mojom = "gfx.mojom. DisplayColorSpaces"
          cpp = "::gfx::DisplayColorSpaces"
        },
      ]
      traits_sources = [ "display_color_spaces_mojom_traits.cc" ]
      traits_headers = [ "display_color_spaces_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. RRectF"
          cpp = "::gfx::RRectF"
        },
      ]
      traits_headers = [ "rrect_f_mojom_traits.h" ]
      traits_public_deps = [ "//ui/gfx/geometry/mojom:mojom_traits" ]
    },
    {
      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. SwapResult"
          cpp = "::gfx::SwapResult"
        },
      ]
      traits_headers = [ "swap_result_mojom_traits.h" ]
      traits_public_deps = [ "//ui/gfx" ]
    },
  ]

  cpp_typemaps += shared_cpp_typemaps
  blink_cpp_typemaps = shared_cpp_typemaps
}

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

  shared_cpp_typemap = {
    types = [
      {
        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 ]
}

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

  public_deps = [ ":mojom" ]
}

component("color_space_mojom_support") {
  sources = [
    "color_space_mojom_traits.cc",
    "color_space_mojom_traits.h",
  ]
  public_deps = [
    ":mojom_shared_cpp_sources",
    "//ui/gfx",
  ]
  defines = [ "IS_UI_GFX_MOJOM_TRAITS_IMPL" ]
}

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",
  ]
}

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",
    "gpu_fence_handle_mojom_traits.cc",
    "gpu_fence_handle_mojom_traits.h",
  ]
  public_deps = [
    ":mojom_shared",
    ":native_handle_types",
    "//ui/gfx",
  ]
}
