From e158ca7e4afa05058fa5290f54f26363b3cee46c Mon Sep 17 00:00:00 2001 From: Jesse Hall Date: Fri, 18 May 2018 15:58:23 -0700 Subject: Fence: use modern sync info API The old sync info API based on the legacy staging Android sync uapi is deprecated; stop using it here so it can eventually be removed. Bug: 35326015 Test: adb shell dumpsys SurfaceFlinger --latency Change-Id: Ida58adb0f0057485d3768b959697b4d583abd80b --- libs/ui/Fence.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'libs/ui/Fence.cpp') diff --git a/libs/ui/Fence.cpp b/libs/ui/Fence.cpp index ff53aa8f25..ed7ccb0bed 100644 --- a/libs/ui/Fence.cpp +++ b/libs/ui/Fence.cpp @@ -109,25 +109,25 @@ nsecs_t Fence::getSignalTime() const { return SIGNAL_TIME_INVALID; } - struct sync_fence_info_data* finfo = sync_fence_info(mFenceFd); + struct sync_file_info* finfo = sync_file_info(mFenceFd); if (finfo == NULL) { - ALOGE("sync_fence_info returned NULL for fd %d", mFenceFd.get()); + ALOGE("sync_file_info returned NULL for fd %d", mFenceFd.get()); return SIGNAL_TIME_INVALID; } if (finfo->status != 1) { - sync_fence_info_free(finfo); + sync_file_info_free(finfo); return SIGNAL_TIME_PENDING; } - struct sync_pt_info* pinfo = NULL; uint64_t timestamp = 0; - while ((pinfo = sync_pt_info(finfo, pinfo)) != NULL) { - if (pinfo->timestamp_ns > timestamp) { - timestamp = pinfo->timestamp_ns; + struct sync_fence_info* pinfo = sync_get_fence_info(finfo); + for (size_t i = 0; i < finfo->num_fences; i++) { + if (pinfo[i].timestamp_ns > timestamp) { + timestamp = pinfo[i].timestamp_ns; } } - sync_fence_info_free(finfo); + sync_file_info_free(finfo); return nsecs_t(timestamp); } -- cgit v1.2.3-59-g8ed1b From 48d7608aa5806192f18e2d572f56a6bc6a10a47c Mon Sep 17 00:00:00 2001 From: Yi Kong Date: Sun, 24 Mar 2019 02:01:06 -0700 Subject: [libs/ui] Modernize codebase by replacing NULL with nullptr Fixes -Wzero-as-null-pointer-constant warning. Test: m Bug: 68236239 Change-Id: I240d39ef4328943447149700b3ece371681078d1 --- libs/ui/Fence.cpp | 2 +- libs/ui/GraphicBuffer.cpp | 16 ++++++++-------- libs/ui/Region.cpp | 2 +- libs/ui/tools/lutgen.cpp | 10 +++++----- 4 files changed, 15 insertions(+), 15 deletions(-) (limited to 'libs/ui/Fence.cpp') diff --git a/libs/ui/Fence.cpp b/libs/ui/Fence.cpp index ed7ccb0bed..4ce891e148 100644 --- a/libs/ui/Fence.cpp +++ b/libs/ui/Fence.cpp @@ -110,7 +110,7 @@ nsecs_t Fence::getSignalTime() const { } struct sync_file_info* finfo = sync_file_info(mFenceFd); - if (finfo == NULL) { + if (finfo == nullptr) { ALOGE("sync_file_info returned NULL for fd %d", mFenceFd.get()); return SIGNAL_TIME_INVALID; } diff --git a/libs/ui/GraphicBuffer.cpp b/libs/ui/GraphicBuffer.cpp index f800627ef7..a66dbc8527 100644 --- a/libs/ui/GraphicBuffer.cpp +++ b/libs/ui/GraphicBuffer.cpp @@ -76,7 +76,7 @@ GraphicBuffer::GraphicBuffer() usage_deprecated = 0; usage = 0; layerCount = 0; - handle = NULL; + handle = nullptr; } // deprecated @@ -143,7 +143,7 @@ void GraphicBuffer::free_handle() GraphicBufferAllocator& allocator(GraphicBufferAllocator::get()); allocator.free(handle); } - handle = NULL; + handle = nullptr; } status_t GraphicBuffer::initCheck() const { @@ -178,7 +178,7 @@ status_t GraphicBuffer::reallocate(uint32_t inWidth, uint32_t inHeight, if (handle) { GraphicBufferAllocator& allocator(GraphicBufferAllocator::get()); allocator.free(handle); - handle = 0; + handle = nullptr; } return initWithSize(inWidth, inHeight, inFormat, inLayerCount, inUsage, "[Reallocation]"); } @@ -452,7 +452,7 @@ status_t GraphicBuffer::unflatten( width = height = stride = format = usage_deprecated = 0; layerCount = 0; usage = 0; - handle = NULL; + handle = nullptr; ALOGE("unflatten: numFds or numInts is too large: %zd, %zd", numFds, numInts); return BAD_VALUE; } @@ -486,7 +486,7 @@ status_t GraphicBuffer::unflatten( width = height = stride = format = usage_deprecated = 0; layerCount = 0; usage = 0; - handle = NULL; + handle = nullptr; ALOGE("unflatten: native_handle_create failed"); return NO_MEMORY; } @@ -497,7 +497,7 @@ status_t GraphicBuffer::unflatten( width = height = stride = format = usage_deprecated = 0; layerCount = 0; usage = 0; - handle = NULL; + handle = nullptr; } mId = static_cast(buf[7]) << 32; @@ -507,7 +507,7 @@ status_t GraphicBuffer::unflatten( mOwner = ownHandle; - if (handle != 0) { + if (handle != nullptr) { buffer_handle_t importedHandle; status_t err = mBufferMapper.importBuffer(handle, uint32_t(width), uint32_t(height), uint32_t(layerCount), format, usage, uint32_t(stride), &importedHandle); @@ -515,7 +515,7 @@ status_t GraphicBuffer::unflatten( width = height = stride = format = usage_deprecated = 0; layerCount = 0; usage = 0; - handle = NULL; + handle = nullptr; ALOGE("unflatten: registerBuffer failed: %s (%d)", strerror(-err), err); return err; } diff --git a/libs/ui/Region.cpp b/libs/ui/Region.cpp index 3bd3748439..224dc2c122 100644 --- a/libs/ui/Region.cpp +++ b/libs/ui/Region.cpp @@ -820,7 +820,7 @@ status_t Region::unflatten(void const* buffer, size_t size) { } if (numRects > (UINT32_MAX / sizeof(Rect))) { - android_errorWriteWithInfoLog(0x534e4554, "29983260", -1, NULL, 0); + android_errorWriteWithInfoLog(0x534e4554, "29983260", -1, nullptr, 0); return NO_MEMORY; } diff --git a/libs/ui/tools/lutgen.cpp b/libs/ui/tools/lutgen.cpp index 97b0822238..85a1cebe7a 100644 --- a/libs/ui/tools/lutgen.cpp +++ b/libs/ui/tools/lutgen.cpp @@ -85,11 +85,11 @@ static const ColorSpace findColorSpace(const string& name) { static int handleCommandLineArgments(int argc, char* argv[]) { static constexpr const char* OPTSTR = "h:d:s:t:"; static const struct option OPTIONS[] = { - { "help", no_argument, 0, 'h' }, - { "dimension", required_argument, 0, 'd' }, - { "source", required_argument, 0, 's' }, - { "target", required_argument, 0, 't' }, - { 0, 0, 0, 0 } // termination of the option list + { "help", no_argument, nullptr, 'h' }, + { "dimension", required_argument, nullptr, 'd' }, + { "source", required_argument, nullptr, 's' }, + { "target", required_argument, nullptr, 't' }, + { nullptr, 0, nullptr, 0 } // termination of the option list }; int opt; -- cgit v1.2.3-59-g8ed1b