Skip to content

Commit

Permalink
cc: Use BUILDFLAG for OS checking
Browse files Browse the repository at this point in the history
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: Iad10bbff875fe65eec44aadcfa90dda28479104a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3373750
Reviewed-by: Nico Weber <thakis@chromium.org>
Owners-Override: Nico Weber <thakis@chromium.org>
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/main@{#957281}
  • Loading branch information
xhwang-chromium authored and Chromium LUCI CQ committed Jan 10, 2022
1 parent 912e770 commit 2392e59
Show file tree
Hide file tree
Showing 37 changed files with 106 additions and 105 deletions.
2 changes: 1 addition & 1 deletion cc/base/features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const base::Feature kImpulseScrollAnimations = {
// submitting a frame.
const base::Feature kSynchronizedScrolling = {
"SynchronizedScrolling",
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
base::FEATURE_DISABLED_BY_DEFAULT};
#else
base::FEATURE_ENABLED_BY_DEFAULT};
Expand Down
2 changes: 1 addition & 1 deletion cc/input/snap_fling_curve.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace cc {
namespace {

#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
constexpr double kDistanceEstimatorScalar = 40;
// The delta to be scrolled in next frame is 0.9 of the delta in last frame.
constexpr double kRatio = 0.9;
Expand Down
2 changes: 1 addition & 1 deletion cc/layers/heads_up_display_layer_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ std::string ToStringTwoDecimalPrecision(double input) {
return stream.str();
}

#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
struct MetricsDrawSizes {
const int kTopPadding = 35;
const int kPadding = 15;
Expand Down
3 changes: 2 additions & 1 deletion cc/layers/texture_layer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "base/threading/thread.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "cc/animation/animation_host.h"
#include "cc/layers/solid_color_layer.h"
#include "cc/layers/texture_layer_client.h"
Expand Down Expand Up @@ -1110,7 +1111,7 @@ class TextureLayerChangeInvisibleMailboxTest
};

// TODO(crbug.com/1197350): Test fails on chromeos-amd64-generic-rel.
#if defined(OS_CHROMEOS)
#if BUILDFLAG(IS_CHROMEOS)
#define MAYBE_SINGLE_AND_MULTI_THREAD_TEST_F MULTI_THREAD_TEST_F
#else
#define MAYBE_SINGLE_AND_MULTI_THREAD_TEST_F SINGLE_AND_MULTI_THREAD_TEST_F
Expand Down
2 changes: 1 addition & 1 deletion cc/metrics/frame_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ bool FrameInfo::IsDroppedAffectingSmoothness() const {
}

void FrameInfo::MergeWith(const FrameInfo& other) {
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
// TODO(1278168): on android-webview, multiple frames can be submitted against
// the same BeginFrameArgs. This can trip the DCHECK()s in this function.
if (was_merged)
Expand Down
4 changes: 2 additions & 2 deletions cc/mojo_embedder/async_layer_tree_frame_sink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ AsyncLayerTreeFrameSink::AsyncLayerTreeFrameSink(
params->gpu_memory_buffer_manager),
synthetic_begin_frame_source_(
std::move(params->synthetic_begin_frame_source)),
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
io_thread_id_(params->io_thread_id),
#endif
pipes_(std::move(params->pipes)),
Expand Down Expand Up @@ -100,7 +100,7 @@ bool AsyncLayerTreeFrameSink::BindToClient(LayerTreeFrameSinkClient* client) {
compositor_frame_sink_ptr_->InitializeCompositorFrameSinkType(
viz::mojom::CompositorFrameSinkType::kLayerTree);

#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
std::vector<int32_t> thread_ids;
thread_ids.push_back(base::PlatformThread::CurrentId());
if (io_thread_id_ != base::kInvalidThreadId)
Expand Down
2 changes: 1 addition & 1 deletion cc/mojo_embedder/async_layer_tree_frame_sink.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class CC_MOJO_EMBEDDER_EXPORT AsyncLayerTreeFrameSink
viz::LocalSurfaceId local_surface_id_;
std::unique_ptr<viz::ExternalBeginFrameSource> begin_frame_source_;
std::unique_ptr<viz::SyntheticBeginFrameSource> synthetic_begin_frame_source_;
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
base::PlatformThreadId io_thread_id_;
#endif

Expand Down
4 changes: 2 additions & 2 deletions cc/mojom/render_frame_metadata_mojom_traits.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ bool StructTraits<
out->external_page_scale_factor = data.external_page_scale_factor();
out->top_controls_height = data.top_controls_height();
out->top_controls_shown_ratio = data.top_controls_shown_ratio();
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
out->bottom_controls_height = data.bottom_controls_height();
out->bottom_controls_shown_ratio = data.bottom_controls_shown_ratio();
out->top_controls_min_height_offset = data.top_controls_min_height_offset();
Expand All @@ -49,7 +49,7 @@ bool StructTraits<
return data.ReadRootScrollOffset(&out->root_scroll_offset) &&
data.ReadSelection(&out->selection) &&
data.ReadDelegatedInkMetadata(&out->delegated_ink_metadata) &&
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
data.ReadScrollableViewportSize(&out->scrollable_viewport_size) &&
data.ReadRootLayerSize(&out->root_layer_size) &&
#endif
Expand Down
2 changes: 1 addition & 1 deletion cc/mojom/render_frame_metadata_mojom_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ struct COMPONENT_EXPORT(CC_SHARED_MOJOM_TRAITS)
return metadata.visual_properties_update_duration;
}

#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
static float bottom_controls_height(const cc::RenderFrameMetadata& metadata) {
return metadata.bottom_controls_height;
}
Expand Down
8 changes: 4 additions & 4 deletions cc/paint/oop_pixeltest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#include "ui/gfx/geometry/skia_conversions.h"
#include "ui/gl/gl_implementation.h"

#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
#include "base/android/build_info.h"
#endif

Expand Down Expand Up @@ -1831,7 +1831,7 @@ class OopTextBlobPixelTest
// and distinctly different from using the wrong glyph or text params.
float error_pixels_percentage = 0.f;
int max_abs_error = 0;
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
// The nexus5 and nexus5x bots are particularly susceptible to small changes
// when bilerping an image (not visible).
const int sdk = base::android::BuildInfo::GetInstance()->sdk_int();
Expand Down Expand Up @@ -2314,7 +2314,7 @@ TEST_F(OopPixelTest, ReadbackImagePixels) {
// A workaround on Android that forces the use of GLES 2.0 instead of 3.0
// prevents the use of the GL_RG textures required for NV12 format. This
// test will be reactiviated on Android once the workaround is removed.
#if !defined(OS_ANDROID)
#if !BUILDFLAG(IS_ANDROID)
TEST_F(OopPixelTest, ConvertNV12ToRGB) {
RasterOptions options(gfx::Size(16, 16));
RasterOptions uv_options(gfx::Size(options.resource_size.width() / 2,
Expand Down Expand Up @@ -2388,7 +2388,7 @@ TEST_F(OopPixelTest, ConvertNV12ToRGB) {
sii->DestroySharedImage(sync_token, y_uv_mailboxes[0]);
sii->DestroySharedImage(sync_token, y_uv_mailboxes[1]);
}
#endif // !defined(OS_ANDROID)
#endif // !BUILDFLAG(IS_ANDROID)

class OopPathPixelTest : public OopPixelTest,
public ::testing::WithParamInterface<bool> {
Expand Down
8 changes: 4 additions & 4 deletions cc/paint/paint_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace cc {
namespace {
const bool kHasNoDiscardableImages = false;

#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
struct StretchShaderUniforms {
// multiplier to apply to scale effect
float uMaxStretchIntensity;
Expand Down Expand Up @@ -1578,7 +1578,7 @@ StretchPaintFilter::StretchPaintFilter(SkScalar stretch_x,
width_(width),
height_(height),
input_(std::move(input)) {
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
float normOverScrollDistX = stretch_x_;
float normOverScrollDistY = stretch_y_;
float distanceStretchedX =
Expand Down Expand Up @@ -1609,10 +1609,10 @@ StretchPaintFilter::StretchPaintFilter(SkScalar stretch_x,
sk_sp<SkData> uniformVals = SkData::MakeWithCopy(&uniforms, sizeof(uniforms));
cached_sk_filter_ = SkMakeRuntimeImageFilter(getStretchEffect(), uniformVals,
GetSkFilter(input_.get()));
#else // defined(OS_ANDROID)
#else // BUILDFLAG(IS_ANDROID)
// Stretch filter is only used on android and removed from other platforms
// to reduce size. See https://crbug.com/1226170.
#endif // defined(OS_ANDROID)
#endif // BUILDFLAG(IS_ANDROID)
}

StretchPaintFilter::~StretchPaintFilter() = default;
Expand Down
8 changes: 4 additions & 4 deletions cc/paint/solid_color_analyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ bool IsSolidColorPaint(const PaintFlags& flags) {
!flags.getLooper() && !flags.getMaskFilter() && !flags.getColorFilter() &&
!flags.getImageFilter() && flags.getStyle() == PaintFlags::kFill_Style;

#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
// Additionally, on Mac, we require that the color is opaque due to
// https://crbug.com/922899.
// TODO(andrescj): remove this condition once that bug is fixed.
is_solid_color = (is_solid_color && SkColorGetA(flags.getColor()) == 255);
#endif // OS_MAC
#endif // BUILDFLAG(IS_MAC)

return is_solid_color;
}
Expand Down Expand Up @@ -174,12 +174,12 @@ void CheckIfSolidColor(const SkCanvas& canvas,
bool solid_color_candidate =
does_cover_canvas && IsSolidColorBlendMode(blendmode);

#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
// Additionally, on Mac, we require that the color is opaque due to
// https://crbug.com/922899.
// TODO(andrescj): remove this condition once that bug is fixed.
solid_color_candidate = (solid_color_candidate && alpha == 255);
#endif // OS_MAC
#endif // BUILDFLAG(IS_MAC)

if (solid_color_candidate) {
CalculateSolidColor(color /* src_color */, blendmode,
Expand Down
12 changes: 6 additions & 6 deletions cc/paint/solid_color_analyzer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ TEST_F(SolidColorAnalyzerTest, ClearTranslucent) {
Initialize();
SkColor color = SkColorSetARGB(128, 11, 22, 33);
canvas()->clear(color);
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
// TODO(andrescj): remove the special treatment of OS_MAC once
// https://crbug.com/922899 is fixed.
EXPECT_FALSE(IsSolidColor());
#else
EXPECT_EQ(color, GetColor());
#endif // OS_MAC
#endif // BUILDFLAG(IS_MAC)
}

TEST_F(SolidColorAnalyzerTest, DrawColor) {
Expand Down Expand Up @@ -295,13 +295,13 @@ TEST_F(SolidColorAnalyzerTest, DrawRectTranslucent) {
flags.setColor(color);
SkRect rect = SkRect::MakeWH(100, 100);
canvas()->drawRect(rect, flags);
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
// TODO(andrescj): remove the special treatment of OS_MAC once
// https://crbug.com/922899 is fixed.
EXPECT_FALSE(IsSolidColor());
#else
EXPECT_EQ(color, GetColor());
#endif // OS_MAC
#endif // BUILDFLAG(IS_MAC)
}

TEST_F(SolidColorAnalyzerTest, DrawRectTranslucentOverNonSolid) {
Expand Down Expand Up @@ -343,14 +343,14 @@ TEST_F(SolidColorAnalyzerTest, DrawRectSolidWithSrcOverBlending) {
flags.setColor(color);
rect = SkRect::MakeWH(100, 100);
canvas()->drawRect(rect, flags);
#if defined(OS_MAC)
#if BUILDFLAG(IS_MAC)
// TODO(andrescj): remove the special treatment of OS_MAC once
// https://crbug.com/922899 is fixed.
EXPECT_FALSE(IsSolidColor());
#else
EXPECT_EQ(SkColorSetARGB(159, 15, 25, 35),
GetColor(2 /* max_ops_to_analyze */));
#endif // OS_MAC
#endif // BUILDFLAG(IS_MAC)
}

TEST_F(SolidColorAnalyzerTest, SaveLayer) {
Expand Down
2 changes: 1 addition & 1 deletion cc/raster/scoped_gpu_raster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void ScopedGpuRaster::BeginGpuRaster() {
// arguments even when tracing is disabled.
gl->TraceBeginCHROMIUM("ScopedGpuRaster", "GpuRasterization");

#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
// TODO(crbug.com/832810): The following reset should not be necessary.
GrDirectContext* gr_context = context_provider_->GrContext();
gr_context->resetContext();
Expand Down
2 changes: 1 addition & 1 deletion cc/resources/ui_resource_bitmap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ UIResourceBitmap::UIResourceBitmap(const SkBitmap& skbitmap) {
DCHECK(skbitmap.isImmutable());

const SkBitmap* target = &skbitmap;
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
SkBitmap copy;
if (features::IsDrDcEnabled()) {
// TODO(vikassoni): Forcing everything to N32 while android backing cannot
Expand Down
6 changes: 3 additions & 3 deletions cc/test/layer_tree_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ LayerTreeTest::LayerTreeTest(viz::RendererType renderer_type)
// SwiftShader is a multi-threaded renderer and TSAN takes a lot longer to
// run tests when using SwiftShader
timeout_seconds_ = 35;
#elif defined(OS_WIN) && defined(_DEBUG)
#elif BUILDFLAG(IS_WIN) && defined(_DEBUG)
// Debug builds on Windows are much slower than on other platforms, possibly
// because Windows uses separate debug versions of the C Run-Time Library
// for debug builds, whereas other platforms use the same system libraries
Expand Down Expand Up @@ -693,9 +693,9 @@ LayerTreeTest::LayerTreeTest(viz::RendererType renderer_type)
init_vulkan = true;
} else if (renderer_type_ == viz::RendererType::kSkiaDawn) {
scoped_feature_list_.InitAndEnableFeature(features::kSkiaDawn);
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
init_vulkan = true;
#elif defined(OS_WIN)
#elif BUILDFLAG(IS_WIN)
// TODO(rivr): Initialize D3D12 for Windows.
#else
NOTREACHED();
Expand Down
2 changes: 1 addition & 1 deletion cc/test/layer_tree_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class LayerTreeTest : public testing::Test, public TestHooks {
return renderer_type_ == viz::RendererType::kSkiaVk;
}
bool use_d3d12() const {
#if defined(OS_WIN)
#if BUILDFLAG(IS_WIN)
return renderer_type_ == viz::RendererType::kSkiaDawn;
#else
return false;
Expand Down
4 changes: 2 additions & 2 deletions cc/test/pixel_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ PixelTest::PixelTest(GraphicsBackend backend)
init_vulkan = true;
} else if (backend == kSkiaDawn) {
scoped_feature_list_.InitAndEnableFeature(features::kSkiaDawn);
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
init_vulkan = true;
#elif defined(OS_WIN)
#elif BUILDFLAG(IS_WIN)
// TODO(rivr): Initialize D3D12 for Windows.
#else
NOTREACHED();
Expand Down
4 changes: 2 additions & 2 deletions cc/tiles/image_decode_cache_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "cc/paint/paint_flags.h"
#include "third_party/skia/include/core/SkPixmap.h"

#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
#include "base/android/build_info.h"
#endif

Expand All @@ -18,7 +18,7 @@ namespace cc {
class ImageDecodeCacheUtils {
public:
static bool CanResizeF16Image(PaintFlags::FilterQuality filter_quality) {
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
// Return false on Android KitKat or lower if filter quality is medium or
// high (hence, mipmaps are used), return true otherwise. This is because
// of skia:8410 which causes a crash when trying to scale a f16 image on
Expand Down
4 changes: 2 additions & 2 deletions cc/tiles/picture_layer_tiling_set_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ TEST_F(PictureLayerTilingSetTestWithResources, TwoTilings_Larger) {
}

// Test is flaky: https://crbug.com/1056828.
#if defined(OS_LINUX) && defined(THREAD_SANITIZER)
#if BUILDFLAG(IS_LINUX) && defined(THREAD_SANITIZER)
#define MAYBE_ManyTilings_Equal DISABLED_ManyTilings_Equal
#else
#define MAYBE_ManyTilings_Equal ManyTilings_Equal
Expand All @@ -329,7 +329,7 @@ TEST_F(PictureLayerTilingSetTestWithResources, MAYBE_ManyTilings_Equal) {
}

// Test is flaky: https://crbug.com/1056828.
#if defined(OS_LINUX) && defined(THREAD_SANITIZER)
#if BUILDFLAG(IS_LINUX) && defined(THREAD_SANITIZER)
#define MAYBE_ManyTilings_NotEqual DISABLED_ManyTilings_NotEqual
#else
#define MAYBE_ManyTilings_NotEqual ManyTilings_NotEqual
Expand Down
6 changes: 3 additions & 3 deletions cc/trees/draw_property_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ void UpdateElasticOverscroll(
ElementId overscroll_elasticity_effect_element_id,
const gfx::Vector2dF& elastic_overscroll,
const ScrollNode* inner_viewport) {
#if defined(OS_ANDROID)
#if BUILDFLAG(IS_ANDROID)
// On android, elastic overscroll is implemented by stretching the content
// from the overscrolled edge.
if (!overscroll_elasticity_effect_element_id &&
Expand Down Expand Up @@ -1184,7 +1184,7 @@ void UpdateElasticOverscroll(
}
overscroll_elasticity_transform_node->needs_local_transform_update = true;
property_trees->transform_tree.set_needs_update(true);
#else // defined(OS_ANDROID)
#else // BUILDFLAG(IS_ANDROID)
if (!overscroll_elasticity_transform_node) {
DCHECK(elastic_overscroll.IsZero());
return;
Expand All @@ -1202,7 +1202,7 @@ void UpdateElasticOverscroll(
overscroll_elasticity_transform_node->needs_local_transform_update = true;
property_trees->transform_tree.set_needs_update(true);

#endif // defined(OS_ANDROID)
#endif // BUILDFLAG(IS_ANDROID)
}

void ComputeDrawPropertiesOfVisibleLayers(const LayerImplList* layer_list,
Expand Down
Loading

0 comments on commit 2392e59

Please sign in to comment.