Improve ResourceRequestInfo::HasUserGesture API docs
[chromium-blink-merge.git] / ui / gl / BUILD.gn
blobfddbde7337fc290ea7d7ac804dba9d7348b17128
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/config.gni")
8   import("//build/config/android/rules.gni")
11 gl_binding_output_dir = target_gen_dir
13 config("gl_config") {
14   if (use_x11) {
15     defines = [ "GL_GLEXT_PROTOTYPES" ]
16   }
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 ]
23 component("gl") {
24   output_name = "gl_wrapper"  # Avoid colliding with OS X"s libGL.dylib.
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   ]
105   defines = [ "GL_IMPLEMENTATION" ]
107   include_dirs = [
108     "//third_party/switfshader/include",
109     "//third_party/khronos",
110     "//third_party/mesa/src/include",
111     gl_binding_output_dir,
112   ]
114   all_dependent_configs = [ ":gl_config" ]
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   ]
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_image_glx.cc",
167       "gl_image_glx.h",
168       "gl_implementation_x11.cc",
169       "gl_surface_glx.cc",
170       "gl_surface_glx.h",
171       "gl_surface_x11.cc",
172       "gl_egl_api_implementation.cc",
173       "gl_egl_api_implementation.h",
174       "$gl_binding_output_dir/gl_bindings_autogen_glx.cc",
175       "$gl_binding_output_dir/gl_bindings_autogen_glx.h",
176     ]
178     configs += [
179       "//build/config/linux:x11",
180       "//build/config/linux:xcomposite",
181       "//build/config/linux:xext",
182     ]
184     deps += [
185       "//ui/gfx/x",
186     ]
187   }
188   if (is_win) {
189     sources += [
190       "gl_context_wgl.cc",
191       "gl_context_wgl.h",
192       "gl_egl_api_implementation.cc",
193       "gl_egl_api_implementation.h",
194       "gl_surface_wgl.cc",
195       "gl_surface_wgl.h",
196       "gl_wgl_api_implementation.cc",
197       "gl_wgl_api_implementation.h",
198       "$gl_binding_output_dir/gl_bindings_autogen_wgl.cc",
199       "$gl_binding_output_dir/gl_bindings_autogen_wgl.h",
200     ]
202     libs = [ "dwmapi.lib" ]
203     ldflags = [ "/DELAYLOAD:dwmapi.dll" ]
204   }
205   if (is_mac) {
206     sources += [
207       "gl_context_cgl.cc",
208       "gl_context_cgl.h",
209       "gl_image_io_surface.cc",
210       "gl_image_io_surface.h",
211       "scoped_cgl.cc",
212       "scoped_cgl.h",
213     ]
215     libs = [
216       "IOSurface.framework",
217       "OpenGL.framework",
218     ]
219   }
220   if (is_android) {
221     sources += [
222       "gl_egl_api_implementation.cc",
223       "gl_egl_api_implementation.h",
224       "gl_image_surface_texture.cc",
225       "gl_image_surface_texture.h",
226     ]
228     defines += [
229       "GL_GLEXT_PROTOTYPES",
230       "EGL_EGLEXT_PROTOTYPES",
231     ]
233     libs = [ "android" ]
235     deps += [
236       ":gl_jni_headers",
237     ]
238   }
239   if (use_ozone) {
240     sources += [
241       "gl_context_ozone.cc",
242       "gl_egl_api_implementation.cc",
243       "gl_egl_api_implementation.h",
244       "gl_implementation_ozone.cc",
245       "gl_surface_ozone.cc",
246     ]
247     deps += [
248       "//ui/ozone",
249       "//ui/ozone:ozone_base",
250     ]
251   }
253   if (is_android && !is_android_webview_build) {
254     deps += [ "//ui/android:ui_java" ]
255   }
258 action("generate_gl_bindings") {
259   visibility = [ ":*" ]  # Only targets in this file can see this.
261   script = "generate_bindings.py"
263   # TODO(brettw) make this dynamic. The GYP version calls "generate_bindings.py
264   # --inputs" to get the list here. What should happen is that the script
265   # should generate a .d file, which we should declare here. That will
266   # eliminate the need bot both hardcoding the list here or calling the script
267   # during GN-time.
268   inputs = [
269     "EGL/eglextchromium.h",
270     "GL/glextchromium.h",
271     "//third_party/mesa/src/include/GL/glext.h",
272     "//third_party/khronos/GLES2/gl2ext.h",
273     "//gpu/GLES2/gl2chromium.h",
274     "//gpu/GLES2/gl2extchromium.h",
275     "//third_party/khronos/EGL/eglext.h",
276     "//third_party/mesa/src/include/GL/wglext.h",
277     "//third_party/mesa/src/include/GL/glx.h",
278     "//third_party/mesa/src/include/GL/glxext.h",
279   ]
281   outputs = [
282     "$gl_binding_output_dir/gl_bindings_autogen_egl.cc",
283     "$gl_binding_output_dir/gl_bindings_autogen_egl.h",
284     "$gl_binding_output_dir/gl_bindings_api_autogen_egl.h",
285     "$gl_binding_output_dir/gl_bindings_autogen_gl.cc",
286     "$gl_binding_output_dir/gl_bindings_autogen_gl.h",
287     "$gl_binding_output_dir/gl_bindings_api_autogen_gl.h",
288     "$gl_binding_output_dir/gl_bindings_autogen_glx.cc",
289     "$gl_binding_output_dir/gl_bindings_autogen_glx.h",
290     "$gl_binding_output_dir/gl_bindings_api_autogen_glx.h",
291     "$gl_binding_output_dir/gl_bindings_autogen_mock.cc",
292     "$gl_binding_output_dir/gl_bindings_autogen_mock.h",
293     "$gl_binding_output_dir/gl_bindings_autogen_osmesa.cc",
294     "$gl_binding_output_dir/gl_bindings_autogen_osmesa.h",
295     "$gl_binding_output_dir/gl_bindings_api_autogen_osmesa.h",
296     "$gl_binding_output_dir/gl_bindings_autogen_wgl.cc",
297     "$gl_binding_output_dir/gl_bindings_autogen_wgl.h",
298     "$gl_binding_output_dir/gl_bindings_api_autogen_wgl.h",
299     "$gl_binding_output_dir/gl_mock_autogen_gl.h",
300   ]
302   args = [
303     "--header-paths=" +
304         rebase_path("//third_party/khronos", root_build_dir) + ":" +
305         rebase_path("//third_party/mesa/src/include", root_build_dir) + ":" +
306         rebase_path("//ui/gl", root_build_dir) + ":" +
307         rebase_path("//gpu", root_build_dir),
308     rebase_path(gl_binding_output_dir, root_build_dir),
309   ]
312 config("gl_unittest_utils_config") {
313   include_dirs = [ gl_binding_output_dir ]
316 source_set("gl_unittest_utils") {
317   testonly = true
318   sources = [
319     "gl_mock.h",
320     "gl_mock.cc",
321     "$gl_binding_output_dir/gl_bindings_autogen_mock.cc",
322     "$gl_binding_output_dir/gl_bindings_autogen_mock.h",
323     "$gl_binding_output_dir/gl_mock_autogen_gl.h",
324   ]
326   configs += [ "//third_party/khronos:khronos_headers" ]
327   public_configs = [ ":gl_unittest_utils_config" ]
329   deps = [
330     ":gl",
331     "//testing/gmock",
332   ]
335 if (is_android) {
336   generate_jar_jni("surface_jni_headers") {
337     jni_package = "ui/gl"
338     classes = [ "android/view/Surface.class" ]
339   }
341   generate_jni("gl_jni_headers") {
342     deps = [ ":surface_jni_headers" ]
343     sources = [
344       "../android/java/src/org/chromium/ui/gl/SurfaceTextureListener.java",
345       "../android/java/src/org/chromium/ui/gl/SurfaceTexturePlatformWrapper.java",
346     ]
347     jni_package = "ui/gl"
348   }