1# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
2# vim: set filetype=python:
3# This Source Code Form is subject to the terms of the Mozilla Public
4# License, v. 2.0. If a copy of the MPL was not distributed with this
5# file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7gl_provider = "Null"
8
9if CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows":
10    gl_provider = "WGL"
11elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa":
12    gl_provider = "CGL"
13elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "uikit":
14    gl_provider = "EAGL"
15elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk":
16    if CONFIG["MOZ_EGL_XRENDER_COMPOSITE"]:
17        gl_provider = "EGL"
18    else:
19        gl_provider = "GLX"
20elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "android":
21    gl_provider = "EGL"
22
23if CONFIG["MOZ_GL_PROVIDER"]:
24    gl_provider = CONFIG["MOZ_GL_PROVIDER"]
25
26EXPORTS += [
27    "AndroidSurfaceTexture.h",
28    "DecomposeIntoNoRepeatTriangles.h",
29    "ForceDiscreteGPUHelperCGL.h",
30    "GfxTexturesReporter.h",
31    "GLBlitHelper.h",
32    "GLConsts.h",
33    "GLContext.h",
34    "GLContextEGL.h",
35    "GLContextProvider.h",
36    "GLContextProviderImpl.h",
37    "GLContextSymbols.h",
38    "GLContextTypes.h",
39    "GLDefs.h",
40    "GLLibraryEGL.h",
41    "GLLibraryLoader.h",
42    "GLReadTexImageHelper.h",
43    "GLScreenBuffer.h",
44    "GLTextureImage.h",
45    "GLTypes.h",
46    "GLUploadHelpers.h",
47    "HeapCopyOfStackArray.h",
48    "MozFramebuffer.h",
49    "ScopedGLHelpers.h",
50    "SharedSurface.h",
51    "SharedSurfaceEGL.h",
52    "SharedSurfaceGL.h",
53    "SurfaceTypes.h",
54]
55
56# Win32 is a special snowflake, for ANGLE
57if CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows":
58    EXPORTS += [
59        "GLContextWGL.h",
60        "SharedSurfaceANGLE.h",  # Needs <windows.h> for `HANDLE`.
61        "SharedSurfaceD3D11Interop.h",
62        "WGLLibrary.h",
63    ]
64    UNIFIED_SOURCES += [
65        "GLBlitHelperD3D.cpp",
66        "GLContextProviderWGL.cpp",
67        "SharedSurfaceANGLE.cpp",
68        "SharedSurfaceD3D11Interop.cpp",
69    ]
70
71if CONFIG["MOZ_WIDGET_TOOLKIT"] == "android":
72    EXPORTS += [
73        "AndroidNativeWindow.h",
74        "SharedSurfaceAndroidHardwareBuffer.h",
75    ]
76    UNIFIED_SOURCES += [
77        "SharedSurfaceAndroidHardwareBuffer.cpp",
78    ]
79
80if gl_provider == "CGL":
81    # These files include Mac headers that are unfriendly to unified builds
82    SOURCES += [
83        "GLContextProviderCGL.mm",
84    ]
85    EXPORTS += [
86        "GLContextCGL.h",
87        "SharedSurfaceIO.h",
88    ]
89    # SharedSurfaceIO.cpp includes MacIOSurface.h which include Mac headers
90    # which define Size and Point types in root namespace with often conflict with
91    # our own types. While I haven't actually hit this issue in the present case,
92    # it's been an issue in gfx/layers so let's not risk it.
93    SOURCES += [
94        "SharedSurfaceIO.cpp",
95    ]
96    OS_LIBS += [
97        "-framework IOSurface",
98    ]
99
100elif gl_provider == "EAGL":
101    # These files include ObjC headers that are unfriendly to unified builds
102    SOURCES += [
103        "GLContextProviderEAGL.mm",
104    ]
105    EXPORTS += [
106        "GLContextEAGL.h",
107    ]
108
109elif gl_provider == "GLX":
110    # GLContextProviderGLX.cpp needs to be kept out of UNIFIED_SOURCES
111    # as it includes X11 headers which cause conflicts.
112    SOURCES += [
113        "GLContextProviderGLX.cpp",
114        "GLContextProviderX11.cpp",
115        "SharedSurfaceGLX.cpp",
116    ]
117    EXPORTS += ["GLContextGLX.h", "GLXLibrary.h", "SharedSurfaceGLX.h"]
118
119if CONFIG["MOZ_WAYLAND"]:
120    SOURCES += ["GLContextProviderWayland.cpp", "SharedSurfaceDMABUF.cpp"]
121
122UNIFIED_SOURCES += [
123    "AndroidSurfaceTexture.cpp",
124    "DecomposeIntoNoRepeatTriangles.cpp",
125    "GfxTexturesReporter.cpp",
126    "GLBlitHelper.cpp",
127    "GLContext.cpp",
128    "GLContextFeatures.cpp",
129    "GLContextProviderEGL.cpp",
130    "GLDebugUtils.cpp",
131    "GLLibraryEGL.cpp",
132    "GLLibraryLoader.cpp",
133    "GLReadTexImageHelper.cpp",
134    "GLTextureImage.cpp",
135    "GLUploadHelpers.cpp",
136    "MozFramebuffer.cpp",
137    "ScopedGLHelpers.cpp",
138    "SharedSurface.cpp",
139    "SharedSurfaceEGL.cpp",
140    "SharedSurfaceGL.cpp",
141]
142SOURCES += [
143    "GLScreenBuffer.cpp",
144]
145
146include("/ipc/chromium/chromium-config.mozbuild")
147
148FINAL_LIBRARY = "xul"
149
150if CONFIG["MOZ_D3DCOMPILER_VISTA_DLL"]:
151    DEFINES["MOZ_D3DCOMPILER_VISTA_DLL"] = CONFIG["MOZ_D3DCOMPILER_VISTA_DLL"]
152
153CXXFLAGS += CONFIG["MOZ_CAIRO_CFLAGS"]
154CXXFLAGS += CONFIG["TK_CFLAGS"]
155CFLAGS += CONFIG["MOZ_CAIRO_CFLAGS"]
156CFLAGS += CONFIG["TK_CFLAGS"]
157
158CXXFLAGS += ["-Werror=switch"]
159
160if CONFIG["MOZ_WAYLAND"]:
161    CXXFLAGS += CONFIG["MOZ_WAYLAND_CFLAGS"]
162    CFLAGS += CONFIG["MOZ_WAYLAND_CFLAGS"]
163
164LOCAL_INCLUDES += CONFIG["SKIA_INCLUDES"]
165
166if CONFIG["CC_TYPE"] in ("clang", "gcc"):
167    CXXFLAGS += ["-Wno-error=shadow"]
168