提交 fad26481 编写于 作者: C chaos.proton@gmail.com

components/rtgui_win: check the return value of overlapFunc

overlapFunc will return RTGUI_REGION_STATUS_FAILURE in some
circumstance(OOM etc), check it and return error if any thing goes
wrong. It prevents garbage values crashing the system.

Please ignore the eol diff noise.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1802 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 3d21a838
...@@ -66,14 +66,14 @@ static rtgui_region_status_t rtgui_break(rtgui_region_t *pReg); ...@@ -66,14 +66,14 @@ static rtgui_region_status_t rtgui_break(rtgui_region_t *pReg);
* the y1 to y2 area spanned by the band), then the rectangle may be broken * the y1 to y2 area spanned by the band), then the rectangle may be broken
* down into two or more smaller rectangles stacked one atop the other. * down into two or more smaller rectangles stacked one atop the other.
* *
* ----------- ----------- * ----------- -----------
* | | | | band 0 * | | | | band 0
* | | -------- ----------- -------- * | | -------- ----------- --------
* | | | | in y-x banded | | | | band 1 * | | | | in y-x banded | | | | band 1
* | | | | form is | | | | * | | | | form is | | | |
* ----------- | | ----------- -------- * ----------- | | ----------- --------
* | | | | band 2 * | | | | band 2
* -------- -------- * -------- --------
* *
* An added constraint on the rectangles is that they must cover as much * An added constraint on the rectangles is that they must cover as much
* horizontal area as possible: no two rectangles within a band are allowed * horizontal area as possible: no two rectangles within a band are allowed
...@@ -113,8 +113,7 @@ static rtgui_region_status_t rtgui_break(rtgui_region_t *pReg); ...@@ -113,8 +113,7 @@ static rtgui_region_status_t rtgui_break(rtgui_region_t *pReg);
((r1)->x2 >= (r2)->x2) && \ ((r1)->x2 >= (r2)->x2) && \
((r1)->y1 <= (r2)->y1) && \ ((r1)->y1 <= (r2)->y1) && \
((r1)->y2 >= (r2)->y2) ) ((r1)->y2 >= (r2)->y2) )
/* true iff box r1 and box r2 constitute cross */
/* true iff Box r1 and Box r2 constitute cross */
#define CROSS(r1,r2) \ #define CROSS(r1,r2) \
( ((r1)->x1 <= (r2)->x1) && \ ( ((r1)->x1 <= (r2)->x1) && \
((r1)->x2 >= (r2)->x2) && \ ((r1)->x2 >= (r2)->x2) && \
...@@ -641,8 +640,9 @@ rtgui_op( ...@@ -641,8 +640,9 @@ rtgui_op(
if (ybot > ytop) if (ybot > ytop)
{ {
curBand = newReg->data->numRects; curBand = newReg->data->numRects;
(* overlapFunc)(newReg, r1, r1BandEnd, r2, r2BandEnd, ytop, ybot, if ((* overlapFunc)(newReg, r1, r1BandEnd, r2, r2BandEnd, ytop, ybot,
pOverlap); pOverlap) == RTGUI_REGION_STATUS_FAILURE)
return RTGUI_REGION_STATUS_FAILURE;
Coalesce(newReg, prevBand, curBand); Coalesce(newReg, prevBand, curBand);
} }
...@@ -886,6 +886,7 @@ rtgui_region_intersect(rtgui_region_t *newReg, ...@@ -886,6 +886,7 @@ rtgui_region_intersect(rtgui_region_t *newReg,
if (!rtgui_op(newReg, reg1, reg2, rtgui_region_intersectO, RTGUI_REGION_STATUS_FAILURE, RTGUI_REGION_STATUS_FAILURE, if (!rtgui_op(newReg, reg1, reg2, rtgui_region_intersectO, RTGUI_REGION_STATUS_FAILURE, RTGUI_REGION_STATUS_FAILURE,
&overlap)) &overlap))
return RTGUI_REGION_STATUS_FAILURE; return RTGUI_REGION_STATUS_FAILURE;
rtgui_set_extents(newReg); rtgui_set_extents(newReg);
} }
...@@ -2243,13 +2244,13 @@ int rtgui_rect_is_intersect(const rtgui_rect_t *rect1, const rtgui_rect_t *rect2 ...@@ -2243,13 +2244,13 @@ int rtgui_rect_is_intersect(const rtgui_rect_t *rect1, const rtgui_rect_t *rect2
{ {
return RT_EOK; return RT_EOK;
} }
else if (CROSS(rect1,rect2)) else if (CROSS(rect1,rect2))
{ {
return RT_EOK; return RT_EOK;
} }
else if (CROSS(rect2,rect1)) else if (CROSS(rect2,rect1))
{ {
return RT_EOK; return RT_EOK;
} }
return -RT_ERROR; return -RT_ERROR;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册