示例#1
0
Destroy_TextLayer( LCUI_TextLayer *layer )
/* 销毁文本图层占用的资源 */
{
	Queue_Destroy( &layer->text_source_data );
	Queue_Destroy( &layer->rows_data );
	Queue_Destroy( &layer->tag_buff );
	Queue_Destroy( &layer->style_data );
	Queue_Destroy( &layer->clear_area );
	LCUIWString_Free( &layer->text_buff );
}
示例#2
0
TextLayer_Text_Clear( LCUI_TextLayer *layer )
/* 清空文本内容 */
{
	TextLayer_Refresh( layer );
	Queue_Destroy( &layer->text_source_data );
	Queue_Destroy( &layer->rows_data );
	Queue_Destroy( &layer->style_data );
	layer->current_src_pos = 0;
	layer->current_des_pos = Pos(0,0);
}
示例#3
0
LCUI_EXPORT(void) FontLIB_DestroyAll( void )
{
	if( !database_init ) {
		return;
	}
	database_init = FALSE;
	Queue_Destroy( &font_database );
	Queue_Destroy( &fontbitmap_database );
#ifdef LCUI_FONT_ENGINE_FREETYPE
	FT_Done_FreeType( library );
#endif
}
示例#4
0
static void 
Destroy_Text_RowData( void *arg )
{
	Text_RowData *data;
	data = (Text_RowData *)arg;
	Queue_Destroy ( &data->string );
}
示例#5
0
文件: graphlayer.c 项目: aem3372/LCUI
LCUI_API void GraphLayer_Free( LCUI_GraphLayer *glayer )
{
	if( glayer == NULL ) {
		return;
	}
	/* 移除该图层在父图层中的记录 */
	GraphLayer_DeleteChild( glayer );
	/* 释放图层的图像数据 */
	Graph_Free( &glayer->graph );
	/* 销毁子图层列表 */
	Queue_Destroy( &glayer->child );
	free( glayer );
}
示例#6
0
文件: main.c 项目: yydaor/LCUI
static void LCUI_DestroyAllApps(void)
{
	LCUI_App *app; 
	int i, total;

	Queue_Lock( &LCUI_Sys.app_list );
	total = Queue_GetTotal(&LCUI_Sys.app_list);
	for (i = 0; i < total; ++i) {
		app = Queue_Get(&LCUI_Sys.app_list, 0);
		if(app == NULL) {
			continue;
		}
		Queue_Delete (&LCUI_Sys.app_list, 0); 
	}
	Queue_Unlock( &LCUI_Sys.app_list );
	Queue_Destroy( &LCUI_Sys.app_list );
}
示例#7
0
static int 
_TextLayer_Text_Delete ( LCUI_TextLayer *layer, LCUI_Pos start_pos, int len )
/* 以start_pos为起点,删除n个文字 */
{
	LCUI_BOOL refresh = TRUE;
	LCUI_CharData *char_ptr;
	LCUI_Pos tmp_pos, pixel_pos;
	int left_or_right, rows, cols;
	Text_RowData *row_ptr, *tmp_row;
	
	if( start_pos.x < 0 ) {
		len += start_pos.x;
		start_pos.x = 0;
	}
	if( start_pos.y < 0 ) {
		start_pos.y = 0;
	}
	if( len <= 0 ) {
		return -1;
	}
	/* 确定起点位置的XY轴坐标 */
	pixel_pos = TextLayer_Char_GetPixelPos( layer, start_pos );
	
	rows = Queue_GetTotal( &layer->rows_data );
	row_ptr = Queue_Get( &layer->rows_data, start_pos.y );
	if( !row_ptr ) {
		return -1;
	}
	cols = Queue_GetTotal( &row_ptr->string );
	
	/* 根据光标所在位置,确定遍历方向 */
	if( layer->current_des_pos.y > start_pos.y 
	 || (layer->current_des_pos.y == start_pos.y 
	 && layer->current_des_pos.x > start_pos.x)) {
		left_or_right = 0;
	}
	else {
		left_or_right = 1;
	}
	
	/* 如果需删除的字符只在当前行 */
	if( start_pos.x + len <= cols ) {
		/* 标记后面的文字位图需要刷新 */
		TextLayer_CharLater_Refresh( layer, start_pos );
	}
	for( ; start_pos.x<=cols && len>0; --len ) {
		/* 如果到了行尾 */
		if( start_pos.x == cols ) {
			/* 如果当前行是最后一行 */
			if( start_pos.y >= rows-1 ) {
				break;
			}
			if( refresh ) {
				tmp_pos.x = 0;
				tmp_pos.y=start_pos.y+1;
				/* 刷新该行后面所有行的字符 */
				for( ; tmp_pos.y<rows; ++tmp_pos.y ) {
					TextLayer_CharLater_Refresh( layer, tmp_pos );
				}
				refresh = FALSE;
			}
			
			/* 将当前行行尾的换行符'\n'从源文本中移除 */
			TextLayer_Text_DeleteChar( layer, row_ptr->last_char, left_or_right );
			/* 获取指向下一行文本的指针 */
			tmp_row = Queue_Get( &layer->rows_data, start_pos.y+1 );
			/* 将下一行的文本拼接至当前行行尾 */
			Queue_Cat( &row_ptr->string, &tmp_row->string );
			/* 将下一行的行尾字符数据转移至当前行 */
			row_ptr->last_char = tmp_row->last_char;
			/* 销毁下一行的文本 */
			Queue_Destroy( &tmp_row->string ); 
			Queue_Delete( &layer->rows_data, start_pos.y+1 );
			/* 更新当前行的总字符数 */
			cols = Queue_GetTotal( &row_ptr->string );
			/* 更新总行数 */
			rows = Queue_GetTotal( &layer->rows_data );
			/* 更新当前行的尺寸 */
			TextLayer_Update_RowSize( layer, start_pos.y );
			continue;
		}
		char_ptr = Queue_Get( &row_ptr->string, start_pos.x );
		if( !char_ptr ) {
			continue;
		}
		TextLayer_Clear( layer, pixel_pos, row_ptr->max_size.h, char_ptr );
		pixel_pos.x += char_ptr->bitmap->advance.x;
		/* 将该字从源文本中移除 */
		TextLayer_Text_DeleteChar( layer, char_ptr, left_or_right );
		/* 该字在这行的字体位图也需要删除 */
		cols = Queue_GetTotal( &row_ptr->string );
		Queue_DeletePointer( &row_ptr->string, start_pos.x );
		cols = Queue_GetTotal( &row_ptr->string );
		char_ptr = Queue_Get( &row_ptr->string, start_pos.x );
		cols = Queue_GetTotal( &row_ptr->string );
	}
	/* 更新当前行的尺寸 */
	TextLayer_Update_RowSize( layer, start_pos.y );
	return 0;
}
示例#8
0
/** 销毁部件事件处理 */
void LCUIWidgetEvent_Destroy(void)
{
	Queue_Destroy( &widget_proc_record );
}
示例#9
0
文件: rect.c 项目: fshunj/LCUI
/* 销毁储存矩形数据的队列 */
LCUI_API void
RectQueue_Destroy( LCUI_RectQueue *queue )
{
	Queue_Destroy( &queue->queue[0] );
	Queue_Destroy( &queue->queue[1] );
}
示例#10
0
文件: files.c 项目: mingpen/OpenNT
/* ss_sendfiles:
   Send a response naming the data pipe, collect further names
   from further client messages, all according to the protocol above.
   Start the data pipe and arrange that all the files are sent
   by getting them all enqueued on the first queue.
   Destroy PackQueue at the end.  Arrange for the other queues
   to be destroyed by the usual Queue mechanism, or destroy them
   explicitly if they never get started.
*/
BOOL
ss_sendfiles(HANDLE hPipe, long lVersion)
{       /* Create the queues and set about filling the first one */

        QUEUE PackQueue, ReadQueue, SendQueue;

#ifdef SOCKETS
        SOCKET hpSend;
        static BOOL SocketsInitialized = FALSE;
#else
        HANDLE hpSend;          /* the data pipe */
#endif /* SOCKETS */

        char PipeName[80];      /* The name of the new data pipe */
        BOOL Started = FALSE;   /* TRUE if something enqueued */


#ifdef SOCKETS
        if( !SocketsInitialized )
        {
                WSADATA WSAData;

                if( ( WSAStartup( MAKEWORD( 1, 1 ), &WSAData ) ) == 0 )
                {
                        SocketsInitialized = TRUE;
                }
                else
                {
                        printf("WSAStartup failed");
                }
        }
#endif

        {
                /****************************************
                We need security attributes for the pipe to let anyone other than the
                current user log on to it.
                ***************************************/

                /* Allocate DWORDs for the ACL to get them aligned.  Round up to next DWORD above */
                DWORD Acl[(sizeof(ACL)+sizeof(ACCESS_ALLOWED_ACE)+3)/4+4];    // + 4 by experiment!!
                SECURITY_DESCRIPTOR sd;
                PSECURITY_DESCRIPTOR psd = &sd;
                PSID psid;
                SID_IDENTIFIER_AUTHORITY SidWorld = SECURITY_WORLD_SID_AUTHORITY;
                PACL pacl = (PACL)(&(Acl[0]));
                SECURITY_ATTRIBUTES sa;
                BOOL brc;
                DWORD lasterr;

                if (!AllocateAndInitializeSid( &SidWorld, 1, SECURITY_WORLD_RID
                                              , 1, 2, 3, 4, 5, 6, 7
                                              , &psid
                                              )
                   ) {
                        Error("AllocateAndInitializeSid");
                        return FALSE;
                   }

                if (!InitializeAcl(pacl, sizeof(Acl), ACL_REVISION)){
                        Error("InitializeAcl");
                        return FALSE;
                }
                if (!AddAccessAllowedAce(pacl, ACL_REVISION, GENERIC_WRITE|GENERIC_READ, psid)){
                        Error("AddAccessAllowedAce");
                        return FALSE;
                }
                if (!InitializeSecurityDescriptor(psd, SECURITY_DESCRIPTOR_REVISION)){
                        Error("InitializeSecurityDescriptor");
                        return FALSE;
                }
                if (!SetSecurityDescriptorDacl(psd, TRUE, pacl, FALSE)){
                        Error("SetSecurityDescriptorDacl");
                        return FALSE;
                }
                sa.nLength = sizeof(sa);
                sa.lpSecurityDescriptor = psd;
                sa.bInheritHandle = TRUE;

                /* We now have a good security descriptor!  */

                /* Create the (new, unique) name of the pipe and then create the pipe */

                /* I am finding it hard to decide whether the following line (++PpipeCount)
                   actually needs a critical section or not.  The worst that could happen
                   would be that we got an attempt to create a pipe with an existing name.
                */
                ++PipeCount;
                sprintf(PipeName, "\\\\.\\pipe\\%s%d", PIPEPREFIX, PipeCount);

#ifdef SOCKETS
                if (!ss_sendnewresp( hPipe, SS_VERSION, SSRESP_PIPENAME
                                   , 0, 0, 0, TCPPORT, "")) {
                        dprintf1(( "Failed to send response on pipe %x naming new pipe.\n"
                              , hPipe));
                        return FALSE;           /* Caller will close hPipe */
                }

                if( !SocketListen( TCPPORT, &hpSend ) )
                {
                    dprintf1(("Could not create socket\n"));
                    return FALSE;
                }

                FreeSid(psid);
#else
                hpSend = CreateNamedPipe(PipeName,              /* pipe name */
                                PIPE_ACCESS_DUPLEX,     /* both read and write */
                                PIPE_WAIT|PIPE_TYPE_MESSAGE|PIPE_READMODE_MESSAGE,
                                1,              /* at most one instance */
                                10000,          /* sizeof(SSNEWPACK) + some for luck */
                                0,              /* dynamic inbound buffer allocation */
                                5000,           /* def. timeout 5 seconds */
                                &sa             /* security descriptor */
                                );
                FreeSid(psid);

                if (hpSend == INVALID_HANDLE_VALUE) {
                        dprintf1(("Could not create named data pipe\n"));
                        return FALSE;
                }
                dprintf1(("Data pipe %x called '%s' created for main pipe %x.\n", hpSend, PipeName, hPipe));

#endif /* SOCKETS */

        }




        /* Send the response which names the data pipe */

#ifndef SOCKETS
        if (!ss_sendnewresp( hPipe, SS_VERSION, SSRESP_PIPENAME
                           , 0, 0, 0, 0, PipeName)) {
                dprintf1(( "Failed to send response on pipe %x naming new pipe.\n"
                      , hPipe));
                CLOSEHANDLE(hpSend);
                return FALSE;           /* Caller will close hPipe */
        }

        if (!ConnectNamedPipe(hpSend, NULL)) {
                CLOSEHANDLE(hpSend);
                return FALSE;
        }
#endif /* NOT SOCKETS */
        //dprintf1(("Client connected to data pipe -- here we go...\n"));

        /* Create all the queues: Allow up to 10K file names to be queued
           up to 10 files to be packed in advance and 6 buffers of data to be
           read into main storage in advance:
                                  proc  MxMT MnQS MxQ Event   InstData   Name*/
        SendQueue = Queue_Create(SendData, 1, 0,  6, NULL, (DWORD)hpSend, "SendQueue");
        ReadQueue = Queue_Create(ReadInFile, 1, 0, 10, NULL, (DWORD)SendQueue, "ReadQueue");
        PackQueue = Queue_Create(PackFile, 3, 0, 99999, NULL, (DWORD)ReadQueue, "PackQueue");

        /* Abort unless it all worked */
        if (PackQueue==NULL || ReadQueue==NULL || SendQueue==NULL) {
                dprintf1(("Queues for pipe %x failed to Create.  Aborting...\n", hPipe));
                if (PackQueue) Queue_Destroy(PackQueue);
                if (ReadQueue) Queue_Destroy(ReadQueue);
                if (SendQueue) Queue_Destroy(SendQueue);
                CLOSEHANDLE(hpSend);
                return FALSE;           /* Caller will close hPipe */
        }


        /* Collect names from client and enqueue each one */
        for (; ; )
        {       SSNEWREQ Request;       /* message from client */
                DWORD    ActSize;       /* bytes read from (main) pipe */

                if (ReadFile(hPipe, &Request, sizeof(Request), &ActSize, NULL)){
                        if (Request.lVersion>SS_VERSION) {
                                dprintf1(("Bad version %d in file list request on pipe %x\n"
                                , Request.lVersion, hPipe));

                                break;

                        }
                        if (Request.lRequest!=LREQUEST) {
                                dprintf1(("Bad LREQUEST from pipe %x\n", hPipe));

                                break;
                        }
                        if (Request.lCode == -SSREQ_ENDFILES) {
                                dprintf1(("End of client's files list on pipe %x\n", hPipe));

                                /* This is the clean way to end */
                                Queue_Destroy(PackQueue);
                                if (!Started) {
                                        /* OK - so the clever clogs requested zero files */
                                        Queue_Destroy(ReadQueue);
                                        Queue_Destroy(SendQueue);
                                        /* Send a No More Files response */
#ifdef SOCKETS
                                        {
                                            SSNEWRESP resp;

                                            resp.lVersion = SS_VERSION;
                                            resp.lResponse = LRESPONSE;
                                            resp.lCode = SSRESP_END;
                                            resp.ulSize = 0;
                                            resp.ulSum = 0;
                                            resp.ft_lastwrite.dwLowDateTime = 0;
                                            resp.ft_lastwrite.dwHighDateTime = 0;

                                            send(hpSend, (PSTR) &resp, sizeof(resp), 0);
                                        }
#else
                                        ss_sendnewresp( hpSend, SS_VERSION, SSRESP_END
                                                , 0,0, 0,0, NULL);
#endif /* SOCKETS */
                                        CLOSEHANDLE(hpSend);
                                }
                                return TRUE;
                        }
                        if (Request.lCode != -SSREQ_NEXTFILE) {

                                dprintf1(( "Bad code (%d) in files list from pipe %x\n"
                                      , Request.lCode, hPipe));

                                break;
                        }
                }
                else {  DWORD errorcode = GetLastError();
                        switch(errorcode) {

                                case ERROR_NO_DATA:
                                case ERROR_BROKEN_PIPE:
                                        /* pipe connection lost - forget it */
                                        dprintf1(("main pipe %x broken on read\n", hPipe));
                                        break;
                                default:
                                        dprintf1(("read error %d on main pipe %x\n", errorcode, hPipe));
                                        break;
                        }
                        break;
                }
                if (!EnqueueName( PackQueue, Request.szPath
                                , (UINT)((LPBYTE)(&Request) + ActSize - (LPBYTE)(&Request.szPath))
                                )
                   ){
                        break;
                }
                Started = TRUE;
        } /* loop */

        /* only exit this way on error */
        /* Close the queues down.  Allow what's in them to run through */
        Queue_Destroy(PackQueue);
        if (!Started) {
                Queue_Destroy(ReadQueue);
                Queue_Destroy(SendQueue);

        }
        return FALSE;
} /* ss_sendfiles */
示例#11
0
static void FontLIB_Destroy( void *arg )
{
	LCUI_FontCharItem *font;
	font = (LCUI_FontCharItem *)arg;
	Queue_Destroy( &font->data );
}
示例#12
0
static void FontLIB_DestroyData( void *arg )
{
	LCUI_FontDataItem *data;
	data = (LCUI_FontDataItem *)arg;
	Queue_Destroy( &data->font_bmp );
}
示例#13
0
static void Destroy_TreeNode( void *arg )
{
	Thread_TreeNode *ttn;
	ttn = (Thread_TreeNode *)arg;
	Queue_Destroy( &ttn->child );
}
示例#14
0
LCUIModule_Thread_End( void )
{
	Queue_Destroy( &thread_tree.child );
}
示例#15
0
文件: rect.c 项目: fshunj/LCUI
/* 将矩形数据追加至队列 */
static int
RectQueue_Add( LCUI_Queue* queue, LCUI_Rect rect )
{ 
	int i, flag = 0;
	LCUI_Rect *rect_ptr, *cur_rect_ptr;
	LCUI_Queue rect_buff;
	
	if( rect.width <= 0 || rect.height <= 0 ) {
		return -1;
	}
	DEBUG_MSG("add new rect: %d,%d,%d,%d, current total: %d\n",
	 rect.x, rect.y, rect.width, rect.height, queue->total_num);
	Queue_Init( &rect_buff, sizeof(LCUI_Rect), NULL );
	
	for (i=0; i<queue->total_num; ++i) {
		cur_rect_ptr = (LCUI_Rect*)Queue_Get( queue, i );
		if( !cur_rect_ptr ) {
			break;
		}
		DEBUG_MSG("[%d] rect: %d,%d,%d,%d\n", i, 
		 cur_rect_ptr->x, cur_rect_ptr->y,
		 cur_rect_ptr->width, cur_rect_ptr->height);
		/* 如果矩形无效,或者被新增的矩形区域包含,则删除 */
		if ( cur_rect_ptr->width <= 0 || cur_rect_ptr->height <= 0
		 || LCUIRect_IncludeRect( rect, *cur_rect_ptr) ) {
			Queue_Delete ( queue, i );
			continue;
		}

		/* 如果与现有的矩形相同,或被现有的矩形包含 */
		if( LCUIRect_Equal( rect, *cur_rect_ptr)
		 || LCUIRect_IncludeRect( *cur_rect_ptr, rect ) ) {
			flag = 1;
			break;
		}
		
		/* 如果新增的矩形与队列中的矩形不重叠 */ 
		if( !LCUIRect_Overlay(rect, *cur_rect_ptr) ) {
			continue;
		}
		continue; // 暂时不对相交的矩形进行分割
		DEBUG_MSG("[%d] rect overlay, start cut\n", i);
		/* 根据当前区域,分割新区域 */
		LCUIRect_Cut( *cur_rect_ptr, rect, &rect_buff );
		for( i=0; i<rect_buff.total_num; ++i ) {
			rect_ptr = (LCUI_Rect*)Queue_Get( &rect_buff, i );
			if( !rect_ptr ) {
				break;
			}
			DEBUG_MSG("[%d] add child rect: %d,%d,%d,%d\n", i, 
				 rect_ptr->x, rect_ptr->y,
				 rect_ptr->width, rect_ptr->height);
			RectQueue_Add( queue, *rect_ptr );
		}
		flag = 1;
		break;
	}
	
	/* 销毁队列 */
	Queue_Destroy( &rect_buff );
	if ( flag == 0 ) {
		return Queue_Add( queue, &rect );
	}
	return -1;
}
示例#16
0
文件: timer.c 项目: fshunj/LCUI
/** 销毁定时器列表 */
static void TimerList_Destroy( LCUI_Queue *timer_list )
{
	Queue_Destroy( timer_list );
}
示例#17
0
LCUI_API void
StyleLib_Free( LCUI_StyleLibrary *lib )
{
	Queue_Destroy( &lib->style_classes );
}
示例#18
0
文件: files.c 项目: mingpen/OpenNT
/* Dequeue elements from Queue, pack them and enqueue them on the next
   queue whose queue handle is the InstanceData of Queue.
   The ErrorCode in fd when Dequeued must be 0.                    ??? Incautious?
   Destroy the output queue at the end.
   On a serious error, Queue_Abort Queue and Queue_Destroy the output queue.
*/
STATIC int PackFile(QUEUE Queue)
{
        FILEDETAILS fd;         /* the queue element processed */
        QUEUE OutQueue;
        BOOL Aborting = FALSE;  /* TRUE means input has been aborted (probably output is sick) */
        DWORD ThreadId;
        ThreadId = GetCurrentThreadId();

        dprintf1(("File packer %d starting \n", ThreadId));         // can't quote hPipe, don't know it
        OutQueue = (QUEUE)Queue_GetInstanceData(Queue);

        for (; ; )
        {       int rc; /* return code from Queue_Get */

                rc = Queue_Get(Queue, (LPBYTE)&fd, sizeof(fd));
                if (rc==ENDQUEUE) {
                        dprintf1(("Packing thread %d ending.\n", ThreadId));
                        Queue_Destroy(OutQueue);
                        // dprintf1(("%d has done Queue_Destroy on ReadQueue.\n", ThreadId));
                        ExitThread(0);
                }
                if (rc==STOPTHREAD) {
                        dprintf1(("%d, a packing thread ending.\n", ThreadId));
                        ExitThread(0);
                }
                else if (rc<0) {
                        dprintf1(( "Packing thread %d aborting.  Bad return code %d from Get.\n"
                              , ThreadId, rc));
                        if (Aborting) break;    /* Touch nothing, just quit! */
                        Queue_Abort(Queue, NULL);
                        continue;               /* Next Queue_Get destroys Queue */
                }


                /* First add the file attributes to fd */
                AddFileAttributes(&fd);
                /* no need to look at return code fd.ErrorCode tells all */

                /* create temp filename */
                if (  0 != fd.ErrorCode
                   || 0==GetTempPath(sizeof(fd.TempName), fd.TempName)
                   || 0==GetTempFileName(fd.TempName, "sum", 0, fd.TempName)
                   )
                        fd.ErrorCode = SSRESP_NOTEMPPATH;

                /* Pack into temp file */
                if (fd.ErrorCode==0) {
                        BOOL bOK = FALSE;

                        //dprintf1(("%d Compressing file '%s' => '%s'\n", ThreadId, fd.Path, fd.TempName));

                        /* compress the file into this temporary file
                           Maybe it will behave badly if there's a large file or
                           no temp space or something...
                        */
                        try{
                            if (!ss_compress(fd.Path, fd.TempName)) {
                                fd.ErrorCode = SSRESP_COMPRESSFAIL;
                                dprintf1(("Compress failure on %d for %s\n", ThreadId, fd.Path));
                            }
                            else bOK = TRUE;
                        } except(EXCEPTION_EXECUTE_HANDLER) {
                            if (!bOK){
                                fd.ErrorCode = SSRESP_COMPRESSEXCEPT;
                                dprintf1(("Compress failure on %d for %s\n", ThreadId, fd.Path));
#ifdef trace
                                {       char msg[80];
                                        wsprintf( msg, "Compress failure on %d for %s\n"
                                                , ThreadId, fd.Path);
                                        Trace_File(msg);
                                }
#endif
                            }
                        }

                }

                //dprintf1(("%d Putting file '%s' onto Read Queue\n", ThreadId, fd.Path));
                if (!Queue_Put(OutQueue, (LPBYTE)&fd, sizeof(fd))) {
                        dprintf1(("%d Put to ReadQueue failed for %s.\n", ThreadId, fd.Path));
                        Queue_Abort(Queue, NULL);
                        DeleteFile(fd.TempName);

                        Aborting = TRUE;
                        /* bug:  If this Queue_Put fails on the very first Put,
                           then the next queue in the chain after OutQueue will
                           never come alive and so will never get Destroyed.
                           Worst it could cause is a memory leak. ???
                        */
                        continue; /* next Queue_Get destroys Queue */
                }
        }
示例#19
0
文件: main.c 项目: yydaor/LCUI
static void
LCUI_DestroyMainLoopQueue(void)
{
	Queue_Destroy( &mainloop_queue );
}
示例#20
0
文件: graphlayer.c 项目: aem3372/LCUI
LCUI_API int GraphLayer_GetGraph( LCUI_GraphLayer *ctnr, 
				LCUI_Graph *graph_buff, LCUI_Rect rect )
{
	int i, total; 
	uchar_t tmp_alpha, alpha;
	LCUI_Pos pos, glayer_pos;
	LCUI_GraphLayer *glayer;
	LCUI_Queue glayerQ;
	LCUI_Rect valid_area;
	LCUI_Graph tmp_graph;
	
	/* 检测这个区域是否有效 */
	if (rect.x < 0 || rect.y < 0) {
		return -1; 
	}
	if (rect.x + rect.width > ctnr->graph.w
	 || rect.y + rect.height > ctnr->graph.h ) {
		 return -1;
	}
	if (rect.width <= 0 || rect.height <= 0) {
		return -2;
	}
	if( !Graph_IsValid(graph_buff) ) {
	graph_buff->color_type = COLOR_TYPE_ARGB;
		Graph_Create( graph_buff, rect.width, rect.height );
	}

	Graph_Init( &tmp_graph );
	Queue_Init( &glayerQ, 0, NULL);
	Queue_UsingPointer( &glayerQ );
	
	/* 获取rect区域内的图层列表 */
	GraphLayer_GetLayers( ctnr, rect, &glayerQ ); 
	total = Queue_GetTotal( &glayerQ ); 
	DEBUG_MSG( "total: %d\n", total );
	/* 若记录数为零,则表明该区域没有图层 */
	if( total <= 0 ) {
		/* 若没有父图层,则填充白色 */
		if( ctnr == NULL ) {
			Graph_FillColor( graph_buff, RGB(255,255,255) );
		} else { /* 否则使用父图层的图形 */
			Graph_Cut( &ctnr->graph, rect, graph_buff );
		}
		/* 销毁记录 */
		Queue_Destroy( &glayerQ );
		return 0;
	}
	/* 从顶层到底层遍历图层,排除被其它图层完全遮挡或者自身完全透明的图层 */
	for(i=total-1; i>=0; --i) {
		glayer = (LCUI_GraphLayer*)Queue_Get( &glayerQ, i );
		valid_area = GraphLayer_GetValidRect( ctnr, glayer );
		glayer_pos = GraphLayer_GetGlobalPos( ctnr, glayer );
		valid_area.x += glayer_pos.x;
		valid_area.y += glayer_pos.y;
		alpha = GraphLayer_GetRealAlpha( glayer );
		/* 当前图层的透明度小于255的话,就跳过 */
		if( alpha < 255 ) {
			continue;
		}
		/* 跳过有alpha通道的图层 */
		if( glayer->graph.color_type == COLOR_TYPE_ARGB ) {
			continue;
		}
		/* 如果该图层的有效区域包含目标区域 */
		if( rect.x >= valid_area.x && rect.y >= valid_area.y
		 && rect.x + rect.w <= valid_area.x + valid_area.w
		 && rect.y + rect.h <= valid_area.y + valid_area.h ) {
			/* 移除底层的图层,因为已经被完全遮挡 */
			for(total=i-1;total>=0; --total) {
				Queue_DeletePointer( &glayerQ, 0 );
			}
			goto skip_loop;
		}
	}
skip_loop:
	total = Queue_GetTotal( &glayerQ );
	DEBUG_MSG( "total: %d\n", total );
	if(i <= 0 && ctnr ) {
			Graph_Cut( &ctnr->graph, rect, graph_buff );
	}
	/* 获取图层列表中的图层 */
	for(i=0; i<total; ++i) {
		glayer = (LCUI_GraphLayer*)Queue_Get( &glayerQ, i );
		//_DEBUG_MSG("%p = Queue_Get( %p, %d )\n", glayer, &glayerQ, i);
		if( !glayer ) {
			continue;
		}
		DEBUG_MSG("%d,%d,%d,%d\n", glayer->pos.x, glayer->pos.y, glayer->graph.w, glayer->graph.h);
		/* 获取该图层的有效区域及全局坐标 */
		pos = GraphLayer_GetGlobalPos( ctnr, glayer );
		valid_area = GraphLayer_GetValidRect( ctnr, glayer );
		/* 引用该图层的有效区域内的图像 */
		Graph_Quote( &tmp_graph, &glayer->graph, valid_area ); 
		//_DEBUG_MSG("valid area: %d,%d,%d,%d, pos: %d,%d, size: %d,%d\n", 
		//	valid_area.x, valid_area.y, valid_area.width, valid_area.height,
		//	pos.x, pos.y, glayer->graph.w, glayer->graph.h
		//	);
		/* 获取相对坐标 */
		pos.x = pos.x - rect.x + valid_area.x;
		pos.y = pos.y - rect.y + valid_area.y;
		//_DEBUG_MSG("mix pos: %d,%d\n", pos.x, pos.y);
		/* 如果该图层没有继承父图层的透明度 */
		if( !glayer->inherit_alpha ) {
			/* 直接叠加至graph_buff */
			Graph_Mix( graph_buff, &tmp_graph, pos );
		} else {
			/* 否则,计算该图层应有的透明度 */
			alpha = GraphLayer_GetRealAlpha( glayer );
			/* 备份该图层的全局透明度 */
			tmp_alpha = glayer->graph.alpha;
			/* 将实际透明度作为全局透明度,参与图像叠加 */
			glayer->graph.alpha = alpha;
			Graph_Mix( graph_buff, &tmp_graph, pos );
			/* 还原全局透明度 */
			glayer->graph.alpha = tmp_alpha;
		}
	}
	Queue_Destroy( &glayerQ );
	return 0;
}
示例#21
0
文件: radiobutton.c 项目: hbao/LCUI
static void __Destroy_MutexData( void *arg )
{
	LCUI_Queue *queue;
	queue = (LCUI_Queue*)arg;
	Queue_Destroy( queue );
}