From: MaJunqing Date: Mon, 31 Oct 2016 05:32:12 +0000 (+0800) Subject: add indicator sliding effect X-Git-Tag: accepted/tizen/common/20161102.121534~2^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=aac2eb53c6119a3a07a880573b8a27bcc1fa818e;p=platform%2Fupstream%2FSDL.git add indicator sliding effect Change-Id: Id5f5d769e5defb4226d6e70d67081377256eb931 --- diff --git a/src/video/tizen/SDL_tizenmouse.c b/src/video/tizen/SDL_tizenmouse.c index ed1b5ad..3ce0a99 100755 --- a/src/video/tizen/SDL_tizenmouse.c +++ b/src/video/tizen/SDL_tizenmouse.c @@ -31,6 +31,7 @@ #include "SDL_tizenmouse.h" #include "SDL_log.h" #include "SDL_tizentouch.h" +#include "SDL_tizenopengles.h" #include #include @@ -246,6 +247,8 @@ Tizen_FiniMouse(void) mouse->SetRelativeMouseMode = NULL; } +ModelMatrix mMatrix; + Eina_Bool _tizen_cb_event_mousedown_change(void *data, int type, void *event) { @@ -260,6 +263,7 @@ _tizen_cb_event_mousedown_change(void *data, int type, void *event) if(e->x > _this->current_glwin->x && e->x < _this->current_glwin->x + _this->current_glwin->w && e->y > _this->current_glwin->y && e->y < _this->current_glwin->y + 52) { + ModelMatrixLoadIdentity(&mMatrix); _this->current_glwin->indicator_show = SDL_TRUE; _this->current_glwin->last_indicator_showtime = SDL_GetTicks(); } @@ -269,6 +273,7 @@ _tizen_cb_event_mousedown_change(void *data, int type, void *event) if(e->x > _this->current_glwin->x && e->x < _this->current_glwin->x + 52 && e->y > _this->current_glwin->y && e->y < _this->current_glwin->y + _this->current_glwin->h) { + ModelMatrixLoadIdentity(&mMatrix); _this->current_glwin->indicator_show = SDL_TRUE; _this->current_glwin->last_indicator_showtime = SDL_GetTicks(); } @@ -278,6 +283,7 @@ _tizen_cb_event_mousedown_change(void *data, int type, void *event) if(e->x > _this->current_glwin->x && e->x < _this->current_glwin->x + _this->current_glwin->w && e->y > _this->current_glwin->y + _this->current_glwin->h -52 && e->y < _this->current_glwin->y + _this->current_glwin->h) { + ModelMatrixLoadIdentity(&mMatrix); _this->current_glwin->indicator_show = SDL_TRUE; _this->current_glwin->last_indicator_showtime = SDL_GetTicks(); } @@ -287,6 +293,7 @@ _tizen_cb_event_mousedown_change(void *data, int type, void *event) if(e->x > _this->current_glwin->x + _this->current_glwin->w -52 && e->x < _this->current_glwin->x + _this->current_glwin->w && e->y > _this->current_glwin->y && e->y < _this->current_glwin->y + _this->current_glwin->h) { + ModelMatrixLoadIdentity(&mMatrix); _this->current_glwin->indicator_show = SDL_TRUE; _this->current_glwin->last_indicator_showtime = SDL_GetTicks(); } diff --git a/src/video/tizen/SDL_tizenopengles.c b/src/video/tizen/SDL_tizenopengles.c index da58f43..b32f8d6 100755 --- a/src/video/tizen/SDL_tizenopengles.c +++ b/src/video/tizen/SDL_tizenopengles.c @@ -134,6 +134,36 @@ unsigned int textureID; unsigned int indicator_vbo[4], indicator_ibo[4]; unsigned short indicator_index; +extern void ModelMatrixLoadIdentity(ModelMatrix* matrix) +{ + matrix->m[0][0] = 1.0f; + matrix->m[0][1] = 0.0f; + matrix->m[0][2] = 0.0f; + matrix->m[0][3] = 0.0f; + + matrix->m[1][0] = 0.0f; + matrix->m[1][1] = 1.0f; + matrix->m[1][2] = 0.0f; + matrix->m[1][3] = 0.0f; + + matrix->m[2][0] = 0.0f; + matrix->m[2][1] = 0.0f; + matrix->m[2][2] = 1.0f; + matrix->m[2][3] = 0.0f; + + matrix->m[3][0] = 0.0f; + matrix->m[3][1] = 0.0f; + matrix->m[3][2] = 0.0f; + matrix->m[3][3] = 1.0f; +} + +static void ModelMatrixTranslate(ModelMatrix* matrix, GLfloat x, GLfloat y, GLfloat z) +{ + matrix->m[3][0] += (matrix->m[0][0] * x + matrix->m[1][0] * y + matrix->m[2][0] * z); + matrix->m[3][1] += (matrix->m[0][1] * x + matrix->m[1][1] * y + matrix->m[2][1] * z); + matrix->m[3][2] += (matrix->m[0][2] * x + matrix->m[1][2] * y + matrix->m[2][2] * z); + matrix->m[3][3] += (matrix->m[0][3] * x + matrix->m[1][3] * y + matrix->m[2][3] * z); +} void Tizen_glTexImage2d() { @@ -146,6 +176,7 @@ void Tizen_glTexImage2d() 0, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned char*)fileInfo.sharedFile->address); } + ModelMatrix mMatrix; static int Indicator_GLES_Init(SDL_Window* window) { SDL_WindowData *wind = window->driverdata; @@ -163,10 +194,11 @@ static int Indicator_GLES_Init(SDL_Window* window) GLchar vShaderStr[] = "attribute vec4 vVertices;\n" "attribute vec2 vCoord;\n" + "uniform mat4 modelMatrix;\n" "varying vec2 Coord;\n" "void main()\n" "{\n" - " gl_Position = vVertices;\n" + " gl_Position = modelMatrix * vVertices;\n" " Coord = vCoord;\n" "}\n"; @@ -201,9 +233,6 @@ static int Indicator_GLES_Init(SDL_Window* window) Mainctx.glAttachShader(programObject, vertexShader); Mainctx.glAttachShader(programObject, fragmentShader); - Mainctx.glBindAttribLocation(programObject, 0, "vVertices"); - Mainctx.glBindAttribLocation(programObject, 1, "vCoord"); - Mainctx.glLinkProgram(programObject); Mainctx.glGetProgramiv(programObject, GL_LINK_STATUS, &linked); @@ -240,6 +269,10 @@ static int Indicator_GLES_Init(SDL_Window* window) /* Ceates and initializes a buffer object's data store */ Mainctx.glBufferData(GL_ARRAY_BUFFER, 12 * 4, vCoord, GL_STATIC_DRAW); + Mainctx.glBindAttribLocation(programObject, 0, "vVertices"); + Mainctx.glBindAttribLocation(programObject, 1, "vCoord"); + + ModelMatrixLoadIdentity(&mMatrix); Mainctx.glGenTextures(1, &textureID); @@ -286,6 +319,27 @@ Tizen_GLES_SwapWindow(_THIS, SDL_Window *window) if(window->last_indicator_showtime + 3000 < SDL_GetTicks()) { + switch(window->indicator_type) + { + case 0://0 + ModelMatrixTranslate(&mMatrix, 0.0f, 0.02f, 0.0f); + break; + case 1://90 + ModelMatrixTranslate(&mMatrix, -0.02f, 0.0f, 0.0f); + break; + case 2://180 + ModelMatrixTranslate(&mMatrix, 0.0f, -0.02f, 0.0f); + break; + case 3://270 + ModelMatrixTranslate(&mMatrix, 0.02f, 0.0f, 0.0f); + break; + } + } + + Uint32 time = window->last_indicator_showtime; + Uint32 getTick = SDL_GetTicks(); + if(time + 3000> getTick && time + 4000 < getTick) + { window->indicator_show = SDL_FALSE; } @@ -301,6 +355,8 @@ Tizen_GLES_SwapWindow(_THIS, SDL_Window *window) Mainctx.glBindBuffer(GL_ARRAY_BUFFER, indicator_ibo[window->indicator_type]); Mainctx.glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, 0); + Mainctx.glUniformMatrix4fv(Mainctx.glGetUniformLocation(programObject, "modelMatrix"), 1, GL_FALSE, mMatrix.m); + Mainctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, fileInfo.ImageWidth, fileInfo.ImageHeight,0, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned char*)fileInfo.sharedFile->address); Mainctx.glEnableVertexAttribArray(0); Mainctx.glEnableVertexAttribArray(1); @@ -466,6 +522,8 @@ SDL_IndicatorProcessEvent(SDL_Event * event, SDL_Window *window) Mainctx.glBindTexture(GL_TEXTURE_2D, textureID); Mainctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, fileInfo.ImageWidth, fileInfo.ImageHeight,0, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned char*)fileInfo.sharedFile->address); + + ModelMatrixLoadIdentity(&mMatrix); window->indicator_show = SDL_TRUE; window->last_indicator_showtime = SDL_GetTicks(); } diff --git a/src/video/tizen/SDL_tizenopengles.h b/src/video/tizen/SDL_tizenopengles.h index 37ba1eb..db7ac37 100755 --- a/src/video/tizen/SDL_tizenopengles.h +++ b/src/video/tizen/SDL_tizenopengles.h @@ -48,6 +48,13 @@ extern SDL_GLContext Tizen_GLES_CreateContext(_THIS, SDL_Window *window); extern void Tizen_GLES_SwapWindow(_THIS, SDL_Window *window); extern int Tizen_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context); extern void Tizen_GLES_DeleteContext(_THIS, SDL_GLContext context); + +typedef struct +{ + float m[4][4]; +}ModelMatrix; + +extern void ModelMatrixLoadIdentity(ModelMatrix* matrix); #endif #endif /* _SDL_tizenopengles_h */