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

Commit e6d95cf8 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add a method to libgui flags to handle ANativeWindow properly for media" into main

parents 283f1a51 2bb603a9
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#include <gui/IGraphicBufferProducer.h>
#include <gui/Surface.h>
#include <gui/view/Surface.h>
#include <system/window.h>

namespace android {
namespace flagtools {
@@ -78,6 +79,20 @@ sp<SurfaceType> convertParcelableSurfaceTypeToSurface(const ParcelableSurfaceTyp
}
} // namespace flagtools
namespace mediaflagtools {

sp<MediaSurfaceType> nativeWindowToSurfaceType(ANativeWindow* anw) {
    if (anw == nullptr) {
        return nullptr;
    }

    sp<Surface> surface = Surface::from(anw);
#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_MEDIA_MIGRATION)
    return surface;
#else
    return surface->getIGraphicBufferProducer();
#endif
}

sp<MediaSurfaceType> igbpToSurfaceType(const sp<IGraphicBufferProducer>& igbp) {
    if (igbp == nullptr) {
        return nullptr;
+4 −0
Original line number Diff line number Diff line
@@ -189,6 +189,10 @@ Surface::~Surface() {
#endif // !defined(NO_BINDER)
}

sp<Surface> Surface::from(ANativeWindow* anw) {
    return sp<Surface>::fromExisting(static_cast<Surface*>(anw));
}

#ifndef NO_BINDER
sp<ISurfaceComposer> Surface::composerService() const {
    return ComposerService::getComposerService();
+3 −0
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@
#include <com_android_graphics_libgui_flags.h>
#include <utils/StrongPointer.h>

struct ANativeWindow;

namespace android {

class IGraphicBufferProducer;
@@ -59,6 +61,7 @@ typedef android::sp<android::IGraphicBufferProducer> MediaParcelableSurfaceType;
#endif

namespace mediaflagtools {
sp<MediaSurfaceType> nativeWindowToSurfaceType(ANativeWindow* anw);
sp<MediaSurfaceType> igbpToSurfaceType(const sp<IGraphicBufferProducer>& igbp);
sp<IGraphicBufferProducer> surfaceTypeToIGBP(const sp<MediaSurfaceType>& mst);
sp<SurfaceType> mediaSurfaceToCameraSurfaceType(const sp<MediaSurfaceType>& mst,
+5 −0
Original line number Diff line number Diff line
@@ -132,6 +132,11 @@ public:
    explicit Surface(const sp<IGraphicBufferProducer>& bufferProducer, bool controlledByApp = false,
                     const sp<IBinder>& surfaceControlHandle = nullptr);

    /*
     * Get the underlying Surface from the given ANativeWindow.
     */
    static sp<Surface> from(ANativeWindow* anw);

    /* getIGraphicBufferProducer() returns the IGraphicBufferProducer this
     * Surface was created with. Usually it's an error to use the
     * IGraphicBufferProducer while the Surface is connected.