From 468038bb703be253c984737ec5ace45a104ec544 Mon Sep 17 00:00:00 2001 From: Kevin Lubick Date: Mon, 9 Jan 2023 18:50:53 +0000 Subject: [PATCH] Remove usage of SkIsPow2 We plan to remove this from the public API Change-Id: Iaea539884e24fe27b1c3a61cbaa719b5f4570132 Bug: skbug.com/13983 --- libs/hwui/RecordingCanvas.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libs/hwui/RecordingCanvas.cpp b/libs/hwui/RecordingCanvas.cpp index 3f21940d35a74..5b6fff158f10a 100644 --- a/libs/hwui/RecordingCanvas.cpp +++ b/libs/hwui/RecordingCanvas.cpp @@ -605,12 +605,17 @@ public: }; } +static constexpr inline bool is_power_of_two(int value) { + return (value & (value - 1)) == 0; +} + template void* DisplayListData::push(size_t pod, Args&&... args) { size_t skip = SkAlignPtr(sizeof(T) + pod); SkASSERT(skip < (1 << 24)); if (fUsed + skip > fReserved) { - static_assert(SkIsPow2(SKLITEDL_PAGE), "This math needs updating for non-pow2."); + static_assert(is_power_of_two(SKLITEDL_PAGE), + "This math needs updating for non-pow2."); // Next greater multiple of SKLITEDL_PAGE. fReserved = (fUsed + skip + SKLITEDL_PAGE) & ~(SKLITEDL_PAGE - 1); fBytes.realloc(fReserved);