From c696704a6605da77db1f8e99e5e45d31466ff329 Mon Sep 17 00:00:00 2001 From: Ink Open Source Date: Mon, 16 Sep 2024 07:55:44 -0700 Subject: [PATCH] Switch from absl:log to absl:absl_log Switch from LOG() to ABSL_LOG() as suggested on https://crrev.com/c/5530802. Then the use of these equivalent macros will be clearly referring to the Abseil version. Update includes and build dependencies to match. For a few files, remove their superfluous log.h #includes. PiperOrigin-RevId: 675148151 --- ink/color/BUILD.bazel | 4 ++-- ink/color/color.cc | 6 +++--- ink/color/color_space.cc | 16 ++++++++++------ ink/geometry/BUILD.bazel | 4 ++-- ink/geometry/internal/BUILD.bazel | 2 +- ink/geometry/internal/mesh_packing.cc | 8 ++++---- ink/geometry/mesh_format.cc | 13 +++++++------ ink/geometry/quad.cc | 4 ++-- ink/rendering/BUILD.bazel | 2 +- ink/rendering/bitmap.cc | 4 ++-- ink/rendering/skia/common_internal/BUILD.bazel | 1 - .../common_internal/mesh_specification_data.cc | 1 - ink/strokes/BUILD.bazel | 4 ++-- ink/strokes/in_progress_stroke.cc | 6 +++--- ink/strokes/internal/BUILD.bazel | 4 ++-- ink/strokes/internal/brush_tip_modeler.cc | 18 ++++++++++-------- ink/strokes/internal/easing_implementation.cc | 9 +++++---- ink/strokes/stroke.cc | 5 +++-- 18 files changed, 59 insertions(+), 52 deletions(-) diff --git a/ink/color/BUILD.bazel b/ink/color/BUILD.bazel index 3a8c7bac..a72df43a 100644 --- a/ink/color/BUILD.bazel +++ b/ink/color/BUILD.bazel @@ -25,8 +25,8 @@ cc_library( ], deps = [ ":color_space", - "@com_google_absl//absl/log", "@com_google_absl//absl/log:absl_check", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings:str_format", ], ) @@ -62,7 +62,7 @@ cc_library( srcs = ["color_space.cc"], hdrs = ["color_space.h"], deps = [ - "@com_google_absl//absl/log", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings:str_format", ], ) diff --git a/ink/color/color.cc b/ink/color/color.cc index 9d6fd79f..aec3f4ae 100644 --- a/ink/color/color.cc +++ b/ink/color/color.cc @@ -21,7 +21,7 @@ #include #include "absl/log/absl_check.h" -#include "absl/log/log.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "ink/color/color_space.h" @@ -59,7 +59,7 @@ Color Color::FromFloat(float red, float green, float blue, float alpha, (red != 0.0f || green != 0.0f || blue != 0.0f)) { // If alpha is zero and the inputs were correctly premultiplied, then all // color channels must necessarily be zero too. - LOG(FATAL) << absl::StrFormat( + ABSL_LOG(FATAL) << absl::StrFormat( "Premultiplied alpha=0 must have RGB=0. Got RGBA={%f, %f, %f, %f}.", red, green, blue, alpha); } @@ -86,7 +86,7 @@ Color Color::FromUint8(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha, (red != 0 || green != 0 || blue != 0)) { // If alpha is zero and the inputs were correctly premultiplied, then all // color channels must necessarily be zero too. - LOG(FATAL) << absl::StrFormat( + ABSL_LOG(FATAL) << absl::StrFormat( "Premultiplied alpha=0 must have RGB=0. Got RGBA={%d, %d, %d, %d}.", red, green, blue, alpha); } diff --git a/ink/color/color_space.cc b/ink/color/color_space.cc index 2bbcb7f9..c2f15109 100644 --- a/ink/color/color_space.cc +++ b/ink/color/color_space.cc @@ -18,7 +18,7 @@ #include #include -#include "absl/log/log.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" namespace ink { @@ -73,7 +73,8 @@ std::array GetFromXyzD65(ColorSpace space) { case ColorSpace::kDisplayP3: return kXyzD65ToDisplayP3; } - LOG(DFATAL) << "Unknown ColorSpace enum value " << static_cast(space); + ABSL_LOG(DFATAL) << "Unknown ColorSpace enum value " + << static_cast(space); return {}; } @@ -84,7 +85,8 @@ std::array GetToXyzD65(ColorSpace space) { case ColorSpace::kDisplayP3: return kDisplayP3ToXyzD65; } - LOG(DFATAL) << "Unknown ColorSpace enum value " << static_cast(space); + ABSL_LOG(DFATAL) << "Unknown ColorSpace enum value " + << static_cast(space); return {}; } @@ -101,7 +103,8 @@ float GammaDecode(float encoded_value, ColorSpace space) { return std::pow(kSrgbA * encoded_value + kSrgbB, kSrgbG); } } - LOG(DFATAL) << "Unknown ColorSpace enum value " << static_cast(space); + ABSL_LOG(DFATAL) << "Unknown ColorSpace enum value " + << static_cast(space); return 0.0f; } @@ -116,7 +119,8 @@ float GammaEncode(float linear_value, ColorSpace space) { return (std::pow(linear_value, 1.0 / kSrgbG) - kSrgbB) / kSrgbA; } } - LOG(DFATAL) << "Unknown ColorSpace enum value " << static_cast(space); + ABSL_LOG(DFATAL) << "Unknown ColorSpace enum value " + << static_cast(space); return 0.0f; } @@ -169,7 +173,7 @@ std::array GetGammaDecodingParameters(ColorSpace space) { return {kSrgbA, kSrgbB, kSrgbC, kSrgbD, kSrgbG}; } } - LOG(DFATAL) << "Unknown ColorSpace enum value " << space; + ABSL_LOG(DFATAL) << "Unknown ColorSpace enum value " << space; return {}; } diff --git a/ink/geometry/BUILD.bazel b/ink/geometry/BUILD.bazel index 90849c2d..cf8652ab 100644 --- a/ink/geometry/BUILD.bazel +++ b/ink/geometry/BUILD.bazel @@ -202,8 +202,8 @@ cc_library( ":rect", ":segment", ":vec", - "@com_google_absl//absl/log", "@com_google_absl//absl/log:absl_check", + "@com_google_absl//absl/log:absl_log", ], ) @@ -417,7 +417,7 @@ cc_library( "//ink/types:small_array", "@com_google_absl//absl/algorithm:container", "@com_google_absl//absl/container:flat_hash_set", - "@com_google_absl//absl/log", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/status", "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings", diff --git a/ink/geometry/internal/BUILD.bazel b/ink/geometry/internal/BUILD.bazel index 69b2455f..b8755c26 100644 --- a/ink/geometry/internal/BUILD.bazel +++ b/ink/geometry/internal/BUILD.bazel @@ -189,8 +189,8 @@ cc_library( "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/container:flat_hash_set", "@com_google_absl//absl/container:inlined_vector", - "@com_google_absl//absl/log", "@com_google_absl//absl/log:absl_check", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/status", "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings", diff --git a/ink/geometry/internal/mesh_packing.cc b/ink/geometry/internal/mesh_packing.cc index 2d0f7dc6..548cca6f 100644 --- a/ink/geometry/internal/mesh_packing.cc +++ b/ink/geometry/internal/mesh_packing.cc @@ -29,7 +29,7 @@ #include "absl/container/flat_hash_set.h" #include "absl/container/inlined_vector.h" #include "absl/log/absl_check.h" -#include "absl/log/log.h" +#include "absl/log/absl_log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/substitute.h" @@ -664,7 +664,7 @@ SmallArray UnpackIntegersFromPackedAttribute( case MeshFormat::AttributeType::kFloat4Unpacked: break; } - LOG(FATAL) << "Non-packed AttributeType: " << static_cast(type); + ABSL_LOG(FATAL) << "Non-packed AttributeType: " << static_cast(type); } SmallArray ReadFloatsFromUnpackedAttribute( @@ -690,7 +690,7 @@ SmallArray ReadFloatsFromUnpackedAttribute( case MeshFormat::AttributeType::kFloat4PackedIn3Floats: break; } - LOG(FATAL) << "Packed AttributeType: " << static_cast(type); + ABSL_LOG(FATAL) << "Packed AttributeType: " << static_cast(type); } std::array ReadTriangleIndicesFromByteArray( @@ -780,7 +780,7 @@ SmallArray ReadUnpackedFloatAttributeFromByteArray( UnalignedLoadFloat(src + 3 * sizeof(float)), }; } - LOG(FATAL) << "Unrecognized AttributeType: " << attr.type; + ABSL_LOG(FATAL) << "Unrecognized AttributeType: " << attr.type; } absl::InlinedVector PartitionTriangles( diff --git a/ink/geometry/mesh_format.cc b/ink/geometry/mesh_format.cc index a0a48aab..452e2355 100644 --- a/ink/geometry/mesh_format.cc +++ b/ink/geometry/mesh_format.cc @@ -24,7 +24,7 @@ #include "absl/algorithm/container.h" #include "absl/container/flat_hash_set.h" -#include "absl/log/log.h" +#include "absl/log/absl_log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/str_cat.h" @@ -201,7 +201,7 @@ uint8_t MeshFormat::ComponentCount(AttributeType type) { case AttributeType::kFloat4PackedIn3Floats: return 4; } - LOG(FATAL) << "Unrecognized AttributeType " << static_cast(type); + ABSL_LOG(FATAL) << "Unrecognized AttributeType " << static_cast(type); } std::optional> MeshFormat::PackedBitsPerComponent( @@ -232,7 +232,7 @@ std::optional> MeshFormat::PackedBitsPerComponent( case AttributeType::kFloat4PackedIn3Floats: return SmallArray({18, 18, 18, 18}); } - LOG(FATAL) << "Unrecognized AttributeType " << static_cast(type); + ABSL_LOG(FATAL) << "Unrecognized AttributeType " << static_cast(type); } uint8_t MeshFormat::UnpackedAttributeSize(AttributeType type) { @@ -258,7 +258,7 @@ bool MeshFormat::IsPackedAsFloat(AttributeType type) { case MeshFormat::AttributeType::kFloat3PackedIn4UnsignedBytes_XYZ10: return false; } - LOG(FATAL) << "Unrecognized AttributeType " << static_cast(type); + ABSL_LOG(FATAL) << "Unrecognized AttributeType " << static_cast(type); } uint8_t MeshFormat::PackedAttributeSize(AttributeType type) { @@ -284,7 +284,7 @@ uint8_t MeshFormat::PackedAttributeSize(AttributeType type) { case AttributeType::kFloat4Unpacked: return 16; } - LOG(FATAL) << "Unrecognized AttributeType " << static_cast(type); + ABSL_LOG(FATAL) << "Unrecognized AttributeType " << static_cast(type); } uint8_t MeshFormat::UnpackedIndexSize(IndexFormat index_format) { @@ -294,7 +294,8 @@ uint8_t MeshFormat::UnpackedIndexSize(IndexFormat index_format) { case IndexFormat::k32BitUnpacked16BitPacked: return 4; } - LOG(FATAL) << "Unrecognized IndexFormat " << static_cast(index_format); + ABSL_LOG(FATAL) << "Unrecognized IndexFormat " + << static_cast(index_format); } void MeshFormat::PopulateOffsetWidthAndStride() { diff --git a/ink/geometry/quad.cc b/ink/geometry/quad.cc index 6dceaab6..8bb5afc6 100644 --- a/ink/geometry/quad.cc +++ b/ink/geometry/quad.cc @@ -21,7 +21,7 @@ #include #include -#include "absl/log/log.h" +#include "absl/log/absl_log.h" #include "ink/geometry/angle.h" #include "ink/geometry/point.h" #include "ink/geometry/segment.h" @@ -62,7 +62,7 @@ Segment Quad::GetEdge(int index) const { case 3: return Segment{corners[3], corners[0]}; default: - LOG(FATAL) << "Index " << index << " out of bounds"; + ABSL_LOG(FATAL) << "Index " << index << " out of bounds"; } } diff --git a/ink/rendering/BUILD.bazel b/ink/rendering/BUILD.bazel index 8a309c0f..977121d2 100644 --- a/ink/rendering/BUILD.bazel +++ b/ink/rendering/BUILD.bazel @@ -23,7 +23,7 @@ cc_library( deps = [ "//ink/color", "//ink/color:color_space", - "@com_google_absl//absl/log", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/status", "@com_google_absl//absl/strings", "@com_google_absl//absl/types:span", diff --git a/ink/rendering/bitmap.cc b/ink/rendering/bitmap.cc index 191c97fb..f27a581c 100644 --- a/ink/rendering/bitmap.cc +++ b/ink/rendering/bitmap.cc @@ -17,7 +17,7 @@ #include #include -#include "absl/log/log.h" +#include "absl/log/absl_log.h" #include "absl/status/status.h" #include "absl/strings/str_cat.h" @@ -76,7 +76,7 @@ size_t PixelFormatBytesPerPixel(Bitmap::PixelFormat format) { case Bitmap::PixelFormat::kRgba8888: return 4; } - LOG(FATAL) << "Invalid PixelFormat value: " << static_cast(format); + ABSL_LOG(FATAL) << "Invalid PixelFormat value: " << static_cast(format); } } // namespace ink diff --git a/ink/rendering/skia/common_internal/BUILD.bazel b/ink/rendering/skia/common_internal/BUILD.bazel index 5447c03a..b1ede5bc 100644 --- a/ink/rendering/skia/common_internal/BUILD.bazel +++ b/ink/rendering/skia/common_internal/BUILD.bazel @@ -38,7 +38,6 @@ cc_library( "//ink/strokes/internal:stroke_vertex", "//ink/types:small_array", "@com_google_absl//absl/container:inlined_vector", - "@com_google_absl//absl/log", "@com_google_absl//absl/log:absl_check", "@com_google_absl//absl/status", "@com_google_absl//absl/status:statusor", diff --git a/ink/rendering/skia/common_internal/mesh_specification_data.cc b/ink/rendering/skia/common_internal/mesh_specification_data.cc index 9cfec038..6d32792a 100644 --- a/ink/rendering/skia/common_internal/mesh_specification_data.cc +++ b/ink/rendering/skia/common_internal/mesh_specification_data.cc @@ -18,7 +18,6 @@ #include "absl/container/inlined_vector.h" #include "absl/log/absl_check.h" -#include "absl/log/log.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/str_cat.h" diff --git a/ink/strokes/BUILD.bazel b/ink/strokes/BUILD.bazel index 5c9baf0a..762581df 100644 --- a/ink/strokes/BUILD.bazel +++ b/ink/strokes/BUILD.bazel @@ -32,8 +32,8 @@ cc_library( "//ink/strokes/internal:stroke_shape_builder", "//ink/strokes/internal:stroke_vertex", "//ink/types:duration", - "@com_google_absl//absl/log", "@com_google_absl//absl/log:absl_check", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/status", "@com_google_absl//absl/types:span", ], @@ -117,8 +117,8 @@ cc_library( "@com_google_absl//absl/base:core_headers", "@com_google_absl//absl/base:nullability", "@com_google_absl//absl/container:inlined_vector", - "@com_google_absl//absl/log", "@com_google_absl//absl/log:absl_check", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/status", "@com_google_absl//absl/strings:str_format", "@com_google_absl//absl/types:span", diff --git a/ink/strokes/in_progress_stroke.cc b/ink/strokes/in_progress_stroke.cc index e8fabee1..18c8b1d6 100644 --- a/ink/strokes/in_progress_stroke.cc +++ b/ink/strokes/in_progress_stroke.cc @@ -21,7 +21,7 @@ #include "absl/algorithm/container.h" #include "absl/container/inlined_vector.h" #include "absl/log/absl_check.h" -#include "absl/log/log.h" +#include "absl/log/absl_log.h" #include "absl/status/status.h" #include "absl/strings/str_format.h" #include "absl/types/span.h" @@ -245,8 +245,8 @@ Stroke InProgressStroke::CopyToStroke( if (modeled_shape.ok()) { return Stroke(*brush, processed_inputs_.MakeDeepCopy(), *modeled_shape); } else { - LOG(WARNING) << "Failed to create ModeledShape for InProgressStroke: " - << modeled_shape.status(); + ABSL_LOG(WARNING) << "Failed to create ModeledShape for InProgressStroke: " + << modeled_shape.status(); return Stroke(*brush, processed_inputs_.MakeDeepCopy(), ModeledShape::WithEmptyGroups(brush->CoatCount())); } diff --git a/ink/strokes/internal/BUILD.bazel b/ink/strokes/internal/BUILD.bazel index 9b24c4f3..67561d4c 100644 --- a/ink/strokes/internal/BUILD.bazel +++ b/ink/strokes/internal/BUILD.bazel @@ -161,8 +161,8 @@ cc_library( "@com_google_absl//absl/algorithm:container", "@com_google_absl//absl/base:nullability", "@com_google_absl//absl/container:inlined_vector", - "@com_google_absl//absl/log", "@com_google_absl//absl/log:absl_check", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/types:span", ], ) @@ -197,8 +197,8 @@ cc_library( "//ink/geometry/internal:algorithms", "@com_google_absl//absl/container:inlined_vector", "@com_google_absl//absl/functional:overload", - "@com_google_absl//absl/log", "@com_google_absl//absl/log:absl_check", + "@com_google_absl//absl/log:absl_log", "@com_google_absl//absl/strings", ], ) diff --git a/ink/strokes/internal/brush_tip_modeler.cc b/ink/strokes/internal/brush_tip_modeler.cc index 5fa0cf10..1558f86a 100644 --- a/ink/strokes/internal/brush_tip_modeler.cc +++ b/ink/strokes/internal/brush_tip_modeler.cc @@ -25,7 +25,7 @@ #include "absl/base/nullability.h" #include "absl/container/inlined_vector.h" #include "absl/log/absl_check.h" -#include "absl/log/log.h" +#include "absl/log/absl_log.h" #include "absl/types/span.h" #include "ink/brush/brush_behavior.h" #include "ink/brush/brush_tip.h" @@ -57,8 +57,9 @@ float InitialTargetModifierValue(BrushBehavior::Target target) { case BrushBehavior::Target::kLuminosity: return 0.f; } - LOG(FATAL) << "`target` should not be able to have non-enumerator value: " - << static_cast(target); + ABSL_LOG(FATAL) + << "`target` should not be able to have non-enumerator value: " + << static_cast(target); } bool SourceOutOfRangeBehaviorHasUpperBound( @@ -70,9 +71,10 @@ bool SourceOutOfRangeBehaviorHasUpperBound( case BrushBehavior::OutOfRange::kMirror: return false; } - LOG(FATAL) << "`source_out_of_range_behavior` should not be able to have: " - "non-enumerator value: " - << static_cast(source_out_of_range_behavior); + ABSL_LOG(FATAL) + << "`source_out_of_range_behavior` should not be able to have: " + "non-enumerator value: " + << static_cast(source_out_of_range_behavior); } // Returns the upper bound for values of input source that are affected by this @@ -140,7 +142,7 @@ float DistanceRemainingUpperBound(const BrushBehavior::SourceNode& node, kInputAccelerationLateralInCentimetersPerSecondSquared: return 0; } - LOG(FATAL) + ABSL_LOG(FATAL) << "`node.source` should not be able to have non-enumerator value: " << static_cast(node.source); } @@ -199,7 +201,7 @@ Duration32 TimeRemainingUpperBound(const BrushBehavior::SourceNode& node) { kInputAccelerationLateralInCentimetersPerSecondSquared: return Duration32::Zero(); } - LOG(FATAL) + ABSL_LOG(FATAL) << "`node.source` should not be able to have non-enumerator value: " << static_cast(node.source); } diff --git a/ink/strokes/internal/easing_implementation.cc b/ink/strokes/internal/easing_implementation.cc index b0902eae..bffd9a0e 100644 --- a/ink/strokes/internal/easing_implementation.cc +++ b/ink/strokes/internal/easing_implementation.cc @@ -23,7 +23,7 @@ #include "absl/container/inlined_vector.h" #include "absl/functional/overload.h" #include "absl/log/absl_check.h" -#include "absl/log/log.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_cat.h" #include "ink/brush/easing_function.h" #include "ink/geometry/internal/algorithms.h" @@ -56,9 +56,10 @@ EasingFunction::CubicBezier GetAsCubicBezierParameters( case EasingFunction::Predefined::kStepEnd: break; } - LOG(FATAL) << "Should only be possible for `predefined` to be a predefined " - "cubic Bezier. Got " - << absl::StrCat(predefined); + ABSL_LOG(FATAL) + << "Should only be possible for `predefined` to be a predefined " + "cubic Bezier. Got " + << absl::StrCat(predefined); } } // namespace diff --git a/ink/strokes/stroke.cc b/ink/strokes/stroke.cc index 1553ce8d..83633881 100644 --- a/ink/strokes/stroke.cc +++ b/ink/strokes/stroke.cc @@ -19,7 +19,7 @@ #include #include "absl/log/absl_check.h" -#include "absl/log/log.h" +#include "absl/log/absl_log.h" #include "absl/status/status.h" #include "absl/types/span.h" #include "ink/brush/brush.h" @@ -190,7 +190,8 @@ void Stroke::RegenerateShape() { if (modeled_shape.ok()) { shape_ = *std::move(modeled_shape); } else { - LOG(WARNING) << "Failed to create ModeledShape: " << modeled_shape.status(); + ABSL_LOG(WARNING) << "Failed to create ModeledShape: " + << modeled_shape.status(); shape_ = ModeledShape::WithEmptyGroups(brush_.CoatCount()); }