Evas GL: Add API evas_gl_rotation_get

This will be used to increase the chances of having direct
rendering (no fallback to FBO) even if the window is rotated.

The client is then responsible for handling the view rotation.

@feature
This commit is contained in:
Jean-Philippe Andre 2014-09-02 21:29:25 +09:00
parent d3ff6dfa7f
commit de7a8a3dab
6 changed files with 64 additions and 3 deletions

View File

@ -424,7 +424,10 @@ typedef enum _Evas_GL_Stencil_Bits
typedef enum _Evas_GL_Options_Bits
{
EVAS_GL_OPTIONS_NONE = 0, /**< No extra options */
EVAS_GL_OPTIONS_DIRECT = (1<<0) /**< Optional hint to allow rendering directly to evas' window when possible */
EVAS_GL_OPTIONS_DIRECT = (1<<0),/**< Optional hint to allow rendering directly to the Evas window if possible */
EVAS_GL_OPTIONS_CLIENT_SIDE_ROTATION = (1<<1) /**< Force direct rendering even if the canvas is rotated.
* In that case, it is the application's role to rotate the contents of
* the Evas_GL view. @see evas_gl_rotation_get. @since 1.12 */
} Evas_GL_Options_Bits;
/**
@ -576,6 +579,31 @@ EAPI Eina_Bool evas_gl_native_surface_get (Evas_GL *evas_gl, Evas
*/
EAPI Evas_GL_API *evas_gl_api_get (Evas_GL *evas_gl) EINA_ARG_NONNULL(1);
/**
* @brief Get the current rotation of the view, in degrees.
*
* This function should be called in order to properly handle the current
* rotation of the view. It will always return 0 unless the option
* @ref EVAS_GL_OPTIONS_CLIENT_SIDE_ROTATION has been set.
*
* Indeed, in case of direct rendering to the back buffer, the client
* application is responsible for properly rotating its view. This can generally
* be done by applying a rotation to a view matrix.
*
* @param[in] evas_gl The current Evas_GL object
*
* @note The returned value may not be the same as the window rotation, for
* example if indirect rendering is used as a fallback, or if the GPU supports
* transparent rotation of the buffer during swap.
*
* @return 0, 90, 180 or 270 depending on the Evas canvas' orientation.
*
* @see EVAS_GL_OPTIONS_CLIENT_SIDE_ROTATION
*
* @since 1.12
*/
EAPI int evas_gl_rotation_get (Evas_GL *evas_gl) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
/**
* @brief Returns the last error of any evas_gl function called in the current thread.
* Initially, the error is set to @ref EVAS_GL_SUCCESS. A call to @ref evas_gl_error_get

View File

@ -496,6 +496,19 @@ evas_gl_api_get(Evas_GL *evas_gl)
return (Evas_GL_API*)evas_gl->evas->engine.func->gl_api_get(evas_gl->evas->engine.data.output);
}
EAPI int
evas_gl_rotation_get(Evas_GL *evas_gl)
{
MAGIC_CHECK(evas_gl, Evas_GL, MAGIC_EVAS_GL);
return 0;
MAGIC_CHECK_END();
if (!evas_gl->evas->engine.func->gl_rotation_angle_get)
return 0;
return evas_gl->evas->engine.func->gl_rotation_angle_get(evas_gl->evas->engine.data.output);
}
EAPI int
evas_gl_error_get(Evas_GL *evas_gl)
{

View File

@ -1247,6 +1247,7 @@ struct _Evas_Func
int (*gl_error_get) (void *data);
void *(*gl_current_context_get) (void *data);
void *(*gl_current_surface_get) (void *data);
int (*gl_rotation_angle_get) (void *data);
int (*image_load_error_get) (void *data, void *image);
int (*font_run_end_get) (void *data, Evas_Font_Set *font, Evas_Font_Instance **script_fi, Evas_Font_Instance **cur_fi, Evas_Script_Type script, const Eina_Unicode *text, int run_len);

View File

@ -1182,6 +1182,13 @@ eng_gl_current_surface_get(void *data EINA_UNUSED)
return ctx->current_sfc;
}
static int
eng_gl_rotation_angle_get(void *data)
{
if (!evgl_engine->funcs->rotation_angle_get) return 0;
return evgl_engine->funcs->rotation_angle_get(data);
}
static void *
eng_gl_string_query(void *data, int name)
{
@ -1802,7 +1809,7 @@ module_open(Evas_Module *em)
//ORD(gl_surface_query);
// gl_current_context_get is in engine
ORD(gl_current_surface_get);
//ORD(gl_rotation_angle_get);
ORD(gl_rotation_angle_get);
ORD(image_load_error_get);

View File

@ -598,7 +598,11 @@ evgl_eng_rotation_angle_get(void *data)
}
if ((eng_get_ob(re)) && (eng_get_ob(re)->gl_context))
return eng_get_ob(re)->gl_context->rot;
{
if (_evgl_direct_enabled())
return eng_get_ob(re)->gl_context->rot;
return 0;
}
else
{
ERR("Unable to retrieve rotation angle.");

View File

@ -2632,6 +2632,12 @@ eng_gl_current_surface_get(void *data EINA_UNUSED)
return eina_tls_get(gl_current_sfc_key);
}
static int
eng_gl_rotation_angle_get(void *data EINA_UNUSED)
{
return 0;
}
//------------------------------------------------//
/* The following function require that any engine
@ -3072,6 +3078,7 @@ static Evas_Func func =
NULL, // need software mesa for gl rendering <- gl_error_get
NULL, // need software mesa for gl rendering <- gl_current_context_get
NULL, // need software mesa for gl rendering <- gl_current_surface_get
NULL, // need software mesa for gl rendering <- gl_rotation_angle_get
eng_image_load_error_get,
eng_font_run_font_end_get,
eng_image_animated_get,
@ -4096,6 +4103,7 @@ init_gl(void)
ORD(gl_error_get);
ORD(gl_current_context_get);
ORD(gl_current_surface_get);
ORD(gl_rotation_angle_get);
#undef ORD
}
}