Loading libs/gui/include/gui/Flags.h +13 −1 Original line number Diff line number Diff line Loading @@ -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 libs/gui/include/gui/view/Surface.h +10 −0 Original line number Diff line number Diff line Loading @@ -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 { Loading @@ -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; Loading libs/gui/view/Surface.cpp +32 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading
libs/gui/include/gui/Flags.h +13 −1 Original line number Diff line number Diff line Loading @@ -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
libs/gui/include/gui/view/Surface.h +10 −0 Original line number Diff line number Diff line Loading @@ -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 { Loading @@ -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; Loading
libs/gui/view/Surface.cpp +32 −0 Original line number Diff line number Diff line Loading @@ -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; Loading