1 //
2 // Copyright 2020 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // DisplayApple_api.cpp:
7 //    Chooses CGL or EAGL either at compile time or runtime based on the platform.
8 //
9 
10 #ifndef LIBANGLE_RENDERER_GL_APPLE_DISPLAYAPPLE_API_H_
11 #define LIBANGLE_RENDERER_GL_APPLE_DISPLAYAPPLE_API_H_
12 
13 #include "gpu_info_util/SystemInfo.h"
14 #include "libANGLE/renderer/DisplayImpl.h"
15 
16 #if defined(ANGLE_PLATFORM_MACOS) || defined(ANGLE_PLATFORM_MACCATALYST)
17 #    include "libANGLE/renderer/gl/cgl/DisplayCGL.h"
18 #    if defined(ANGLE_PLATFORM_MACCATALYST) && defined(ANGLE_CPU_ARM64)
19 #        include "libANGLE/renderer/gl/eagl/DisplayEAGL.h"
20 #    endif
21 #elif defined(ANGLE_PLATFORM_IOS)
22 #    include "libANGLE/renderer/gl/eagl/DisplayEAGL.h"
23 #endif
24 
25 namespace rx
26 {
27 
CreateDisplayCGLOrEAGL(const egl::DisplayState & state)28 DisplayImpl *CreateDisplayCGLOrEAGL(const egl::DisplayState &state)
29 {
30 #if defined(ANGLE_PLATFORM_MACOS)
31     return new rx::DisplayCGL(state);
32 #elif defined(ANGLE_PLATFORM_MACCATALYST)
33 #    if defined(ANGLE_CPU_ARM64)
34     angle::SystemInfo info;
35     if (!angle::GetSystemInfo(&info))
36     {
37         return nullptr;
38     }
39 
40     if (info.needsEAGLOnMac)
41     {
42         return new rx::DisplayEAGL(state);
43     }
44     else
45     {
46         return new rx::DisplayCGL(state);
47     }
48 #    else
49     return new rx::DisplayCGL(state);
50 #    endif
51 #elif defined(ANGLE_PLATFORM_IOS)
52     return new rx::DisplayEAGL(state);
53 #endif
54 }
55 
56 }  // namespace rx
57 
58 #endif /* LIBANGLE_RENDERER_GL_APPLE_DISPLAYAPPLE_API_H_ */
59