Update widget invalid area processing

This commit is contained in:
Liu Chao
2017-06-25 22:46:08 +08:00
parent e0867a5768
commit dfdc3d08b2
11 changed files with 151 additions and 131 deletions
+12 -6
View File
@@ -2,7 +2,7 @@
/* ***************************************************************************
* widget_paint.h -- LCUI widget paint module.
*
* Copyright (C) 2013-2016 by Liu Chao <lc-soft@live.cn>
* Copyright (C) 2013-2017 by Liu Chao <lc-soft@live.cn>
*
* This file is part of the LCUI project, and may only be used, modified, and
* distributed under the terms of the GPLv2.
@@ -23,7 +23,7 @@
/* ****************************************************************************
* widget_paint.h -- LCUI部件绘制模块
*
* 版权所有 (C) 2013-2016 归属于 刘超 <lc-soft@live.cn>
* 版权所有 (C) 2013-2017 归属于 刘超 <lc-soft@live.cn>
*
* 这个文件是LCUI项目的一部分,并且只可以根据GPLv2许可协议来使用、更改和发布。
*
@@ -43,7 +43,7 @@
LCUI_BEGIN_HEADER
/**
/**
* 标记部件中的无效区域
* @param[in] w 区域所在的部件
* @param[in] r 矩形区域
@@ -51,8 +51,7 @@ LCUI_BEGIN_HEADER
* @returns 标记成功返回 TRUE,如果该区域处于屏幕可见区域外则标记失败,返回FALSE
*/
LCUI_API LCUI_BOOL Widget_InvalidateArea( LCUI_Widget widget,
LCUI_Rect *r, int box_type );
LCUI_RectF *in_rect, int box_type );
/**
* 取出部件中的无效区域
@@ -60,7 +59,7 @@ LCUI_API LCUI_BOOL Widget_InvalidateArea( LCUI_Widget widget,
* @param[out] rects 输出的区域列表
* @return 无效区域的数量
*/
size_t Widget_GetInvalidArea( LCUI_Widget w, LinkedList *rects );
LCUI_API size_t Widget_GetInvalidArea( LCUI_Widget w, LinkedList *rects );
/**
* 将部件中的矩形区域转换成指定范围框内有效的矩形区域
@@ -72,6 +71,12 @@ size_t Widget_GetInvalidArea( LCUI_Widget w, LinkedList *rects );
LCUI_API int Widget_ConvertArea( LCUI_Widget w, LCUI_Rect *in_rect,
LCUI_Rect *out_rect, int box_type );
/** 将 LCUI_RectF 类型数据转换为无效区域 */
LCUI_API void RectFToInvalidArea( const LCUI_RectF *rect, LCUI_Rect *area );
/** 将 LCUI_Rect 类型数据转换为无效区域 */
LCUI_API void RectToInvalidArea( const LCUI_Rect *rect, LCUI_Rect *area );
/**
* 渲染指定部件呈现的图形内容
* @param[in] w 部件
@@ -82,6 +87,7 @@ LCUI_API void Widget_Render( LCUI_Widget w, LCUI_PaintContext paint );
LCUI_API void LCUIWidget_InitRenderer( void );
LCUI_API void LCUIWidget_ExitRenderer( void );
LCUI_END_HEADER
#endif
+1 -1
View File
@@ -51,7 +51,7 @@ typedef void(*LCUI_EventFunc)(LCUI_Event, void*);
typedef struct LCUI_EventTriggerRec_ {
int handler_base_id; /**< 事件处理器ID */
RBTree events; /**< 事件绑定记录 */
RBTree events; /**< 事件绑定记录 */
RBTree handlers; /**< 事件处理器记录 */
} LCUI_EventTriggerRec, *LCUI_EventTrigger;
+9 -10
View File
@@ -42,19 +42,9 @@
LCUI_BEGIN_HEADER
#define RectF2Rect(rf, r) do { \
(r).x = (int)((rf).x + 0.5); \
(r).y = (int)((rf).y + 0.5); \
(r).width = (int)((rf).width + 0.5); \
(r).height = (int)((rf).height + 0.5); \
} while( 0 );
/* 将数值转换成LCUI_Rect型结构体 */
LCUI_API LCUI_Rect Rect( int x, int y, int w, int h );
/** 按比例缩放矩形 */
LCUI_API void LCUIRect_Scale( LCUI_Rect *dst, const LCUI_Rect *src, float scale );
/** 根据容器尺寸,获取指定区域中需要裁剪的区域 */
LCUI_API void LCUIRect_GetCutArea( int box_w, int box_h,
LCUI_Rect rect, LCUI_Rect *cut );
@@ -68,6 +58,15 @@ LCUI_API void LCUIRect_ValidateArea( LCUI_Rect *rect, int box_w, int box_h );
LCUI_API void LCUIRectF_ValidateArea( LCUI_RectF *rect, float box_w, float box_h );
LCUI_API void LCUIRect_ToRectF( const LCUI_Rect *rect,
LCUI_RectF *rectf, float scale );
LCUI_API void LCUIRect_Scale( const LCUI_Rect *src,
LCUI_Rect *dst, float scale );
LCUI_API void LCUIRectF_ToRect( const LCUI_RectF *rectf,
LCUI_Rect *rect, float scale );
/** 检测矩形是否遮盖另一个矩形 */
LCUI_API LCUI_BOOL LCUIRect_IsCoverRect( LCUI_Rect *rect1, LCUI_Rect *rect2 );
+18 -18
View File
@@ -133,14 +133,14 @@ void LCUIDisplay_Update( void )
void LCUIDisplay_Render( void )
{
float scale;
LinkedListNode *sn, *rn;
LCUI_PaintContext paint;
LCUI_SysEventRec ev;
if( !display.is_working ) {
return;
}
scale = LCUIMetrics_GetScale();
ev.type = LCUI_PAINT;
/* 遍历当前的 surface 记录列表 */
for( LinkedList_Each( sn, &display.surfaces ) ) {
SurfaceRecord record = sn->data;
@@ -153,16 +153,13 @@ void LCUIDisplay_Render( void )
record->rendered = FALSE;
/* 在 surface 上逐个重绘无效区域 */
for( LinkedList_Each( rn, &record->rects ) ) {
LCUI_Rect rect;
LCUI_Rect *r = rn->data;
rect.x = r->x * scale;
rect.y = r->y * scale;
rect.width = r->width * scale;
rect.height = r->height * scale;
paint = Surface_BeginPaint( surface, &rect );
paint = Surface_BeginPaint( surface, r );
if( !paint ) {
continue;
}
ev.paint.rect = *r;
LCUI_TriggerEvent( &ev, NULL );
DEBUG_MSG( "[%s]: render rect: (%d,%d,%d,%d)\n",
record->widget->type,
paint->rect.x, paint->rect.y,
@@ -198,18 +195,20 @@ void LCUIDisplay_Present( void )
void LCUIDisplay_InvalidateArea( LCUI_Rect *rect )
{
LCUI_Rect screen;
LCUI_Rect area;
if( !display.is_working ) {
return;
}
if( !rect ) {
screen.x = 0;
screen.y = 0;
screen.width = LCUIDisplay_GetWidth();
screen.height = LCUIDisplay_GetHeight();
rect = &screen;
if( rect ) {
area.x = 0;
area.y = 0;
area.width = LCUIDisplay_GetWidth();
area.height = LCUIDisplay_GetHeight();
RectList_Add( &display.rects, &area );
} else {
RectToInvalidArea( rect, &area );
RectList_Add( &display.rects, &area );
}
RectList_Add( &display.rects, rect );
}
static LCUI_Widget LCUIDisplay_GetBindWidget( LCUI_Surface surface )
@@ -619,6 +618,7 @@ static void OnSurfaceEvent( LCUI_Widget w, LCUI_WidgetEvent e, void *arg )
/** 在 surface 主动产生无效区域并需要绘制的时候 */
static void OnPaint( LCUI_Event e, void *arg )
{
LCUI_RectF rect;
LinkedListNode *node;
LCUI_DisplayEvent dpy_ev = arg;
for( LinkedList_Each( node, &display.surfaces ) ) {
@@ -626,8 +626,8 @@ static void OnPaint( LCUI_Event e, void *arg )
if( record && record->surface != dpy_ev->surface ) {
continue;
}
Widget_InvalidateArea( record->widget,
&dpy_ev->paint.rect, SV_GRAPH_BOX );
LCUIRect_ToRectF( &dpy_ev->paint.rect, &rect, 1.0f );
Widget_InvalidateArea( record->widget, &rect, SV_GRAPH_BOX );
}
}
+15 -8
View File
@@ -358,14 +358,17 @@ static void TextEdit_ProcTextBlock( LCUI_Widget widget, LCUI_TextBlock txtblk )
}
/** 更新文本框的文本图层 */
static void TextEdit_UpdateTextLayer( LCUI_Widget widget )
static void TextEdit_UpdateTextLayer( LCUI_Widget w )
{
float scale;
LinkedList rects;
LCUI_RectF rect;
LCUI_TextEdit edit;
LCUI_TextStyle style;
LinkedListNode *node;
LinkedList_Init( &rects );
edit = Widget_GetData( widget, self.prototype );
scale = LCUIMetrics_GetScale();
edit = Widget_GetData( w, self.prototype );
TextStyle_Copy( &style, &edit->layer_source->text_style );
if( edit->password_char ) {
TextLayer_SetTextStyle( edit->layer_mask, &style );
@@ -376,7 +379,8 @@ static void TextEdit_UpdateTextLayer( LCUI_Widget widget )
TextStyle_Destroy( &style );
TextLayer_Update( edit->layer, &rects );
for( LinkedList_Each( node, &rects ) ) {
Widget_InvalidateArea( widget, node->data, SV_CONTENT_BOX );
LCUIRect_ToRectF( node->data, &rect, 1.0f / scale );
Widget_InvalidateArea( w, &rect, SV_CONTENT_BOX );
}
TextLayer_ClearInvalidRect( edit->layer );
RectList_Clear( &rects );
@@ -750,9 +754,10 @@ static void TextEdit_OnTextInput( LCUI_Widget widget,
static void TextEdit_OnResize( LCUI_Widget w, LCUI_WidgetEvent e, void *arg )
{
int iw, ih;
LCUI_RectF rect;
LinkedList rects;
LinkedListNode *node;
float width = 0, height = 0;
float scale, width = 0, height = 0;
float max_width = 0, max_height = 0;
LCUI_TextEdit edit = GetData( w );
if( !w->style->sheet[key_width].is_valid ||
@@ -769,18 +774,20 @@ static void TextEdit_OnResize( LCUI_Widget w, LCUI_WidgetEvent e, void *arg )
max_height = height = w->box.content.width;
}
LinkedList_Init( &rects );
iw = roundi( width );
ih = roundi( height );
iw = iround( width );
ih = iround( height );
TextLayer_SetFixedSize( edit->layer_mask, iw, ih );
TextLayer_SetFixedSize( edit->layer_source, iw, ih );
TextLayer_SetFixedSize( edit->layer_placeholder, iw, ih );
iw = roundi( max_width );
ih = roundi( max_height );
iw = iround( max_width );
ih = iround( max_height );
TextLayer_SetMaxSize( edit->layer_mask, iw, ih );
TextLayer_SetMaxSize( edit->layer_source, iw, ih );
TextLayer_SetMaxSize( edit->layer_placeholder, iw, ih );
TextLayer_Update( edit->layer, &rects );
scale = LCUIMetrics_GetScale();
for( LinkedList_Each( node, &rects ) ) {
LCUIRect_ToRectF( node->data, &rect, 1.0f / scale );
Widget_InvalidateArea( w, node->data, SV_CONTENT_BOX );
}
RectList_Clear( &rects );
+7 -5
View File
@@ -136,9 +136,10 @@ static void TextView_UpdateStyle( LCUI_Widget w )
static void TextView_OnResize( LCUI_Widget w, LCUI_WidgetEvent e, void *arg )
{
LCUI_RectF rect;
LCUI_TextView txt;
LinkedList rects;
LinkedListNode *node;
LCUI_TextView txt;
int width = 0, height = 0;
float scale, max_width = 0, max_height = 0;
@@ -165,8 +166,8 @@ static void TextView_OnResize( LCUI_Widget w, LCUI_WidgetEvent e, void *arg )
TextLayer_SetMaxSize( txt->layer, width, height );
TextLayer_Update( txt->layer, &rects );
for( LinkedList_Each( node, &rects ) ) {
LCUIRect_Scale( node->data, node->data, 1.0f / scale );
Widget_InvalidateArea( w, node->data, SV_CONTENT_BOX );
LCUIRect_ToRectF( node->data, &rect, 1.0f / scale );
Widget_InvalidateArea( w, &rect, SV_CONTENT_BOX );
}
RectList_Clear( &rects );
TextLayer_ClearInvalidRect( txt->layer );
@@ -251,6 +252,7 @@ static void TextView_OnTask( LCUI_Widget w )
{
int i;
float scale;
LCUI_RectF rect;
LinkedList rects;
LinkedListNode *node;
LCUI_TextView txt = Widget_GetData( w, self.prototype );
@@ -287,8 +289,8 @@ static void TextView_OnTask( LCUI_Widget w )
scale = LCUIMetrics_GetScale();
TextLayer_Update( txt->layer, &rects );
for( LinkedList_Each( node, &rects ) ) {
LCUIRect_Scale( node->data, node->data, 1.0f / scale );
Widget_InvalidateArea( w, node->data, SV_CONTENT_BOX );
LCUIRect_ToRectF( node->data, &rect, 1.0f / scale );
Widget_InvalidateArea( w, &rect, SV_CONTENT_BOX );
}
RectList_Clear( &rects );
TextLayer_ClearInvalidRect( txt->layer );
+6 -10
View File
@@ -701,7 +701,7 @@ static void Widget_UpdateChildrenSize( LCUI_Widget w )
void Widget_UpdatePosition( LCUI_Widget w )
{
LCUI_Rect rect;
LCUI_RectF rect;
int position = ComputeStyleOption( w, key_position, SV_STATIC );
int valign = ComputeStyleOption( w, key_vertical_align, SV_TOP );
w->computed_style.vertical_align = valign;
@@ -721,8 +721,8 @@ void Widget_UpdatePosition( LCUI_Widget w )
}
}
w->computed_style.position = position;
RectF2Rect( w->box.graph, rect );
Widget_UpdateZIndex( w );
rect = w->box.graph;
w->x = w->origin_x;
w->y = w->origin_y;
switch( position ) {
@@ -799,8 +799,6 @@ void Widget_UpdatePosition( LCUI_Widget w )
w->box.graph.x -= Widget_GetBoxShadowOffsetX( w );
w->box.graph.y -= Widget_GetBoxShadowOffsetY( w );
if( w->parent ) {
DEBUG_MSG("new-rect: %d,%d,%d,%d\n", w->box.graph.x, w->box.graph.y, w->box.graph.w, w->box.graph.h);
DEBUG_MSG("old-rect: %d,%d,%d,%d\n", rect.x, rect.y, rect.width, rect.height);
/* 标记移动前后的区域 */
Widget_InvalidateArea( w, NULL, SV_GRAPH_BOX );
Widget_InvalidateArea( w->parent, &rect, SV_PADDING_BOX );
@@ -1211,12 +1209,10 @@ void Widget_UpdateSize( LCUI_Widget w )
}
}
if( w->parent ) {
LCUI_Rect r;
RectF2Rect( rect, r );
Widget_InvalidateArea( w->parent, &r, SV_PADDING_BOX );
r.width = roundi( w->box.graph.width );
r.height = roundi( w->box.graph.height );
Widget_InvalidateArea( w->parent, &r, SV_PADDING_BOX );
Widget_InvalidateArea( w->parent, &rect, SV_PADDING_BOX );
rect.width = w->box.graph.width;
rect.height = w->box.graph.height;
Widget_InvalidateArea( w->parent, &rect, SV_PADDING_BOX );
if( w->parent->style->sheet[key_width].type == SVT_AUTO
|| w->parent->style->sheet[key_height].type == SVT_AUTO ) {
Widget_AddTask( w->parent, WTT_RESIZE );
+20 -31
View File
@@ -38,6 +38,7 @@
* ***************************************************************************/
#include <string.h>
#include <math.h>
#include <LCUI_Build.h>
#include <LCUI/LCUI.h>
#include <LCUI/gui/metrics.h>
@@ -142,9 +143,26 @@ void Widget_SetBorder( LCUI_Widget w, float width, int style, LCUI_Color clr )
Widget_UpdateStyle( w, FALSE );
}
static unsigned int ComputeActual( float width )
{
unsigned int w;
w = LCUIMetrics_ComputeActual( width, SVT_PX );
if( width > 0 && w < 1 ) {
return 1;
}
return w;
}
static float ComputeBorderWidth( float width )
{
if( width < 1.0f && width > 0 ) {
return 1.0f;
}
return roundf( width );
}
void Widget_UpdateBorder( LCUI_Widget w )
{
LCUI_Rect rect;
LCUI_BorderStyle ob, *nb;
ob = w->computed_style.border;
Widget_ComputeBorderStyle( w );
@@ -158,38 +176,9 @@ void Widget_UpdateBorder( LCUI_Widget w )
Widget_AddTask( w, WTT_POSITION );
return;
}
rect.x = rect.y = 0;
rect.width = roundi( w->box.border.width );
rect.width -= max( ob.top_right_radius, ob.right.width );
rect.height = max( ob.top_left_radius, ob.top.width );
/* 上 */
Widget_InvalidateArea( w, &rect, SV_BORDER_BOX );
rect.x = roundi( w->box.border.width );
rect.width = max( ob.top_right_radius, ob.right.width );
rect.x -= rect.width;
rect.height = roundi( w->box.border.height );
rect.height -= max( ob.bottom_right_radius, ob.bottom.width );
/* 右 */
Widget_InvalidateArea( w, &rect, SV_BORDER_BOX );
rect.x = max( ob.bottom_left_radius, ob.left.width );
rect.y = roundi( w->box.border.height );
rect.width = roundi( w->box.border.width );
rect.width -= rect.x;
rect.height = max( ob.bottom_right_radius, ob.bottom.width );
rect.y -= rect.height;
/* 下 */
Widget_InvalidateArea( w, &rect, SV_BORDER_BOX );
rect.width = rect.x;
rect.x = 0;
rect.y = max( ob.top_left_radius, ob.left.width );
rect.height = roundi( w->box.border.height );
rect.height -= rect.y;
/* 左 */
Widget_InvalidateArea( w, &rect, SV_BORDER_BOX );
Widget_InvalidateArea( w, NULL, SV_BORDER_BOX );
}
#define ComputeActual(VALUE) LCUIMetrics_ComputeActual( VALUE, SVT_PX )
/** 计算部件边框样式的实际值 */
static void Widget_ComputeBorder( LCUI_Widget w, LCUI_Border *out )
{
+32 -23
View File
@@ -77,8 +77,8 @@ static LCUI_BOOL Widget_IsPaintable( LCUI_Widget w )
* @param[out] out_rect 调整后的矩形
* @param[in] box_type 区域相对于何种框进行定位
*/
static void Widget_AdjustArea( LCUI_Widget w, LCUI_Rect *in_rect,
LCUI_Rect *out_rect, int box_type )
static void Widget_AdjustArea( LCUI_Widget w, LCUI_RectF *in_rect,
LCUI_RectF *out_rect, int box_type )
{
LCUI_RectF *box;
switch( box_type ) {
@@ -91,24 +91,35 @@ static void Widget_AdjustArea( LCUI_Widget w, LCUI_Rect *in_rect,
/* 如果为NULL,则视为使用整个部件区域 */
if( !in_rect ) {
out_rect->x = out_rect->y = 0;
out_rect->width = roundi( box->width );
out_rect->height = roundi( box->height );
out_rect->width = box->width;
out_rect->height = box->height;
} else {
*out_rect = *in_rect;
LCUIRect_ValidateArea( out_rect, roundi( box->width ),
roundi( box->height ) );
LCUIRectF_ValidateArea( out_rect, box->width, box->height );
}
/* 将坐标转换成相对于图像呈现区的坐标 */
out_rect->x += roundi( box->x - w->box.graph.x );
out_rect->y += roundi( box->y - w->box.graph.y );
out_rect->x += box->x - w->box.graph.x;
out_rect->y += box->y - w->box.graph.y;
}
void RectFToInvalidArea( const LCUI_RectF *rect, LCUI_Rect *area )
{
LCUIMetrics_ComputeRectActual( area, rect );
}
void RectToInvalidArea( const LCUI_Rect *rect, LCUI_Rect *area )
{
LCUI_RectF rectf;
LCUIRect_ToRectF( rect, &rectf, 1.0f );
LCUIMetrics_ComputeRectActual( area, &rectf );
}
LCUI_BOOL Widget_InvalidateArea( LCUI_Widget widget,
LCUI_Rect *r, int box_type )
LCUI_RectF *in_rect, int box_type )
{
int mode;
LCUI_Rect rect;
LCUI_RectF rectf;
LCUI_Rect area;
LCUI_RectF rect;
LCUI_Widget w = widget;
LCUI_Widget root = LCUIWidget_GetRoot();
LCUI_RectGroup group;
@@ -117,27 +128,25 @@ LCUI_BOOL Widget_InvalidateArea( LCUI_Widget widget,
w = root;
}
mode = LCUIDisplay_GetMode();
Widget_AdjustArea( w, r, &rect, box_type );
rectf.x = rect.x + w->box.graph.x;
rectf.y = rect.y + w->box.graph.y;
rectf.width = (float)rect.width;
rectf.height = (float)rect.height;
Widget_AdjustArea( w, in_rect, &rect, box_type );
rect.x += w->box.graph.x;
rect.y += w->box.graph.y;
while( w && w->parent ) {
LCUIRectF_ValidateArea( &rectf, w->parent->box.padding.width,
LCUIRectF_ValidateArea( &rect, w->parent->box.padding.width,
w->parent->box.padding.height );
if( rectf.width <= 0 || rectf.height <= 0 ) {
if( rect.width <= 0 || rect.height <= 0 ) {
return FALSE;
}
if( mode != LCDM_SEAMLESS && w->parent == root ) {
break;
}
w = w->parent;
rectf.x += w->box.padding.x;
rectf.y += w->box.padding.y;
rect.x += w->box.padding.x;
rect.y += w->box.padding.y;
}
RectF2Rect( rectf, rect );
RectFToInvalidArea( &rect, &area );
if( mode != LCDM_SEAMLESS ) {
RectList_Add( &self.rects, &rect );
RectList_Add( &self.rects, &area );
return TRUE;
}
group = RBTree_CustomGetData( &self.groups, w );
@@ -147,7 +156,7 @@ LCUI_BOOL Widget_InvalidateArea( LCUI_Widget widget,
LinkedList_Init( &group->rects );
RBTree_CustomInsert( &self.groups, w, group );
}
return RectList_Add( &group->rects, &rect ) == 0;
return RectList_Add( &group->rects, &area ) == 0;
}
size_t Widget_GetInvalidArea( LCUI_Widget w, LinkedList *rects )
+7 -5
View File
@@ -97,6 +97,7 @@ static void Widget_ComputeBoxShadowStyle( LCUI_Widget w )
void Widget_UpdateBoxShadow( LCUI_Widget w )
{
int i;
LCUI_RectF rect;
LCUI_Rect rects[4], rb, rg;
LCUI_BoxShadowStyle *sd = &w->computed_style.shadow;
LCUI_BoxShadowStyle old_sd = w->computed_style.shadow;
@@ -104,13 +105,14 @@ void Widget_UpdateBoxShadow( LCUI_Widget w )
/* 如果阴影变化并未导致图层尺寸变化,则只重绘阴影 */
if( sd->x == old_sd.x && sd->y == old_sd.y &&
sd->blur == old_sd.blur ) {
RectF2Rect( w->box.border, rb );
RectF2Rect( w->box.graph, rg );
LCUIRectF_ToRect( &w->box.border, &rb, 1.0f );
LCUIRectF_ToRect( &w->box.graph, &rg, 1.0f );
LCUIRect_CutFourRect( &rb, &rg, rects );
for( i = 0; i < 4; ++i ) {
rects[i].x -= roundi( w->box.graph.x );
rects[i].y -= roundi( w->box.graph.y );
Widget_InvalidateArea( w, &rects[i], SV_GRAPH_BOX );
LCUIRect_ToRectF( &rects[i], &rect, 1.0f );
rect.x -= w->box.graph.x;
rect.y -= w->box.graph.y;
Widget_InvalidateArea( w, &rect, SV_GRAPH_BOX );
}
return;
}
+24 -14
View File
@@ -46,7 +46,6 @@
b->x >= a->x && b->x + b->width <= a->x + a->width \
&& b->y >= a->y && b->y + b->height <= a->y + a->height
/* 将数值转换成LCUI_Rect型结构体 */
LCUI_Rect Rect( int x, int y, int w, int h )
{
LCUI_Rect r;
@@ -57,12 +56,31 @@ LCUI_Rect Rect( int x, int y, int w, int h )
return r;
}
void LCUIRect_Scale( LCUI_Rect *dst, const LCUI_Rect *src, float scale )
void LCUIRect_ToRectF( const LCUI_Rect *rect,
LCUI_RectF *rectf, float scale )
{
dst->x = (int)( src->x * scale );
dst->y = (int)( src->y * scale );
dst->width = roundi( src->width * scale );
dst->height = roundi( src->height * scale );
rectf->x = rect->x * scale;
rectf->y = rect->y * scale;
rectf->width = rect->width * scale;
rectf->height = rect->height * scale;
}
void LCUIRect_Scale( const LCUI_Rect *src,
LCUI_Rect *dst, float scale )
{
dst->x = iround( src->x * scale );
dst->y = iround( src->y * scale );
dst->width = iround( src->width * scale );
dst->height = iround( src->height * scale );
}
void LCUIRectF_ToRect( const LCUI_RectF *rectf,
LCUI_Rect *rect, float scale )
{
rect->x = iround( rectf->x * scale );
rect->y = iround( rectf->y * scale );
rect->width = iround( rectf->width * scale );
rect->height = iround( rectf->height * scale );
}
void LCUIRect_GetCutArea( int box_w, int box_h,
@@ -144,7 +162,6 @@ void LCUIRectF_ValidateArea( LCUI_RectF *rect, float box_w, float box_h )
}
}
/** 检测矩形是否遮盖另一个矩形 */
LCUI_BOOL LCUIRect_IsCoverRect( LCUI_Rect *rect1, LCUI_Rect *rect2 )
{
if( rect1->x > rect2->x ) {
@@ -168,13 +185,6 @@ LCUI_BOOL LCUIRect_IsCoverRect( LCUI_Rect *rect1, LCUI_Rect *rect2 )
return TRUE;
}
/**
* 获取两个矩形中的重叠矩形
* @param[in] a 矩形A
* @param[in] b 矩形B
* @param[out] out 矩形A和B重叠处的矩形
* @returns 如果两个矩形重叠,则返回TRUE,否则返回FALSE
*/
LCUI_BOOL LCUIRect_GetOverlayRect( const LCUI_Rect *a,
const LCUI_Rect *b,
LCUI_Rect *out )