Update To 11.40.268.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/config.gni")
8   import("//build/config/android/rules.gni")
9 }
10
11 gl_binding_output_dir = target_gen_dir
12
13 config("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
23 component("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     "gl_bindings.h",
36     "gl_bindings_skia_in_process.cc",
37     "gl_bindings_skia_in_process.h",
38     "gl_context.cc",
39     "gl_context.h",
40     "gl_context_android.cc",
41     "gl_context_mac.mm",
42     "gl_context_osmesa.cc",
43     "gl_context_osmesa.h",
44     "gl_context_stub.cc",
45     "gl_context_stub.h",
46     "gl_context_stub_with_extensions.cc",
47     "gl_context_stub_with_extensions.h",
48     "gl_context_win.cc",
49     "gl_export.h",
50     "gl_fence.cc",
51     "gl_fence.h",
52     "gl_fence_arb.cc",
53     "gl_fence_arb.h",
54     "gl_fence_nv.cc",
55     "gl_fence_nv.h",
56     "gl_gl_api_implementation.cc",
57     "gl_gl_api_implementation.h",
58     "gl_image.h",
59     "gl_image_memory.cc",
60     "gl_image_memory.h",
61     "gl_image_ref_counted_memory.cc",
62     "gl_image_ref_counted_memory.h",
63     "gl_image_shared_memory.cc",
64     "gl_image_shared_memory.h",
65     "gl_image_stub.cc",
66     "gl_image_stub.h",
67     "gl_implementation.cc",
68     "gl_implementation.h",
69     "gl_implementation_android.cc",
70     "gl_implementation_mac.cc",
71     "gl_implementation_win.cc",
72     "gl_osmesa_api_implementation.cc",
73     "gl_osmesa_api_implementation.h",
74     "gl_share_group.cc",
75     "gl_share_group.h",
76     "gl_state_restorer.cc",
77     "gl_state_restorer.h",
78     "gl_surface.cc",
79     "gl_surface.h",
80     "gl_surface_android.cc",
81     "gl_surface_mac.cc",
82     "gl_surface_stub.cc",
83     "gl_surface_stub.h",
84     "gl_surface_win.cc",
85     "gl_surface_osmesa.cc",
86     "gl_surface_osmesa.h",
87     "gl_switches.cc",
88     "gl_switches.h",
89     "gl_version_info.cc",
90     "gl_version_info.h",
91     "gpu_switching_manager.cc",
92     "gpu_switching_manager.h",
93     "scoped_binders.cc",
94     "scoped_binders.h",
95     "scoped_make_current.cc",
96     "scoped_make_current.h",
97     "sync_control_vsync_provider.cc",
98     "sync_control_vsync_provider.h",
99     "$gl_binding_output_dir/gl_bindings_autogen_gl.cc",
100     "$gl_binding_output_dir/gl_bindings_autogen_gl.h",
101     "$gl_binding_output_dir/gl_bindings_autogen_osmesa.cc",
102     "$gl_binding_output_dir/gl_bindings_autogen_osmesa.h",
103   ]
104
105   defines = [ "GL_IMPLEMENTATION" ]
106
107   include_dirs = [
108     "//third_party/switfshader/include",
109     "//third_party/khronos",
110     "//third_party/mesa/src/include",
111     gl_binding_output_dir,
112   ]
113
114   all_dependent_configs = [ ":gl_config" ]
115
116   deps = [
117     ":generate_gl_bindings",
118     "//base/third_party/dynamic_annotations",
119     "//gpu/command_buffer/common",
120     "//skia",
121   ]
122   public_deps = [
123     "//base",
124     "//third_party/mesa:mesa_headers",
125     "//ui/events/platform",
126     "//ui/gfx",
127     "//ui/gfx/geometry",
128   ]
129
130   if (is_win || is_android || is_linux) {
131     sources += [
132       "egl_util.cc",
133       "egl_util.h",
134       "gl_context_egl.cc",
135       "gl_context_egl.h",
136       "gl_fence_egl.cc",
137       "gl_fence_egl.h",
138       "gl_image_egl.cc",
139       "gl_image_egl.h",
140       "gl_surface_egl.cc",
141       "gl_surface_egl.h",
142       "$gl_binding_output_dir/gl_bindings_autogen_egl.cc",
143       "$gl_binding_output_dir/gl_bindings_autogen_egl.h",
144     ]
145   }
146   if (is_android || is_linux) {
147     sources += [
148       "gl_implementation_osmesa.cc",
149       "gl_implementation_osmesa.h",
150     ]
151   }
152   if (is_linux) {
153     deps += [ "//third_party/libevent" ]
154     sources += [
155       "gl_image_linux_dma_buffer.cc",
156       "gl_image_linux_dma_buffer.h",
157     ]
158   }
159   if (use_x11) {
160     sources += [
161       "gl_context_glx.cc",
162       "gl_context_glx.h",
163       "gl_context_x11.cc",
164       "gl_glx_api_implementation.cc",
165       "gl_glx_api_implementation.h",
166       "gl_implementation_x11.cc",
167       "gl_surface_glx.cc",
168       "gl_surface_glx.h",
169       "gl_surface_x11.cc",
170       "gl_egl_api_implementation.cc",
171       "gl_egl_api_implementation.h",
172       "$gl_binding_output_dir/gl_bindings_autogen_glx.cc",
173       "$gl_binding_output_dir/gl_bindings_autogen_glx.h",
174     ]
175
176     configs += [
177       "//build/config/linux:x11",
178       "//build/config/linux:xcomposite",
179       "//build/config/linux:xext",
180     ]
181
182     deps += [
183       "//ui/gfx/x",
184     ]
185   }
186   if (is_win) {
187     sources += [
188       "gl_context_wgl.cc",
189       "gl_context_wgl.h",
190       "gl_egl_api_implementation.cc",
191       "gl_egl_api_implementation.h",
192       "gl_surface_wgl.cc",
193       "gl_surface_wgl.h",
194       "gl_wgl_api_implementation.cc",
195       "gl_wgl_api_implementation.h",
196       "$gl_binding_output_dir/gl_bindings_autogen_wgl.cc",
197       "$gl_binding_output_dir/gl_bindings_autogen_wgl.h",
198     ]
199
200     libs = [ "dwmapi.lib" ]
201     ldflags = [ "/DELAYLOAD:dwmapi.dll" ]
202   }
203   if (is_mac) {
204     sources += [
205       "gl_context_cgl.cc",
206       "gl_context_cgl.h",
207       "gl_image_io_surface.cc",
208       "gl_image_io_surface.h",
209       "scoped_cgl.cc",
210       "scoped_cgl.h",
211     ]
212
213     libs = [
214       "IOSurface.framework",
215       "OpenGL.framework",
216     ]
217   }
218   if (is_android) {
219     sources += [
220       "gl_egl_api_implementation.cc",
221       "gl_egl_api_implementation.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_egl_api_implementation.cc",
241       "gl_egl_api_implementation.h",
242       "gl_implementation_ozone.cc",
243       "gl_surface_ozone.cc",
244     ]
245     deps += [
246       "//ui/ozone",
247       "//ui/ozone:ozone_base",
248     ]
249   }
250
251   if (is_android && !is_android_webview_build) {
252     deps += [ "//ui/android:ui_java" ]
253   }
254 }
255
256 action("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   inputs = [
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
310 config("gl_unittest_utils_config") {
311   include_dirs = [ gl_binding_output_dir ]
312 }
313
314 source_set("gl_unittest_utils") {
315   testonly = true
316   sources = [
317     "gl_mock.h",
318     "gl_mock.cc",
319     "$gl_binding_output_dir/gl_bindings_autogen_mock.cc",
320     "$gl_binding_output_dir/gl_bindings_autogen_mock.h",
321     "$gl_binding_output_dir/gl_mock_autogen_gl.h",
322   ]
323
324   configs += [ "//third_party/khronos:khronos_headers" ]
325   public_configs = [ ":gl_unittest_utils_config" ]
326
327   deps = [
328     ":gl",
329     "//testing/gmock",
330   ]
331 }
332
333 if (is_android) {
334   generate_jar_jni("surface_jni_headers") {
335     jni_package = "ui/gl"
336     classes = [ "android/view/Surface.class" ]
337   }
338
339   generate_jni("gl_jni_headers") {
340     deps = [ ":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 }