xref: /aosp_15_r20/external/skia/tools/window/BUILD.gn (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1# Copyright 2023 Google Inc.
2#
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6import("../../gn/skia.gni")
7
8if (skia_use_dawn) {
9  import("//third_party/externals/dawn/scripts/dawn_features.gni")
10}
11
12config("public_config") {
13  defines = []
14  include_dirs = [ "." ]
15}
16
17skia_component("window") {
18  check_includes = false
19  testonly = true  # For access to gpu_tool_utils. TODO: clean up
20  public_configs = [ ":public_config" ]
21  public = [
22    "DisplayParams.h",
23    "WindowContext.h",
24  ]
25  sources = [
26    "DisplayParams.h",
27    "RasterWindowContext.h",
28    "WindowContext.cpp",
29    "WindowContext.h",
30  ]
31
32  libs = []
33  frameworks = []
34
35  if (is_android) {
36    sources += [
37      "android/RasterWindowContext_android.cpp",
38      "android/WindowContextFactory_android.h",
39    ]
40    libs += [ "android" ]
41  } else if (is_linux) {
42    sources += [
43      "unix/RasterWindowContext_unix.cpp",
44      "unix/RasterWindowContext_unix.h",
45      "unix/XlibWindowInfo.h",
46    ]
47    libs += [ "X11" ]
48  } else if (is_win) {
49    sources += [
50      "win/RasterWindowContext_win.cpp",
51      "win/WindowContextFactory_win.h",
52    ]
53  } else if (is_mac) {
54    sources += [ "mac/MacWindowInfo.h" ]
55    frameworks += [
56      "QuartzCore.framework",
57      "Cocoa.framework",
58      "Foundation.framework",
59    ]
60  } else if (is_ios) {
61    sources += [ "ios/WindowContextFactory_ios.h" ]
62    frameworks += [ "QuartzCore.framework" ]
63  }
64
65  if (skia_use_gl) {
66    sources += [
67      "GLWindowContext.cpp",
68      "GLWindowContext.h",
69    ]
70    if (skia_use_angle) {
71      sources += [ "ANGLEWindowContext.cpp" ]
72    }
73    if (is_android) {
74      sources += [ "android/GLWindowContext_android.cpp" ]
75    } else if (is_linux) {
76      sources += [
77        "unix/GaneshGLWindowContext_unix.cpp",
78        "unix/GaneshGLWindowContext_unix.h",
79      ]
80      libs += [ "GL" ]
81    } else if (is_win) {
82      sources += [ "win/GLWindowContext_win.cpp" ]
83      if (skia_use_angle) {
84        sources += [ "win/ANGLEWindowContext_win.cpp" ]
85      }
86    } else if (is_mac) {
87      sources += [
88        # The Mac Raster implementation has a GL dependency
89        "mac/GaneshGLWindowContext_mac.h",
90        "mac/GaneshGLWindowContext_mac.mm",
91        "mac/MacWindowGLUtils.h",
92        "mac/RasterWindowContext_mac.h",
93        "mac/RasterWindowContext_mac.mm",
94      ]
95      if (skia_use_angle) {
96        sources += [
97          "mac/GaneshANGLEWindowContext_mac.h",
98          "mac/GaneshANGLEWindowContext_mac.mm",
99          "mac/MacWindowGLUtils.h",
100        ]
101      }
102    } else if (is_ios) {
103      sources += [
104        "ios/GLWindowContext_ios.mm",
105        "ios/RasterWindowContext_ios.mm",
106      ]
107    }
108  }
109
110  if (skia_use_vulkan) {
111    sources += [
112      "VulkanWindowContext.cpp",
113      "VulkanWindowContext.h",
114    ]
115    if (skia_enable_graphite) {
116      sources += [
117        "GraphiteNativeVulkanWindowContext.cpp",
118        "GraphiteNativeVulkanWindowContext.h",
119      ]
120    }
121    if (is_android) {
122      sources += [ "android/VulkanWindowContext_android.cpp" ]
123      if (skia_enable_graphite) {
124        sources += [ "android/GraphiteVulkanWindowContext_android.cpp" ]
125      }
126    } else if (is_linux) {
127      sources += [
128        "unix/GaneshVulkanWindowContext_unix.cpp",
129        "unix/GaneshVulkanWindowContext_unix.h",
130      ]
131      if (skia_enable_graphite) {
132        sources += [
133          "unix/GraphiteNativeVulkanWindowContext_unix.cpp",
134          "unix/GraphiteNativeVulkanWindowContext_unix.h",
135        ]
136      }
137      libs += [ "X11-xcb" ]
138    } else if (is_win) {
139      sources += [ "win/VulkanWindowContext_win.cpp" ]
140      if (skia_enable_graphite) {
141        sources += [ "win/GraphiteVulkanWindowContext_win.cpp" ]
142      }
143    }
144  }
145
146  if (skia_use_metal) {
147    sources += [
148      "MetalWindowContext.h",
149      "MetalWindowContext.mm",
150    ]
151    if (skia_enable_graphite) {
152      sources += [
153        "GraphiteNativeMetalWindowContext.h",
154        "GraphiteNativeMetalWindowContext.mm",
155      ]
156    }
157    if (is_mac) {
158      sources += [
159        "mac/GaneshMetalWindowContext_mac.h",
160        "mac/GaneshMetalWindowContext_mac.mm",
161      ]
162      if (skia_enable_graphite) {
163        sources += [
164          "mac/GraphiteNativeMetalWindowContext_mac.h",
165          "mac/GraphiteNativeMetalWindowContext_mac.mm",
166        ]
167      }
168    } else if (is_ios) {
169      sources += [ "ios/MetalWindowContext_ios.mm" ]
170      if (skia_enable_graphite) {
171        sources += [ "ios/GraphiteMetalWindowContext_ios.mm" ]
172      }
173    }
174  }
175
176  if (skia_use_direct3d) {
177    sources += [ "win/D3D12WindowContext_win.cpp" ]
178  }
179
180  if (skia_use_dawn) {
181    if (is_linux) {
182      if (dawn_enable_vulkan) {
183        defines = [ "VK_USE_PLATFORM_XCB_KHR" ]
184        libs += [ "X11-xcb" ]
185        if (skia_enable_graphite) {
186          sources += [
187            "GraphiteDawnWindowContext.cpp",
188            "GraphiteDawnWindowContext.h",
189            "unix/GraphiteDawnVulkanWindowContext_unix.cpp",
190            "unix/GraphiteDawnVulkanWindowContext_unix.h",
191          ]
192        }
193      }
194    } else if (is_win) {
195      if (dawn_enable_d3d12 || dawn_enable_d3d11 || dawn_enable_vulkan) {
196        if (skia_enable_graphite) {
197          sources += [
198            "GraphiteDawnWindowContext.cpp",
199            "GraphiteDawnWindowContext.h",
200            "win/GraphiteDawnD3D12WindowContext_win.cpp",
201          ]
202        }
203      }
204    } else if (is_mac) {
205      if (dawn_enable_metal) {
206        if (skia_enable_graphite) {
207          sources += [
208            "GraphiteDawnWindowContext.cpp",
209            "GraphiteDawnWindowContext.h",
210            "mac/GraphiteDawnMetalWindowContext_mac.h",
211            "mac/GraphiteDawnMetalWindowContext_mac.mm",
212          ]
213        }
214      }
215    }
216  }
217
218  configs = [ "../../:skia_private" ]
219  deps = [
220    "../..:gpu_tool_utils",
221    "../..:skia",
222  ]
223
224  if (skia_use_gl && skia_use_angle) {
225    deps += [ "//third_party/angle2" ]
226  }
227}
228