diff options
author | 2024-09-12 09:24:41 -0700 | |
---|---|---|
committer | 2024-10-23 10:00:17 -0700 | |
commit | 1d2eb22c39fdfa3d90141a2f56c048161d66cd51 (patch) | |
tree | 3ba38969ef3a581d95bc7952d9079b661f9c79b5 | |
parent | fbf5a5bd50458e284a141867d344938ee7f5b40c (diff) |
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
-rw-r--r-- | libs/gui/include/gui/Flags.h | 14 | ||||
-rw-r--r-- | libs/gui/include/gui/view/Surface.h | 10 | ||||
-rw-r--r-- | libs/gui/view/Surface.cpp | 32 |
3 files changed, 55 insertions, 1 deletions
diff --git a/libs/gui/include/gui/Flags.h b/libs/gui/include/gui/Flags.h index 735375a1e7..34350d2c91 100644 --- a/libs/gui/include/gui/Flags.h +++ b/libs/gui/include/gui/Flags.h @@ -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))
\ No newline at end of file + 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 diff --git a/libs/gui/include/gui/view/Surface.h b/libs/gui/include/gui/view/Surface.h index 7ddac8139a..7c762d3869 100644 --- a/libs/gui/include/gui/view/Surface.h +++ b/libs/gui/include/gui/view/Surface.h @@ -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; diff --git a/libs/gui/view/Surface.cpp b/libs/gui/view/Surface.cpp index 84c2a6ac71..9f57923886 100644 --- a/libs/gui/view/Surface.cpp +++ b/libs/gui/view/Surface.cpp @@ -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; |