Skip to content

Commit f80c2b6

Browse files
ddorwinCQ Bot
authored andcommitted
[versioning][zircon][ulib] Use new C++ macros for API level checks
Replace comparisons to `__Fuchsia_API_level__` with the macros. Bug: 42084512 Change-Id: Ic71354769c2b165fca99ae6f943eb3d5340e8023 Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1054581 Commit-Queue: Auto-Submit <auto-submit@fuchsia-infra.iam.gserviceaccount.com> Fuchsia-Auto-Submit: David Dorwin <ddorwin@google.com> Reviewed-by: John Bauman <jbauman@google.com>
1 parent 8672f74 commit f80c2b6

File tree

4 files changed

+50
-50
lines changed

4 files changed

+50
-50
lines changed

zircon/system/ulib/image-format/image_format.cc

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// This file is always in the GN sources list, but its contents should not be
88
// used for API levels other than HEAD where images2 and sysmem2 are supported.
99

10-
#if __Fuchsia_API_level__ < 19
10+
#if FUCHSIA_API_LEVEL_LESS_THAN(19)
1111
// Enable a subset of functionality. See https://fxbug.dev/42085119.
1212
// It cannot be undefined because other Fuchsia headers may indirectly include image_format.h.
1313
#define __ALLOW_IMAGES2_AND_SYSMEM2_TYPES_ONLY__
@@ -38,7 +38,7 @@ using safemath::CheckDiv;
3838
using safemath::CheckMul;
3939
using safemath::CheckSub;
4040

41-
#if __Fuchsia_API_level__ < 19
41+
#if FUCHSIA_API_LEVEL_LESS_THAN(19)
4242
// This is used by the ImageFormatSet implementations before it is defined.
4343
// Normally, it is declared by the header.
4444
uint32_t ImageFormatStrideBytesPerWidthPixel(const PixelFormatAndModifier& pixel_format);
@@ -56,7 +56,7 @@ using ImageFormatWire = fuchsia_images2::wire::ImageFormat;
5656
using ImageFormatConstraintsWire = fuchsia_sysmem2::wire::ImageFormatConstraints;
5757
using PixelFormatWire = fuchsia_images2::wire::PixelFormat;
5858

59-
#if __Fuchsia_API_level__ >= 19
59+
#if FUCHSIA_API_LEVEL_AT_LEAST(19)
6060
// There are two aspects of the ColorSpaceWire and PixelFormatWire that we care about:
6161
// * bits-per-sample - bits per primary sample (R, G, B, or Y)
6262
// * RGB vs. YUV - whether the system supports the ColorSpaceWire or PixelFormatWire
@@ -114,7 +114,7 @@ const std::map<PixelFormatWire, SamplingInfo> kPixelFormatSamplingInfo = {
114114
{PixelFormat::kA2B10G10R10, {{8}, {kColorType_RGB}}},
115115
{PixelFormat::kA2R10G10B10, {{8}, {kColorType_RGB}}},
116116
};
117-
#endif // __Fuchsia_API_level__ >= 19
117+
#endif // FUCHSIA_API_LEVEL_AT_LEAST(19)
118118

119119
constexpr uint32_t kTransactionEliminationAlignment = 64;
120120
// The transaction elimination buffer is always reported as plane 3.
@@ -990,7 +990,7 @@ constexpr const ImageFormatSet* kImageFormats[] = {
990990

991991
} // namespace
992992

993-
#if __Fuchsia_API_level__ >= 19
993+
#if FUCHSIA_API_LEVEL_AT_LEAST(19)
994994

