• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2014 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
5import("//build/config/ui.gni")
6if (is_android) {
7  import("//build/config/android/config.gni")
8  import("//build/config/android/rules.gni")
9}
10
11gl_binding_output_dir = target_gen_dir
12
13config("gl_config") {
14  if (use_x11) {
15    defines = [ "GL_GLEXT_PROTOTYPES" ]
16  }
17
18  # TODO(brettw) this should be removed and the the files using the generated
19  # GL bindings should use the path inside the gen directory.
20  include_dirs = [ gl_binding_output_dir ]
21}
22
23component("gl") {
24  output_name = "gl_wrapper"  # Avoid colliding with OS X"s libGL.dylib.
25
26  sources = [
27    "android/gl_jni_registrar.cc",
28    "android/gl_jni_registrar.h",
29    "android/scoped_java_surface.cc",
30    "android/scoped_java_surface.h",
31    "android/surface_texture.cc",
32    "android/surface_texture.h",
33    "android/surface_texture_listener.cc",
34    "android/surface_texture_listener.h",
35    "android/surface_texture_tracker.cc",
36    "android/surface_texture_tracker.h",
37    "gl_bindings.h",
38    "gl_bindings_skia_in_process.cc",
39    "gl_bindings_skia_in_process.h",
40    "gl_context.cc",
41    "gl_context.h",
42    "gl_context_android.cc",
43    "gl_context_mac.mm",
44    "gl_context_osmesa.cc",
45    "gl_context_osmesa.h",
46    "gl_context_stub.cc",
47    "gl_context_stub.h",
48    "gl_context_stub_with_extensions.cc",
49    "gl_context_stub_with_extensions.h",
50    "gl_context_win.cc",
51    "gl_export.h",
52    "gl_fence.cc",
53    "gl_fence.h",
54    "gl_fence_arb.cc",
55    "gl_fence_arb.h",
56    "gl_fence_nv.cc",
57    "gl_fence_nv.h",
58    "gl_gl_api_implementation.cc",
59    "gl_gl_api_implementation.h",
60    "gl_image.cc",
61    "gl_image.h",
62    "gl_image_memory.cc",
63    "gl_image_memory.h",
64    "gl_image_ref_counted_memory.cc",
65    "gl_image_ref_counted_memory.h",
66    "gl_image_shared_memory.cc",
67    "gl_image_shared_memory.h",
68    "gl_image_stub.cc",
69    "gl_image_stub.h",
70    "gl_implementation.cc",
71    "gl_implementation.h",
72    "gl_implementation_android.cc",
73    "gl_implementation_mac.cc",
74    "gl_implementation_win.cc",
75    "gl_osmesa_api_implementation.cc",
76    "gl_osmesa_api_implementation.h",
77    "gl_share_group.cc",
78    "gl_share_group.h",
79    "gl_state_restorer.cc",
80    "gl_state_restorer.h",
81    "gl_surface.cc",
82    "gl_surface.h",
83    "gl_surface_android.cc",
84    "gl_surface_mac.cc",
85    "gl_surface_stub.cc",
86    "gl_surface_stub.h",
87    "gl_surface_win.cc",
88    "gl_surface_osmesa.cc",
89    "gl_surface_osmesa.h",
90    "gl_switches.cc",
91    "gl_switches.h",
92    "gl_version_info.cc",
93    "gl_version_info.h",
94    "gpu_switching_manager.cc",
95    "gpu_switching_manager.h",
96    "scoped_binders.cc",
97    "scoped_binders.h",
98    "scoped_make_current.cc",
99    "scoped_make_current.h",
100    "sync_control_vsync_provider.cc",
101    "sync_control_vsync_provider.h",
102    "$gl_binding_output_dir/gl_bindings_autogen_gl.cc",
103    "$gl_binding_output_dir/gl_bindings_autogen_gl.h",
104    "$gl_binding_output_dir/gl_bindings_autogen_osmesa.cc",
105    "$gl_binding_output_dir/gl_bindings_autogen_osmesa.h",
106  ]
107
108  defines = [ "GL_IMPLEMENTATION" ]
109
110  include_dirs = [
111    "//third_party/switfshader/include",
112    "//third_party/khronos",
113    "//third_party/mesa/src/include",
114    gl_binding_output_dir,
115  ]
116
117  all_dependent_configs = [ ":gl_config" ]
118
119  deps = [
120    ":generate_gl_bindings",
121    "//base/third_party/dynamic_annotations",
122    "//gpu/command_buffer/common",
123    "//skia",
124  ]
125  public_deps = [
126    "//base",
127    "//third_party/mesa:mesa_headers",
128    "//ui/events/platform",
129    "//ui/gfx",
130    "//ui/gfx/geometry",
131  ]
132
133  if (is_win || is_android || is_linux) {
134    sources += [
135      "egl_util.cc",
136      "egl_util.h",
137      "gl_context_egl.cc",
138      "gl_context_egl.h",
139      "gl_fence_egl.cc",
140      "gl_fence_egl.h",
141      "gl_image_egl.cc",
142      "gl_image_egl.h",
143      "gl_surface_egl.cc",
144      "gl_surface_egl.h",
145      "$gl_binding_output_dir/gl_bindings_autogen_egl.cc",
146      "$gl_binding_output_dir/gl_bindings_autogen_egl.h",
147    ]
148  }
149  if (is_android || is_linux) {
150    sources += [
151      "gl_implementation_osmesa.cc",
152      "gl_implementation_osmesa.h",
153    ]
154  }
155  if (is_linux) {
156    deps += [ "//third_party/libevent" ]
157  }
158  if (use_x11) {
159    sources += [
160      "gl_context_glx.cc",
161      "gl_context_glx.h",
162      "gl_context_x11.cc",
163      "gl_glx_api_implementation.cc",
164      "gl_glx_api_implementation.h",
165      "gl_image_glx.cc",
166      "gl_image_glx.h",
167      "gl_implementation_x11.cc",
168      "gl_surface_glx.cc",
169      "gl_surface_glx.h",
170      "gl_surface_x11.cc",
171      "gl_egl_api_implementation.cc",
172      "gl_egl_api_implementation.h",
173      "$gl_binding_output_dir/gl_bindings_autogen_glx.cc",
174      "$gl_binding_output_dir/gl_bindings_autogen_glx.h",
175    ]
176
177    configs += [
178      "//build/config/linux:x11",
179      "//build/config/linux:xcomposite",
180      "//build/config/linux:xext",
181    ]
182
183    deps += [
184      "//ui/gfx/x",
185    ]
186  }
187  if (is_win) {
188    sources += [
189      "gl_context_wgl.cc",
190      "gl_context_wgl.h",
191      "gl_egl_api_implementation.cc",
192      "gl_egl_api_implementation.h",
193      "gl_surface_wgl.cc",
194      "gl_surface_wgl.h",
195      "gl_wgl_api_implementation.cc",
196      "gl_wgl_api_implementation.h",
197      "$gl_binding_output_dir/gl_bindings_autogen_wgl.cc",
198      "$gl_binding_output_dir/gl_bindings_autogen_wgl.h",
199    ]
200
201    libs = [ "dwmapi.lib" ]
202    ldflags = [ "/DELAYLOAD:dwmapi.dll" ]
203  }
204  if (is_mac) {
205    sources += [
206      "gl_context_cgl.cc",
207      "gl_context_cgl.h",
208      "gl_image_io_surface.cc",
209      "gl_image_io_surface.h",
210      "scoped_cgl.cc",
211      "scoped_cgl.h",
212    ]
213
214    libs = [
215      "IOSurface.framework",
216      "OpenGL.framework",
217    ]
218  }
219  if (is_android) {
220    sources += [
221      "gl_egl_api_implementation.cc",
222      "gl_egl_api_implementation.h",
223      "gl_image_android_native_buffer.cc",
224      "gl_image_android_native_buffer.h",
225      "gl_image_surface_texture.cc",
226      "gl_image_surface_texture.h",
227    ]
228
229    defines += [
230      "GL_GLEXT_PROTOTYPES",
231      "EGL_EGLEXT_PROTOTYPES",
232    ]
233
234    libs = [ "android" ]
235
236    deps += [
237      ":gl_jni_headers",
238    ]
239  }
240  if (use_ozone) {
241    sources += [
242      "gl_context_ozone.cc",
243      "gl_egl_api_implementation.cc",
244      "gl_egl_api_implementation.h",
245      "gl_implementation_ozone.cc",
246      "gl_surface_ozone.cc",
247    ]
248    deps += [
249      "//ui/ozone",
250      "//ui/ozone:ozone_base",
251    ]
252  }
253
254  if (is_android && !is_android_webview_build) {
255    deps += [ "//ui/android:ui_java" ]
256  }
257}
258
259action("generate_gl_bindings") {
260  visibility = [ ":*" ]  # Only targets in this file can see this.
261
262  script = "generate_bindings.py"
263
264  # TODO(brettw) make this dynamic. The GYP version calls "generate_bindings.py
265  # --inputs" to get the list here. What should happen is that the script
266  # should generate a .d file, which we should declare here. That will
267  # eliminate the need bot both hardcoding the list here or calling the script
268  # during GN-time.
269  inputs = [
270    "EGL/eglextchromium.h",
271    "GL/glextchromium.h",
272    "//third_party/mesa/src/include/GL/glext.h",
273    "//third_party/khronos/GLES2/gl2ext.h",
274    "//gpu/GLES2/gl2chromium.h",
275    "//gpu/GLES2/gl2extchromium.h",
276    "//third_party/khronos/EGL/eglext.h",
277    "//third_party/mesa/src/include/GL/wglext.h",
278    "//third_party/mesa/src/include/GL/glx.h",
279    "//third_party/mesa/src/include/GL/glxext.h",
280  ]
281
282  outputs = [
283    "$gl_binding_output_dir/gl_bindings_autogen_egl.cc",
284    "$gl_binding_output_dir/gl_bindings_autogen_egl.h",
285    "$gl_binding_output_dir/gl_bindings_api_autogen_egl.h",
286    "$gl_binding_output_dir/gl_bindings_autogen_gl.cc",
287    "$gl_binding_output_dir/gl_bindings_autogen_gl.h",
288    "$gl_binding_output_dir/gl_bindings_api_autogen_gl.h",
289    "$gl_binding_output_dir/gl_bindings_autogen_glx.cc",
290    "$gl_binding_output_dir/gl_bindings_autogen_glx.h",
291    "$gl_binding_output_dir/gl_bindings_api_autogen_glx.h",
292    "$gl_binding_output_dir/gl_bindings_autogen_mock.cc",
293    "$gl_binding_output_dir/gl_bindings_autogen_mock.h",
294    "$gl_binding_output_dir/gl_bindings_autogen_osmesa.cc",
295    "$gl_binding_output_dir/gl_bindings_autogen_osmesa.h",
296    "$gl_binding_output_dir/gl_bindings_api_autogen_osmesa.h",
297    "$gl_binding_output_dir/gl_bindings_autogen_wgl.cc",
298    "$gl_binding_output_dir/gl_bindings_autogen_wgl.h",
299    "$gl_binding_output_dir/gl_bindings_api_autogen_wgl.h",
300    "$gl_binding_output_dir/gl_mock_autogen_gl.h",
301  ]
302
303  args = [
304    "--header-paths=" +
305        rebase_path("//third_party/khronos", root_build_dir) + ":" +
306        rebase_path("//third_party/mesa/src/include", root_build_dir) + ":" +
307        rebase_path("//ui/gl", root_build_dir) + ":" +
308        rebase_path("//gpu", root_build_dir),
309    rebase_path(gl_binding_output_dir, root_build_dir),
310  ]
311}
312
313config("gl_unittest_utils_config") {
314  include_dirs = [ gl_binding_output_dir ]
315}
316
317source_set("gl_unittest_utils") {
318  testonly = true
319  sources = [
320    "gl_mock.h",
321    "gl_mock.cc",
322    "$gl_binding_output_dir/gl_bindings_autogen_mock.cc",
323    "$gl_binding_output_dir/gl_bindings_autogen_mock.h",
324    "$gl_binding_output_dir/gl_mock_autogen_gl.h",
325  ]
326
327  configs += [ "//third_party/khronos:khronos_headers" ]
328  public_configs = [ ":gl_unittest_utils_config" ]
329
330  deps = [
331    ":gl",
332    "//testing/gmock",
333  ]
334}
335
336if (is_android) {
337  generate_jar_jni("surface_jni_headers") {
338    jni_package = "ui/gl"
339    classes = [ "android/view/Surface.class" ]
340  }
341
342  generate_jni("gl_jni_headers") {
343    deps = [ ":surface_jni_headers" ]
344    sources = [
345      "../android/java/src/org/chromium/ui/gl/SurfaceTextureListener.java",
346      "../android/java/src/org/chromium/ui/gl/SurfaceTexturePlatformWrapper.java",
347    ]
348    jni_package = "ui/gl"
349  }
350}
351