Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
test_swangle_utils.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter 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.
4
6
7#include <EGL/egl.h>
8#include <EGL/eglext.h>
9
10#include <cstring>
11
12#include "flutter/fml/logging.h"
13
14namespace flutter::testing {
15
16namespace {
17
18bool HasExtension(const char* extensions, const char* name) {
19 const char* r = strstr(extensions, name);
20 auto len = strlen(name);
21 // check that the extension name is terminated by space or null terminator
22 return r != nullptr && (r[len] == ' ' || r[len] == 0);
23}
24
25} // namespace
26
28 const char* extensions = ::eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
29
30 if (!extensions) {
31 FML_LOG(ERROR) << "Could not query EGL extensions.";
32 return EGL_NO_DISPLAY;
33 }
34
35 if (!HasExtension(extensions, "EGL_EXT_platform_base")) {
36 FML_LOG(ERROR) << "EGL_EXT_platform_base extension not available";
37 return EGL_NO_DISPLAY;
38 }
39
40 if (!HasExtension(extensions, "EGL_ANGLE_platform_angle_vulkan")) {
41 FML_LOG(ERROR) << "EGL_ANGLE_platform_angle_vulkan extension not available";
42 return EGL_NO_DISPLAY;
43 }
44
45 if (!HasExtension(extensions,
46 "EGL_ANGLE_platform_angle_device_type_swiftshader")) {
47 FML_LOG(ERROR) << "EGL_ANGLE_platform_angle_device_type_swiftshader "
48 "extension not available";
49 return EGL_NO_DISPLAY;
50 }
51
52 PFNEGLGETPLATFORMDISPLAYEXTPROC egl_get_platform_display_EXT =
53 reinterpret_cast<PFNEGLGETPLATFORMDISPLAYEXTPROC>(
54 eglGetProcAddress("eglGetPlatformDisplayEXT"));
55
56 if (!egl_get_platform_display_EXT) {
57 FML_LOG(ERROR) << "eglGetPlatformDisplayEXT not available.";
58 return EGL_NO_DISPLAY;
59 }
60
61 const EGLint display_config[] = {
62 EGL_PLATFORM_ANGLE_TYPE_ANGLE,
63 EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE,
64 EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE,
65 EGL_PLATFORM_ANGLE_DEVICE_TYPE_SWIFTSHADER_ANGLE,
66 EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE,
67 EGL_PLATFORM_VULKAN_DISPLAY_MODE_HEADLESS_ANGLE,
68 EGL_NONE,
69 };
70
71 return egl_get_platform_display_EXT(
72 EGL_PLATFORM_ANGLE_ANGLE,
73 reinterpret_cast<EGLNativeDisplayType*>(EGL_DEFAULT_DISPLAY),
74 display_config);
75}
76
77} // namespace flutter::testing
#define FML_LOG(severity)
Definition logging.h:101
static bool HasExtension(const char *extensions, const char *name)
EGLDisplay CreateSwangleDisplay()
Creates an EGLDisplay using ANGLE with the Vulkan backend and SwiftShader as the device type.
DEF_SWITCHES_START aot vmservice shared library name
Definition switch_defs.h:27