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

Commit 582270d6 authored by Jamie Gennis's avatar Jamie Gennis
Browse files

SurfaceTexture: fix queues-to-composer

This change fixes the NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER query of
Surface and SurfaceTextureClient.  Surface now uses the inherited
SurfaceTextureClient implementation of this query.  SurfaceTextureClient
now queries SurfaceFlinger to determine whether buffers that are queued
to its ISurfaceTexture will be sent to SurfaceFlinger (as opposed to
some other process).

Change-Id: Iff187e72f30d454229f07f896b438198978270a8
parent 3cff0866
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -132,9 +132,10 @@ public:
    virtual status_t turnElectronBeamOff(int32_t mode) = 0;
    virtual status_t turnElectronBeamOff(int32_t mode) = 0;
    virtual status_t turnElectronBeamOn(int32_t mode) = 0;
    virtual status_t turnElectronBeamOn(int32_t mode) = 0;


    /* verify that an ISurface was created by SurfaceFlinger.
    /* verify that an ISurfaceTexture was created by SurfaceFlinger.
     */
     */
    virtual bool authenticateSurface(const sp<ISurface>& surface) const = 0;
    virtual bool authenticateSurfaceTexture(
            const sp<ISurfaceTexture>& surface) const = 0;
};
};


// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
+15 −11
Original line number Original line Diff line number Diff line
@@ -31,6 +31,8 @@


#include <ui/DisplayInfo.h>
#include <ui/DisplayInfo.h>


#include <gui/ISurfaceTexture.h>

#include <utils/Log.h>
#include <utils/Log.h>


// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
@@ -166,35 +168,36 @@ public:
        return reply.readInt32();
        return reply.readInt32();
    }
    }


    virtual bool authenticateSurface(const sp<ISurface>& surface) const
    virtual bool authenticateSurfaceTexture(
            const sp<ISurfaceTexture>& surfaceTexture) const
    {
    {
        Parcel data, reply;
        Parcel data, reply;
        int err = NO_ERROR;
        int err = NO_ERROR;
        err = data.writeInterfaceToken(
        err = data.writeInterfaceToken(
                ISurfaceComposer::getInterfaceDescriptor());
                ISurfaceComposer::getInterfaceDescriptor());
        if (err != NO_ERROR) {
        if (err != NO_ERROR) {
            LOGE("ISurfaceComposer::authenticateSurface: error writing "
            LOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
                    "interface descriptor: %s (%d)", strerror(-err), -err);
                    "interface descriptor: %s (%d)", strerror(-err), -err);
            return false;
            return false;
        }
        }
        err = data.writeStrongBinder(surface->asBinder());
        err = data.writeStrongBinder(surfaceTexture->asBinder());
        if (err != NO_ERROR) {
        if (err != NO_ERROR) {
            LOGE("ISurfaceComposer::authenticateSurface: error writing strong "
            LOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
                    "binder to parcel: %s (%d)", strerror(-err), -err);
                    "strong binder to parcel: %s (%d)", strerror(-err), -err);
            return false;
            return false;
        }
        }
        err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data,
        err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data,
                &reply);
                &reply);
        if (err != NO_ERROR) {
        if (err != NO_ERROR) {
            LOGE("ISurfaceComposer::authenticateSurface: error performing "
            LOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
                    "transaction: %s (%d)", strerror(-err), -err);
                    "performing transaction: %s (%d)", strerror(-err), -err);
            return false;
            return false;
        }
        }
        int32_t result = 0;
        int32_t result = 0;
        err = reply.readInt32(&result);
        err = reply.readInt32(&result);
        if (err != NO_ERROR) {
        if (err != NO_ERROR) {
            LOGE("ISurfaceComposer::authenticateSurface: error retrieving "
            LOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
                    "result: %s (%d)", strerror(-err), -err);
                    "retrieving result: %s (%d)", strerror(-err), -err);
            return false;
            return false;
        }
        }
        return result != 0;
        return result != 0;
@@ -291,8 +294,9 @@ status_t BnSurfaceComposer::onTransact(
        } break;
        } break;
        case AUTHENTICATE_SURFACE: {
        case AUTHENTICATE_SURFACE: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            sp<ISurface> surface = interface_cast<ISurface>(data.readStrongBinder());
            sp<ISurfaceTexture> surfaceTexture =
            int32_t result = authenticateSurface(surface) ? 1 : 0;
                    interface_cast<ISurfaceTexture>(data.readStrongBinder());
            int32_t result = authenticateSurfaceTexture(surfaceTexture) ? 1 : 0;
            reply->writeInt32(result);
            reply->writeInt32(result);
        } break;
        } break;
        default:
        default:
+0 −3
Original line number Original line Diff line number Diff line
@@ -342,9 +342,6 @@ sp<IBinder> Surface::asBinder() const {


int Surface::query(int what, int* value) const {
int Surface::query(int what, int* value) const {
    switch (what) {
    switch (what) {
    case NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER:
        *value = 1;
        return NO_ERROR;
    case NATIVE_WINDOW_CONCRETE_TYPE:
    case NATIVE_WINDOW_CONCRETE_TYPE:
        *value = NATIVE_WINDOW_SURFACE;
        *value = NATIVE_WINDOW_SURFACE;
        return NO_ERROR;
        return NO_ERROR;
+11 −1
Original line number Original line Diff line number Diff line
@@ -18,6 +18,8 @@
//#define LOG_NDEBUG 0
//#define LOG_NDEBUG 0


#include <gui/SurfaceTextureClient.h>
#include <gui/SurfaceTextureClient.h>
#include <surfaceflinger/ISurfaceComposer.h>
#include <surfaceflinger/SurfaceComposerClient.h>


#include <utils/Log.h>
#include <utils/Log.h>


@@ -234,7 +236,15 @@ int SurfaceTextureClient::query(int what, int* value) const {
                }
                }
                break;
                break;
            case NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER:
            case NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER:
                {
                    sp<ISurfaceComposer> composer(
                            ComposerService::getComposerService());
                    if (composer->authenticateSurfaceTexture(mSurfaceTexture)) {
                        *value = 1;
                    } else {
                        *value = 0;
                        *value = 0;
                    }
                }
                return NO_ERROR;
                return NO_ERROR;
            case NATIVE_WINDOW_CONCRETE_TYPE:
            case NATIVE_WINDOW_CONCRETE_TYPE:
                *value = NATIVE_WINDOW_SURFACE_TEXTURE_CLIENT;
                *value = NATIVE_WINDOW_SURFACE_TEXTURE_CLIENT;
+5 −0
Original line number Original line Diff line number Diff line
@@ -133,6 +133,11 @@ sp<ISurface> Layer::createSurface()
    return sur;
    return sur;
}
}


wp<IBinder> Layer::getSurfaceTextureBinder() const
{
    return mSurfaceTexture->asBinder();
}

status_t Layer::setBuffers( uint32_t w, uint32_t h,
status_t Layer::setBuffers( uint32_t w, uint32_t h,
                            PixelFormat format, uint32_t flags)
                            PixelFormat format, uint32_t flags)
{
{
Loading