jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=de7a8a3dab14d917b9e914e3b3c7fb44679dd708

commit de7a8a3dab14d917b9e914e3b3c7fb44679dd708
Author: Jean-Philippe Andre <[email protected]>
Date:   Tue Sep 2 21:29:25 2014 +0900

    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
---
 src/lib/evas/Evas_GL.h                             | 30 +++++++++++++++++++++-
 src/lib/evas/canvas/evas_gl.c                      | 13 ++++++++++
 src/lib/evas/include/evas_private.h                |  1 +
 src/modules/evas/engines/gl_generic/evas_engine.c  |  9 ++++++-
 src/modules/evas/engines/gl_x11/evas_engine.c      |  6 ++++-
 .../evas/engines/software_generic/evas_engine.c    |  8 ++++++
 6 files changed, 64 insertions(+), 3 deletions(-)

diff --git a/src/lib/evas/Evas_GL.h b/src/lib/evas/Evas_GL.h
index 2a51825..8c7f68f 100644
--- a/src/lib/evas/Evas_GL.h
+++ b/src/lib/evas/Evas_GL.h
@@ -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;
 
 /**
@@ -577,6 +580,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
  *        resets the error to @ref EVAS_GL_SUCCESS.
diff --git a/src/lib/evas/canvas/evas_gl.c b/src/lib/evas/canvas/evas_gl.c
index 4ccb937..7984b03 100644
--- a/src/lib/evas/canvas/evas_gl.c
+++ b/src/lib/evas/canvas/evas_gl.c
@@ -497,6 +497,19 @@ evas_gl_api_get(Evas_GL *evas_gl)
 }
 
 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)
 {
    int err;
diff --git a/src/lib/evas/include/evas_private.h 
b/src/lib/evas/include/evas_private.h
index c23b1d4..c1ebb46 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -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);
diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c 
b/src/modules/evas/engines/gl_generic/evas_engine.c
index 499a1b2..37dc5eb 100644
--- a/src/modules/evas/engines/gl_generic/evas_engine.c
+++ b/src/modules/evas/engines/gl_generic/evas_engine.c
@@ -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);
 
diff --git a/src/modules/evas/engines/gl_x11/evas_engine.c 
b/src/modules/evas/engines/gl_x11/evas_engine.c
index 9e6b3c5..877cf17 100644
--- a/src/modules/evas/engines/gl_x11/evas_engine.c
+++ b/src/modules/evas/engines/gl_x11/evas_engine.c
@@ -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.");
diff --git a/src/modules/evas/engines/software_generic/evas_engine.c 
b/src/modules/evas/engines/software_generic/evas_engine.c
index 957ec4e..dca7868 100644
--- a/src/modules/evas/engines/software_generic/evas_engine.c
+++ b/src/modules/evas/engines/software_generic/evas_engine.c
@@ -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
      }
 }

-- 


Reply via email to