0

ui/gl: Use BUILDFLAG for OS checking

Use BUILDFLAG(IS_XXX) instead of defined(OS_XXX).

Generated by `os_buildflag_migration.py` (https://crrev.com/c/3311983).

R=thakis@chromium.org

Bug: 1234043
Test: No functionality change
Change-Id: I56085b377c2d824afa52faa9ac6cd4cabb184297
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3403352
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/main@{#961344}
This commit is contained in:
Xiaohan Wang
2022-01-20 06:59:15 +00:00
committed by Chromium LUCI CQ
parent d5bf6f7f93
commit 07d6fc6039
36 changed files with 109 additions and 104 deletions

@ -27,7 +27,7 @@ class EGLApiTest : public testing::Test {
g_driver_egl.fn.eglGetErrorFn = &FakeGetError;
g_driver_egl.fn.eglGetProcAddressFn = &FakeGetProcAddress;
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
SetGLImplementation(kGLImplementationEGLANGLE);
#else
SetGLImplementation(kGLImplementationEGLGLES2);

@ -6,7 +6,7 @@
#include "build/build_config.h"
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
#include <EGL/egl.h>
#else
#include "third_party/khronos/EGL/egl.h"

@ -13,7 +13,7 @@
// __STDC_FORMAT_MACROS is defined in order for //base/format_macros.h to
// function correctly. See comment and #error message in //base/format_macros.h
// for details.
#if defined(OS_POSIX) && !defined(__STDC_FORMAT_MACROS)
#if BUILDFLAG(IS_POSIX) && !defined(__STDC_FORMAT_MACROS)
#define __STDC_FORMAT_MACROS
#endif
@ -32,9 +32,9 @@
#include "ui/gl/gl_export.h"
// The standard OpenGL native extension headers are also included.
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include <GL/wglext.h>
#elif defined(OS_APPLE)
#elif BUILDFLAG(IS_APPLE)
#include <OpenGL/OpenGL.h>
#elif defined(USE_GLX)
using Display = struct _XDisplay;
@ -483,7 +483,7 @@ struct XVisualInfo;
#define GL_GLEXT_PROTOTYPES 1
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#define GL_BINDING_CALL WINAPI
#else
#define GL_BINDING_CALL

@ -25,7 +25,7 @@
#include "ui/gl/gl_version_info.h"
#include "ui/gl/gpu_timing.h"
#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
#include "base/mac/mac_util.h"
#endif
@ -74,7 +74,7 @@ GLContext::GLContext(GLShareGroup* share_group) : share_group_(share_group) {
}
GLContext::~GLContext() {
#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
DCHECK(!HasBackpressureFences());
#endif
share_group_->RemoveContext(this);
@ -185,7 +185,7 @@ void GLContext::DirtyVirtualContextState() {
current_virtual_context_ = nullptr;
}
#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
constexpr uint64_t kInvalidFenceId = 0;
uint64_t GLContext::BackpressureFenceCreate() {

@ -247,7 +247,7 @@ class GL_EXPORT GLContext : public base::RefCounted<GLContext>,
// context is made current.
void DirtyVirtualContextState();
#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
// Create a fence for all work submitted to this context so far, and return a
// monotonically increasing handle to it. This returned handle never needs to
// be freed. This method is used to create backpressure to throttle GL work
@ -297,7 +297,7 @@ class GL_EXPORT GLContext : public base::RefCounted<GLContext>,
GLApi* gl_api() { return gl_api_wrapper_->api(); }
#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
// Child classes are responsible for calling DestroyBackpressureFences during
// their destruction while a context is current.
bool HasBackpressureFences() const;
@ -338,7 +338,7 @@ class GL_EXPORT GLContext : public base::RefCounted<GLContext>,
// where this underlying context becomes lost. https://crbug.com/1061442
bool context_lost_ = false;
#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
std::map<uint64_t, std::unique_ptr<GLFence>> backpressure_fences_;
uint64_t next_backpressure_fence_ = 0;
#endif

@ -404,7 +404,7 @@ void GLContextEGL::SetVisibility(bool visibility) {
}
void GLContextEGL::ReleaseYUVToRGBConvertersAndBackpressureFences() {
#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
bool has_backpressure_fences = HasBackpressureFences();
#else
bool has_backpressure_fences = false;
@ -434,7 +434,7 @@ void GLContextEGL::ReleaseYUVToRGBConvertersAndBackpressureFences() {
}
yuv_to_rgb_converters_.clear();
#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
DestroyBackpressureFences();
#endif

@ -4,6 +4,7 @@
#include "ui/gl/gl_context_stub.h"
#include "build/build_config.h"
#include "ui/gl/gl_gl_api_implementation.h"
#include "ui/gl/gl_stub_api.h"
@ -75,7 +76,7 @@ bool GLContextStub::HasRobustness() {
HasExtension("GL_KHR_robustness") || HasExtension("GL_EXT_robustness");
}
#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
void GLContextStub::FlushForDriverCrashWorkaround() {}
#endif

@ -38,7 +38,7 @@ class GL_EXPORT GLContextStub : public GLContextReal {
void SetGLVersionString(const char* version_str);
bool HasRobustness();
#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
void FlushForDriverCrashWorkaround() override;
#endif

@ -10,7 +10,7 @@
#include "build/chromeos_buildflags.h"
#include "ui/gl/gl_switches.h"
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
#include "base/android/build_info.h"
#include "base/metrics/field_trial_params.h"
#include "base/strings/pattern.h"
@ -22,7 +22,7 @@ namespace {
const base::Feature kGpuVsync{"GpuVsync", base::FEATURE_ENABLED_BY_DEFAULT};
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
const base::FeatureParam<std::string>
kPassthroughCommandDecoderBlockListByBrand{
&kDefaultPassthroughCommandDecoder, "BlockListByBrand", ""};
@ -71,8 +71,8 @@ bool IsDeviceBlocked(const char* field, const std::string& block_list) {
// Launched on Windows, still experimental on other platforms.
const base::Feature kDefaultPassthroughCommandDecoder {
"DefaultPassthroughCommandDecoder",
#if defined(OS_WIN) || defined(OS_FUCHSIA) || \
((defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) && \
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_FUCHSIA) || \
((BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) && \
!defined(CHROMECAST_BUILD))
base::FEATURE_ENABLED_BY_DEFAULT
#else
@ -90,7 +90,7 @@ bool UsePassthroughCommandDecoder() {
if (!base::FeatureList::IsEnabled(kDefaultPassthroughCommandDecoder))
return false;
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
// Check block list against build info.
const auto* build_info = base::android::BuildInfo::GetInstance();
if (IsDeviceBlocked(build_info->brand(),
@ -116,7 +116,7 @@ bool UsePassthroughCommandDecoder() {
build_info->android_build_fp(),
kPassthroughCommandDecoderBlockListByAndroidBuildFP.Get()))
return false;
#endif // defined(OS_ANDROID)
#endif // BUILDFLAG(IS_ANDROID)
return true;
}

@ -14,17 +14,17 @@
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_version_info.h"
#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
#include "ui/gl/gl_fence_apple.h"
#endif
#if defined(USE_EGL) && defined(OS_POSIX) && !defined(OS_APPLE)
#if defined(USE_EGL) && BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_APPLE)
#define USE_GL_FENCE_ANDROID_NATIVE_FENCE_SYNC
#include "ui/gl/gl_fence_android_native_fence_sync.h"
#include "ui/gl/gl_surface_egl.h"
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include "ui/gl/gl_fence_win.h"
#endif
@ -41,7 +41,7 @@ bool GLFence::IsSupported() {
return g_current_gl_driver->ext.b_GL_ARB_sync ||
g_current_gl_version->is_es3 ||
g_current_gl_version->is_desktop_core_profile ||
#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
g_current_gl_driver->ext.b_GL_APPLE_fence ||
#else
g_driver_egl.ext.b_EGL_KHR_fence_sync ||
@ -54,7 +54,7 @@ std::unique_ptr<GLFence> GLFence::Create() {
<< "Trying to create fence with no context";
std::unique_ptr<GLFence> fence;
#if !defined(OS_APPLE)
#if !BUILDFLAG(IS_APPLE)
if (g_driver_egl.ext.b_EGL_KHR_fence_sync &&
g_driver_egl.ext.b_EGL_KHR_wait_sync) {
// Prefer GLFenceEGL which doesn't require GL context switching.
@ -67,7 +67,7 @@ std::unique_ptr<GLFence> GLFence::Create() {
g_current_gl_version->is_desktop_core_profile) {
// Prefer ARB_sync which supports server-side wait.
fence = std::make_unique<GLFenceARB>();
#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
} else if (g_current_gl_driver->ext.b_GL_APPLE_fence) {
fence = std::make_unique<GLFenceAPPLE>();
#else
@ -99,7 +99,7 @@ void GLFence::Invalidate() {
bool GLFence::IsGpuFenceSupported() {
#if defined(USE_GL_FENCE_ANDROID_NATIVE_FENCE_SYNC)
return gl::GLSurfaceEGL::IsAndroidNativeFenceSyncSupported();
#elif defined(OS_WIN)
#elif BUILDFLAG(IS_WIN)
return gl::GLFenceWin::IsSupported();
#else
return false;
@ -112,7 +112,7 @@ std::unique_ptr<GLFence> GLFence::CreateFromGpuFence(
DCHECK(IsGpuFenceSupported());
#if defined(USE_GL_FENCE_ANDROID_NATIVE_FENCE_SYNC)
return GLFenceAndroidNativeFenceSync::CreateFromGpuFence(gpu_fence);
#elif defined(OS_WIN)
#elif BUILDFLAG(IS_WIN)
return GLFenceWin::CreateFromGpuFence(gpu_fence);
#else
NOTREACHED();
@ -125,7 +125,7 @@ std::unique_ptr<GLFence> GLFence::CreateForGpuFence() {
DCHECK(IsGpuFenceSupported());
#if defined(USE_GL_FENCE_ANDROID_NATIVE_FENCE_SYNC)
return GLFenceAndroidNativeFenceSync::CreateForGpuFence();
#elif defined(OS_WIN)
#elif BUILDFLAG(IS_WIN)
return GLFenceWin::CreateForGpuFence();
#else
NOTREACHED();

@ -10,11 +10,12 @@
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "ui/gfx/gpu_fence.h"
#include "ui/gfx/gpu_fence_handle.h"
#include "ui/gl/gl_surface_egl.h"
#if defined(OS_POSIX) || defined(OS_FUCHSIA)
#if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
#include <unistd.h>
#include "base/posix/eintr_wrapper.h"

@ -5,9 +5,10 @@
#include "ui/gl/gl_image.h"
#include "base/notreached.h"
#include "build/build_config.h"
#include "ui/gl/gl_bindings.h"
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
#include "base/android/scoped_hardware_buffer_fence_sync.h"
#endif
@ -118,7 +119,7 @@ GLImage::Type GLImage::GetType() const {
return Type::NONE;
}
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
std::unique_ptr<base::android::ScopedHardwareBufferFenceSync>
GLImage::GetAHardwareBuffer() {
return nullptr;

@ -23,7 +23,7 @@
#include "ui/gfx/overlay_transform.h"
#include "ui/gl/gl_export.h"
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
#include <android/hardware_buffer.h>
#include <memory>
#include "base/android/scoped_hardware_buffer_handle.h"
@ -126,7 +126,7 @@ class GL_EXPORT GLImage : public base::RefCounted<GLImage> {
// If called, then IsInUseByWindowServer will always return false.
virtual void DisableInUseByWindowServer();
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
// Provides the buffer backing this image, if it is backed by an
// AHardwareBuffer. The ScopedHardwareBuffer returned may include a fence
// which will be signaled when all pending work for the buffer has been

@ -266,9 +266,9 @@ bool GLImageMemory::Initialize(const unsigned char* memory,
stride_ = stride;
bool tex_image_from_pbo_is_slow = false;
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
tex_image_from_pbo_is_slow = true;
#endif // OS_WIN
#endif // BUILDFLAG(IS_WIN)
GLContext* context = GLContext::GetCurrent();
DCHECK(context);
if (!tex_image_from_pbo_is_slow && SupportsPBO(context) &&

@ -275,11 +275,11 @@ gfx::NativePixmapHandle GLImageNativePixmap::ExportHandle() {
}
}
#if defined(OS_FUCHSIA)
#if BUILDFLAG(IS_FUCHSIA)
// TODO(crbug.com/852011): Implement image handle export on Fuchsia.
NOTIMPLEMENTED();
return gfx::NativePixmapHandle();
#else // defined(OS_FUCHSIA)
#else // BUILDFLAG(IS_FUCHSIA)
std::vector<int> fds(num_planes);
std::vector<EGLint> strides(num_planes);
std::vector<EGLint> offsets(num_planes);
@ -308,7 +308,7 @@ gfx::NativePixmapHandle GLImageNativePixmap::ExportHandle() {
}
return handle;
#endif // !defined(OS_FUCHSIA)
#endif // BUILDFLAG(IS_FUCHSIA)
}
unsigned GLImageNativePixmap::GetInternalFormat() {

@ -34,7 +34,7 @@ class GLImageNativePixmapTestDelegate : public GLImageTestDelegateBase {
public:
absl::optional<GLImplementationParts> GetPreferedGLImplementation()
const override {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
return absl::optional<GLImplementationParts>(GLImplementationParts(
kGLImplementationEGLANGLE, ANGLEImplementation::kNone));
#else

@ -51,7 +51,7 @@ using GLImageTestTypes = testing::Types<
GLImageSharedMemoryTestDelegate<gfx::BufferFormat::RGBX_8888>,
GLImageSharedMemoryTestDelegate<gfx::BufferFormat::RGBA_8888>,
GLImageSharedMemoryTestDelegate<gfx::BufferFormat::BGRX_8888>,
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
// Fails on Win nVidia and linux android: the test writes nothing (we read
// back the color used to clear the buffer).
// TODO(mcasas): enable those paltforms https://crbug.com/803451.
@ -115,7 +115,7 @@ class GLImageSharedMemoryPoolTestDelegate : public GLImageTestDelegateBase {
};
// Disabled on Windows, see crbug.com/1036138
#if !defined(OS_WIN)
#if !BUILDFLAG(IS_WIN)
INSTANTIATE_TYPED_TEST_SUITE_P(GLImageSharedMemoryPool,
GLImageCopyTest,
GLImageSharedMemoryPoolTestDelegate);

@ -160,7 +160,7 @@ const struct {
GLImplementationParts(kGLImplementationDesktopGL)},
{kGLImplementationSwiftShaderName, kANGLEImplementationNoneName,
GLImplementationParts(kGLImplementationSwiftShaderGL)},
#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
{kGLImplementationAppleName, kANGLEImplementationNoneName,
GLImplementationParts(kGLImplementationAppleGL)},
#endif

@ -83,7 +83,7 @@ struct GL_EXPORT GLWindowSystemBindingInfo {
};
using GLFunctionPointerType = void (*)();
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
typedef GLFunctionPointerType(WINAPI* GLGetProcAddressProc)(const char* name);
#else
typedef GLFunctionPointerType (*GLGetProcAddressProc)(const char* name);

@ -12,7 +12,7 @@
namespace gl {
GLShareGroup::GLShareGroup()
#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
: renderer_id_(-1)
#endif
{
@ -50,7 +50,7 @@ void GLShareGroup::SetSharedContext(GLContext* context) {
shared_context_ = context;
}
#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
void GLShareGroup::SetRendererID(int renderer_id) {
renderer_id_ = renderer_id;
}

@ -41,7 +41,7 @@ class GL_EXPORT GLShareGroup : public base::RefCounted<GLShareGroup> {
void SetSharedContext(GLContext* context);
GLContext* shared_context() { return shared_context_; }
#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
// Sets and returns the ID of the renderer that all contexts in this share
// group should be on.
void SetRendererID(int renderer_id);
@ -60,7 +60,7 @@ class GL_EXPORT GLShareGroup : public base::RefCounted<GLShareGroup> {
raw_ptr<GLContext> shared_context_ = nullptr;
#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
int renderer_id_;
#endif
};

@ -42,7 +42,7 @@
#include "ui/gl/scoped_make_current.h"
#include "ui/gl/sync_control_vsync_provider.h"
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
#include <android/native_window_jni.h>
#include "base/android/build_info.h"
#endif
@ -896,7 +896,7 @@ void GetEGLInitDisplays(bool supports_angle_d3d,
if (supports_angle_opengl) {
if (use_angle_default && !supports_angle_d3d) {
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
// Don't request desktopGL on android
AddInitDisplay(init_displays, ANGLE_OPENGLES);
#else
@ -1065,7 +1065,7 @@ bool GLSurfaceEGL::InitializeOneOffCommon() {
// because it is emulated with pbuffers if native support is not present. See
// https://crbug.com/382349.
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
// Use the WebGL compatibility extension for detecting ANGLE. ANGLE always
// exposes it.
bool is_angle = g_egl_create_context_webgl_compatability_supported;
@ -1103,7 +1103,7 @@ bool GLSurfaceEGL::InitializeOneOffCommon() {
// that version onward.
g_egl_android_native_fence_sync_supported =
HasEGLExtension("EGL_ANDROID_native_fence_sync");
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
if (!g_egl_android_native_fence_sync_supported &&
base::android::BuildInfo::GetInstance()->sdk_int() >=
base::android::SDK_VERSION_NOUGAT &&
@ -1459,12 +1459,12 @@ NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(
EGLNativeWindowType window,
std::unique_ptr<gfx::VSyncProvider> vsync_provider)
: window_(window), vsync_provider_external_(std::move(vsync_provider)) {
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
if (window)
ANativeWindow_acquire(window);
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
RECT windowRect;
if (GetClientRect(window_, &windowRect))
size_ = gfx::Rect(windowRect).size();
@ -2126,7 +2126,7 @@ bool NativeViewGLSurfaceEGL::ScheduleOverlayPlane(
NativeViewGLSurfaceEGL::~NativeViewGLSurfaceEGL() {
Destroy();
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
if (window_)
ANativeWindow_release(window_);
#endif
@ -2144,7 +2144,7 @@ PbufferGLSurfaceEGL::PbufferGLSurfaceEGL(const gfx::Size& size)
bool PbufferGLSurfaceEGL::Initialize(GLSurfaceFormat format) {
EGLSurface old_surface = surface_;
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
// This is to allow context virtualization which requires on- and offscreen
// to use a compatible config. We expect the client to request RGB565
// onscreen surface also for this to work (with the exception of
@ -2244,7 +2244,7 @@ EGLSurface PbufferGLSurfaceEGL::GetHandle() {
}
void* PbufferGLSurfaceEGL::GetShareHandle() {
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
NOTREACHED();
return NULL;
#else

@ -7,7 +7,7 @@
#include "build/build_config.h"
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include <windows.h>
#endif

@ -13,7 +13,7 @@
#include "ui/gl/init/gl_factory.h"
#include "ui/gl/test/gl_surface_test_support.h"
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include "ui/platform_window/platform_window_delegate.h"
#include "ui/platform_window/win/win_window.h"
#endif
@ -31,7 +31,7 @@ namespace {
class GLSurfaceEGLTest : public testing::Test {
protected:
void SetUp() override {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
GLSurfaceTestSupport::InitializeOneOffImplementation(
GLImplementationParts(kGLImplementationEGLANGLE), true);
#else
@ -67,7 +67,7 @@ TEST_F(GLSurfaceEGLTest, MAYBE_SurfaceFormatTest) {
}
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
class TestPlatformDelegate : public ui::PlatformWindowDelegate {
public:

@ -215,7 +215,7 @@ void GLSurfacePresentationHelper::OnMakeCurrent(GLContext* context,
// https://crbug.com/854298 : disable GLFence on Android as they seem to cause
// issues on some devices.
#if !defined(OS_ANDROID)
#if !BUILDFLAG(IS_ANDROID)
gl_fence_supported_ = GLFence::IsSupported();
#endif
}

@ -7,7 +7,7 @@
#include "base/cxx17_backports.h"
#include "build/build_config.h"
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
#include "base/android/build_info.h"
#endif
@ -246,13 +246,13 @@ const base::Feature kVulkanFromANGLE{"VulkanFromANGLE",
base::FEATURE_DISABLED_BY_DEFAULT};
bool IsDefaultANGLEVulkan() {
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
// No support for devices before Q -- exit before checking feature flags
// so that devices are not counted in finch trials.
if (base::android::BuildInfo::GetInstance()->sdk_int() <
base::android::SDK_VERSION_Q)
return false;
#endif // defined(OS_ANDROID)
#endif // BUILDFLAG(IS_ANDROID)
return base::FeatureList::IsEnabled(kDefaultANGLEVulkan);
}

@ -9,6 +9,7 @@
#include "base/command_line.h"
#include "base/debug/alias.h"
#include "base/logging.h"
#include "build/build_config.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_features.h"
#include "ui/gl/gl_switches.h"
@ -17,12 +18,12 @@
#include "ui/gl/gl_surface_egl.h"
#endif // defined(USE_EGL)
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
#include "base/posix/eintr_wrapper.h"
#include "third_party/libsync/src/include/sync/sync.h"
#endif
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include <d3d11_1.h>
#include "base/strings/stringprintf.h"
#include "media/base/win/mf_helpers.h"
@ -67,7 +68,7 @@ void Hang() {
}
}
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
base::ScopedFD MergeFDs(base::ScopedFD a, base::ScopedFD b) {
if (!a.is_valid())
return b;
@ -112,7 +113,7 @@ bool PassthroughCommandDecoderSupported() {
#endif // defined(USE_EGL)
}
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// This function is thread safe.
bool AreOverlaysSupportedWin() {
return gl::DirectCompositionSurfaceWin::AreOverlaysSupported();
@ -193,9 +194,9 @@ void LabelSwapChainAndBuffers(IDXGISwapChain* swap_chain,
media::SetDebugName(swap_chain, name_prefix);
LabelSwapChainBuffers(swap_chain, name_prefix);
}
#endif // OS_WIN
#endif // BUILDFLAG(IS_WIN)
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
ScopedEnableTextureRectangleInShaderCompiler::
ScopedEnableTextureRectangleInShaderCompiler(gl::GLApi* gl_api) {
@ -214,7 +215,7 @@ ScopedEnableTextureRectangleInShaderCompiler::
gl_api_->glDisableFn(GL_TEXTURE_RECTANGLE_ANGLE);
}
#endif // defined(OS_MAC)
#endif // BUILDFLAG(IS_MAC)
ScopedPixelStore::ScopedPixelStore(unsigned int name, int value)
: name_(name), old_value_(GetIntegerv(name)), value_(value) {

@ -11,11 +11,11 @@
#include "build/build_config.h"
#include "ui/gl/gl_export.h"
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
#include <dxgi1_6.h>
#endif
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
#include "base/files/scoped_file.h"
#endif
@ -25,7 +25,7 @@ class GLApi;
GL_EXPORT void Crash();
GL_EXPORT void Hang();
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
GL_EXPORT base::ScopedFD MergeFDs(base::ScopedFD a, base::ScopedFD b);
#endif
@ -34,7 +34,7 @@ GL_EXPORT bool UsePassthroughCommandDecoder(
GL_EXPORT bool PassthroughCommandDecoderSupported();
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
GL_EXPORT bool AreOverlaysSupportedWin();
// Calculates present during in 100 ns from number of frames per second.
@ -72,7 +72,7 @@ class GL_EXPORT ScopedEnableTextureRectangleInShaderCompiler {
const ScopedEnableTextureRectangleInShaderCompiler&) = delete;
// This class is a no-op except on macOS.
#if !defined(OS_MAC)
#if !BUILDFLAG(IS_MAC)
explicit ScopedEnableTextureRectangleInShaderCompiler(gl::GLApi* gl_api) {}
#else

@ -13,7 +13,7 @@
#include "ui/gl/gl_version_info.h"
#include "ui/gl/progress_reporter.h"
#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
#include "base/mac/mac_util.h"
#endif
@ -93,7 +93,7 @@ GLboolean glIsSyncEmulateEGL(GLsync sync) {
return true;
}
#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
std::map<GLuint, base::TimeTicks>& GetProgramCreateTimesMap() {
static base::NoDestructor<std::map<GLuint, base::TimeTicks>> instance;
return *instance.get();
@ -140,7 +140,7 @@ template <bool droppable_call = false, typename R, typename... Args>
GrGLFunction<R GR_GL_FUNCTION_TYPE(Args...)> bind_slow_on_mac(
R(GL_BINDING_CALL* func)(Args...),
gl::ProgressReporter* progress_reporter) {
#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
if (!progress_reporter) {
return maybe_drop_call<droppable_call>(func);
}
@ -159,7 +159,7 @@ template <bool droppable_call = false, typename R, typename... Args>
GrGLFunction<R GR_GL_FUNCTION_TYPE(Args...)> bind_with_flush_on_mac(
R(GL_BINDING_CALL* func)(Args...),
bool is_angle) {
#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
// If running on Apple silicon or ANGLE, regardless of the architecture,
// disable this workaround. See https://crbug.com/1131312.
const bool needs_flush =
@ -325,7 +325,7 @@ sk_sp<GrGLInterface> CreateGrGLInterface(
bind_slow(gl->glCompressedTexSubImage2DFn, progress_reporter);
functions->fCopyTexSubImage2D =
bind_slow(gl->glCopyTexSubImage2DFn, progress_reporter);
#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
functions->fCreateProgram = [func = gl->glCreateProgramFn]() {
auto& program_create_times = GetProgramCreateTimesMap();
GLuint program = func();
@ -339,7 +339,7 @@ sk_sp<GrGLInterface> CreateGrGLInterface(
functions->fCullFace = gl->glCullFaceFn;
functions->fDeleteBuffers =
bind_slow(gl->glDeleteBuffersARBFn, progress_reporter);
#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
functions->fDeleteProgram = [func = gl->glDeleteProgramFn](GLuint program) {
auto& program_create_times = GetProgramCreateTimesMap();
program_create_times.erase(program);
@ -409,7 +409,7 @@ sk_sp<GrGLInterface> CreateGrGLInterface(
functions->fGetQueryiv = gl->glGetQueryivFn;
functions->fGetProgramBinary = gl->glGetProgramBinaryFn;
functions->fGetProgramInfoLog = gl->glGetProgramInfoLogFn;
#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
functions->fGetProgramiv = [func = gl->glGetProgramivFn](
GLuint program, GLenum pname, GLint* params) {
func(program, pname, params);

@ -171,7 +171,7 @@ bool InitializeGLOneOffPlatformHelper(bool init_extensions) {
} // namespace
GLImplementationParts GetSoftwareGLImplementationForPlatform() {
#if defined(OS_WIN) || defined(OS_LINUX)
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)
return GetSoftwareGLImplementation();
#else
return GetLegacySoftwareGLImplementation();

@ -6,13 +6,14 @@
#include "base/check.h"
#include "base/no_destructor.h"
#include "build/build_config.h"
#include "ui/gl/gl_switches.h"
namespace gl {
// static
ShaderTracking* ShaderTracking::GetInstance() {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
// Shaders can only be reliably retrieved with ANGLE backend. Therefore,
// limit to Windows platform only.
static bool enabled =
@ -21,7 +22,7 @@ ShaderTracking* ShaderTracking::GetInstance() {
static base::NoDestructor<ShaderTracking> instance;
return instance.get();
}
#endif // OS_WIN
#endif // BUILDFLAG(IS_WIN)
return nullptr;
}

@ -11,7 +11,7 @@
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
// These constants define a reasonable range for a calculated refresh interval.
// Calculating refreshes out of this range will be considered a fatal error.
const int64_t kMinVsyncIntervalUs = base::Time::kMicrosecondsPerSecond / 400;
@ -26,7 +26,7 @@ const double kRelativeIntervalDifferenceThreshold = 0.05;
namespace gl {
SyncControlVSyncProvider::SyncControlVSyncProvider() : gfx::VSyncProvider() {
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
// On platforms where we can't get an accurate reading on the refresh
// rate we fall back to the assumption that we're displaying 60 frames
// per second.
@ -48,7 +48,7 @@ bool SyncControlVSyncProvider::GetVSyncParametersIfAvailable(
base::TimeTicks* timebase_out,
base::TimeDelta* interval_out) {
TRACE_EVENT0("gpu", "SyncControlVSyncProvider::GetVSyncParameters");
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
// The actual clock used for the system time returned by glXGetSyncValuesOML
// is unspecified. In practice, the clock used is likely to be either
// CLOCK_REALTIME or CLOCK_MONOTONIC, so we compare the returned time to the
@ -155,11 +155,11 @@ bool SyncControlVSyncProvider::GetVSyncParametersIfAvailable(
return true;
#else
return false;
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
}
bool SyncControlVSyncProvider::SupportGetVSyncParametersIfAvailable() const {
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
return true;
#else
return false;

@ -30,11 +30,11 @@ class SyncControlVSyncProvider : public gfx::VSyncProvider {
bool SupportGetVSyncParametersIfAvailable() const override;
static constexpr bool IsSupported() {
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
return true;
#else
return false;
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
}
protected:
@ -45,7 +45,7 @@ class SyncControlVSyncProvider : public gfx::VSyncProvider {
virtual bool GetMscRate(int32_t* numerator, int32_t* denominator) = 0;
private:
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
base::TimeTicks last_timebase_;
uint64_t last_media_stream_counter_ = 0;
base::TimeDelta last_good_interval_;
@ -56,7 +56,7 @@ class SyncControlVSyncProvider : public gfx::VSyncProvider {
// from configuration change (monitor reconfiguration, moving windows
// between monitors, suspend and resume, etc.).
base::queue<base::TimeDelta> last_computed_intervals_;
#endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
};
} // namespace gl

@ -28,7 +28,7 @@
#include "ui/gl/test/gl_image_test_support.h"
#include "ui/gl/test/gl_test_helper.h"
#if defined(OS_APPLE)
#if BUILDFLAG(IS_APPLE)
#include "base/mac/mac_util.h"
#endif

@ -14,7 +14,7 @@
#include "ui/gl/gl_switches.h"
#include "ui/gl/init/gl_factory.h"
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#include "ui/platform_window/common/platform_window_defaults.h" // nogncheck
#endif
@ -34,7 +34,7 @@ void InitializeOneOffHelper(bool init_extensions) {
ui::OzonePlatform::InitializeForGPU(params);
#endif
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
ui::test::EnableTestConfigForPlatformWindows();
#endif
@ -47,7 +47,7 @@ void InitializeOneOffHelper(bool init_extensions) {
use_software_gl = false;
}
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
// On Android we always use hardware GL.
use_software_gl = false;
#endif

@ -10,7 +10,7 @@
#include "base/test/test_suite.h"
#include "build/build_config.h"
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
#include "base/test/mock_chrome_application_mac.h"
#endif
@ -34,7 +34,7 @@ class GlTestSuite : public base::TestSuite {
void Initialize() override {
base::TestSuite::Initialize();
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
// This registers a custom NSApplication. It must be done before
// TaskEnvironment registers a regular NSApplication.
mock_cr_app::RegisterMockCrApp();