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.eglGetErrorFn = &FakeGetError;
g_driver_egl.fn.eglGetProcAddressFn = &FakeGetProcAddress; g_driver_egl.fn.eglGetProcAddressFn = &FakeGetProcAddress;
#if defined(OS_WIN) #if BUILDFLAG(IS_WIN)
SetGLImplementation(kGLImplementationEGLANGLE); SetGLImplementation(kGLImplementationEGLANGLE);
#else #else
SetGLImplementation(kGLImplementationEGLGLES2); SetGLImplementation(kGLImplementationEGLGLES2);

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

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

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

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

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

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

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

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

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

@@ -10,11 +10,12 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "build/build_config.h"
#include "ui/gfx/gpu_fence.h" #include "ui/gfx/gpu_fence.h"
#include "ui/gfx/gpu_fence_handle.h" #include "ui/gfx/gpu_fence_handle.h"
#include "ui/gl/gl_surface_egl.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 <unistd.h>
#include "base/posix/eintr_wrapper.h" #include "base/posix/eintr_wrapper.h"

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

@@ -23,7 +23,7 @@
#include "ui/gfx/overlay_transform.h" #include "ui/gfx/overlay_transform.h"
#include "ui/gl/gl_export.h" #include "ui/gl/gl_export.h"
#if defined(OS_ANDROID) #if BUILDFLAG(IS_ANDROID)
#include <android/hardware_buffer.h> #include <android/hardware_buffer.h>
#include <memory> #include <memory>
#include "base/android/scoped_hardware_buffer_handle.h" #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. // If called, then IsInUseByWindowServer will always return false.
virtual void DisableInUseByWindowServer(); virtual void DisableInUseByWindowServer();
#if defined(OS_ANDROID) #if BUILDFLAG(IS_ANDROID)
// Provides the buffer backing this image, if it is backed by an // Provides the buffer backing this image, if it is backed by an
// AHardwareBuffer. The ScopedHardwareBuffer returned may include a fence // AHardwareBuffer. The ScopedHardwareBuffer returned may include a fence
// which will be signaled when all pending work for the buffer has been // 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; stride_ = stride;
bool tex_image_from_pbo_is_slow = false; bool tex_image_from_pbo_is_slow = false;
#if defined(OS_WIN) #if BUILDFLAG(IS_WIN)
tex_image_from_pbo_is_slow = true; tex_image_from_pbo_is_slow = true;
#endif // OS_WIN #endif // BUILDFLAG(IS_WIN)
GLContext* context = GLContext::GetCurrent(); GLContext* context = GLContext::GetCurrent();
DCHECK(context); DCHECK(context);
if (!tex_image_from_pbo_is_slow && SupportsPBO(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. // TODO(crbug.com/852011): Implement image handle export on Fuchsia.
NOTIMPLEMENTED(); NOTIMPLEMENTED();
return gfx::NativePixmapHandle(); return gfx::NativePixmapHandle();
#else // defined(OS_FUCHSIA) #else // BUILDFLAG(IS_FUCHSIA)
std::vector<int> fds(num_planes); std::vector<int> fds(num_planes);
std::vector<EGLint> strides(num_planes); std::vector<EGLint> strides(num_planes);
std::vector<EGLint> offsets(num_planes); std::vector<EGLint> offsets(num_planes);
@@ -308,7 +308,7 @@ gfx::NativePixmapHandle GLImageNativePixmap::ExportHandle() {
} }
return handle; return handle;
#endif // !defined(OS_FUCHSIA) #endif // BUILDFLAG(IS_FUCHSIA)
} }
unsigned GLImageNativePixmap::GetInternalFormat() { unsigned GLImageNativePixmap::GetInternalFormat() {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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