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

import("//build/config/ui.gni")
import("//third_party/protobuf/proto_library.gni")

group("service") {
  if (is_component_build) {
    public_deps = [
      "//gpu",
    ]
  } else {
    public_deps = [
      ":service_sources",
    ]
  }
}

if (is_component_build) {
  link_target_type = "source_set"
} else {
  link_target_type = "static_library"
}
target(link_target_type, "service_sources") {
  # External code should depend on this via //gpu/command_buffer/service above
  # rather than depending on this directly or the component build will break.
  visibility = [ "//gpu/*" ]

  sources = [
    "buffer_manager.cc",
    "buffer_manager.h",
    "client_service_map.h",
    "cmd_buffer_engine.h",
    "cmd_parser.cc",
    "cmd_parser.h",
    "command_buffer_service.cc",
    "command_buffer_service.h",
    "command_executor.cc",
    "command_executor.h",
    "common_decoder.cc",
    "common_decoder.h",
    "context_group.cc",
    "context_group.h",
    "context_state.cc",
    "context_state.h",
    "context_state_autogen.h",
    "context_state_impl_autogen.h",
    "error_state.cc",
    "error_state.h",
    "feature_info.cc",
    "feature_info.h",
    "framebuffer_completeness_cache.cc",
    "framebuffer_completeness_cache.h",
    "framebuffer_manager.cc",
    "framebuffer_manager.h",
    "gl_context_virtual.cc",
    "gl_context_virtual.h",
    "gl_state_restorer_impl.cc",
    "gl_state_restorer_impl.h",
    "gl_utils.cc",
    "gl_utils.h",
    "gles2_cmd_apply_framebuffer_attachment_cmaa_intel.cc",
    "gles2_cmd_apply_framebuffer_attachment_cmaa_intel.h",
    "gles2_cmd_clear_framebuffer.cc",
    "gles2_cmd_clear_framebuffer.h",
    "gles2_cmd_copy_tex_image.cc",
    "gles2_cmd_copy_tex_image.h",
    "gles2_cmd_copy_texture_chromium.cc",
    "gles2_cmd_copy_texture_chromium.h",
    "gles2_cmd_decoder.cc",
    "gles2_cmd_decoder.h",
    "gles2_cmd_decoder_autogen.h",
    "gles2_cmd_decoder_passthrough.cc",
    "gles2_cmd_decoder_passthrough.h",
    "gles2_cmd_decoder_passthrough_doer_prototypes.h",
    "gles2_cmd_decoder_passthrough_doers.cc",
    "gles2_cmd_decoder_passthrough_handlers.cc",
    "gles2_cmd_decoder_passthrough_handlers_autogen.cc",
    "gles2_cmd_srgb_converter.cc",
    "gles2_cmd_srgb_converter.h",
    "gles2_cmd_validation.cc",
    "gles2_cmd_validation.h",
    "gles2_cmd_validation_autogen.h",
    "gles2_cmd_validation_implementation_autogen.h",
    "gpu_preferences.cc",
    "gpu_preferences.h",
    "gpu_state_tracer.cc",
    "gpu_state_tracer.h",
    "gpu_switches.cc",
    "gpu_switches.h",
    "gpu_tracer.cc",
    "gpu_tracer.h",
    "id_manager.cc",
    "id_manager.h",
    "image_factory.cc",
    "image_factory.h",
    "image_manager.cc",
    "image_manager.h",
    "indexed_buffer_binding_host.cc",
    "indexed_buffer_binding_host.h",
    "logger.cc",
    "logger.h",
    "mailbox_manager.cc",
    "mailbox_manager.h",
    "mailbox_manager_impl.cc",
    "mailbox_manager_impl.h",
    "mailbox_manager_sync.cc",
    "mailbox_manager_sync.h",
    "memory_program_cache.cc",
    "memory_program_cache.h",
    "path_manager.cc",
    "path_manager.h",
    "program_cache.cc",
    "program_cache.h",
    "program_manager.cc",
    "program_manager.h",
    "query_manager.cc",
    "query_manager.h",
    "renderbuffer_manager.cc",
    "renderbuffer_manager.h",
    "sampler_manager.cc",
    "sampler_manager.h",
    "service_utils.cc",
    "service_utils.h",
    "shader_manager.cc",
    "shader_manager.h",
    "shader_translator.cc",
    "shader_translator.h",
    "shader_translator_cache.cc",
    "shader_translator_cache.h",
    "sync_point_manager.cc",
    "sync_point_manager.h",
    "texture_definition.cc",
    "texture_definition.h",
    "texture_manager.cc",
    "texture_manager.h",
    "transfer_buffer_manager.cc",
    "transfer_buffer_manager.h",
    "transform_feedback_manager.cc",
    "transform_feedback_manager.h",
    "vertex_array_manager.cc",
    "vertex_array_manager.h",
    "vertex_attrib_manager.cc",
    "vertex_attrib_manager.h",
  ]

  configs += [
    "//build/config:precompiled_headers",
    "//gpu:gpu_implementation",
    "//third_party/khronos:khronos_headers",
  ]

  # Prefer mesa GL headers to system headers, which cause problems on Win.
  include_dirs = [ "//third_party/mesa/src/include" ]

  public_deps = [
    "//gpu/command_buffer/common:common_sources",
  ]
  deps = [
    ":disk_cache_proto",
    "//base",
    "//base/third_party/dynamic_annotations",
    "//crypto",
    "//gpu/command_buffer/client:client_sources",
    "//gpu/command_buffer/common:gles2_utils",
    "//gpu/config:config_sources",
    "//gpu/ipc/common:surface_handle_type",
    "//third_party/angle:angle_image_util",
    "//third_party/angle:commit_id",
    "//third_party/angle:translator",
    "//third_party/protobuf:protobuf_lite",
    "//third_party/re2",
    "//third_party/smhasher:cityhash",
    "//ui/gfx",
    "//ui/gfx/geometry",
    "//ui/gl",
    "//ui/gl/init",
  ]

  if (is_mac) {
    # Required by gles2_cmd_decoder.cc on Mac.
    libs = [
      "IOSurface.framework",
      "OpenGL.framework",
    ]
  }

  if (is_android && !is_debug) {
    # On Android optimize more since this component can be a bottleneck.
    configs -= [ "//build/config/compiler:default_optimization" ]
    configs += [ "//build/config/compiler:optimize_max" ]
  }
}

proto_library("disk_cache_proto") {
  sources = [
    "disk_cache_proto.proto",
  ]
}
