diff options
author | 2020-08-24 18:18:19 -0700 | |
---|---|---|
committer | 2020-09-16 10:04:12 -0700 | |
commit | 74e17562e4166e11c2e4f33126088c5ed35ea0e7 (patch) | |
tree | 0f2c1593ecb62de6dd3cf3425c90f9a5aaa8dc89 /libs/gui/ISurfaceComposer.cpp | |
parent | 934e82a98dd5a528bef61e035db412963f9ab5f3 (diff) |
SurfaceFlinger: Shared timeline plumbing
Add plumbing to get shared timeline data from Surface Flinger to HWUI
and back.
Bug: 162890382
Bug: 162888881
Test: SF unit tests
Change-Id: Ifb76e6bf28d43c051e6c8ff568437ec9a106b865
Diffstat (limited to 'libs/gui/ISurfaceComposer.cpp')
-rw-r--r-- | libs/gui/ISurfaceComposer.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp index 0ac493dab1..8b65ea1cbe 100644 --- a/libs/gui/ISurfaceComposer.cpp +++ b/libs/gui/ISurfaceComposer.cpp @@ -1150,6 +1150,38 @@ public: return NO_ERROR; } + + virtual status_t setFrameTimelineVsync(const sp<IGraphicBufferProducer>& surface, + int64_t frameTimelineVsyncId) { + Parcel data, reply; + status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); + if (err != NO_ERROR) { + ALOGE("setFrameTimelineVsync: failed writing interface token: %s (%d)", strerror(-err), + -err); + return err; + } + + err = data.writeStrongBinder(IInterface::asBinder(surface)); + if (err != NO_ERROR) { + ALOGE("setFrameTimelineVsync: failed writing strong binder: %s (%d)", strerror(-err), + -err); + return err; + } + + err = data.writeInt64(frameTimelineVsyncId); + if (err != NO_ERROR) { + ALOGE("setFrameTimelineVsync: failed writing int64_t: %s (%d)", strerror(-err), -err); + return err; + } + + err = remote()->transact(BnSurfaceComposer::SET_FRAME_TIMELINE_VSYNC, data, &reply); + if (err != NO_ERROR) { + ALOGE("setFrameTimelineVsync: failed to transact: %s (%d)", strerror(-err), err); + return err; + } + + return reply.readInt32(); + } }; // Out-of-line virtual method definition to trigger vtable emission in this @@ -1950,6 +1982,33 @@ status_t BnSurfaceComposer::onTransact( } return NO_ERROR; } + case SET_FRAME_TIMELINE_VSYNC: { + CHECK_INTERFACE(ISurfaceComposer, data, reply); + sp<IBinder> binder; + status_t err = data.readStrongBinder(&binder); + if (err != NO_ERROR) { + ALOGE("setFrameTimelineVsync: failed to read strong binder: %s (%d)", + strerror(-err), -err); + return err; + } + sp<IGraphicBufferProducer> surface = interface_cast<IGraphicBufferProducer>(binder); + if (!surface) { + ALOGE("setFrameTimelineVsync: failed to cast to IGraphicBufferProducer: %s (%d)", + strerror(-err), -err); + return err; + } + int64_t frameTimelineVsyncId; + err = data.readInt64(&frameTimelineVsyncId); + if (err != NO_ERROR) { + ALOGE("setFrameTimelineVsync: failed to read int64_t: %s (%d)", strerror(-err), + -err); + return err; + } + + status_t result = setFrameTimelineVsync(surface, frameTimelineVsyncId); + reply->writeInt32(result); + return NO_ERROR; + } default: { return BBinder::onTransact(code, data, reply, flags); } |