diff options
| author | 2017-12-05 15:41:05 +0000 | |
|---|---|---|
| committer | 2017-12-05 15:41:05 +0000 | |
| commit | 1eaa10357344343b91d242a7ea774cc23beeab74 (patch) | |
| tree | 365a0ab6b375415e9afa5d0138b5ff0b6a7321af /libs/gui/SurfaceControl.cpp | |
| parent | 5d95727816f7660c86c329a15a7af398c3d94f29 (diff) | |
| parent | f3cf4bcfa2c558f03e178f7044d3cb12fa0e73ed (diff) | |
Merge "Make SurfaceControl parcelable (2/2)"
Diffstat (limited to 'libs/gui/SurfaceControl.cpp')
| -rw-r--r-- | libs/gui/SurfaceControl.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libs/gui/SurfaceControl.cpp b/libs/gui/SurfaceControl.cpp index f6a2b8fed6..f5fb8acf44 100644 --- a/libs/gui/SurfaceControl.cpp +++ b/libs/gui/SurfaceControl.cpp @@ -166,5 +166,28 @@ sp<SurfaceComposerClient> SurfaceControl::getClient() const return mClient; } +void SurfaceControl::writeToParcel(Parcel* parcel) +{ + parcel->writeStrongBinder(ISurfaceComposerClient::asBinder(mClient->getClient())); + parcel->writeStrongBinder(mHandle); + parcel->writeStrongBinder(IGraphicBufferProducer::asBinder(mGraphicBufferProducer)); +} + +sp<SurfaceControl> SurfaceControl::readFromParcel(Parcel* parcel) +{ + sp<IBinder> client = parcel->readStrongBinder(); + sp<IBinder> handle = parcel->readStrongBinder(); + if (client == nullptr || handle == nullptr) + { + ALOGE("Invalid parcel"); + return nullptr; + } + sp<IBinder> gbp; + parcel->readNullableStrongBinder(&gbp); + return new SurfaceControl(new SurfaceComposerClient( + interface_cast<ISurfaceComposerClient>(client)), + handle.get(), interface_cast<IGraphicBufferProducer>(gbp)); +} + // ---------------------------------------------------------------------------- }; // namespace android |