BUILD.gn 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. # Copyright 2016 The Chromium Authors. All rights reserved.
  2. # Use of this source code is governed by a BSD-style license that can be
  3. # found in the LICENSE file.
  4. import("//device/vr/buildflags/buildflags.gni")
  5. if (is_android) {
  6. import("//build/config/android/rules.gni") # For generate_jni().
  7. }
  8. config("vr_gl_mode") {
  9. if (use_command_buffer) {
  10. defines = [
  11. "VR_USE_COMMAND_BUFFER",
  12. "GL_GLEXT_PROTOTYPES",
  13. ]
  14. } else {
  15. defines = [ "VR_USE_NATIVE_GL" ]
  16. }
  17. }
  18. source_set("vr_gl_bindings") {
  19. sources = [ "gl_bindings.h" ]
  20. public_configs = [ ":vr_gl_mode" ]
  21. if (use_command_buffer) {
  22. public_deps = [ "//gpu/command_buffer/client:gles2_c_lib" ]
  23. } else {
  24. public_deps = [ "//ui/gl" ]
  25. }
  26. }
  27. if (enable_vr) {
  28. # This target is intended to contain generic base classes or utils that are
  29. # used by ALL (or almost All) XR devices/runtimes.
  30. # TODO(https://crbug.com/1073113): Flesh out and cleanup this target, this
  31. # includes determination of which things (if any) should be in the public
  32. # target.
  33. component("vr_base") {
  34. # This list should not be expanded, ideally all references outside of this
  35. # directory would be removed; we should consider moving the classes that
  36. # the isolated_xr_device service needs to the public target, or document why
  37. # we opted to leave the exception.
  38. visibility = [
  39. # TODO(https://crbug.com/843374): Move arcore_device
  40. "//chrome/browser/*",
  41. "//content/services/isolated_xr_device/*",
  42. "//device/vr/*",
  43. ]
  44. output_name = "device_vr_base"
  45. defines = [ "IS_DEVICE_VR_BASE_IMPL" ]
  46. sources = [
  47. "vr_device.h",
  48. "vr_device_base.cc",
  49. "vr_device_base.h",
  50. "vr_gl_util.cc",
  51. "vr_gl_util.h",
  52. ]
  53. public_configs = [ ":vr_gl_mode" ]
  54. public_deps = [
  55. ":vr_gl_bindings",
  56. "//device/vr/public/cpp",
  57. "//device/vr/public/mojom:isolated_xr_service",
  58. ]
  59. deps = [
  60. "//base",
  61. "//mojo/public/cpp/bindings",
  62. ]
  63. }
  64. # Contains useful helper classes that are used by either multiple XR Devices,
  65. # or are useful to classes interacting with them (e.g. to measure performance
  66. # or to ease working with data coming in/out of mojom).
  67. component("vr_util") {
  68. output_name = "device_vr_util"
  69. defines = [ "IS_DEVICE_VR_UTIL_IMPL" ]
  70. sources = [
  71. "util/fps_meter.cc",
  72. "util/fps_meter.h",
  73. "util/gamepad_builder.cc",
  74. "util/gamepad_builder.h",
  75. "util/hit_test_subscription_data.cc",
  76. "util/hit_test_subscription_data.h",
  77. "util/sample_queue.cc",
  78. "util/sample_queue.h",
  79. "util/sliding_average.cc",
  80. "util/sliding_average.h",
  81. "util/stage_utils.cc",
  82. "util/stage_utils.h",
  83. "util/transform_utils.cc",
  84. "util/transform_utils.h",
  85. "util/xr_standard_gamepad_builder.cc",
  86. "util/xr_standard_gamepad_builder.h",
  87. ]
  88. deps = [
  89. "//base",
  90. "//device/vr/public/mojom:isolated_xr_service",
  91. "//ui/gfx",
  92. ]
  93. }
  94. if (enable_openxr) {
  95. source_set("openxr_data") {
  96. sources = [
  97. "openxr/openxr_defs.h",
  98. "openxr/openxr_interaction_profile_type.h",
  99. ]
  100. deps = [
  101. "//base",
  102. "//device/gamepad/public/cpp:shared_with_blink",
  103. "//third_party/openxr:openxr_headers",
  104. ]
  105. }
  106. }
  107. # TODO(alcooper): Ultimately, this component should be either deleted entirely
  108. # or used as a helper component aggregating all XR Runtimes that are in use.
  109. # Each XR Device should be split into its own component.
  110. component("vr") {
  111. output_name = "device_vr"
  112. defines = [ "DEVICE_VR_IMPLEMENTATION" ]
  113. sources = [ "vr_export.h" ]
  114. public_deps = [ "//device/vr/public/cpp" ]
  115. deps = [
  116. ":vr_base",
  117. ":vr_util",
  118. "//base",
  119. "//components/ukm:ukm",
  120. "//device/base",
  121. "//device/vr/buildflags",
  122. "//device/vr/public/mojom:isolated_xr_service",
  123. "//gpu/ipc/common:interfaces",
  124. "//mojo/public/cpp/bindings",
  125. "//services/device/public/cpp/generic_sensor",
  126. "//services/metrics/public/cpp:ukm_builders",
  127. "//ui/display",
  128. "//ui/gfx",
  129. "//ui/gfx/mojom",
  130. ]
  131. if (enable_gvr_services) {
  132. sources += [
  133. "android/gvr/gvr_delegate.cc",
  134. "android/gvr/gvr_delegate.h",
  135. "android/gvr/gvr_delegate_provider.h",
  136. "android/gvr/gvr_delegate_provider_factory.cc",
  137. "android/gvr/gvr_delegate_provider_factory.h",
  138. "android/gvr/gvr_device.cc",
  139. "android/gvr/gvr_device.h",
  140. "android/gvr/gvr_device_provider.cc",
  141. "android/gvr/gvr_device_provider.h",
  142. "android/gvr/gvr_utils.cc",
  143. "android/gvr/gvr_utils.h",
  144. ]
  145. deps += [
  146. ":jni_headers",
  147. "//third_party/blink/public:blink_headers",
  148. "//third_party/gvr-android-sdk:gvr_shim",
  149. ]
  150. ldflags = [ "-landroid" ]
  151. configs += [ "//third_party/gvr-android-sdk:libgvr_config" ]
  152. }
  153. if (enable_openxr) {
  154. if (is_win) {
  155. libs = [
  156. "d3d11.lib",
  157. "DXGI.lib",
  158. ]
  159. sources += [
  160. "windows/d3d11_texture_helper.cc",
  161. "windows/d3d11_texture_helper.h",
  162. "windows/flip_pixel_shader.h",
  163. "windows/geometry_shader.h",
  164. "windows/vertex_shader.h",
  165. ]
  166. deps += [ ":directx_helpers" ]
  167. }
  168. sources += [
  169. "openxr/context_provider_callbacks.h",
  170. "openxr/openxr_anchor_manager.cc",
  171. "openxr/openxr_anchor_manager.h",
  172. "openxr/openxr_anchor_request.cc",
  173. "openxr/openxr_anchor_request.h",
  174. "openxr/openxr_api_wrapper.cc",
  175. "openxr/openxr_api_wrapper.h",
  176. "openxr/openxr_controller.cc",
  177. "openxr/openxr_controller.h",
  178. "openxr/openxr_device.cc",
  179. "openxr/openxr_device.h",
  180. "openxr/openxr_extension_handle.h",
  181. "openxr/openxr_extension_helper.cc",
  182. "openxr/openxr_extension_helper.h",
  183. "openxr/openxr_input_helper.cc",
  184. "openxr/openxr_input_helper.h",
  185. "openxr/openxr_interaction_profiles.cc",
  186. "openxr/openxr_interaction_profiles.h",
  187. "openxr/openxr_path_helper.cc",
  188. "openxr/openxr_path_helper.h",
  189. "openxr/openxr_render_loop.cc",
  190. "openxr/openxr_render_loop.h",
  191. "openxr/openxr_scene.cc",
  192. "openxr/openxr_scene.h",
  193. "openxr/openxr_scene_bounds.cc",
  194. "openxr/openxr_scene_bounds.h",
  195. "openxr/openxr_scene_object.cc",
  196. "openxr/openxr_scene_object.h",
  197. "openxr/openxr_scene_observer.cc",
  198. "openxr/openxr_scene_observer.h",
  199. "openxr/openxr_scene_plane.cc",
  200. "openxr/openxr_scene_plane.h",
  201. "openxr/openxr_scene_understanding_manager.cc",
  202. "openxr/openxr_scene_understanding_manager.h",
  203. "openxr/openxr_statics.cc",
  204. "openxr/openxr_statics.h",
  205. "openxr/openxr_util.cc",
  206. "openxr/openxr_util.h",
  207. "openxr/openxr_view_configuration.cc",
  208. "openxr/openxr_view_configuration.h",
  209. "test/test_hook.h",
  210. "windows/compositor_base.cc",
  211. "windows/compositor_base.h",
  212. ]
  213. deps += [
  214. ":openxr_data",
  215. "//components/version_info",
  216. "//device/base",
  217. "//third_party/openxr",
  218. ]
  219. }
  220. }
  221. component("vr_fakes") {
  222. testonly = true
  223. defines = [ "DEVICE_VR_IMPLEMENTATION" ]
  224. sources = [
  225. "test/fake_orientation_provider.cc",
  226. "test/fake_orientation_provider.h",
  227. "test/fake_sensor_provider.cc",
  228. "test/fake_sensor_provider.h",
  229. "test/fake_vr_device.cc",
  230. "test/fake_vr_device.h",
  231. "test/fake_vr_device_provider.cc",
  232. "test/fake_vr_device_provider.h",
  233. "test/fake_vr_service_client.cc",
  234. "test/fake_vr_service_client.h",
  235. "vr_export.h",
  236. ]
  237. public_deps = [
  238. ":vr",
  239. ":vr_base",
  240. "//base",
  241. "//device/vr/orientation",
  242. "//device/vr/public/mojom:isolated_xr_service",
  243. "//mojo/public/cpp/bindings",
  244. "//services/device/public/cpp/generic_sensor",
  245. "//testing/gmock",
  246. ]
  247. }
  248. if (is_win) {
  249. static_library("directx_helpers") {
  250. sources = [
  251. "windows/d3d11_device_helpers.cc",
  252. "windows/d3d11_device_helpers.h",
  253. ]
  254. libs = [
  255. "d3d11.lib",
  256. "DXGI.lib",
  257. ]
  258. deps = [ "//base" ]
  259. }
  260. }
  261. } else {
  262. source_set("vr") {
  263. # We need to include an empty .cc file so that mac and windows don't fall over when trying to
  264. # compile this when webvr is disabled.
  265. sources = [ "empty.cc" ]
  266. }
  267. }
  268. if (enable_openxr) {
  269. # The OpenXR Loader by default looks for the path to the OpenXR Runtime from a
  270. # registry key, which typically points to the OpenXR runtime installed on the
  271. # system. In test, we want to use the mock OpenXR runtime that is created
  272. # below in :openxr_mock. If the XR_RUNTIME_JSON environment variable is set,
  273. # the OpenXR loader instead looks for the path to the OpenXR runtime in the
  274. # json file instead of the registry key. This json file copied to the output
  275. # folder points to our mock OpenXR runtime.
  276. copy("json_mock") {
  277. sources = [ "openxr/test/openxr.json" ]
  278. outputs = [ "$root_out_dir/mock_vr_clients/bin/openxr/openxr.json" ]
  279. }
  280. shared_library("openxr_mock") {
  281. testonly = true
  282. output_name = "mock_vr_clients/bin/openxr/openxrruntime"
  283. include_dirs = [ "//third_party/openxr/src/include" ]
  284. sources = [
  285. "openxr/openxr_extension_helper.cc",
  286. "openxr/openxr_extension_helper.h",
  287. "openxr/openxr_util.cc",
  288. "openxr/openxr_util.h",
  289. "openxr/openxr_view_configuration.cc",
  290. "openxr/openxr_view_configuration.h",
  291. "openxr/test/fake_openxr_impl_api.cc",
  292. "openxr/test/openxr.def",
  293. "openxr/test/openxr_negotiate.h",
  294. "openxr/test/openxr_test_helper.cc",
  295. "openxr/test/openxr_test_helper.h",
  296. "test/test_hook.h",
  297. ]
  298. libs = [
  299. "d3d11.lib",
  300. "DXGI.lib",
  301. ]
  302. deps = [
  303. "//base",
  304. "//components/version_info",
  305. "//device/vr/public/mojom:test_mojom",
  306. "//third_party/openxr:openxr_headers",
  307. ]
  308. public_deps = [ ":openxr_data" ]
  309. data_deps = [ "//device/vr:json_mock" ]
  310. }
  311. }
  312. if (enable_gvr_services) {
  313. java_sources_needing_jni =
  314. [ "android/java/src/org/chromium/device/vr/NonPresentingGvrContext.java" ]
  315. generate_jni("jni_headers") {
  316. sources = java_sources_needing_jni
  317. split_name = "vr"
  318. }
  319. android_library("java") {
  320. sources = java_sources_needing_jni
  321. deps = [
  322. "//base:base_java",
  323. "//base:jni_java",
  324. "//build/android:build_java",
  325. "//third_party/gvr-android-sdk:gvr_common_java",
  326. "//ui/android:ui_java",
  327. ]
  328. annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
  329. }
  330. }