995995
bool ImageFormatIsPixelFormatEqual(const PixelFormatAndModifier& a,
996996
const PixelFormatAndModifier& b) {
@@ -1059,7 +1059,7 @@ bool ImageFormatIsSupportedColorSpaceForPixelFormat(
10591059
return ImageFormatIsSupportedColorSpaceForPixelFormat(color_space_v2, pixel_format_v2);
10601060
}
10611061

1062-
#endif // __Fuchsia_API_level__ >= 19
1062+
#endif // FUCHSIA_API_LEVEL_AT_LEAST(19)
10631063

10641064
bool ImageFormatIsSupported(const PixelFormatAndModifier& pixel_format) {
10651065
return std::any_of(std::begin(kImageFormats), std::end(kImageFormats),
@@ -1068,7 +1068,7 @@ bool ImageFormatIsSupported(const PixelFormatAndModifier& pixel_format) {
10681068
});
10691069
}
10701070

1071-
#if __Fuchsia_API_level__ >= 19
1071+
#if FUCHSIA_API_LEVEL_AT_LEAST(19)
10721072

10731073
bool ImageFormatIsSupported(const fuchsia_sysmem::wire::PixelFormat& wire_pixel_format_v1) {
10741074
auto pixel_format_v1 = fidl::ToNatural(wire_pixel_format_v1);
@@ -1129,7 +1129,7 @@ uint32_t ImageFormatBitsPerPixel(const fuchsia_sysmem::wire::PixelFormat& wire_p
11291129
return ImageFormatBitsPerPixel(pixel_format_v2);
11301130
}
11311131

1132-
#endif // __Fuchsia_API_level__ >= 19
1132+
#endif // FUCHSIA_API_LEVEL_AT_LEAST(19)
11331133

11341134
uint32_t ImageFormatStrideBytesPerWidthPixel(const PixelFormatAndModifier& pixel_format) {
11351135
ZX_DEBUG_ASSERT(ImageFormatIsSupported(pixel_format));
@@ -1183,7 +1183,7 @@ uint32_t ImageFormatStrideBytesPerWidthPixel(const PixelFormatAndModifier& pixel
11831183
}
11841184
}
11851185

1186-
#if __Fuchsia_API_level__ >= 19
1186+
#if FUCHSIA_API_LEVEL_AT_LEAST(19)
11871187

11881188
uint32_t ImageFormatStrideBytesPerWidthPixel(
11891189
const fuchsia_sysmem::wire::PixelFormat& wire_pixel_format_v1) {
@@ -1388,7 +1388,7 @@ uint32_t ImageFormatSampleAlignment(const fuchsia_sysmem::wire::PixelFormat& wir
13881388
return ImageFormatSampleAlignment(pixel_format_v2);
13891389
}
13901390

1391-
#endif // __Fuchsia_API_level__ >= 19
1391+
#endif // FUCHSIA_API_LEVEL_AT_LEAST(19)
13921392

13931393
bool ImageFormatMinimumRowBytes(const fuchsia_sysmem2::ImageFormatConstraints& constraints,
13941394
uint32_t width, uint32_t* minimum_row_bytes_out) {
@@ -1408,7 +1408,7 @@ bool ImageFormatMinimumRowBytes(const fuchsia_sysmem2::ImageFormatConstraints& c
14081408
return false;
14091409
}
14101410

1411-
#if __Fuchsia_API_level__ >= 19
1411+
#if FUCHSIA_API_LEVEL_AT_LEAST(19)
14121412

14131413
bool ImageFormatMinimumRowBytes(
14141414
const fuchsia_sysmem2::wire::ImageFormatConstraints& wire_constraints, uint32_t width,
@@ -1468,7 +1468,7 @@ fpromise::result<fuchsia_images2::wire::PixelFormat> ImageFormatConvertZbiToSysm
14681468
}
14691469
}
14701470

1471-
#endif // __Fuchsia_API_level__ >= 19
1471+
#endif // FUCHSIA_API_LEVEL_AT_LEAST(19)
14721472

14731473
fpromise::result<ImageFormat> ImageConstraintsToFormat(const ImageFormatConstraints& constraints,
14741474
uint32_t width, uint32_t height) {
@@ -1500,7 +1500,7 @@ fpromise::result<ImageFormat> ImageConstraintsToFormat(const ImageFormatConstrai
15001500
return fpromise::ok(std::move(result));
15011501
}
15021502

1503-
#if __Fuchsia_API_level__ >= 19
1503+
#if FUCHSIA_API_LEVEL_AT_LEAST(19)
15041504
fpromise::result<ImageFormatWire> ImageConstraintsToFormat(
15051505
fidl::AnyArena& allocator, const ImageFormatConstraintsWire& wire_constraints, uint32_t width,
15061506
uint32_t height) {
@@ -1511,7 +1511,7 @@ fpromise::result<ImageFormatWire> ImageConstraintsToFormat(
15111511
}
15121512
return fpromise::ok(fidl::ToWire(allocator, result.take_value()));
15131513
}
1514-
#endif // __Fuchsia_API_level__ >= 19
1514+
#endif // FUCHSIA_API_LEVEL_AT_LEAST(19)
15151515

15161516
fpromise::result<fuchsia_sysmem::wire::ImageFormat2> ImageConstraintsToFormat(
15171517
const fuchsia_sysmem::wire::ImageFormatConstraints& wire_image_format_constraints_v1,
@@ -1551,12 +1551,12 @@ bool ImageFormatPlaneByteOffset(const ImageFormat& image_format, uint32_t plane,
15511551
return false;
15521552
}
15531553

1554-
#if __Fuchsia_API_level__ >= 19
1554+
#if FUCHSIA_API_LEVEL_AT_LEAST(19)
15551555
bool ImageFormatPlaneByteOffset(const ImageFormatWire& image_format, uint32_t plane,
15561556
uint64_t* offset_out) {
15571557
return ImageFormatPlaneByteOffset(fidl::ToNatural(image_format), plane, offset_out);
15581558
}
1559-
#endif // __Fuchsia_API_level__ >= 19
1559+
#endif // FUCHSIA_API_LEVEL_AT_LEAST(19)
15601560

15611561
bool ImageFormatPlaneByteOffset(const fuchsia_sysmem::wire::ImageFormat2& wire_image_format_v1,
15621562
uint32_t plane, uint64_t* offset_out) {
@@ -1582,12 +1582,12 @@ bool ImageFormatPlaneRowBytes(const ImageFormat& image_format, uint32_t plane,
15821582
return false;
15831583
}
15841584

1585-
#if __Fuchsia_API_level__ >= 19
1585+
#if FUCHSIA_API_LEVEL_AT_LEAST(19)
15861586
bool ImageFormatPlaneRowBytes(const ImageFormatWire& wire_image_format, uint32_t plane,
15871587
uint32_t* row_bytes_out) {
15881588
return ImageFormatPlaneRowBytes(fidl::ToNatural(wire_image_format), plane, row_bytes_out);
15891589
}
1590-
#endif // __Fuchsia_API_level__ >= 19
1590+
#endif // FUCHSIA_API_LEVEL_AT_LEAST(19)
15911591

15921592
bool ImageFormatPlaneRowBytes(const fuchsia_sysmem::wire::ImageFormat2& wire_image_format_v1,
15931593
uint32_t plane, uint32_t* row_bytes_out) {
@@ -1601,7 +1601,7 @@ bool ImageFormatPlaneRowBytes(const fuchsia_sysmem::wire::ImageFormat2& wire_ima
16011601
return ImageFormatPlaneRowBytes(image_format_v2, plane, row_bytes_out);
16021602
}
16031603

1604-
#if __Fuchsia_API_level__ >= 19
1604+
#if FUCHSIA_API_LEVEL_AT_LEAST(19)
16051605

16061606
bool ImageFormatCompatibleWithProtectedMemory(const PixelFormatAndModifier& pixel_format) {
16071607
// AKA kFormatModifierLinear
@@ -1630,4 +1630,4 @@ bool ImageFormatCompatibleWithProtectedMemory(
16301630
return ImageFormatCompatibleWithProtectedMemory(pixel_format_v2);
16311631
}
16321632

1633-
#endif // __Fuchsia_API_level__ >= 19
1633+
#endif // FUCHSIA_API_LEVEL_AT_LEAST(19)

zircon/system/ulib/image-format/include/lib/image-format/image_format.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// Most of the functions in this file are only available at HEAD because they
1515
// depend on fuchsia.images2 and fuchsia.sysmem2 which are currently
1616
// `added=HEAD`. See https://fxbug.dev/42085119.
17-
#if __Fuchsia_API_level__ >= 19
17+
#if FUCHSIA_API_LEVEL_AT_LEAST(19)
1818

1919
#include <fidl/fuchsia.images2/cpp/fidl.h>
2020
#include <fidl/fuchsia.sysmem/cpp/fidl.h>
@@ -137,7 +137,7 @@ bool ImageFormatCompatibleWithProtectedMemory(const PixelFormatAndModifier& pixe
137137
bool ImageFormatCompatibleWithProtectedMemory(
138138
const fuchsia_sysmem::wire::PixelFormat& pixel_format);
139139

140-
#else // __Fuchsia_API_level__ >= 19
140+
#else // FUCHSIA_API_LEVEL_AT_LEAST(19)
141141

142142
// A small subset of the functions are exposed for use by zircon_platform_sysmem_connection.cc when
143143
// __ALLOW_IMAGES2_AND_SYSMEM2_TYPES_ONLY__ is defined. See https://fxbug.dev/42085119.
@@ -159,6 +159,6 @@ bool ImageFormatPlaneRowBytes(const fuchsia_sysmem::wire::ImageFormat2& image_fo
159159
#error Should only be included for API level HEAD where fuchsia.images2 and fuchsia.sysmem2 are supported.
160160
#endif // defined(__ALLOW_IMAGES2_AND_SYSMEM2_TYPES_ONLY__)
161161

162-
#endif // __Fuchsia_API_level__ >= 19
162+
#endif // FUCHSIA_API_LEVEL_AT_LEAST(19)
163163

164164
#endif // LIB_IMAGE_FORMAT_IMAGE_FORMAT_H_

zircon/system/ulib/sysmem-version/include/lib/sysmem-version/sysmem-version.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// While most of the code in this file is only available at HEAD, a subset is
2222
// available for a specific use case when
2323
// __ALLOW_IMAGES2_AND_SYSMEM2_TYPES_ONLY__ is defined. See https://fxbug.dev/42085119.
24-
#if (__Fuchsia_API_level__ < 19) && !defined(__ALLOW_IMAGES2_AND_SYSMEM2_TYPES_ONLY__)
24+
#if (FUCHSIA_API_LEVEL_LESS_THAN(19)) && !defined(__ALLOW_IMAGES2_AND_SYSMEM2_TYPES_ONLY__)
2525
#error Should only be included for API level >= 19 where fuchsia.images2 and fuchsia.sysmem2 are supported.
2626
#endif
2727

@@ -66,7 +66,7 @@ inline PixelFormatAndModifier PixelFormatAndModifierFromImageFormat(
6666
return PixelFormatAndModifier(*image_format.pixel_format(), pixel_format_modifier);
6767
}
6868

69-
#if __Fuchsia_API_level__ >= 19
69+
#if FUCHSIA_API_LEVEL_AT_LEAST(19)
7070
inline PixelFormatAndModifier PixelFormatAndModifierFromImageFormat(
7171
const fuchsia_images2::wire::ImageFormat& image_format) {
7272
ZX_ASSERT(image_format.has_pixel_format());
@@ -75,7 +75,7 @@ inline PixelFormatAndModifier PixelFormatAndModifierFromImageFormat(
7575
: fuchsia_images2::PixelFormatModifier::kLinear;
7676
return PixelFormatAndModifier(image_format.pixel_format(), pixel_format_modifier);
7777
}
78-
#endif // __Fuchsia_API_level__ >= 19
78+
#endif // FUCHSIA_API_LEVEL_AT_LEAST(19)
7979

8080
namespace sysmem {
8181

@@ -179,7 +179,7 @@ constexpr FidlUnderlyingTypeOrType_t<T> fidl_underlying_cast(const T& value) {
179179
return static_cast<FidlUnderlyingTypeOrType_t<T>>(value);
180180
}
181181

182-
#if __Fuchsia_API_level__ >= 19
182+
#if FUCHSIA_API_LEVEL_AT_LEAST(19)
183183

184184
///////////////////////
185185
// V2 Copy/Move from V1
@@ -403,7 +403,7 @@ V2CopyFromV1ImageFormatConstraints(const fuchsia_sysmem::ImageFormatConstraints&
403403
[[nodiscard]] fpromise::result<fuchsia_sysmem::ImageFormat2> V1CopyFromV2ImageFormat(
404404
fuchsia_images2::ImageFormat& v2);
405405

406-
#endif // __Fuchsia_API_level__ >= 19
406+
#endif // FUCHSIA_API_LEVEL_AT_LEAST(19)
407407

408408
} // namespace sysmem
409409

0 commit comments

Comments
 (0)