Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ui / gl / BUILD.gn
blobf4c94b0b1f4cdc1f49a3a828606762961492cb30
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.
5 import("//build/config/ui.gni")
6 if (is_android) {
7   import("//build/config/android/rules.gni")
10 gl_binding_output_dir = target_gen_dir
12 config("gl_config") {
13   if (use_x11) {
14     defines = [ "GL_GLEXT_PROTOTYPES" ]
15   }
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 ]
22 component("gl") {
23   output_name = "gl_wrapper"  # Avoid colliding with OS X"s libGL.dylib.
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_memory.cc",
62     "gl_image_memory.h",
63     "gl_image_ref_counted_memory.cc",
64     "gl_image_ref_counted_memory.h",
65     "gl_image_shared_memory.cc",
66     "gl_image_shared_memory.h",
67     "gl_image_stub.cc",
68     "gl_image_stub.h",
69     "gl_implementation.cc",
70     "gl_implementation.h",
71     "gl_implementation_android.cc",
72     "gl_implementation_mac.cc",
73     "gl_implementation_win.cc",
74     "gl_osmesa_api_implementation.cc",
75     "gl_osmesa_api_implementation.h",
76     "gl_share_group.cc",
77     "gl_share_group.h",
78     "gl_state_restorer.cc",
79     "gl_state_restorer.h",
80     "gl_surface.cc",
81     "gl_surface.h",
82     "gl_surface_android.cc",
83     "gl_surface_mac.cc",
84     "gl_surface_stub.cc",
85     "gl_surface_stub.h",
86     "gl_surface_win.cc",
87     "gl_surface_osmesa.cc",
88     "gl_surface_osmesa.h",
89     "gl_switches.cc",
90     "gl_switches.h",
91     "gl_version_info.cc",
92     "gl_version_info.h",
93     "gpu_switching_manager.cc",
94     "gpu_switching_manager.h",
95     "scoped_binders.cc",
96     "scoped_binders.h",
97     "scoped_make_current.cc",
98     "scoped_make_current.h",
99     "sync_control_vsync_provider.cc",
100     "sync_control_vsync_provider.h",
101     "$gl_binding_output_dir/gl_bindings_autogen_gl.cc",
102     "$gl_binding_output_dir/gl_bindings_autogen_gl.h",
103     "$gl_binding_output_dir/gl_bindings_autogen_osmesa.cc",
104     "$gl_binding_output_dir/gl_bindings_autogen_osmesa.h",
105   ]
107   defines = [ "GL_IMPLEMENTATION" ]
109   include_dirs = [
110     "//third_party/switfshader/include",
111     "//third_party/khronos",
112     "//third_party/mesa/src/include",
113     gl_binding_output_dir,
114   ]
116   all_dependent_configs = [ ":gl_config" ]
118   deps = [
119     ":generate_gl_bindings",
120     "//base",
121     "//base/third_party/dynamic_annotations",
122     "//gpu/command_buffer/common",
123     "//third_party/mesa:mesa_headers",
124     "//skia",
125     "//ui/events/platform",
126     "//ui/gfx",
127     "//ui/gfx/geometry",
128   ]
130   # TODO(GYP) hook up once this is converted.
131   forward_dependent_configs_from = [ "//third_party/mesa:mesa_headers" ]
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     ]
177     configs += [
178       "//build/config/linux:x11",
179       "//build/config/linux:xcomposite",
180       "//build/config/linux:xext",
181     ]
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     ]
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     ]
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     ]
229     defines += [
230       "GL_GLEXT_PROTOTYPES",
231       "EGL_EGLEXT_PROTOTYPES",
232     ]
234     libs = [ "android" ]
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/gfx/ozone",
250       "//ui/ozone",
251     ]
252   }
254   # TODO(GYP) enable this dependency once its written.
255   #if (is_android && !android_webview_build) {
256   #  deps += [ "//ui/android:ui_java" ]
257   #}
260 action("generate_gl_bindings") {
261   visibility = ":*"  # Only targets in this file can see this.
263   script = "generate_bindings.py"
265   # TODO(brettw) make this dynamic. The GYP version calls "generate_bindings.py
266   # --inputs" to get the list here. What should happen is that the script
267   # should generate a .d file, which we should declare here. That will
268   # eliminate the need bot both hardcoding the list here or calling the script
269   # during GN-time.
270   inputs = [
271     "EGL/eglextchromium.h",
272     "GL/glextchromium.h",
273     "//third_party/mesa/src/include/GL/glext.h",
274     "//third_party/khronos/GLES2/gl2ext.h",
275     "//gpu/GLES2/gl2chromium.h",
276     "//gpu/GLES2/gl2extchromium.h",
277     "//third_party/khronos/EGL/eglext.h",
278     "//third_party/mesa/src/include/GL/wglext.h",
279     "//third_party/mesa/src/include/GL/glx.h",
280     "//third_party/mesa/src/include/GL/glxext.h",
281   ]
283   outputs = [
284     "$gl_binding_output_dir/gl_bindings_autogen_egl.cc",
285     "$gl_binding_output_dir/gl_bindings_autogen_egl.h",
286     "$gl_binding_output_dir/gl_bindings_api_autogen_egl.h",
287     "$gl_binding_output_dir/gl_bindings_autogen_gl.cc",
288     "$gl_binding_output_dir/gl_bindings_autogen_gl.h",
289     "$gl_binding_output_dir/gl_bindings_api_autogen_gl.h",
290     "$gl_binding_output_dir/gl_bindings_autogen_glx.cc",
291     "$gl_binding_output_dir/gl_bindings_autogen_glx.h",
292     "$gl_binding_output_dir/gl_bindings_api_autogen_glx.h",
293     "$gl_binding_output_dir/gl_bindings_autogen_mock.cc",
294     "$gl_binding_output_dir/gl_bindings_autogen_mock.h",
295     "$gl_binding_output_dir/gl_bindings_autogen_osmesa.cc",
296     "$gl_binding_output_dir/gl_bindings_autogen_osmesa.h",
297     "$gl_binding_output_dir/gl_bindings_api_autogen_osmesa.h",
298     "$gl_binding_output_dir/gl_bindings_autogen_wgl.cc",
299     "$gl_binding_output_dir/gl_bindings_autogen_wgl.h",
300     "$gl_binding_output_dir/gl_bindings_api_autogen_wgl.h",
301     "$gl_binding_output_dir/gl_mock_autogen_gl.h",
302   ]
304   args = [
305     "--header-paths=" +
306         rebase_path("//third_party/khronos", root_build_dir) + ":" +
307         rebase_path("//third_party/mesa/src/include", root_build_dir) + ":" +
308         rebase_path("//ui/gl", root_build_dir) + ":" +
309         rebase_path("//gpu", root_build_dir),
310     rebase_path(gl_binding_output_dir, root_build_dir),
311   ]
314 config("gl_unittest_utils_config") {
315   include_dirs = [ gl_binding_output_dir ]
318 source_set("gl_unittest_utils") {
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   ]
327   configs += [ "//third_party/khronos:khronos_headers" ]
328   direct_dependent_configs = [ ":gl_unittest_utils_config" ]
330   deps = [
331     ":gl",
332     "//testing/gmock",
333   ]
336 if (is_android) {
337   generate_jar_jni("surface_jni_headers") {
338     jni_package = "ui/gl"
339     classes = [ "android/view/Surface.class" ]
340   }
342   generate_jni("gl_jni_headers") {
343     deps = [ ":surface_jni_headers" ]
344     forward_dependent_configs_from = [ ":surface_jni_headers" ]
345     sources = [
346       "../android/java/src/org/chromium/ui/gl/SurfaceTextureListener.java",
347       "../android/java/src/org/chromium/ui/gl/SurfaceTexturePlatformWrapper.java",
348     ]
349     jni_package = "ui/gl"
350   }