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

Commit 1d2eb22c authored by Carlos Martinez Romero's avatar Carlos Martinez Romero
Browse files

Remove some usage of IGBPs in the ICamera.

This change removes the usage of IGBPs in ICamera and the surrounding
code where reasonable. This is part of a refactor outline at go/warren-buffers.

BYPASS_IGBP_IGBC_API_REASON: this CL is part of the migration.
Bug: 342197849
Test: atest android.hardware.cts.CameraTest
Flag: com.android.graphics.libgui.flags.wb_libcameraservice

Change-Id: Ia6632ed53dfa0daa3b9b9c870864e382eed51124
parent fbf5a5bd
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -17,8 +17,20 @@
#pragma once

#include <com_android_graphics_libgui_flags.h>
#include <gui/IGraphicBufferProducer.h>
#include <gui/Surface.h>

#define WB_CAMERA3_AND_PROCESSORS_WITH_DEPENDENCIES                  \
    (COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CAMERA3_AND_PROCESSORS) && \
     COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CONSUMER_BASE_OWNS_BQ) &&  \
     COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_PLATFORM_API_IMPROVEMENTS))

#define WB_LIBCAMERASERVICE_WITH_DEPENDENCIES       \
    (WB_CAMERA3_AND_PROCESSORS_WITH_DEPENDENCIES && \
     COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_LIBCAMERASERVICE))

#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
typedef android::Surface SurfaceType;
#else
typedef android::IGraphicBufferProducer SurfaceType;
#endif
 No newline at end of file
+10 −0
Original line number Diff line number Diff line
@@ -24,7 +24,9 @@
#include <binder/IBinder.h>
#include <binder/Parcelable.h>

#include <gui/Flags.h>
#include <gui/IGraphicBufferProducer.h>
#include <gui/Surface.h>

namespace android {

@@ -46,6 +48,14 @@ class Surface : public Parcelable {
    sp<IGraphicBufferProducer> graphicBufferProducer;
    sp<IBinder> surfaceControlHandle;

#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
    // functions used to convert to a parcelable Surface so it can be passed over binder.
    static Surface fromSurface(const sp<android::Surface>& surface);
    sp<android::Surface> toSurface() const;

    status_t getUniqueId(/* out */ uint64_t* id) const;
#endif

    virtual status_t writeToParcel(Parcel* parcel) const override;
    virtual status_t readFromParcel(const Parcel* parcel) override;

+32 −0
Original line number Diff line number Diff line
@@ -121,6 +121,38 @@ String16 Surface::readMaybeEmptyString16(const Parcel* parcel) {
    return str.value_or(String16());
}

#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
Surface Surface::fromSurface(const sp<android::Surface>& surface) {
    if (surface == nullptr) {
        ALOGE("%s: Error: view::Surface::fromSurface failed due to null surface.", __FUNCTION__);
        return Surface();
    }
    Surface s;
    s.name = String16(surface->getConsumerName());
    s.graphicBufferProducer = surface->getIGraphicBufferProducer();
    s.surfaceControlHandle = surface->getSurfaceControlHandle();
    return s;
}

sp<android::Surface> Surface::toSurface() const {
    if (graphicBufferProducer == nullptr) return nullptr;
    return new android::Surface(graphicBufferProducer, false, surfaceControlHandle);
}

status_t Surface::getUniqueId(uint64_t* out_id) const {
    if (graphicBufferProducer == nullptr) {
        ALOGE("android::viewSurface::getUniqueId() failed because it's not initialized.");
        return UNEXPECTED_NULL;
    }
    status_t status = graphicBufferProducer->getUniqueId(out_id);
    if (status != OK) {
        ALOGE("android::viewSurface::getUniqueId() failed.");
        return status;
    }
    return OK;
}
#endif

std::string Surface::toString() const {
    std::stringstream out;
    out << name;