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

Commit 4133181b authored by Arne Coucheron's avatar Arne Coucheron
Browse files

libagl: Add eglGetRenderBufferANDROID() extension

which returns the current render buffer as an android_native_buffer_t*

This was removed in AOSP for Gingerbread, but at CAF they put it back
as part of their patch for re-enabling the usage of copybit for
accelerating 2D rendering -> http://tinyurl.com/65mm5p6

Change-Id: I0165bf5b481ae097848c1c644785819f0c127ef1
parent 9f3cd90b
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -229,6 +229,14 @@ struct android_native_buffer_t;
#define EGL_NATIVE_BUFFER_ANDROID       0x3140  /* eglCreateImageKHR target */
#endif

#ifndef EGL_ANDROID_get_render_buffer
#define EGL_ANDROID_get_render_buffer 1
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLClientBuffer EGLAPIENTRY eglGetRenderBufferANDROID(EGLDisplay dpy, EGLSurface draw);
#endif
typedef EGLClientBuffer (EGLAPIENTRYP PFNEGLGETRENDERBUFFERANDROIDPROC) (EGLDisplay dpy, EGLSurface draw);
#endif

#ifndef EGL_ANDROID_swap_rectangle
#define EGL_ANDROID_swap_rectangle 1
#ifdef EGL_EGLEXT_PROTOTYPES
+29 −1
Original line number Diff line number Diff line
@@ -158,6 +158,7 @@ struct egl_surface_t
    virtual     EGLint      getSwapBehavior() const;
    virtual     EGLBoolean  swapBuffers();
    virtual     EGLBoolean  setSwapRectangle(EGLint l, EGLint t, EGLint w, EGLint h);
    virtual     EGLClientBuffer getRenderBuffer() const;
protected:
    GGLSurface              depth;
};
@@ -201,6 +202,9 @@ EGLBoolean egl_surface_t::setSwapRectangle(
{
    return EGL_FALSE;
}
EGLClientBuffer egl_surface_t::getRenderBuffer() const {
    return 0;
}

// ----------------------------------------------------------------------------

@@ -226,6 +230,7 @@ struct egl_window_surface_v2_t : public egl_surface_t
    virtual     EGLint      getRefreshRate() const;
    virtual     EGLint      getSwapBehavior() const;
    virtual     EGLBoolean  setSwapRectangle(EGLint l, EGLint t, EGLint w, EGLint h);
    virtual     EGLClientBuffer  getRenderBuffer() const;

private:
    status_t lock(android_native_buffer_t* buf, int usage, void** vaddr);
@@ -621,6 +626,11 @@ EGLBoolean egl_window_surface_v2_t::setSwapRectangle(
    return EGL_TRUE;
}

EGLClientBuffer egl_window_surface_v2_t::getRenderBuffer() const
{
    return buffer;
}

#ifdef LIBAGL_USE_GRALLOC_COPYBITS

static bool supportedCopybitsDestinationFormat(int format) {
@@ -879,6 +889,7 @@ static char const * const gExtensionsString =
        // "KHR_image_pixmap "
        "EGL_ANDROID_image_native_buffer "
        "EGL_ANDROID_swap_rectangle "
        "EGL_ANDROID_get_render_buffer "
        ;

// ----------------------------------------------------------------------------
@@ -931,6 +942,8 @@ static const extention_map_t gExtentionMap[] = {
            (__eglMustCastToProperFunctionPointerType)&eglDestroyImageKHR }, 
    { "eglSetSwapRectangleANDROID", 
            (__eglMustCastToProperFunctionPointerType)&eglSetSwapRectangleANDROID }, 
    { "eglGetRenderBufferANDROID",
            (__eglMustCastToProperFunctionPointerType)&eglGetRenderBufferANDROID },
};

/*
@@ -2160,3 +2173,18 @@ EGLBoolean eglSetSwapRectangleANDROID(EGLDisplay dpy, EGLSurface draw,

    return EGL_TRUE;
}

EGLClientBuffer eglGetRenderBufferANDROID(EGLDisplay dpy, EGLSurface draw)
{
    if (egl_display_t::is_valid(dpy) == EGL_FALSE)
        return setError(EGL_BAD_DISPLAY, (EGLClientBuffer)0);

    egl_surface_t* d = static_cast<egl_surface_t*>(draw);
    if (!d->isValid())
        return setError(EGL_BAD_SURFACE, (EGLClientBuffer)0);
    if (d->dpy != dpy)
        return setError(EGL_BAD_DISPLAY, (EGLClientBuffer)0);

    // post the surface
    return d->getRenderBuffer();
}
+19 −0
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ static char const * const gExtensionString =
#endif
        "EGL_ANDROID_image_native_buffer "
        "EGL_ANDROID_swap_rectangle "
        "EGL_ANDROID_get_render_buffer "
        ;

// ----------------------------------------------------------------------------
@@ -427,6 +428,8 @@ static const extention_map_t gExtentionMap[] = {
            (__eglMustCastToProperFunctionPointerType)NULL },
    { "glEGLImageTargetRenderbufferStorageOES",
            (__eglMustCastToProperFunctionPointerType)NULL },
    { "eglGetRenderBufferANDROID",
            (__eglMustCastToProperFunctionPointerType)&eglGetRenderBufferANDROID },
};

extern const __eglMustCastToProperFunctionPointerType gExtensionForwarders[MAX_NUMBER_OF_GL_EXTENSIONS];
@@ -1905,3 +1908,19 @@ EGLBoolean eglSetSwapRectangleANDROID(EGLDisplay dpy, EGLSurface draw,
    }
    return setError(EGL_BAD_DISPLAY, NULL);
}

EGLClientBuffer eglGetRenderBufferANDROID(EGLDisplay dpy, EGLSurface draw)
{
    SurfaceRef _s(draw);
    if (!_s.get()) return setError(EGL_BAD_SURFACE, (EGLClientBuffer*)0);

    if (!validate_display_surface(dpy, draw))
        return 0;
    egl_display_t const * const dp = get_display(dpy);
    egl_surface_t const * const s = get_surface(draw);
    if (s->cnx->egl.eglGetRenderBufferANDROID) {
        return s->cnx->egl.eglGetRenderBufferANDROID(
                dp->disp[s->impl].dpy, s->surface);
    }
    return setError(EGL_BAD_DISPLAY, (EGLClientBuffer*)0);
}