}
-void SetSharedImageInfo(Ecore_Ipc_Event_Server_Data* epcEvent, SharedFileInfo* fileInfo)
+void SetSharedImageInfo(Ecore_Ipc_Event_Server_Data* epcEvent, SharedIndicatorInfo* shared_info)
{
if ( (epcEvent->data) && (epcEvent->size > 0) && (((unsigned char *)epcEvent->data)[epcEvent->size - 1] == 0) )
{
int n = epcEvent->response;
- if(n == 0 /*&& n < SHARED_FILE_NUMBER*/)
+ if( n < SHARED_FILE_NUMBER)
{
- fileInfo->SharedFileName = (char*)epcEvent->data;
- fileInfo->SharedFileID = epcEvent->ref;
- fileInfo->SharedFileNumber = epcEvent->ref_to;
- SDL_Log("SetSharedImageInfo: shared file name: %s, shared file id: %d, shared file number: %d", fileInfo->SharedFileName, fileInfo->SharedFileID, fileInfo->SharedFileNumber);
+ shared_info->fileInfo[n].SharedFileName = (char*)epcEvent->data;
+ shared_info->fileInfo[n].SharedFileID = epcEvent->ref;
+ shared_info->fileInfo[n].SharedFileNumber = epcEvent->ref_to;
+ SDL_Log("SetSharedImageInfo: shared file name: %s, shared file id: %d, shared file number: %d", shared_info->fileInfo[n].SharedFileName, shared_info->fileInfo[n].SharedFileID, shared_info->fileInfo[n].SharedFileNumber);
SDL_Log("epcEvent->response: %d", n);
}
}
}
-void SetLockFileInfo(Ecore_Ipc_Event_Server_Data* epcEvent, SharedFileInfo *fileInfo)
+void SetLockFileInfo(Ecore_Ipc_Event_Server_Data* epcEvent, SharedIndicatorInfo *shared_info)
{
if((epcEvent->ref > 0) && (epcEvent->ref_to > 0) && (epcEvent->data) && (((unsigned char *)epcEvent->data)[epcEvent->size - 1] == 0))
{
int n = epcEvent->response;
- if(n == 0/* && n < SHARED_FILE_NUMBER*/)
+ if(n < SHARED_FILE_NUMBER)
{
- fileInfo->ImageWidth = epcEvent->ref;
- fileInfo->ImageHeight = epcEvent->ref_to;
- fileInfo->LockFileName = epcEvent->data;
- SDL_Log("SetLockFileInfo: width %d, height %d, filename %s", fileInfo->ImageWidth, fileInfo->ImageHeight, fileInfo->LockFileName);
+ shared_info->fileInfo[n].ImageWidth = epcEvent->ref;
+ shared_info->fileInfo[n].ImageHeight = epcEvent->ref_to;
+ shared_info->fileInfo[n].LockFileName = epcEvent->data;
+ SDL_Log("SetLockFileInfo: width %d, height %d, filename %s", shared_info->fileInfo[n].ImageWidth, shared_info->fileInfo[n].ImageHeight, shared_info->fileInfo[n].LockFileName);
SDL_Log("epcEvent->response: %d", n);
}
}
return (unsigned char*)fileInfo->sharedFile->address;
}
-void LoadSharedImage(Ecore_Ipc_Event_Server_Data* epcEvent, SharedFileInfo *fileInfo)
+void shared_free(SharedIndicatorInfo *shared_info, int n)
+{
+ LockFile* lockFile = shared_info->fileInfo[n].lockFile;
+ if(lockFile!=NULL) {
+ if(lockFile->fileDescriptor>=0) {
+ if(lockf(lockFile->fileDescriptor, F_ULOCK, 0) <0 )
+ {
+ SDL_Log("[SDL] Lock release fail");
+ return;
+ }
+ }
+ lockFile = NULL;
+ }
+
+ SharedFile* sharedFile = shared_info->fileInfo[n].sharedFile;
+
+ if(sharedFile!=NULL) {
+ if (sharedFile->address != MAP_FAILED) munmap(sharedFile->address, sharedFile->size);
+ if (sharedFile->fileDescriptor >= 0) close(sharedFile->fileDescriptor);
+
+ sharedFile->address = MAP_FAILED;
+ sharedFile->fileDescriptor = 1;
+ sharedFile->fileName = NULL;
+ sharedFile->size = 0;
+
+ }
+}
+
+void LoadSharedImage(Ecore_Ipc_Event_Server_Data* epcEvent, SharedIndicatorInfo *shared_info)
{
char sharedFilename[256];
int n = epcEvent->response;
- if(n == 0 /*&& n < SHARED_FILE_NUMBER*/)
+ SDL_Log("[SDL] LoadSharedImage print n: %d\n",n);
+ if(n < SHARED_FILE_NUMBER)
{
- snprintf(sharedFilename, 256, "/%s-%d.%d", fileInfo->SharedFileName, fileInfo->SharedFileID, fileInfo->SharedFileNumber);
+ snprintf(sharedFilename, 256, "/%s-%d.%d", shared_info->fileInfo[n].SharedFileName, shared_info->fileInfo[n].SharedFileID, shared_info->fileInfo[n].SharedFileNumber);
SDL_Log("The shared file name is %s", sharedFilename);
- fileInfo->sharedFile = CreateSharedFile(sharedFilename, fileInfo->ImageWidth * fileInfo->ImageHeight * 4);
- if(fileInfo->sharedFile != NULL)
+
+ shared_free(shared_info, n);
+
+ shared_info->fileInfo[n].sharedFile = CreateSharedFile(sharedFilename, shared_info->fileInfo[n].ImageWidth * shared_info->fileInfo[n].ImageHeight * 4);
+ if(shared_info->fileInfo[n].sharedFile != NULL)
{
- fileInfo->lockFile = CreateLockeFile(fileInfo->LockFileName);
+ shared_info->fileInfo[n].lockFile = CreateLockeFile(shared_info->fileInfo[n].LockFileName);
}
else
{
}
}
-
-void DataReceived(void* event, SharedFileInfo* fileInfo)
+void DataReceived(void* event, SharedIndicatorInfo* shared_info)
{
Ecore_Ipc_Event_Server_Data* epcEvent = (Ecore_Ipc_Event_Server_Data*)event;
switch(epcEvent->minor)
case OP_SHM_REF0:
{
SDL_Log("Indicator client received: OP_SHM_REF0\n");
- SetSharedImageInfo(epcEvent, fileInfo);
+ SetSharedImageInfo(epcEvent, shared_info);
break;
}
case OP_SHM_REF1:
{
SDL_Log("Indicator client received: OP_SHM_REF1\n");
- SetLockFileInfo(epcEvent, fileInfo);
+ SetLockFileInfo(epcEvent, shared_info);
break;
}
case OP_SHM_REF2:
{
SDL_Log("Indicator client received: OP_SHM_REF2\n");
- LoadSharedImage(epcEvent, fileInfo);
+ LoadSharedImage(epcEvent, shared_info);
break;
}
case OP_PIXMAP_REF:
}
case OP_UPDATE:
{
-// Tizen_glTexImage2d();
- SDL_Log("Indicator client received: OP_UPDATE\n");
+ int n = epcEvent->response;
+ SDL_Log("Indicator client received: OP_UPDATE : %d\n", n);
+ break;
+ }
+ case OP_UPDATE_DONE:
+ {
+ int n = epcEvent->response;
+ SDL_Log("[SDL] OP_UPDATE_DONE n: %d\n", n);
+ if( n < SHARED_FILE_NUMBER)
+ {
+ shared_info->cur_idx = n;
+ if(shared_info->fileInfo[n].sharedFile
+ && shared_info->fileInfo[n].ImageWidth != 0
+ && shared_info->fileInfo[n].ImageHeight != 0)
+ {
+ Tizen_glTexImage2d(n);
+ }
+ else
+ {
+ SDL_Log("[SDL] OP_UPDATE_DONE Fail");
+ }
+ }
+ break;
+ }
+ case OP_RESIZE:
+ {
+ SDL_Log("Indicator client received: OP_RESIZE\n");
break;
}
}
int handler_server_data(void *data, int ev_type, void *ev)
{
Ecore_Ipc_Event_Server_Data *e = (Ecore_Ipc_Event_Server_Data *)ev;
- SharedFileInfo* fileInfo = (SharedFileInfo*)data;
- DataReceived(ev, fileInfo);
+ SharedIndicatorInfo* shared_info = (SharedIndicatorInfo*)data;
+ DataReceived(ev, shared_info);
return 1;
}
-Ecore_Ipc_Server* serverConnection(const char* serviceName, SharedFileInfo* fileInfo)
+Ecore_Ipc_Server* serverConnection(const char* serviceName, SharedIndicatorInfo* shared_info)
{
- Ecore_Ipc_Server* IpcServer;
Ecore_Ipc_Type ipctype = ECORE_IPC_LOCAL_USER;
if(!ecore_ipc_init())
return NULL;
}
- IpcServer = ecore_ipc_server_connect(ipctype, (char*)serviceName, 0, NULL);
+ Ecore_Ipc_Server* IpcServer = ecore_ipc_server_connect(ipctype, (char*)serviceName, 0, NULL);
if(IpcServer)
{
ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_ADD, handler_server_add, NULL);
ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DEL, handler_server_del, NULL);
- ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DATA, handler_server_data, fileInfo);
+ ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DATA, handler_server_data, shared_info);
}
else
{
Uint32 _tizen_timer_callback_indicator(void *data)
{
- SDL_Log("[SDL} callbackck ckck clalall!\n");
SDL_VideoDevice *_this = SDL_GetVideoDevice();
drawIndicator(_this->windows);
}
-SharedFileInfo fileInfo;
-
+SharedIndicatorInfo shared_info;
unsigned int textureID;
unsigned int indicator_vbo[4], indicator_ibo[4];
unsigned short indicator_index;
matrix->m[3][3] += (matrix->m[0][3] * x + matrix->m[1][3] * y + matrix->m[2][3] * z);
}
-void Tizen_glTexImage2d()
+void Tizen_glTexImage2d(int idx)
{
-
GLES2_Context Mainctx;
LoadContext(&Mainctx);
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);
+ Mainctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, shared_info.fileInfo[idx].ImageWidth, shared_info.fileInfo[idx].ImageHeight,
+ 0, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned char*)(shared_info.fileInfo[idx].sharedFile->address));
}
void drawIndicator(SDL_Window *window)
Mainctx.glVertexAttribPointer(cIndex, 2, GL_FLOAT, GL_FALSE, 0, vCoord);
Mainctx.glUniformMatrix4fv(Mainctx.glGetUniformLocation(programObject, "modelMatrix"), 1, GL_FALSE, mMatrix.m);
- Mainctx.glBindTexture(GL_TEXTURE_2D, textureID);
- if(fileInfo.ImageWidth!=0 && fileInfo.ImageHeight!=0)
- 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(vIndex);
Mainctx.glEnableVertexAttribArray(cIndex);
ecore_wl_window_indicator_opacity_set(wind->window, ECORE_WL_INDICATOR_OPAQUE);
ecore_wl_window_indicator_state_set(wind->window, ECORE_WL_INDICATOR_STATE_ON);
- Ecore_Ipc_Server* IpcServer = serverConnection("elm_indicator", &fileInfo);
+ Ecore_Ipc_Server* IpcServer = serverConnection("elm_indicator", &shared_info);
if(!IpcServer)
{
SDL_Log("Fail to connect elm_indicator!\n");
" gl_FragColor = texture2D(s_texture,Coord);\n"
"}\n";
- ecore_main_loop_iterate();
-
GLuint vertexShader;
GLuint fragmentShader;
Mainctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
Mainctx.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-
- if(fileInfo.ImageWidth != 0 && fileInfo.ImageHeight != 0)
- Mainctx.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, fileInfo.ImageWidth, fileInfo.ImageHeight,0, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned char*)fileInfo.sharedFile->address);
-
wind->indicator_show = SDL_TRUE;
wind->last_indicator_showtime = SDL_GetTicks();
+ ecore_main_loop_iterate();
+
_tizen_indicator_event_filter();
return 1;
Mainctx.glBindBuffer(GL_ARRAY_BUFFER, indicator_ibo[wind->indicator_type]);
Mainctx.glBufferData(GL_ARRAY_BUFFER, 12 * 4, vCoord, GL_STATIC_DRAW);
- Mainctx.glBindTexture(GL_TEXTURE_2D, textureID);
-
- if(fileInfo.ImageWidth != 0 && fileInfo.ImageHeight != 0)
- 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);
wind->indicator_show = SDL_TRUE;
wind->last_indicator_showtime = SDL_GetTicks();