From 012d15196023467be913ef6d537417be91e68e16 Mon Sep 17 00:00:00 2001 From: James Darpinian Date: Thu, 31 Oct 2019 16:50:23 -0700 Subject: [PATCH] Stop using __has_include __has_include seems to cause problems with goma builds. Instead, detect iOS vs MacOS using TargetConditionals.h. Also use plain C++ instead of Objective-C++ when possible. Bug: angleproject:3439 Bug: 1015591 Change-Id: I816624e0cdc54ad3a18d3891b4efecf6fe640574 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1894243 Reviewed-by: Kenneth Russell Reviewed-by: Jamie Madill Reviewed-by: Geoff Lang Commit-Queue: James Darpinian --- src/common/platform.h | 9 ++++++++ src/gpu_info_util/SystemInfo_mac.mm | 8 ++++--- src/libANGLE/renderer/gl/cgl/DeviceCGL.cpp | 6 +++-- src/libANGLE/renderer/gl/cgl/DisplayCGL.mm | 6 +++-- ...eSurfaceCGL.mm => IOSurfaceSurfaceCGL.cpp} | 8 ++++--- ...ferSurfaceCGL.mm => PbufferSurfaceCGL.cpp} | 23 +++++++++++-------- .../cgl/{RendererCGL.mm => RendererCGL.cpp} | 8 ++++++- .../renderer/gl/cgl/WindowSurfaceCGL.mm | 6 +++-- src/libGLESv2.gni | 6 ++--- 9 files changed, 54 insertions(+), 26 deletions(-) rename src/libANGLE/renderer/gl/cgl/{IOSurfaceSurfaceCGL.mm => IOSurfaceSurfaceCGL.cpp} (98%) rename src/libANGLE/renderer/gl/cgl/{PbufferSurfaceCGL.mm => PbufferSurfaceCGL.cpp} (91%) rename src/libANGLE/renderer/gl/cgl/{RendererCGL.mm => RendererCGL.cpp} (83%) diff --git a/src/common/platform.h b/src/common/platform.h index c981f9c19..60db96d0b 100644 --- a/src/common/platform.h +++ b/src/common/platform.h @@ -114,4 +114,13 @@ # endif // defined(__GNUC__) || defined(__clang__) #endif // !defined(ANGLE_LIKELY) || !defined(ANGLE_UNLIKELY) +#ifdef ANGLE_PLATFORM_APPLE +# include +# if TARGET_OS_OSX +# define ANGLE_PLATFORM_MACOS 1 +# elif TARGET_OS_IOS +# define ANGLE_PLATFORM_IOS 1 +# endif +#endif + #endif // COMMON_PLATFORM_H_ diff --git a/src/gpu_info_util/SystemInfo_mac.mm b/src/gpu_info_util/SystemInfo_mac.mm index 9b4f97bdf..3a90b08ad 100644 --- a/src/gpu_info_util/SystemInfo_mac.mm +++ b/src/gpu_info_util/SystemInfo_mac.mm @@ -4,9 +4,11 @@ // found in the LICENSE file. // -// SystemInfo_mac.cpp: implementation of the Mac-specific parts of SystemInfo.h +// SystemInfo_mac.mm: implementation of the Mac-specific parts of SystemInfo.h -#if __has_include() +#include "common/platform.h" + +#ifdef ANGLE_PLATFORM_MACOS # include "gpu_info_util/SystemInfo_internal.h" @@ -242,4 +244,4 @@ bool GetSystemInfo(SystemInfo *info) } // namespace angle -#endif // __has_include() +#endif // ANGLE_PLATFORM_MACOS diff --git a/src/libANGLE/renderer/gl/cgl/DeviceCGL.cpp b/src/libANGLE/renderer/gl/cgl/DeviceCGL.cpp index 1cddd29f5..f952551e0 100644 --- a/src/libANGLE/renderer/gl/cgl/DeviceCGL.cpp +++ b/src/libANGLE/renderer/gl/cgl/DeviceCGL.cpp @@ -6,7 +6,9 @@ // DeviceCGL.cpp: CGL implementation of egl::Device -#if __has_include() +#include "common/platform.h" + +#ifdef ANGLE_PLATFORM_MACOS # include "libANGLE/renderer/gl/cgl/DeviceCGL.h" @@ -56,4 +58,4 @@ void DeviceCGL::generateExtensions(egl::DeviceExtensions *outExtensions) const } // namespace rx -#endif // __has_include() +#endif // ANGLE_PLATFORM_MACOS diff --git a/src/libANGLE/renderer/gl/cgl/DisplayCGL.mm b/src/libANGLE/renderer/gl/cgl/DisplayCGL.mm index 7ba0f8c30..3cee77462 100644 --- a/src/libANGLE/renderer/gl/cgl/DisplayCGL.mm +++ b/src/libANGLE/renderer/gl/cgl/DisplayCGL.mm @@ -6,7 +6,9 @@ // DisplayCGL.mm: CGL implementation of egl::Display -#if __has_include() +#include "common/platform.h" + +#ifdef ANGLE_PLATFORM_MACOS # include "libANGLE/renderer/gl/cgl/DisplayCGL.h" @@ -446,4 +448,4 @@ void DisplayCGL::populateFeatureList(angle::FeatureList *features) } } -#endif // __has_include() +#endif // ANGLE_PLATFORM_MACOS diff --git a/src/libANGLE/renderer/gl/cgl/IOSurfaceSurfaceCGL.mm b/src/libANGLE/renderer/gl/cgl/IOSurfaceSurfaceCGL.cpp similarity index 98% rename from src/libANGLE/renderer/gl/cgl/IOSurfaceSurfaceCGL.mm rename to src/libANGLE/renderer/gl/cgl/IOSurfaceSurfaceCGL.cpp index 33a0a3f5b..4bb93d0bd 100644 --- a/src/libANGLE/renderer/gl/cgl/IOSurfaceSurfaceCGL.mm +++ b/src/libANGLE/renderer/gl/cgl/IOSurfaceSurfaceCGL.cpp @@ -7,13 +7,15 @@ // PBufferSurfaceCGL.cpp: an implementation of PBuffers created from IOSurfaces using // EGL_ANGLE_iosurface_client_buffer -#if __has_include() +#include "common/platform.h" + +#ifdef ANGLE_PLATFORM_MACOS # include "libANGLE/renderer/gl/cgl/IOSurfaceSurfaceCGL.h" -# import # include # include +# include # include "common/debug.h" # include "libANGLE/AttributeMap.h" @@ -333,4 +335,4 @@ bool IOSurfaceSurfaceCGL::hasEmulatedAlphaChannel() const } // namespace rx -#endif // __has_include() +#endif // ANGLE_PLATFORM_MACOS diff --git a/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.mm b/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.cpp similarity index 91% rename from src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.mm rename to src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.cpp index 398927e80..e81425ede 100644 --- a/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.mm +++ b/src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.cpp @@ -9,11 +9,15 @@ #include "libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.h" -#include "common/debug.h" -#include "libANGLE/renderer/gl/FunctionsGL.h" -#include "libANGLE/renderer/gl/FramebufferGL.h" -#include "libANGLE/renderer/gl/RendererGL.h" -#include "libANGLE/renderer/gl/StateManagerGL.h" +#include "common/platform.h" + +#ifdef ANGLE_PLATFORM_MACOS + +# include "common/debug.h" +# include "libANGLE/renderer/gl/FramebufferGL.h" +# include "libANGLE/renderer/gl/FunctionsGL.h" +# include "libANGLE/renderer/gl/RendererGL.h" +# include "libANGLE/renderer/gl/StateManagerGL.h" namespace rx { @@ -29,8 +33,7 @@ PbufferSurfaceCGL::PbufferSurfaceCGL(const egl::SurfaceState &state, mStateManager(renderer->getStateManager()), mColorRenderbuffer(0), mDSRenderbuffer(0) -{ -} +{} PbufferSurfaceCGL::~PbufferSurfaceCGL() { @@ -98,9 +101,7 @@ egl::Error PbufferSurfaceCGL::releaseTexImage(const gl::Context *context, EGLint return egl::NoError(); } -void PbufferSurfaceCGL::setSwapInterval(EGLint interval) -{ -} +void PbufferSurfaceCGL::setSwapInterval(EGLint interval) {} EGLint PbufferSurfaceCGL::getWidth() const { @@ -141,3 +142,5 @@ FramebufferImpl *PbufferSurfaceCGL::createDefaultFramebuffer(const gl::Context * } } // namespace rx + +#endif // ANGLE_PLATFORM_MACOS diff --git a/src/libANGLE/renderer/gl/cgl/RendererCGL.mm b/src/libANGLE/renderer/gl/cgl/RendererCGL.cpp similarity index 83% rename from src/libANGLE/renderer/gl/cgl/RendererCGL.mm rename to src/libANGLE/renderer/gl/cgl/RendererCGL.cpp index 56f37a9e3..ea1acef0a 100644 --- a/src/libANGLE/renderer/gl/cgl/RendererCGL.mm +++ b/src/libANGLE/renderer/gl/cgl/RendererCGL.cpp @@ -8,7 +8,11 @@ #include "libANGLE/renderer/gl/cgl/RendererCGL.h" -#include "libANGLE/renderer/gl/cgl/DisplayCGL.h" +#include "common/platform.h" + +#ifdef ANGLE_PLATFORM_MACOS + +# include "libANGLE/renderer/gl/cgl/DisplayCGL.h" namespace rx { @@ -27,3 +31,5 @@ WorkerContext *RendererCGL::createWorkerContext(std::string *infoLog) } } // namespace rx + +#endif // ANGLE_PLATFORM_MACOS diff --git a/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.mm b/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.mm index 5fa2f354c..0814659a8 100644 --- a/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.mm +++ b/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.mm @@ -6,7 +6,9 @@ // WindowSurfaceCGL.cpp: CGL implementation of egl::Surface for windows -#if __has_include() +#include "common/platform.h" + +#ifdef ANGLE_PLATFORM_MACOS # include "libANGLE/renderer/gl/cgl/WindowSurfaceCGL.h" @@ -337,4 +339,4 @@ FramebufferImpl *WindowSurfaceCGL::createDefaultFramebuffer(const gl::Context *c } // namespace rx -#endif // __has_include() +#endif // ANGLE_PLATFORM_MACOS diff --git a/src/libGLESv2.gni b/src/libGLESv2.gni index b62126019..c2a9783e4 100644 --- a/src/libGLESv2.gni +++ b/src/libGLESv2.gni @@ -854,11 +854,11 @@ libangle_gl_cgl_sources = [ "src/libANGLE/renderer/gl/cgl/DeviceCGL.h", "src/libANGLE/renderer/gl/cgl/DisplayCGL.mm", "src/libANGLE/renderer/gl/cgl/DisplayCGL.h", - "src/libANGLE/renderer/gl/cgl/IOSurfaceSurfaceCGL.mm", + "src/libANGLE/renderer/gl/cgl/IOSurfaceSurfaceCGL.cpp", "src/libANGLE/renderer/gl/cgl/IOSurfaceSurfaceCGL.h", - "src/libANGLE/renderer/gl/cgl/RendererCGL.mm", + "src/libANGLE/renderer/gl/cgl/RendererCGL.cpp", "src/libANGLE/renderer/gl/cgl/RendererCGL.h", - "src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.mm", + "src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.cpp", "src/libANGLE/renderer/gl/cgl/PbufferSurfaceCGL.h", "src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.mm", "src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.h",