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