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

Commit 0256f72d authored by Peiyong Lin's avatar Peiyong Lin
Browse files

[SurfaceFlinger] Add getCompositionPreference APIs to SurfaceComposer.

Previously we added APIs in ConfigStore to return the composition data space
and pixel format that SurfaceFlinger would prefer for the device. This patch we
plumb such information up to SurfaceComposer to prepare HWUI to use it to
render.

BUG: 113530681
Test: Build, flash, boot and verified the output in adb logcat.
Change-Id: Ic96156e103af9f12febc98081179c2dc035a5139
parent 1c960b34
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -558,6 +558,25 @@ public:
        outLayers->clear();
        return reply.readParcelableVector(outLayers);
    }

    virtual status_t getCompositionPreference(ui::Dataspace* dataSpace,
                                              ui::PixelFormat* pixelFormat) const {
        Parcel data, reply;
        status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
        if (error != NO_ERROR) {
            return error;
        }
        error = remote()->transact(BnSurfaceComposer::GET_COMPOSITION_PREFERENCE, data, &reply);
        if (error != NO_ERROR) {
            return error;
        }
        error = static_cast<status_t>(reply.readInt32());
        if (error == NO_ERROR) {
            *dataSpace = static_cast<ui::Dataspace>(reply.readInt32());
            *pixelFormat = static_cast<ui::PixelFormat>(reply.readInt32());
        }
        return error;
    }
};

// Out-of-line virtual method definition to trigger vtable emission in this
@@ -881,6 +900,18 @@ status_t BnSurfaceComposer::onTransact(
            }
            return result;
        }
        case GET_COMPOSITION_PREFERENCE: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            ui::Dataspace dataSpace;
            ui::PixelFormat pixelFormat;
            status_t error = getCompositionPreference(&dataSpace, &pixelFormat);
            reply->writeInt32(error);
            if (error == NO_ERROR) {
                reply->writeInt32(static_cast<int32_t>(dataSpace));
                reply->writeInt32(static_cast<int32_t>(pixelFormat));
            }
            return NO_ERROR;
        }
        default: {
            return BBinder::onTransact(code, data, reply, flags);
        }
+5 −0
Original line number Diff line number Diff line
@@ -854,6 +854,11 @@ void SurfaceComposerClient::setDisplayPowerMode(const sp<IBinder>& token,
    ComposerService::getComposerService()->setPowerMode(token, mode);
}

status_t SurfaceComposerClient::getCompositionPreference(ui::Dataspace* dataSpace,
                                                         ui::PixelFormat* pixelFormat) {
    return ComposerService::getComposerService()->getCompositionPreference(dataSpace, pixelFormat);
}

status_t SurfaceComposerClient::clearAnimationFrameStats() {
    return ComposerService::getComposerService()->clearAnimationFrameStats();
}
+5 −1
Original line number Diff line number Diff line
@@ -214,6 +214,9 @@ public:
     * Requires the ACCESS_SURFACE_FLINGER permission.
     */
    virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const = 0;

    virtual status_t getCompositionPreference(ui::Dataspace* dataSpace,
                                              ui::PixelFormat* pixelFormat) const = 0;
};

// ----------------------------------------------------------------------------
@@ -250,7 +253,8 @@ public:
        ENABLE_VSYNC_INJECTIONS,
        INJECT_VSYNC,
        GET_LAYER_DEBUG_INFO,
        CREATE_SCOPED_CONNECTION
        CREATE_SCOPED_CONNECTION,
        GET_COMPOSITION_PREFERENCE,
    };

    virtual status_t onTransact(uint32_t code, const Parcel& data,
+4 −0
Original line number Diff line number Diff line
@@ -101,6 +101,10 @@ public:
    /* Triggers screen on/off or low power mode and waits for it to complete */
    static void setDisplayPowerMode(const sp<IBinder>& display, int mode);

    //
    static status_t getCompositionPreference(ui::Dataspace* dataSpace,
                                             ui::PixelFormat* pixelFormat);

    // ------------------------------------------------------------------------
    // surface creation / destruction

+4 −0
Original line number Diff line number Diff line
@@ -622,6 +622,10 @@ public:
    status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* /*layers*/) const override {
        return NO_ERROR;
    }
    status_t getCompositionPreference(ui::Dataspace* /*outDataSpace*/,
                                      ui::PixelFormat* /*outPixelFormat*/) const override {
        return NO_ERROR;
    }

protected:
    IBinder* onAsBinder() override { return nullptr; }
Loading