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