egl/android: refactor to use the legit vndk/window.h header
Using the system/window.h header can potentially cause AHB breakage because the system header is reserved for platform internal use. Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org> Reviewed-by: Rob Clark <robdclark@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11206>
This commit is contained in:
parent
1ea949429c
commit
8b7ff78443
|
@ -28,7 +28,6 @@ cp -av platform-frameworks-native/libs/nativewindow/include/vndk \
|
|||
platform-system-core/libsystem/include/system \
|
||||
platform-system-core/liblog/include/log \
|
||||
platform-frameworks-native/libs/nativewindow/include/apex \
|
||||
platform-frameworks-native/libs/nativewindow/include/system \
|
||||
platform-frameworks-native/libs/nativebase/include/nativebase \
|
||||
${dest}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -18,7 +18,6 @@
|
|||
|
||||
/* MESA: A hack to avoid #ifdefs in driver code. */
|
||||
#ifdef ANDROID
|
||||
#include <system/window.h>
|
||||
#include <cutils/native_handle.h>
|
||||
#include <vulkan/vulkan.h>
|
||||
#else
|
||||
|
|
|
@ -2,27 +2,103 @@
|
|||
|
||||
extern "C" {
|
||||
|
||||
AHardwareBuffer* ANativeWindowBuffer_getHardwareBuffer(ANativeWindowBuffer* anwb) {
|
||||
AHardwareBuffer *
|
||||
ANativeWindowBuffer_getHardwareBuffer(ANativeWindowBuffer *anwb)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void AHardwareBuffer_acquire(AHardwareBuffer* buffer) {
|
||||
void
|
||||
AHardwareBuffer_acquire(AHardwareBuffer *buffer)
|
||||
{
|
||||
}
|
||||
|
||||
void AHardwareBuffer_release(AHardwareBuffer* buffer) {
|
||||
void
|
||||
AHardwareBuffer_release(AHardwareBuffer *buffer)
|
||||
{
|
||||
}
|
||||
|
||||
void AHardwareBuffer_describe(const AHardwareBuffer* buffer,
|
||||
AHardwareBuffer_Desc* outDesc) {
|
||||
void
|
||||
AHardwareBuffer_describe(const AHardwareBuffer *buffer,
|
||||
AHardwareBuffer_Desc *outDesc)
|
||||
{
|
||||
}
|
||||
|
||||
int AHardwareBuffer_allocate(const AHardwareBuffer_Desc* desc,
|
||||
AHardwareBuffer** outBuffer) {
|
||||
int
|
||||
AHardwareBuffer_allocate(const AHardwareBuffer_Desc *desc,
|
||||
AHardwareBuffer **outBuffer)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const native_handle_t* AHardwareBuffer_getNativeHandle(const AHardwareBuffer* buffer) {
|
||||
const native_handle_t *
|
||||
AHardwareBuffer_getNativeHandle(const AHardwareBuffer *buffer)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
ANativeWindow_acquire(ANativeWindow *window)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
ANativeWindow_release(ANativeWindow *window)
|
||||
{
|
||||
}
|
||||
|
||||
int32_t
|
||||
ANativeWindow_getFormat(ANativeWindow *window)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ANativeWindow_setSwapInterval(ANativeWindow *window, int interval)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ANativeWindow_query(const ANativeWindow *window,
|
||||
ANativeWindowQuery query,
|
||||
int *value)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ANativeWindow_dequeueBuffer(ANativeWindow *window,
|
||||
ANativeWindowBuffer **buffer,
|
||||
int *fenceFd)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ANativeWindow_queueBuffer(ANativeWindow *window,
|
||||
ANativeWindowBuffer *buffer,
|
||||
int fenceFd)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ANativeWindow_cancelBuffer(ANativeWindow* window,
|
||||
ANativeWindowBuffer* buffer,
|
||||
int fenceFd) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ANativeWindow_setUsage(ANativeWindow *window, uint64_t usage)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ANativeWindow_setSharedBufferMode(ANativeWindow *window,
|
||||
bool sharedBufferMode)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,8 +65,8 @@ struct zwp_linux_dmabuf_v1;
|
|||
#ifdef HAVE_ANDROID_PLATFORM
|
||||
#define LOG_TAG "EGL-DRI2"
|
||||
|
||||
#include <system/window.h>
|
||||
#include <hardware/gralloc.h>
|
||||
#include <vndk/window.h>
|
||||
#endif /* HAVE_ANDROID_PLATFORM */
|
||||
|
||||
#include "eglconfig.h"
|
||||
|
|
|
@ -409,7 +409,7 @@ droid_window_dequeue_buffer(struct dri2_egl_surface *dri2_surf)
|
|||
{
|
||||
int fence_fd;
|
||||
|
||||
if (dri2_surf->window->dequeueBuffer(dri2_surf->window, &dri2_surf->buffer,
|
||||
if (ANativeWindow_dequeueBuffer(dri2_surf->window, &dri2_surf->buffer,
|
||||
&fence_fd))
|
||||
return EGL_FALSE;
|
||||
|
||||
|
@ -420,7 +420,7 @@ droid_window_dequeue_buffer(struct dri2_egl_surface *dri2_surf)
|
|||
* immediate need to write to the buffer. But doing so would require adding
|
||||
* hooks to the DRI2 loader.
|
||||
*
|
||||
* From the ANativeWindow::dequeueBuffer documentation:
|
||||
* From the ANativeWindow_dequeueBuffer documentation:
|
||||
*
|
||||
* The libsync fence file descriptor returned in the int pointed to by
|
||||
* the fenceFd argument will refer to the fence that must signal
|
||||
|
@ -493,8 +493,7 @@ droid_window_enqueue_buffer(_EGLDisplay *disp, struct dri2_egl_surface *dri2_sur
|
|||
*/
|
||||
int fence_fd = dri2_surf->out_fence_fd;
|
||||
dri2_surf->out_fence_fd = -1;
|
||||
dri2_surf->window->queueBuffer(dri2_surf->window, dri2_surf->buffer,
|
||||
fence_fd);
|
||||
ANativeWindow_queueBuffer(dri2_surf->window, dri2_surf->buffer, fence_fd);
|
||||
|
||||
dri2_surf->buffer = NULL;
|
||||
dri2_surf->back = NULL;
|
||||
|
@ -516,11 +515,11 @@ droid_window_cancel_buffer(struct dri2_egl_surface *dri2_surf)
|
|||
int fence_fd = dri2_surf->out_fence_fd;
|
||||
|
||||
dri2_surf->out_fence_fd = -1;
|
||||
ret = dri2_surf->window->cancelBuffer(dri2_surf->window,
|
||||
dri2_surf->buffer, fence_fd);
|
||||
ret = ANativeWindow_cancelBuffer(dri2_surf->window, dri2_surf->buffer,
|
||||
fence_fd);
|
||||
dri2_surf->buffer = NULL;
|
||||
if (ret < 0) {
|
||||
_eglLog(_EGL_WARNING, "ANativeWindow::cancelBuffer failed");
|
||||
_eglLog(_EGL_WARNING, "ANativeWindow_cancelBuffer failed");
|
||||
dri2_surf->base.Lost = EGL_TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -537,8 +536,8 @@ droid_set_shared_buffer_mode(_EGLDisplay *disp, _EGLSurface *surf, bool mode)
|
|||
|
||||
_eglLog(_EGL_DEBUG, "%s: mode=%d", __func__, mode);
|
||||
|
||||
if (native_window_set_shared_buffer_mode(window, mode)) {
|
||||
_eglLog(_EGL_WARNING, "failed native_window_set_shared_buffer_mode"
|
||||
if (ANativeWindow_setSharedBufferMode(window, mode)) {
|
||||
_eglLog(_EGL_WARNING, "failed ANativeWindow_setSharedBufferMode"
|
||||
"(window=%p, mode=%d)", window, mode);
|
||||
return false;
|
||||
}
|
||||
|
@ -575,14 +574,8 @@ droid_create_surface(_EGLDisplay *disp, EGLint type, _EGLConfig *conf,
|
|||
int buffer_count;
|
||||
int min_undequeued_buffers;
|
||||
|
||||
/* Prefer triple buffering for performance reasons. */
|
||||
const int preferred_buffer_count = 3;
|
||||
|
||||
if (window->common.magic != ANDROID_NATIVE_WINDOW_MAGIC) {
|
||||
_eglError(EGL_BAD_NATIVE_WINDOW, "droid_create_surface");
|
||||
goto cleanup_surface;
|
||||
}
|
||||
if (window->query(window, NATIVE_WINDOW_FORMAT, &format)) {
|
||||
format = ANativeWindow_getFormat(window);
|
||||
if (format < 0) {
|
||||
_eglError(EGL_BAD_NATIVE_WINDOW, "droid_create_surface");
|
||||
goto cleanup_surface;
|
||||
}
|
||||
|
@ -590,7 +583,8 @@ droid_create_surface(_EGLDisplay *disp, EGLint type, _EGLConfig *conf,
|
|||
/* Query ANativeWindow for MIN_UNDEQUEUED_BUFFER, minimum amount
|
||||
* of undequeued buffers.
|
||||
*/
|
||||
if (window->query(window, NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS,
|
||||
if (ANativeWindow_query(window,
|
||||
ANATIVEWINDOW_QUERY_MIN_UNDEQUEUED_BUFFERS,
|
||||
&min_undequeued_buffers)) {
|
||||
_eglError(EGL_BAD_NATIVE_WINDOW, "droid_create_surface");
|
||||
goto cleanup_surface;
|
||||
|
@ -612,8 +606,10 @@ droid_create_surface(_EGLDisplay *disp, EGLint type, _EGLConfig *conf,
|
|||
format, dri2_conf->base.NativeVisualID);
|
||||
}
|
||||
|
||||
window->query(window, NATIVE_WINDOW_WIDTH, &dri2_surf->base.Width);
|
||||
window->query(window, NATIVE_WINDOW_HEIGHT, &dri2_surf->base.Height);
|
||||
ANativeWindow_query(window, ANATIVEWINDOW_QUERY_DEFAULT_WIDTH,
|
||||
&dri2_surf->base.Width);
|
||||
ANativeWindow_query(window, ANATIVEWINDOW_QUERY_DEFAULT_HEIGHT,
|
||||
&dri2_surf->base.Height);
|
||||
|
||||
uint32_t usage = strcmp(dri2_dpy->driver_name, "kms_swrast") == 0
|
||||
? GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN
|
||||
|
@ -622,7 +618,7 @@ droid_create_surface(_EGLDisplay *disp, EGLint type, _EGLConfig *conf,
|
|||
if (conf->SurfaceType & EGL_MUTABLE_RENDER_BUFFER_BIT_KHR)
|
||||
usage |= dri2_dpy->front_rendering_usage;
|
||||
|
||||
native_window_set_usage(window, usage);
|
||||
ANativeWindow_setUsage(window, usage);
|
||||
}
|
||||
|
||||
config = dri2_get_dri_config(dri2_conf, type,
|
||||
|
@ -636,7 +632,7 @@ droid_create_surface(_EGLDisplay *disp, EGLint type, _EGLConfig *conf,
|
|||
goto cleanup_surface;
|
||||
|
||||
if (window) {
|
||||
window->common.incRef(&window->common);
|
||||
ANativeWindow_acquire(window);
|
||||
dri2_surf->window = window;
|
||||
}
|
||||
|
||||
|
@ -678,7 +674,7 @@ droid_destroy_surface(_EGLDisplay *disp, _EGLSurface *surf)
|
|||
if (dri2_surf->buffer)
|
||||
droid_window_cancel_buffer(dri2_surf);
|
||||
|
||||
dri2_surf->window->common.decRef(&dri2_surf->window->common);
|
||||
ANativeWindow_release(dri2_surf->window);
|
||||
}
|
||||
|
||||
if (dri2_surf->dri_image_back) {
|
||||
|
@ -708,7 +704,7 @@ droid_swap_interval(_EGLDisplay *disp, _EGLSurface *surf, EGLint interval)
|
|||
struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
|
||||
struct ANativeWindow *window = dri2_surf->window;
|
||||
|
||||
if (window->setSwapInterval(window, interval))
|
||||
if (ANativeWindow_setSwapInterval(window, interval))
|
||||
return EGL_FALSE;
|
||||
|
||||
surf->SwapInterval = interval;
|
||||
|
@ -924,7 +920,7 @@ droid_swap_buffers(_EGLDisplay *disp, _EGLSurface *draw)
|
|||
/* dri2_surf->buffer can be null even when no error has occured. For
|
||||
* example, if the user has called no GL rendering commands since the
|
||||
* previous eglSwapBuffers, then the driver may have not triggered
|
||||
* a callback to ANativeWindow::dequeueBuffer, in which case
|
||||
* a callback to ANativeWindow_dequeueBuffer, in which case
|
||||
* dri2_surf->buffer remains null.
|
||||
*/
|
||||
if (dri2_surf->buffer)
|
||||
|
@ -1006,15 +1002,15 @@ droid_query_surface(_EGLDisplay *disp, _EGLSurface *surf,
|
|||
switch (attribute) {
|
||||
case EGL_WIDTH:
|
||||
if (dri2_surf->base.Type == EGL_WINDOW_BIT && dri2_surf->window) {
|
||||
dri2_surf->window->query(dri2_surf->window,
|
||||
NATIVE_WINDOW_DEFAULT_WIDTH, value);
|
||||
ANativeWindow_query(dri2_surf->window,
|
||||
ANATIVEWINDOW_QUERY_DEFAULT_WIDTH, value);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
break;
|
||||
case EGL_HEIGHT:
|
||||
if (dri2_surf->base.Type == EGL_WINDOW_BIT && dri2_surf->window) {
|
||||
dri2_surf->window->query(dri2_surf->window,
|
||||
NATIVE_WINDOW_DEFAULT_HEIGHT, value);
|
||||
ANativeWindow_query(dri2_surf->window,
|
||||
ANATIVEWINDOW_QUERY_DEFAULT_HEIGHT, value);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
break;
|
||||
|
@ -1337,22 +1333,22 @@ droid_display_shared_buffer(__DRIdrawable *driDrawable, int fence_fd,
|
|||
dri2_surf->out_fence_fd = -1;
|
||||
}
|
||||
|
||||
if (dri2_surf->window->queueBuffer(dri2_surf->window, dri2_surf->buffer,
|
||||
if (ANativeWindow_queueBuffer(dri2_surf->window, dri2_surf->buffer,
|
||||
fence_fd)) {
|
||||
_eglLog(_EGL_WARNING, "%s: ANativeWindow::queueBuffer failed", __func__);
|
||||
_eglLog(_EGL_WARNING, "%s: ANativeWindow_queueBuffer failed", __func__);
|
||||
close(fence_fd);
|
||||
return;
|
||||
}
|
||||
|
||||
fence_fd = -1;
|
||||
|
||||
if (dri2_surf->window->dequeueBuffer(dri2_surf->window, &dri2_surf->buffer,
|
||||
if (ANativeWindow_dequeueBuffer(dri2_surf->window, &dri2_surf->buffer,
|
||||
&fence_fd)) {
|
||||
/* Tear down the surface because it no longer has a back buffer. */
|
||||
struct dri2_egl_display *dri2_dpy =
|
||||
dri2_egl_display(dri2_surf->base.Resource.Display);
|
||||
|
||||
_eglLog(_EGL_WARNING, "%s: ANativeWindow::dequeueBuffer failed", __func__);
|
||||
_eglLog(_EGL_WARNING, "%s: ANativeWindow_dequeueBuffer failed", __func__);
|
||||
|
||||
dri2_surf->base.Lost = true;
|
||||
dri2_surf->buffer = NULL;
|
||||
|
|
Loading…
Reference in New Issue