Fix WindowAndroid leak in Android WebView
[chromium-blink-merge.git] / ui / gl / BUILD.gn
blobae1132e06f43a540ed2e674dd79a2d13f947a07b
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 config("gl_config") {
12   if (use_x11) {
13     defines = [ "GL_GLEXT_PROTOTYPES" ]
14   }
17 component("gl") {
18   output_name = "gl_wrapper"  # Avoid colliding with OS X"s libGL.dylib.
20   sources = [
21     "android/gl_jni_registrar.cc",
22     "android/gl_jni_registrar.h",
23     "android/scoped_java_surface.cc",
24     "android/scoped_java_surface.h",
25     "android/surface_texture.cc",
26     "android/surface_texture.h",
27     "android/surface_texture_listener.cc",
28     "android/surface_texture_listener.h",
29     "gl_bindings.cc",
30     "gl_bindings.h",
31     "gl_bindings_autogen_gl.cc",
32     "gl_bindings_autogen_gl.h",
33     "gl_bindings_autogen_osmesa.cc",
34     "gl_bindings_autogen_osmesa.h",
35     "gl_bindings_skia_in_process.cc",
36     "gl_bindings_skia_in_process.h",
37     "gl_context.cc",
38     "gl_context.h",
39     "gl_context_android.cc",
40     "gl_context_mac.mm",
41     "gl_context_osmesa.cc",
42     "gl_context_osmesa.h",
43     "gl_context_stub.cc",
44     "gl_context_stub.h",
45     "gl_context_stub_with_extensions.cc",
46     "gl_context_stub_with_extensions.h",
47     "gl_context_win.cc",
48     "gl_enums.cc",
49     "gl_enums.h",
50     "gl_enums_implementation_autogen.h",
51     "gl_export.h",
52     "gl_fence.cc",
53     "gl_fence.h",
54     "gl_fence_arb.cc",
55     "gl_fence_arb.h",
56     "gl_fence_nv.cc",
57     "gl_fence_nv.h",
58     "gl_gl_api_implementation.cc",
59     "gl_gl_api_implementation.h",
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_osmesa.cc",
85     "gl_surface_osmesa.h",
86     "gl_surface_stub.cc",
87     "gl_surface_stub.h",
88     "gl_surface_win.cc",
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     "gpu_timing.cc",
96     "gpu_timing.h",
97     "scoped_binders.cc",
98     "scoped_binders.h",
99     "scoped_make_current.cc",
100     "scoped_make_current.h",
101     "sync_control_vsync_provider.cc",
102     "sync_control_vsync_provider.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   ]
113   all_dependent_configs = [ ":gl_config" ]
115   deps = [
116     "//base/third_party/dynamic_annotations",
117     "//gpu/command_buffer/common",
118     "//skia",
119   ]
120   public_deps = [
121     "//base",
122     "//third_party/mesa:mesa_headers",
123     "//ui/events/platform",
124     "//ui/gfx",
125     "//ui/gfx/geometry",
126   ]
128   if (is_win || is_android || is_linux) {
129     sources += [
130       "egl_util.cc",
131       "egl_util.h",
132       "gl_bindings_autogen_egl.cc",
133       "gl_bindings_autogen_egl.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     ]
143   }
144   if (is_android || is_linux) {
145     sources += [
146       "gl_implementation_osmesa.cc",
147       "gl_implementation_osmesa.h",
148     ]
149   }
150   if (is_linux) {
151     deps += [ "//third_party/libevent" ]
152     sources += [
153       "gl_image_linux_dma_buffer.cc",
154       "gl_image_linux_dma_buffer.h",
155     ]
156   }
157   if (use_x11) {
158     sources += [
159       "gl_bindings_autogen_glx.cc",
160       "gl_bindings_autogen_glx.h",
161       "gl_context_glx.cc",
162       "gl_context_glx.h",
163       "gl_context_x11.cc",
164       "gl_egl_api_implementation.cc",
165       "gl_egl_api_implementation.h",
166       "gl_glx_api_implementation.cc",
167       "gl_glx_api_implementation.h",
168       "gl_image_glx.cc",
169       "gl_image_glx.h",
170       "gl_implementation_x11.cc",
171       "gl_surface_glx.cc",
172       "gl_surface_glx.h",
173       "gl_surface_x11.cc",
174     ]
176     configs += [
177       "//build/config/linux:x11",
178       "//build/config/linux:xcomposite",
179       "//build/config/linux:xext",
180     ]
182     deps += [ "//ui/gfx/x" ]
183   }
184   if (is_win) {
185     sources += [
186       "angle_platform_impl.cc",
187       "angle_platform_impl.h",
188       "gl_bindings_autogen_wgl.cc",
189       "gl_bindings_autogen_wgl.h",
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     ]
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_fence_apple.cc",
208       "gl_fence_apple.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 += [ ":gl_jni_headers" ]
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   }
251   if (is_android && !is_android_webview_build) {
252     deps += [ "//ui/android:ui_java" ]
253   }
256 source_set("gl_unittest_utils") {
257   testonly = true
258   sources = [
259     "gl_bindings_autogen_mock.cc",
260     "gl_bindings_autogen_mock.h",
261     "gl_mock.cc",
262     "gl_mock.h",
263     "gl_mock_autogen_gl.h",
264   ]
266   configs += [ "//third_party/khronos:khronos_headers" ]
268   deps = [
269     ":gl",
270     "//testing/gmock",
271   ]
274 if (is_android) {
275   generate_jar_jni("surface_jni_headers") {
276     jni_package = "ui/gl"
277     classes = [ "android/view/Surface.class" ]
278   }
280   generate_jni("gl_jni_headers") {
281     deps = [
282       ":surface_jni_headers",
283     ]
284     sources = [
285       "../android/java/src/org/chromium/ui/gl/SurfaceTextureListener.java",
286       "../android/java/src/org/chromium/ui/gl/SurfaceTexturePlatformWrapper.java",
287     ]
288     jni_package = "ui/gl"
289   }