Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / ui / gl / BUILD.gn
blob0eee63e5d0888cc662137ae3c032c301683e2061
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 import("//testing/test.gni")
8 if (is_android) {
9   import("//build/config/android/config.gni")
10   import("//build/config/android/rules.gni")
13 config("gl_config") {
14   if (use_x11) {
15     defines = [ "GL_GLEXT_PROTOTYPES" ]
16   }
19 component("gl") {
20   output_name = "gl_wrapper"  # Avoid colliding with OS X"s libGL.dylib.
22   sources = [
23     "android/gl_jni_registrar.cc",
24     "android/gl_jni_registrar.h",
25     "android/scoped_java_surface.cc",
26     "android/scoped_java_surface.h",
27     "android/surface_texture.cc",
28     "android/surface_texture.h",
29     "android/surface_texture_listener.cc",
30     "android/surface_texture_listener.h",
31     "gl_bindings.cc",
32     "gl_bindings.h",
33     "gl_bindings_autogen_gl.cc",
34     "gl_bindings_autogen_gl.h",
35     "gl_bindings_autogen_osmesa.cc",
36     "gl_bindings_autogen_osmesa.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_enums.cc",
51     "gl_enums.h",
52     "gl_enums_implementation_autogen.h",
53     "gl_export.h",
54     "gl_fence.cc",
55     "gl_fence.h",
56     "gl_fence_arb.cc",
57     "gl_fence_arb.h",
58     "gl_fence_nv.cc",
59     "gl_fence_nv.h",
60     "gl_gl_api_implementation.cc",
61     "gl_gl_api_implementation.h",
62     "gl_image.h",
63     "gl_image_memory.cc",
64     "gl_image_memory.h",
65     "gl_image_ref_counted_memory.cc",
66     "gl_image_ref_counted_memory.h",
67     "gl_image_shared_memory.cc",
68     "gl_image_shared_memory.h",
69     "gl_image_stub.cc",
70     "gl_image_stub.h",
71     "gl_implementation.cc",
72     "gl_implementation.h",
73     "gl_implementation_android.cc",
74     "gl_implementation_mac.cc",
75     "gl_implementation_win.cc",
76     "gl_osmesa_api_implementation.cc",
77     "gl_osmesa_api_implementation.h",
78     "gl_share_group.cc",
79     "gl_share_group.h",
80     "gl_state_restorer.cc",
81     "gl_state_restorer.h",
82     "gl_surface.cc",
83     "gl_surface.h",
84     "gl_surface_android.cc",
85     "gl_surface_mac.cc",
86     "gl_surface_osmesa.cc",
87     "gl_surface_osmesa.h",
88     "gl_surface_stub.cc",
89     "gl_surface_stub.h",
90     "gl_surface_win.cc",
91     "gl_switches.cc",
92     "gl_switches.h",
93     "gl_version_info.cc",
94     "gl_version_info.h",
95     "gpu_switching_manager.cc",
96     "gpu_switching_manager.h",
97     "gpu_timing.cc",
98     "gpu_timing.h",
99     "scoped_api.cc",
100     "scoped_api.h",
101     "scoped_binders.cc",
102     "scoped_binders.h",
103     "scoped_make_current.cc",
104     "scoped_make_current.h",
105     "sync_control_vsync_provider.cc",
106     "sync_control_vsync_provider.h",
107     "trace_util.cc",
108     "trace_util.h",
109   ]
111   configs += [ "//build/config:precompiled_headers" ]
112   defines = [ "GL_IMPLEMENTATION" ]
114   include_dirs = [
115     "//third_party/switfshader/include",
116     "//third_party/mesa/src/include",
117   ]
119   all_dependent_configs = [ ":gl_config" ]
121   public_configs = [ "//third_party/khronos:khronos_headers" ]
123   deps = [
124     "//base/third_party/dynamic_annotations",
125     "//skia",
126   ]
127   public_deps = [
128     "//base",
129     "//third_party/mesa:mesa_headers",
130     "//ui/events/platform",
131     "//ui/gfx",
132     "//ui/gfx/geometry",
133   ]
135   if (is_win || is_android || is_linux) {
136     sources += [
137       "egl_util.cc",
138       "egl_util.h",
139       "gl_bindings_autogen_egl.cc",
140       "gl_bindings_autogen_egl.h",
141       "gl_context_egl.cc",
142       "gl_context_egl.h",
143       "gl_fence_egl.cc",
144       "gl_fence_egl.h",
145       "gl_image_egl.cc",
146       "gl_image_egl.h",
147       "gl_surface_egl.cc",
148       "gl_surface_egl.h",
149     ]
150   }
151   if (is_android || is_linux) {
152     sources += [
153       "gl_implementation_osmesa.cc",
154       "gl_implementation_osmesa.h",
155     ]
156   }
157   if (is_linux) {
158     deps += [ "//third_party/libevent" ]
159   }
160   if (use_x11) {
161     sources += [
162       "gl_bindings_autogen_glx.cc",
163       "gl_bindings_autogen_glx.h",
164       "gl_context_glx.cc",
165       "gl_context_glx.h",
166       "gl_context_x11.cc",
167       "gl_egl_api_implementation.cc",
168       "gl_egl_api_implementation.h",
169       "gl_glx_api_implementation.cc",
170       "gl_glx_api_implementation.h",
171       "gl_image_glx.cc",
172       "gl_image_glx.h",
173       "gl_implementation_x11.cc",
174       "gl_surface_glx.cc",
175       "gl_surface_glx.h",
176       "gl_surface_x11.cc",
177     ]
179     configs += [
180       "//build/config/linux:x11",
181       "//build/config/linux:xcomposite",
182       "//build/config/linux:xext",
183     ]
185     deps += [ "//ui/gfx/x" ]
186   }
187   if (is_win) {
188     sources += [
189       "angle_platform_impl.cc",
190       "angle_platform_impl.h",
191       "gl_bindings_autogen_wgl.cc",
192       "gl_bindings_autogen_wgl.h",
193       "gl_context_wgl.cc",
194       "gl_context_wgl.h",
195       "gl_egl_api_implementation.cc",
196       "gl_egl_api_implementation.h",
197       "gl_surface_wgl.cc",
198       "gl_surface_wgl.h",
199       "gl_wgl_api_implementation.cc",
200       "gl_wgl_api_implementation.h",
201     ]
203     libs = [ "dwmapi.lib" ]
204     ldflags = [ "/DELAYLOAD:dwmapi.dll" ]
206     data_deps = [
207       "//third_party/angle:libEGL",
208       "//third_party/angle:libGLESv2",
209       "//third_party/mesa:osmesa",
210     ]
211   }
212   if (is_mac) {
213     sources += [
214       "gl_context_cgl.cc",
215       "gl_context_cgl.h",
216       "gl_fence_apple.cc",
217       "gl_fence_apple.h",
218       "gl_image_io_surface.h",
219       "gl_image_io_surface.mm",
220       "scoped_cgl.cc",
221       "scoped_cgl.h",
222     ]
224     libs = [
225       "IOSurface.framework",
226       "OpenGL.framework",
227       "Quartz.framework",
228     ]
229   }
230   if (is_android) {
231     sources += [
232       "gl_egl_api_implementation.cc",
233       "gl_egl_api_implementation.h",
234       "gl_image_surface_texture.cc",
235       "gl_image_surface_texture.h",
236     ]
238     defines += [
239       "GL_GLEXT_PROTOTYPES",
240       "EGL_EGLEXT_PROTOTYPES",
241     ]
243     libs = [ "android" ]
245     deps += [
246       ":gl_jni_headers",
247       "//ui/android:ui_java",
248     ]
249   }
250   if (use_ozone) {
251     sources += [
252       "gl_context_ozone.cc",
253       "gl_egl_api_implementation.cc",
254       "gl_egl_api_implementation.h",
255       "gl_image_ozone_native_pixmap.cc",
256       "gl_image_ozone_native_pixmap.h",
257       "gl_implementation_ozone.cc",
258       "gl_surface_ozone.cc",
259     ]
260     deps += [
261       "//ui/ozone",
262       "//ui/ozone:ozone_base",
263     ]
264   }
267 source_set("gl_unittest_utils") {
268   testonly = true
269   sources = [
270     "gl_bindings_autogen_mock.cc",
271     "gl_bindings_autogen_mock.h",
272     "gl_mock.cc",
273     "gl_mock.h",
274     "gl_mock_autogen_gl.h",
275     "gpu_timing_fake.cc",
276     "gpu_timing_fake.h",
277   ]
279   configs += [ "//third_party/khronos:khronos_headers" ]
281   deps = [
282     ":gl",
283     "//testing/gmock",
284   ]
287 source_set("test_support") {
288   sources = [
289     "test/gl_surface_test_support.cc",
290     "test/gl_surface_test_support.h",
291   ]
293   configs += [ "//third_party/khronos:khronos_headers" ]
295   deps = [
296     ":gl",
297   ]
299   if (use_x11) {
300     configs += [ "//build/config/linux:x11" ]
301     deps += [
302       "//ui/gfx/x",
303       "//ui/platform_window/x11",
304     ]
305   }
308 # TODO(GYP): Delete this after we've converted everything to GN.
309 # The _run targets exist only for compatibility w/ GYP.
310 group("gl_unittests_run") {
311   testonly = true
312   deps = [
313     ":gl_unittests",
314   ]
317 test("gl_unittests") {
318   sources = [
319     "gl_api_unittest.cc",
320     "gpu_timing_unittest.cc",
321     "test/run_all_unittests.cc",
322   ]
324   if (is_win || is_android || is_linux) {
325     sources += [
326       "egl_api_unittest.cc",
327       "test/egl_initialization_displays_unittest.cc",
328     ]
329   }
331   if (use_x11) {
332     sources += [ "glx_api_unittest.cc" ]
333   }
335   include_dirs = [ "//third_party/khronos" ]
337   deps = [
338     ":gl",
339     ":gl_unittest_utils",
340     ":test_support",
341     "//base",
342     "//base/test:test_support",
343     "//testing/gmock",
344     "//testing/gtest",
345   ]
348 if (is_android) {
349   generate_jar_jni("surface_jni_headers") {
350     jni_package = "ui/gl"
351     classes = [ "android/view/Surface.class" ]
352   }
354   generate_jni("gl_jni_headers") {
355     deps = [
356       ":surface_jni_headers",
357     ]
358     sources = [
359       "../android/java/src/org/chromium/ui/gl/SurfaceTextureListener.java",
360       "../android/java/src/org/chromium/ui/gl/SurfaceTexturePlatformWrapper.java",
361     ]
362     jni_package = "ui/gl"
363   }