From: Stanislav Vorobiov Date: Tue, 29 Jul 2014 14:01:35 +0000 (+0400) Subject: VIGS/qt5: support rotation X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F07%2F25107%2F2;p=sdk%2Femulator%2Fqemu.git VIGS/qt5: support rotation Rotation is supported via ortho multiplication Change-Id: I1f569e259a61b200adb707104b066a4f9fa69213 Signed-off-by: Stanislav Vorobiov --- diff --git a/hw/vigs/vigs_gl_backend.c b/hw/vigs/vigs_gl_backend.c index eda75cd316..8b527b9975 100644 --- a/hw/vigs/vigs_gl_backend.c +++ b/hw/vigs/vigs_gl_backend.c @@ -35,9 +35,11 @@ #include "vigs_utils.h" #include "vigs_ref.h" #include "winsys_gl.h" +#include extern uint32_t qt5_window_width; extern uint32_t qt5_window_height; +extern int qt5_window_angle; struct vigs_gl_surface; @@ -99,6 +101,13 @@ struct vigs_gl_surface * Ortho matrix for this surface. */ GLfloat ortho[16]; + + /* + * Rotation angle and corresponding ortho, + * for display. + */ + int dpy_angle; + GLfloat dpy_ortho[16]; }; static __inline struct vigs_winsys_gl_surface @@ -657,6 +666,28 @@ static void vigs_gl_create_ortho(GLfloat left, GLfloat right, ortho[15] = 1.0f; } +static void vigs_gl_rotate_ortho(const GLfloat ortho[16], + GLfloat angle, + GLfloat res[16]) +{ + GLfloat rot[4][4] = { + { cos(angle), sin(angle), 0, 0 }, + { -sin(angle), cos(angle), 0, 0 }, + { 0, 0, 1, 0 }, + { 0, 0, 0, 1 } + }; + int i, j, k; + + for (i = 0; i < 4; ++i) { + for (j = 0; j < 4; ++j) { + res[i * 4 + j] = 0.0f; + for (k = 0; k < 4; ++k) { + res[i * 4 + j] += ortho[i * 4 + k] * rot[k][j]; + } + } + } +} + static void vigs_gl_translate_color(vigsp_color color, vigsp_surface_format format, GLfloat res[4]) @@ -1399,6 +1430,7 @@ static bool vigs_gl_backend_composite(struct vigs_surface *surface, GLfloat *tex_coords; const struct vigs_plane *sorted_planes[VIGS_MAX_PLANES]; bool scale; + GLfloat *ortho; VIGS_LOG_TRACE("enter"); @@ -1439,6 +1471,18 @@ static bool vigs_gl_backend_composite(struct vigs_surface *surface, } } + if (qt5_window_angle == 0) { + ortho = gl_root_sfc->ortho; + } else { + if (gl_root_sfc->dpy_angle != qt5_window_angle) { + vigs_gl_rotate_ortho(gl_root_sfc->ortho, + (float)(360.0f - qt5_window_angle) * M_PI / 180.0f, + gl_root_sfc->dpy_ortho); + gl_root_sfc->dpy_angle = qt5_window_angle; + } + ortho = gl_root_sfc->dpy_ortho; + } + scale = (qt5_window_width != ws_root_sfc->base.base.width) || (qt5_window_height != ws_root_sfc->base.base.height); @@ -1451,7 +1495,7 @@ static bool vigs_gl_backend_composite(struct vigs_surface *surface, gl_backend->UseProgram(gl_backend->dpy_scale_prog_id); gl_backend->UniformMatrix4fv(gl_backend->dpy_scale_prog_proj_loc, 1, GL_FALSE, - gl_root_sfc->ortho); + ortho); texSize[0] = ws_root_sfc->base.base.width; texSize[1] = ws_root_sfc->base.base.height; @@ -1460,7 +1504,7 @@ static bool vigs_gl_backend_composite(struct vigs_surface *surface, } else { gl_backend->UseProgram(gl_backend->dpy_tex_prog_id); gl_backend->UniformMatrix4fv(gl_backend->dpy_tex_prog_proj_loc, 1, GL_FALSE, - gl_root_sfc->ortho); + ortho); } gl_backend->BindTexture(GL_TEXTURE_2D, ws_root_sfc->tex); diff --git a/tizen/src/ui/displaywidget.cpp b/tizen/src/ui/displaywidget.cpp index 9d469c44fd..953dd52897 100644 --- a/tizen/src/ui/displaywidget.cpp +++ b/tizen/src/ui/displaywidget.cpp @@ -10,6 +10,7 @@ void do_mouse_event(int button_type, int event_type, uint32_t qt5_window_width = 0; uint32_t qt5_window_height = 0; +int qt5_window_angle = 0; DisplayWidget::DisplayWidget(QSize resolution, QGLContext *context, QWidget *parent) : QGLWidget(context, parent) @@ -39,6 +40,8 @@ void DisplayWidget::rotate(int angle) rotateAngle = angle; + qt5_window_angle = angle; + /* adjustSize() doesn't work */ resize(0, 0);