Loading aidl/gui/android/view/Surface.aidl +1 −1 Original line number Original line Diff line number Diff line Loading @@ -17,4 +17,4 @@ package android.view; package android.view; parcelable Surface cpp_header "gui/view/Surface.h"; @JavaOnlyStableParcelable @NdkOnlyStableParcelable parcelable Surface cpp_header "gui/view/Surface.h" ndk_header "android/native_window_aidl.h"; libs/gui/include/gui/Surface.h +18 −0 Original line number Original line Diff line number Diff line Loading @@ -113,6 +113,24 @@ public: return surface != nullptr && surface->getIGraphicBufferProducer() != nullptr; return surface != nullptr && surface->getIGraphicBufferProducer() != nullptr; } } static sp<IGraphicBufferProducer> getIGraphicBufferProducer(ANativeWindow* window) { int val; if (window->query(window, NATIVE_WINDOW_CONCRETE_TYPE, &val) >= 0 && val == NATIVE_WINDOW_SURFACE) { return ((Surface*) window)->mGraphicBufferProducer; } return nullptr; } static sp<IBinder> getSurfaceControlHandle(ANativeWindow* window) { int val; if (window->query(window, NATIVE_WINDOW_CONCRETE_TYPE, &val) >= 0 && val == NATIVE_WINDOW_SURFACE) { return ((Surface*) window)->mSurfaceControlHandle; } return nullptr; } /* Attaches a sideband buffer stream to the Surface's IGraphicBufferProducer. /* Attaches a sideband buffer stream to the Surface's IGraphicBufferProducer. * * * A sideband stream is a device-specific mechanism for passing buffers * A sideband stream is a device-specific mechanism for passing buffers Loading libs/nativewindow/ANativeWindow.cpp +48 −0 Original line number Original line Diff line number Diff line Loading @@ -20,10 +20,15 @@ // from nativewindow/includes/system/window.h // from nativewindow/includes/system/window.h // (not to be confused with the compatibility-only window.h from system/core/includes) // (not to be confused with the compatibility-only window.h from system/core/includes) #include <system/window.h> #include <system/window.h> #include <android/native_window_aidl.h> #include <private/android/AHardwareBufferHelpers.h> #include <private/android/AHardwareBufferHelpers.h> #include <log/log.h> #include <ui/GraphicBuffer.h> #include <ui/GraphicBuffer.h> #include <gui/Surface.h> #include <gui/view/Surface.h> #include <android/binder_libbinder.h> using namespace android; using namespace android; Loading Loading @@ -59,6 +64,13 @@ static bool isDataSpaceValid(ANativeWindow* window, int32_t dataSpace) { return false; return false; } } } } static sp<IGraphicBufferProducer> IGraphicBufferProducer_from_ANativeWindow(ANativeWindow* window) { return Surface::getIGraphicBufferProducer(window); } static sp<IBinder> SurfaceControlHandle_from_ANativeWindow(ANativeWindow* window) { return Surface::getSurfaceControlHandle(window); } /************************************************************************************************** /************************************************************************************************** * NDK * NDK Loading Loading @@ -350,6 +362,42 @@ int ANativeWindow_setAutoPrerotation(ANativeWindow* window, bool autoPrerotation return native_window_set_auto_prerotation(window, autoPrerotation); return native_window_set_auto_prerotation(window, autoPrerotation); } } binder_status_t ANativeWindow_readFromParcel( const AParcel* _Nonnull parcel, ANativeWindow* _Nullable* _Nonnull outWindow) { const Parcel* nativeParcel = AParcel_viewPlatformParcel(parcel); // Use a android::view::Surface to unparcel the window std::shared_ptr<android::view::Surface> shimSurface = std::shared_ptr<android::view::Surface>(); status_t ret = shimSurface->readFromParcel(nativeParcel); if (ret != OK) { ALOGE("%s: Error: Failed to create android::view::Surface from AParcel", __FUNCTION__); return STATUS_BAD_VALUE; } sp<Surface> surface = sp<Surface>::make( shimSurface->graphicBufferProducer, false, shimSurface->surfaceControlHandle); ANativeWindow* anw = surface.get(); ANativeWindow_acquire(anw); *outWindow = anw; return STATUS_OK; } binder_status_t ANativeWindow_writeToParcel( ANativeWindow* _Nonnull window, AParcel* _Nonnull parcel) { int value; int err = (*window->query)(window, NATIVE_WINDOW_CONCRETE_TYPE, &value); if (err != OK || value != NATIVE_WINDOW_SURFACE) { ALOGE("Error: ANativeWindow is not backed by Surface"); return STATUS_BAD_VALUE; } // Use a android::view::Surface to parcelize the window std::shared_ptr<android::view::Surface> shimSurface = std::shared_ptr<android::view::Surface>(); shimSurface->graphicBufferProducer = IGraphicBufferProducer_from_ANativeWindow(window); shimSurface->surfaceControlHandle = SurfaceControlHandle_from_ANativeWindow(window); Parcel* nativeParcel = AParcel_viewPlatformParcel(parcel); return shimSurface->writeToParcel(nativeParcel); } /************************************************************************************************** /************************************************************************************************** * apex-stable * apex-stable **************************************************************************************************/ **************************************************************************************************/ Loading libs/nativewindow/Android.bp +2 −0 Original line number Original line Diff line number Diff line Loading @@ -110,9 +110,11 @@ cc_library { static_libs: [ static_libs: [ "libarect", "libarect", "libgrallocusage", "libgrallocusage", "libgui_aidl_static", ], ], header_libs: [ header_libs: [ "libgui_headers", "libarect_headers", "libarect_headers", "libnativebase_headers", "libnativebase_headers", "libnativewindow_headers", "libnativewindow_headers", Loading libs/nativewindow/include/android/native_window.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -376,7 +376,7 @@ int32_t ANativeWindow_clearFrameRate(ANativeWindow* window) __INTRODUCED_IN(__ANDROID_API_U__); __INTRODUCED_IN(__ANDROID_API_U__); #ifdef __cplusplus #ifdef __cplusplus }; } #endif #endif #endif // ANDROID_NATIVE_WINDOW_H #endif // ANDROID_NATIVE_WINDOW_H Loading Loading
aidl/gui/android/view/Surface.aidl +1 −1 Original line number Original line Diff line number Diff line Loading @@ -17,4 +17,4 @@ package android.view; package android.view; parcelable Surface cpp_header "gui/view/Surface.h"; @JavaOnlyStableParcelable @NdkOnlyStableParcelable parcelable Surface cpp_header "gui/view/Surface.h" ndk_header "android/native_window_aidl.h";
libs/gui/include/gui/Surface.h +18 −0 Original line number Original line Diff line number Diff line Loading @@ -113,6 +113,24 @@ public: return surface != nullptr && surface->getIGraphicBufferProducer() != nullptr; return surface != nullptr && surface->getIGraphicBufferProducer() != nullptr; } } static sp<IGraphicBufferProducer> getIGraphicBufferProducer(ANativeWindow* window) { int val; if (window->query(window, NATIVE_WINDOW_CONCRETE_TYPE, &val) >= 0 && val == NATIVE_WINDOW_SURFACE) { return ((Surface*) window)->mGraphicBufferProducer; } return nullptr; } static sp<IBinder> getSurfaceControlHandle(ANativeWindow* window) { int val; if (window->query(window, NATIVE_WINDOW_CONCRETE_TYPE, &val) >= 0 && val == NATIVE_WINDOW_SURFACE) { return ((Surface*) window)->mSurfaceControlHandle; } return nullptr; } /* Attaches a sideband buffer stream to the Surface's IGraphicBufferProducer. /* Attaches a sideband buffer stream to the Surface's IGraphicBufferProducer. * * * A sideband stream is a device-specific mechanism for passing buffers * A sideband stream is a device-specific mechanism for passing buffers Loading
libs/nativewindow/ANativeWindow.cpp +48 −0 Original line number Original line Diff line number Diff line Loading @@ -20,10 +20,15 @@ // from nativewindow/includes/system/window.h // from nativewindow/includes/system/window.h // (not to be confused with the compatibility-only window.h from system/core/includes) // (not to be confused with the compatibility-only window.h from system/core/includes) #include <system/window.h> #include <system/window.h> #include <android/native_window_aidl.h> #include <private/android/AHardwareBufferHelpers.h> #include <private/android/AHardwareBufferHelpers.h> #include <log/log.h> #include <ui/GraphicBuffer.h> #include <ui/GraphicBuffer.h> #include <gui/Surface.h> #include <gui/view/Surface.h> #include <android/binder_libbinder.h> using namespace android; using namespace android; Loading Loading @@ -59,6 +64,13 @@ static bool isDataSpaceValid(ANativeWindow* window, int32_t dataSpace) { return false; return false; } } } } static sp<IGraphicBufferProducer> IGraphicBufferProducer_from_ANativeWindow(ANativeWindow* window) { return Surface::getIGraphicBufferProducer(window); } static sp<IBinder> SurfaceControlHandle_from_ANativeWindow(ANativeWindow* window) { return Surface::getSurfaceControlHandle(window); } /************************************************************************************************** /************************************************************************************************** * NDK * NDK Loading Loading @@ -350,6 +362,42 @@ int ANativeWindow_setAutoPrerotation(ANativeWindow* window, bool autoPrerotation return native_window_set_auto_prerotation(window, autoPrerotation); return native_window_set_auto_prerotation(window, autoPrerotation); } } binder_status_t ANativeWindow_readFromParcel( const AParcel* _Nonnull parcel, ANativeWindow* _Nullable* _Nonnull outWindow) { const Parcel* nativeParcel = AParcel_viewPlatformParcel(parcel); // Use a android::view::Surface to unparcel the window std::shared_ptr<android::view::Surface> shimSurface = std::shared_ptr<android::view::Surface>(); status_t ret = shimSurface->readFromParcel(nativeParcel); if (ret != OK) { ALOGE("%s: Error: Failed to create android::view::Surface from AParcel", __FUNCTION__); return STATUS_BAD_VALUE; } sp<Surface> surface = sp<Surface>::make( shimSurface->graphicBufferProducer, false, shimSurface->surfaceControlHandle); ANativeWindow* anw = surface.get(); ANativeWindow_acquire(anw); *outWindow = anw; return STATUS_OK; } binder_status_t ANativeWindow_writeToParcel( ANativeWindow* _Nonnull window, AParcel* _Nonnull parcel) { int value; int err = (*window->query)(window, NATIVE_WINDOW_CONCRETE_TYPE, &value); if (err != OK || value != NATIVE_WINDOW_SURFACE) { ALOGE("Error: ANativeWindow is not backed by Surface"); return STATUS_BAD_VALUE; } // Use a android::view::Surface to parcelize the window std::shared_ptr<android::view::Surface> shimSurface = std::shared_ptr<android::view::Surface>(); shimSurface->graphicBufferProducer = IGraphicBufferProducer_from_ANativeWindow(window); shimSurface->surfaceControlHandle = SurfaceControlHandle_from_ANativeWindow(window); Parcel* nativeParcel = AParcel_viewPlatformParcel(parcel); return shimSurface->writeToParcel(nativeParcel); } /************************************************************************************************** /************************************************************************************************** * apex-stable * apex-stable **************************************************************************************************/ **************************************************************************************************/ Loading
libs/nativewindow/Android.bp +2 −0 Original line number Original line Diff line number Diff line Loading @@ -110,9 +110,11 @@ cc_library { static_libs: [ static_libs: [ "libarect", "libarect", "libgrallocusage", "libgrallocusage", "libgui_aidl_static", ], ], header_libs: [ header_libs: [ "libgui_headers", "libarect_headers", "libarect_headers", "libnativebase_headers", "libnativebase_headers", "libnativewindow_headers", "libnativewindow_headers", Loading
libs/nativewindow/include/android/native_window.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -376,7 +376,7 @@ int32_t ANativeWindow_clearFrameRate(ANativeWindow* window) __INTRODUCED_IN(__ANDROID_API_U__); __INTRODUCED_IN(__ANDROID_API_U__); #ifdef __cplusplus #ifdef __cplusplus }; } #endif #endif #endif // ANDROID_NATIVE_WINDOW_H #endif // ANDROID_NATIVE_WINDOW_H Loading