Loading libs/binder/ndk/include_ndk/android/binder_ibinder.h +21 −12 Original line number Diff line number Diff line Loading @@ -660,13 +660,15 @@ const char* AIBinder_Class_getDescriptor(const AIBinder_Class* clazz) __INTRODUC /** * Whether AIBinder is less than another. * * This provides a per-process-unique total ordering of binders determined by * an underlying allocation address where a null AIBinder* is considered to be * ordered before all other binders. * This provides a per-process-unique total ordering of binders where a null * AIBinder* object is considered to be before all other binder objects. * For instance, two binders refer to the same object in a local or remote * process when both AIBinder_lt(a, b) and AIBinder(b, a) are false. This API * might be used to insert and lookup binders in binary search trees. * * AIBinder* pointers themselves actually also create a per-process-unique total * ordering. However, this ordering is inconsistent with AIBinder_Weak_lt for * remote binders. * remote binders. So, in general, this function should be preferred. * * Available since API level 31. * Loading Loading @@ -698,14 +700,21 @@ AIBinder_Weak* AIBinder_Weak_clone(const AIBinder_Weak* weak); * the same as AIBinder_lt. Similarly, a null AIBinder_Weak* is considered to be * ordered before all other weak references. * * If you have many AIBinder_Weak* objects which are all references to distinct * binder objects which happen to have the same underlying address (as ordered * by AIBinder_lt), these AIBinder_Weak* objects will retain the same order with * respect to all other AIBinder_Weak* pointers with different underlying * addresses and are also guaranteed to have a per-process-unique ordering. That * is, even though multiple AIBinder* instances may happen to be allocated at * the same underlying address, this function will still correctly distinguish * that these are weak pointers to different binder objects. * This function correctly distinguishes binders even if one is deallocated. So, * for instance, an AIBinder_Weak* entry representing a deleted binder will * never compare as equal to an AIBinder_Weak* entry which represents a * different allocation of a binder, even if the two binders were originally * allocated at the same address. That is: * * AIBinder* a = ...; // imagine this has address 0x8 * AIBinder_Weak* bWeak = AIBinder_Weak_new(a); * AIBinder_decStrong(a); // a may be deleted, if this is the last reference * AIBinder* b = ...; // imagine this has address 0x8 (same address as b) * AIBinder_Weak* bWeak = AIBinder_Weak_new(b); * * Then when a/b are compared with other binders, their order will be preserved, * and it will either be the case that AIBinder_Weak_lt(aWeak, bWeak) OR * AIBinder_Weak_lt(bWeak, aWeak), but not both. * * Unlike AIBinder*, the AIBinder_Weak* addresses themselves have nothing to do * with the underlying binder. Loading libs/gui/BLASTBufferQueue.cpp +11 −3 Original line number Diff line number Diff line Loading @@ -117,11 +117,13 @@ void BLASTBufferItemConsumer::getConnectionEvents(uint64_t frameNumber, bool* ne } BLASTBufferQueue::BLASTBufferQueue(const std::string& name, const sp<SurfaceControl>& surface, int width, int height, bool enableTripleBuffering) int width, int height, int32_t format, bool enableTripleBuffering) : mName(name), mSurfaceControl(surface), mSize(width, height), mRequestedSize(mSize), mFormat(format), mNextTransaction(nullptr) { createBufferQueue(&mProducer, &mConsumer); // since the adapter is in the client process, set dequeue timeout Loading @@ -140,7 +142,7 @@ BLASTBufferQueue::BLASTBufferQueue(const std::string& name, const sp<SurfaceCont mBufferItemConsumer->setFrameAvailableListener(this); mBufferItemConsumer->setBufferFreedListener(this); mBufferItemConsumer->setDefaultBufferSize(mSize.width, mSize.height); mBufferItemConsumer->setDefaultBufferFormat(PIXEL_FORMAT_RGBA_8888); mBufferItemConsumer->setDefaultBufferFormat(format); mTransformHint = mSurfaceControl->getTransformHint(); mBufferItemConsumer->setTransformHint(mTransformHint); Loading @@ -164,10 +166,16 @@ BLASTBufferQueue::~BLASTBufferQueue() { t.apply(); } void BLASTBufferQueue::update(const sp<SurfaceControl>& surface, uint32_t width, uint32_t height) { void BLASTBufferQueue::update(const sp<SurfaceControl>& surface, uint32_t width, uint32_t height, int32_t format) { std::unique_lock _lock{mMutex}; mSurfaceControl = surface; if (mFormat != format) { mFormat = format; mBufferItemConsumer->setDefaultBufferFormat(format); } ui::Size newSize(width, height); if (mRequestedSize != newSize) { mRequestedSize.set(newSize); Loading libs/gui/include/gui/BLASTBufferQueue.h +3 −2 Original line number Diff line number Diff line Loading @@ -68,7 +68,7 @@ class BLASTBufferQueue { public: BLASTBufferQueue(const std::string& name, const sp<SurfaceControl>& surface, int width, int height, bool enableTripleBuffering = true); int height, int32_t format, bool enableTripleBuffering = true); sp<IGraphicBufferProducer> getIGraphicBufferProducer() const { return mProducer; Loading @@ -88,7 +88,7 @@ public: void setTransactionCompleteCallback(uint64_t frameNumber, std::function<void(int64_t)>&& transactionCompleteCallback); void update(const sp<SurfaceControl>& surface, uint32_t width, uint32_t height); void update(const sp<SurfaceControl>& surface, uint32_t width, uint32_t height, int32_t format); void flushShadowQueue() { mFlushShadowQueue = true; } status_t setFrameRate(float frameRate, int8_t compatibility, bool shouldBeSeamless); Loading Loading @@ -136,6 +136,7 @@ private: ui::Size mSize GUARDED_BY(mMutex); ui::Size mRequestedSize GUARDED_BY(mMutex); int32_t mFormat GUARDED_BY(mMutex); uint32_t mTransformHint GUARDED_BY(mMutex); Loading libs/gui/tests/BLASTBufferQueue_test.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -45,11 +45,12 @@ using android::hardware::graphics::common::V1_2::BufferUsage; class BLASTBufferQueueHelper { public: BLASTBufferQueueHelper(const sp<SurfaceControl>& sc, int width, int height) { mBlastBufferQueueAdapter = new BLASTBufferQueue("TestBLASTBufferQueue", sc, width, height); mBlastBufferQueueAdapter = new BLASTBufferQueue("TestBLASTBufferQueue", sc, width, height, PIXEL_FORMAT_RGBA_8888); } void update(const sp<SurfaceControl>& sc, int width, int height) { mBlastBufferQueueAdapter->update(sc, width, height); mBlastBufferQueueAdapter->update(sc, width, height, PIXEL_FORMAT_RGBA_8888); } void setNextTransaction(Transaction* next) { Loading services/surfaceflinger/FrameTimeline/FrameTimeline.cpp +27 −12 Original line number Diff line number Diff line Loading @@ -481,22 +481,22 @@ void SurfaceFrame::onPresent(nsecs_t presentTime, int32_t displayFrameJankType, void SurfaceFrame::trace(int64_t displayFrameToken) { using FrameTimelineDataSource = impl::FrameTimeline::FrameTimelineDataSource; { int64_t expectedTimelineCookie = mTraceCookieCounter.getCookieForTracing(); bool missingToken = false; // Expected timeline start FrameTimelineDataSource::Trace([&](FrameTimelineDataSource::TraceContext ctx) { std::lock_guard<std::mutex> lock(mMutex); if (mToken == ISurfaceComposer::INVALID_VSYNC_ID) { ALOGD("Cannot trace SurfaceFrame - %s with invalid token", mLayerName.c_str()); missingToken = true; return; } else if (displayFrameToken == ISurfaceComposer::INVALID_VSYNC_ID) { ALOGD("Cannot trace SurfaceFrame - %s with invalid displayFrameToken", mLayerName.c_str()); missingToken = true; return; } } int64_t expectedTimelineCookie = mTraceCookieCounter.getCookieForTracing(); // Expected timeline start FrameTimelineDataSource::Trace([&](FrameTimelineDataSource::TraceContext ctx) { std::lock_guard<std::mutex> lock(mMutex); auto packet = ctx.NewTracePacket(); packet->set_timestamp_clock_id(perfetto::protos::pbzero::BUILTIN_CLOCK_MONOTONIC); packet->set_timestamp(static_cast<uint64_t>(mPredictions.startTime)); Loading @@ -512,6 +512,13 @@ void SurfaceFrame::trace(int64_t displayFrameToken) { expectedSurfaceFrameStartEvent->set_pid(mOwnerPid); expectedSurfaceFrameStartEvent->set_layer_name(mDebugName); }); if (missingToken) { // If one packet can't be traced because of missing token, then no packets can be traced. // Exit early in this case. return; } // Expected timeline end FrameTimelineDataSource::Trace([&](FrameTimelineDataSource::TraceContext ctx) { std::lock_guard<std::mutex> lock(mMutex); Loading Loading @@ -814,15 +821,16 @@ void FrameTimeline::DisplayFrame::onPresent(nsecs_t signalTime) { } void FrameTimeline::DisplayFrame::trace(pid_t surfaceFlingerPid) const { if (mToken == ISurfaceComposer::INVALID_VSYNC_ID) { ALOGD("Cannot trace DisplayFrame with invalid token"); return; } int64_t expectedTimelineCookie = mTraceCookieCounter.getCookieForTracing(); bool missingToken = false; // Expected timeline start FrameTimelineDataSource::Trace([&](FrameTimelineDataSource::TraceContext ctx) { auto packet = ctx.NewTracePacket(); if (mToken == ISurfaceComposer::INVALID_VSYNC_ID) { ALOGD("Cannot trace DisplayFrame with invalid token"); missingToken = true; return; } packet->set_timestamp_clock_id(perfetto::protos::pbzero::BUILTIN_CLOCK_MONOTONIC); packet->set_timestamp(static_cast<uint64_t>(mSurfaceFlingerPredictions.startTime)); Loading @@ -834,6 +842,13 @@ void FrameTimeline::DisplayFrame::trace(pid_t surfaceFlingerPid) const { expectedDisplayFrameStartEvent->set_token(mToken); expectedDisplayFrameStartEvent->set_pid(surfaceFlingerPid); }); if (missingToken) { // If one packet can't be traced because of missing token, then no packets can be traced. // Exit early in this case. return; } // Expected timeline end FrameTimelineDataSource::Trace([&](FrameTimelineDataSource::TraceContext ctx) { auto packet = ctx.NewTracePacket(); Loading Loading
libs/binder/ndk/include_ndk/android/binder_ibinder.h +21 −12 Original line number Diff line number Diff line Loading @@ -660,13 +660,15 @@ const char* AIBinder_Class_getDescriptor(const AIBinder_Class* clazz) __INTRODUC /** * Whether AIBinder is less than another. * * This provides a per-process-unique total ordering of binders determined by * an underlying allocation address where a null AIBinder* is considered to be * ordered before all other binders. * This provides a per-process-unique total ordering of binders where a null * AIBinder* object is considered to be before all other binder objects. * For instance, two binders refer to the same object in a local or remote * process when both AIBinder_lt(a, b) and AIBinder(b, a) are false. This API * might be used to insert and lookup binders in binary search trees. * * AIBinder* pointers themselves actually also create a per-process-unique total * ordering. However, this ordering is inconsistent with AIBinder_Weak_lt for * remote binders. * remote binders. So, in general, this function should be preferred. * * Available since API level 31. * Loading Loading @@ -698,14 +700,21 @@ AIBinder_Weak* AIBinder_Weak_clone(const AIBinder_Weak* weak); * the same as AIBinder_lt. Similarly, a null AIBinder_Weak* is considered to be * ordered before all other weak references. * * If you have many AIBinder_Weak* objects which are all references to distinct * binder objects which happen to have the same underlying address (as ordered * by AIBinder_lt), these AIBinder_Weak* objects will retain the same order with * respect to all other AIBinder_Weak* pointers with different underlying * addresses and are also guaranteed to have a per-process-unique ordering. That * is, even though multiple AIBinder* instances may happen to be allocated at * the same underlying address, this function will still correctly distinguish * that these are weak pointers to different binder objects. * This function correctly distinguishes binders even if one is deallocated. So, * for instance, an AIBinder_Weak* entry representing a deleted binder will * never compare as equal to an AIBinder_Weak* entry which represents a * different allocation of a binder, even if the two binders were originally * allocated at the same address. That is: * * AIBinder* a = ...; // imagine this has address 0x8 * AIBinder_Weak* bWeak = AIBinder_Weak_new(a); * AIBinder_decStrong(a); // a may be deleted, if this is the last reference * AIBinder* b = ...; // imagine this has address 0x8 (same address as b) * AIBinder_Weak* bWeak = AIBinder_Weak_new(b); * * Then when a/b are compared with other binders, their order will be preserved, * and it will either be the case that AIBinder_Weak_lt(aWeak, bWeak) OR * AIBinder_Weak_lt(bWeak, aWeak), but not both. * * Unlike AIBinder*, the AIBinder_Weak* addresses themselves have nothing to do * with the underlying binder. Loading
libs/gui/BLASTBufferQueue.cpp +11 −3 Original line number Diff line number Diff line Loading @@ -117,11 +117,13 @@ void BLASTBufferItemConsumer::getConnectionEvents(uint64_t frameNumber, bool* ne } BLASTBufferQueue::BLASTBufferQueue(const std::string& name, const sp<SurfaceControl>& surface, int width, int height, bool enableTripleBuffering) int width, int height, int32_t format, bool enableTripleBuffering) : mName(name), mSurfaceControl(surface), mSize(width, height), mRequestedSize(mSize), mFormat(format), mNextTransaction(nullptr) { createBufferQueue(&mProducer, &mConsumer); // since the adapter is in the client process, set dequeue timeout Loading @@ -140,7 +142,7 @@ BLASTBufferQueue::BLASTBufferQueue(const std::string& name, const sp<SurfaceCont mBufferItemConsumer->setFrameAvailableListener(this); mBufferItemConsumer->setBufferFreedListener(this); mBufferItemConsumer->setDefaultBufferSize(mSize.width, mSize.height); mBufferItemConsumer->setDefaultBufferFormat(PIXEL_FORMAT_RGBA_8888); mBufferItemConsumer->setDefaultBufferFormat(format); mTransformHint = mSurfaceControl->getTransformHint(); mBufferItemConsumer->setTransformHint(mTransformHint); Loading @@ -164,10 +166,16 @@ BLASTBufferQueue::~BLASTBufferQueue() { t.apply(); } void BLASTBufferQueue::update(const sp<SurfaceControl>& surface, uint32_t width, uint32_t height) { void BLASTBufferQueue::update(const sp<SurfaceControl>& surface, uint32_t width, uint32_t height, int32_t format) { std::unique_lock _lock{mMutex}; mSurfaceControl = surface; if (mFormat != format) { mFormat = format; mBufferItemConsumer->setDefaultBufferFormat(format); } ui::Size newSize(width, height); if (mRequestedSize != newSize) { mRequestedSize.set(newSize); Loading
libs/gui/include/gui/BLASTBufferQueue.h +3 −2 Original line number Diff line number Diff line Loading @@ -68,7 +68,7 @@ class BLASTBufferQueue { public: BLASTBufferQueue(const std::string& name, const sp<SurfaceControl>& surface, int width, int height, bool enableTripleBuffering = true); int height, int32_t format, bool enableTripleBuffering = true); sp<IGraphicBufferProducer> getIGraphicBufferProducer() const { return mProducer; Loading @@ -88,7 +88,7 @@ public: void setTransactionCompleteCallback(uint64_t frameNumber, std::function<void(int64_t)>&& transactionCompleteCallback); void update(const sp<SurfaceControl>& surface, uint32_t width, uint32_t height); void update(const sp<SurfaceControl>& surface, uint32_t width, uint32_t height, int32_t format); void flushShadowQueue() { mFlushShadowQueue = true; } status_t setFrameRate(float frameRate, int8_t compatibility, bool shouldBeSeamless); Loading Loading @@ -136,6 +136,7 @@ private: ui::Size mSize GUARDED_BY(mMutex); ui::Size mRequestedSize GUARDED_BY(mMutex); int32_t mFormat GUARDED_BY(mMutex); uint32_t mTransformHint GUARDED_BY(mMutex); Loading
libs/gui/tests/BLASTBufferQueue_test.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -45,11 +45,12 @@ using android::hardware::graphics::common::V1_2::BufferUsage; class BLASTBufferQueueHelper { public: BLASTBufferQueueHelper(const sp<SurfaceControl>& sc, int width, int height) { mBlastBufferQueueAdapter = new BLASTBufferQueue("TestBLASTBufferQueue", sc, width, height); mBlastBufferQueueAdapter = new BLASTBufferQueue("TestBLASTBufferQueue", sc, width, height, PIXEL_FORMAT_RGBA_8888); } void update(const sp<SurfaceControl>& sc, int width, int height) { mBlastBufferQueueAdapter->update(sc, width, height); mBlastBufferQueueAdapter->update(sc, width, height, PIXEL_FORMAT_RGBA_8888); } void setNextTransaction(Transaction* next) { Loading
services/surfaceflinger/FrameTimeline/FrameTimeline.cpp +27 −12 Original line number Diff line number Diff line Loading @@ -481,22 +481,22 @@ void SurfaceFrame::onPresent(nsecs_t presentTime, int32_t displayFrameJankType, void SurfaceFrame::trace(int64_t displayFrameToken) { using FrameTimelineDataSource = impl::FrameTimeline::FrameTimelineDataSource; { int64_t expectedTimelineCookie = mTraceCookieCounter.getCookieForTracing(); bool missingToken = false; // Expected timeline start FrameTimelineDataSource::Trace([&](FrameTimelineDataSource::TraceContext ctx) { std::lock_guard<std::mutex> lock(mMutex); if (mToken == ISurfaceComposer::INVALID_VSYNC_ID) { ALOGD("Cannot trace SurfaceFrame - %s with invalid token", mLayerName.c_str()); missingToken = true; return; } else if (displayFrameToken == ISurfaceComposer::INVALID_VSYNC_ID) { ALOGD("Cannot trace SurfaceFrame - %s with invalid displayFrameToken", mLayerName.c_str()); missingToken = true; return; } } int64_t expectedTimelineCookie = mTraceCookieCounter.getCookieForTracing(); // Expected timeline start FrameTimelineDataSource::Trace([&](FrameTimelineDataSource::TraceContext ctx) { std::lock_guard<std::mutex> lock(mMutex); auto packet = ctx.NewTracePacket(); packet->set_timestamp_clock_id(perfetto::protos::pbzero::BUILTIN_CLOCK_MONOTONIC); packet->set_timestamp(static_cast<uint64_t>(mPredictions.startTime)); Loading @@ -512,6 +512,13 @@ void SurfaceFrame::trace(int64_t displayFrameToken) { expectedSurfaceFrameStartEvent->set_pid(mOwnerPid); expectedSurfaceFrameStartEvent->set_layer_name(mDebugName); }); if (missingToken) { // If one packet can't be traced because of missing token, then no packets can be traced. // Exit early in this case. return; } // Expected timeline end FrameTimelineDataSource::Trace([&](FrameTimelineDataSource::TraceContext ctx) { std::lock_guard<std::mutex> lock(mMutex); Loading Loading @@ -814,15 +821,16 @@ void FrameTimeline::DisplayFrame::onPresent(nsecs_t signalTime) { } void FrameTimeline::DisplayFrame::trace(pid_t surfaceFlingerPid) const { if (mToken == ISurfaceComposer::INVALID_VSYNC_ID) { ALOGD("Cannot trace DisplayFrame with invalid token"); return; } int64_t expectedTimelineCookie = mTraceCookieCounter.getCookieForTracing(); bool missingToken = false; // Expected timeline start FrameTimelineDataSource::Trace([&](FrameTimelineDataSource::TraceContext ctx) { auto packet = ctx.NewTracePacket(); if (mToken == ISurfaceComposer::INVALID_VSYNC_ID) { ALOGD("Cannot trace DisplayFrame with invalid token"); missingToken = true; return; } packet->set_timestamp_clock_id(perfetto::protos::pbzero::BUILTIN_CLOCK_MONOTONIC); packet->set_timestamp(static_cast<uint64_t>(mSurfaceFlingerPredictions.startTime)); Loading @@ -834,6 +842,13 @@ void FrameTimeline::DisplayFrame::trace(pid_t surfaceFlingerPid) const { expectedDisplayFrameStartEvent->set_token(mToken); expectedDisplayFrameStartEvent->set_pid(surfaceFlingerPid); }); if (missingToken) { // If one packet can't be traced because of missing token, then no packets can be traced. // Exit early in this case. return; } // Expected timeline end FrameTimelineDataSource::Trace([&](FrameTimelineDataSource::TraceContext ctx) { auto packet = ctx.NewTracePacket(); Loading