Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1eaa1035 authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Android (Google) Code Review
Browse files

Merge "Make SurfaceControl parcelable (2/2)"

parents 5d957278 f3cf4bcf
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -543,9 +543,14 @@ SurfaceComposerClient::SurfaceComposerClient(const sp<IGraphicBufferProducer>& r
{
}

SurfaceComposerClient::SurfaceComposerClient(const sp<ISurfaceComposerClient>& client)
    : mStatus(NO_ERROR), mClient(client)
{
}

void SurfaceComposerClient::onFirstRef() {
    sp<ISurfaceComposer> sf(ComposerService::getComposerService());
    if (sf != 0) {
    if (sf != 0 && mStatus == NO_INIT) {
        auto rootProducer = mParent.promote();
        sp<ISurfaceComposerClient> conn;
        conn = (rootProducer != nullptr) ? sf->createScopedConnection(rootProducer) :
+23 −0
Original line number Diff line number Diff line
@@ -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
+1 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ class SurfaceComposerClient : public RefBase
    friend class Composer;
public:
                SurfaceComposerClient();
                SurfaceComposerClient(const sp<ISurfaceComposerClient>& client);
                SurfaceComposerClient(const sp<IGraphicBufferProducer>& parent);
    virtual     ~SurfaceComposerClient();

+3 −0
Original line number Diff line number Diff line
@@ -44,6 +44,9 @@ class SurfaceComposerClient;
class SurfaceControl : public RefBase
{
public:
    static sp<SurfaceControl> readFromParcel(Parcel* parcel);
    void writeToParcel(Parcel* parcel);

    static bool isValid(const sp<SurfaceControl>& surface) {
        return (surface != 0) && surface->isValid();
    }