2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FGrp_CanvasGpLine.cpp
20 * @brief This is the implementation file for _CanvasLine class.
28 #include <FGrpPoint.h>
30 #include <FBaseSysLog.h>
32 #include "FGrp_CanvasGpPrimitive.h"
35 using namespace Tizen::Base;
36 using namespace Tizen::Graphics;
39 namespace Tizen { namespace Graphics
43 _CanvasLine::SetLineWidth(int lineWidth)
45 __lineWidth = lineWidth;
51 _CanvasLine::GetLineWidth(void) const
57 _CanvasLine::DrawLine(const _GpPoint& startPt, const _GpPoint& endPt, const _GpBufferInfo& bufInfo)
61 _GpResult ret = GP_RESULT_FAIL;
62 bool finalRet = false;
65 halfLineW = __lineWidth >> 1;
67 if (startPt.x > endPt.x)
70 rcLine.width = startPt.x - endPt.x + 1;
75 rcLine.width = endPt.x - startPt.x + 1;
78 if (startPt.y > endPt.y)
81 rcLine.height = startPt.y - endPt.y + 1;
86 rcLine.height = endPt.y - startPt.y + 1;
89 if (_IsInClipRect(rcLine.x - halfLineW, rcLine.y - halfLineW, rcLine.width + __lineWidth, rcLine.height + __lineWidth, bufInfo))
91 _SetNotClipFunction(true);
97 if (startPt.x == endPt.x)
99 ret = (this->*pFuncVerticalLine)(startPt.x, startPt.y, endPt.y, bufInfo);
101 else if (startPt.y == endPt.y)
103 ret = (this->*pFuncHorizontalLine)(startPt.x, endPt.x, startPt.y, bufInfo);
107 ret = _DrawUnitLineSlant(startPt, endPt, bufInfo);
112 if ((bufInfo.color32 & 0xFF000000) == 0xFF000000)
114 finalRet = __DrawWideLine(startPt, endPt, bufInfo);
116 else if ((bufInfo.color32 & 0xFF000000) > 0)
118 finalRet = __DrawWideLineWithOpacity32(startPt, endPt, bufInfo);
122 if (__lineWidth > 2 && (bufInfo.color32 & 0xFF000000) == 0xFF000000)
126 int lineW = __lineWidth;
134 _CanvasEllipse ellipse;
136 ellipse.SetLineWidth(lineW);
139 if (ellipse.FillElliepse(startPt.x - halfLineW, startPt.y - halfLineW, lineW, lineW, bufInfo) == E_SYSTEM)
141 SysLog(NID_GRP, "DrawLine: FillElliepse() is failed!\n");
145 if (ellipse.FillElliepse(endPt.x - halfLineW, endPt.y - halfLineW, lineW, lineW, bufInfo) == E_SYSTEM)
147 SysLog(NID_GRP, "DrawLine: FillElliepse() is failed!\n");
151 else if (__lineWidth == 4)
155 (this->*pFuncHorizontalLine)(startPt.x - 1, startPt.x, startPt.y - 2, bufInfo);
156 (this->*pFuncHorizontalLine)(startPt.x - 2, startPt.x + 1, startPt.y - 1, bufInfo);
157 (this->*pFuncHorizontalLine)(startPt.x - 2, startPt.x + 1, startPt.y, bufInfo);
158 (this->*pFuncHorizontalLine)(startPt.x - 1, startPt.x, startPt.y + 1, bufInfo);
160 (this->*pFuncHorizontalLine)(endPt.x - 1, endPt.x, endPt.y - 2, bufInfo);
161 (this->*pFuncHorizontalLine)(endPt.x - 2, endPt.x + 1, endPt.y - 1, bufInfo);
162 (this->*pFuncHorizontalLine)(endPt.x - 2, endPt.x + 1, endPt.y, bufInfo);
163 (this->*pFuncHorizontalLine)(endPt.x - 1, endPt.x, endPt.y + 1, bufInfo);
167 else // __lineWidth = 3
171 (this->*pFuncHorizontalLine)(startPt.x, startPt.x, startPt.y - 1, bufInfo);
172 (this->*pFuncHorizontalLine)(startPt.x - 1, startPt.x + 1, startPt.y, bufInfo);
173 (this->*pFuncHorizontalLine)(startPt.x, startPt.x, startPt.y + 1, bufInfo);
175 (this->*pFuncHorizontalLine)(endPt.x, endPt.x, endPt.y - 1, bufInfo);
176 (this->*pFuncHorizontalLine)(endPt.x - 1, endPt.x + 1, endPt.y, bufInfo);
177 (this->*pFuncHorizontalLine)(endPt.x, endPt.x, endPt.y + 1, bufInfo);
185 _SetClipFunction(true);
188 return ((ret == GP_RESULT_FAIL) && (finalRet == false) ? E_SYSTEM : E_SUCCESS);
192 _CanvasLine::_DrawUnitLineVertical(int x, int startY, int endY, const _GpBufferInfo& bufInfo)
196 if (bufInfo.bitsPerPixel == 32)
198 unsigned long* pFrmbuf32 = (unsigned long*) bufInfo.pPixels;
204 GP_SWAP(startY, endY);
208 if ((bufInfo.color32 & 0xFF000000) == 0xFF000000)
212 pFrmbuf32[bufInfo.pixelPerLine * pt.y + pt.x] = bufInfo.color32;
216 else if ((bufInfo.color32 & 0xFF000000) > 0)
220 __DrawHorizontalLineWithOpacity32(pt.x, pt.x, pt.y, bufInfo);
227 SysLog(NID_GRP, "_DrawUnitLineVertical: pFrmbuf32 is invalid!\n");
228 return GP_RESULT_FAIL;
234 SysLog(NID_GRP, "_DrawUnitLineVertical: not support 16 bpp!\n");
235 return GP_RESULT_FAIL;
238 return GP_RESULT_SUCCESS;
242 _CanvasLine::_DrawUnitLineHorizontal(int startX, int endX, int y, const _GpBufferInfo& bufInfo)
246 if (bufInfo.bitsPerPixel == 32)
248 unsigned long* pFrmbuf32 = (unsigned long*) bufInfo.pPixels;
254 GP_SWAP(startX, endX);
258 if ((bufInfo.color32 & 0xFF000000) == 0xFF000000)
262 pFrmbuf32[bufInfo.pixelPerLine * pt.y + pt.x] = bufInfo.color32;
266 else if ((bufInfo.color32 & 0xFF000000) > 0)
268 __DrawHorizontalLineWithOpacity32(pt.x, endX, pt.y, bufInfo);
273 SysLog(NID_GRP, "_DrawUnitLineHorizontal: pFrmbuf32 is null!\n");
275 return GP_RESULT_FAIL;
281 SysLog(NID_GRP, "_DrawUnitLineHorizontal: not support 16 bpp!\n");
283 return GP_RESULT_FAIL;
286 return GP_RESULT_SUCCESS;
290 _CanvasLine::_DrawWideLineVertical(int x, int startY, int endY, const _GpBufferInfo& bufInfo)
297 if (bufInfo.bitsPerPixel == 32)
299 unsigned long* pFrmbuf32 = (unsigned long*) bufInfo.pPixels;
305 GP_SWAP(startY, endY);
309 halfLineW = __lineWidth >> 1;
311 if (__lineWidth == 1) //is this part necessary?
313 if ((bufInfo.color32 & 0xFF000000) == 0xFF000000)
317 pFrmbuf32[bufInfo.pixelPerLine * pt.y + pt.x] = bufInfo.color32;
321 else if ((bufInfo.color32 & 0xFF000000) > 0)
325 __DrawHorizontalLineWithOpacity32(pt.x, pt.x, pt.y, bufInfo);
332 int realEndX = x + halfLineW;
334 if (__lineWidth % 2 == 0)
339 if (__lineWidth == 2 && pt.y >= 1)
344 posX = x - halfLineW;
351 for (; posX <= realEndX; posX++)
353 // draw vertical line
354 if ((bufInfo.color32 & 0xFF000000) == 0xFF000000)
358 pFrmbuf32[bufInfo.pixelPerLine * pt.y + posX] = bufInfo.color32;
362 else if ((bufInfo.color32 & 0xFF000000) > 0)
366 __DrawHorizontalLineWithOpacity32(posX, posX, pt.y, bufInfo);
377 SysLog(NID_GRP, "_DrawWideLineVertical: pFrmbuf32 is invalid!\n");
379 return GP_RESULT_FAIL;
385 SysLog(NID_GRP, "_DrawWideLineVertical: not support 16 bpp!\n");
387 return GP_RESULT_FAIL;
390 return GP_RESULT_SUCCESS;
394 _CanvasLine::_DrawWideLineHorizontal(int startX, int endX, int y, const _GpBufferInfo& bufInfo)
399 if (bufInfo.bitsPerPixel == 32)
401 unsigned long* pFrmbuf32 = (unsigned long*) bufInfo.pPixels;
408 GP_SWAP(startX, endX);
412 // Calculate half Width of Line
413 halfLineW = __lineWidth >> 1;
415 if (__lineWidth == 1) // is this part necessary?
417 // draw primitive line
418 if ((bufInfo.color32 & 0xFF000000) == 0xFF000000)
422 pFrmbuf32[bufInfo.pixelPerLine * pt.y + pt.x] = bufInfo.color32;
426 else if ((bufInfo.color32 & 0xFF000000) > 0)
428 __DrawHorizontalLineWithOpacity32(pt.x, endX, y, bufInfo);
433 int realEndY = y + halfLineW;
435 if (__lineWidth % 2 == 0)
440 if (__lineWidth == 2 && pt.x >= 1)
445 posY = y - halfLineW;
452 for (; posY <= realEndY; posY++)
454 if ((bufInfo.color32 & 0xFF000000) == 0xFF000000)
458 pFrmbuf32[bufInfo.pixelPerLine * posY + pt.x] = bufInfo.color32;
462 else if ((bufInfo.color32 & 0xFF000000) > 0)
464 __DrawHorizontalLineWithOpacity32(pt.x, endX, posY, bufInfo);
473 SysLog(NID_GRP, "_DrawWideLineHorizontal: pFrmbuf32 is invalid!\n");
475 return GP_RESULT_FAIL;
481 SysLog(NID_GRP, "_DrawWideLineHorizontal: not support 16 bpp!\n");
483 return GP_RESULT_FAIL;
486 return GP_RESULT_SUCCESS;
490 _CanvasLine::_DrawUnitLineSlant(const _GpPoint& point1, const _GpPoint& point2, const _GpBufferInfo& bufInfo)
501 if (bufInfo.bitsPerPixel == 32)
503 Point startPt(point1.x, point1.y);
504 Point endPt(point2.x, point2.y);
506 absX = GP_ABS(endPt.x - startPt.x);
507 absY = GP_ABS(endPt.y - startPt.y);
511 if (startPt.x > endPt.x)
513 GP_SWAP(startPt.x, endPt.x);
514 GP_SWAP(startPt.y, endPt.y);
517 inc = (endPt.y > startPt.y) ? 1 : -1;
518 deltaX = endPt.x - startPt.x;
519 deltaY = GP_ABS(endPt.y - startPt.y);
520 deltaDiff = (deltaY << 1) - deltaX;
521 errorInc = (deltaY << 1);
522 errorIncCount = (deltaY - deltaX) << 1;
524 Point pt(startPt.x, startPt.y);
526 (this->*pFuncSetPixel)(startPt.x, startPt.y, bufInfo);
528 while (pt.x < endPt.x)
535 deltaDiff += errorIncCount;
539 deltaDiff += errorInc;
542 (this->*pFuncSetPixel)(pt.x, pt.y, bufInfo);
547 if (startPt.y > endPt.y)
549 GP_SWAP(startPt.x, endPt.x);
550 GP_SWAP(startPt.y, endPt.y);
553 inc = (endPt.x > startPt.x) ? 1 : -1;
554 deltaX = GP_ABS(endPt.x - startPt.x);
555 deltaY = endPt.y - startPt.y;
556 deltaDiff = (deltaX << 1) - deltaY;
557 errorInc = (deltaX << 1);
558 errorIncCount = (deltaX - deltaY) << 1;
560 Point pt(startPt.x, startPt.y);
562 (this->*pFuncSetPixel)(startPt.x, startPt.y, bufInfo);
564 while (pt.y < endPt.y)
571 deltaDiff += errorIncCount;
575 deltaDiff += errorInc;
578 (this->*pFuncSetPixel)(pt.x, pt.y, bufInfo);
585 return GP_RESULT_FAIL;
588 return GP_RESULT_SUCCESS;
592 _CanvasLine::_DrawPixel(int x, int y, const _GpBufferInfo& bufInfo)
594 if (bufInfo.bitsPerPixel == 32)
596 unsigned long* pFrmbuf32 = (unsigned long*) bufInfo.pPixels;
600 if ((bufInfo.color32 & 0xFF000000) == 0xFF000000)
602 pFrmbuf32[bufInfo.pixelPerLine * y + x] = bufInfo.color32;
604 else if ((bufInfo.color32 & 0xFF000000) > 0)
606 __DrawHorizontalLineWithOpacity32(x, x, y, bufInfo);
611 SysLog(NID_GRP, "_DrawPixel: pFrmbuf32 is null!\n");
613 return GP_RESULT_FAIL;
619 SysLog(NID_GRP, "_DrawPixel: not support 16 bpp!\n");
621 return GP_RESULT_FAIL;
624 return GP_RESULT_SUCCESS;
628 _CanvasLine::_DrawUnitLineVerticalWithClipping(int x, int startY, int endY, const _GpBufferInfo& bufInfo)
632 if (bufInfo.bitsPerPixel == 32)
634 unsigned long* pFrmbuf32 = (unsigned long*) bufInfo.pPixels;
640 GP_SWAP(startY, endY);
644 if (bufInfo.isClipBoundsSet)
646 if (pt.x < bufInfo.clipBounds.x || pt.x > bufInfo.clipBounds.x + bufInfo.clipBounds.width - 1)
648 return GP_RESULT_OUTOFBOUNDS;
651 if (pt.y > bufInfo.clipBounds.y + bufInfo.clipBounds.height - 1 || endY < bufInfo.clipBounds.y)
653 return GP_RESULT_OUTOFBOUNDS;
656 if (pt.y < bufInfo.clipBounds.y)
658 pt.y = bufInfo.clipBounds.y;
661 if (endY > bufInfo.clipBounds.y + bufInfo.clipBounds.height - 1)
663 endY = bufInfo.clipBounds.y + bufInfo.clipBounds.height - 1;
668 if (pt.x < 0 || pt.x > bufInfo.width - 1)
670 return GP_RESULT_OUTOFBOUNDS;
673 if (endY < 0 || pt.y > bufInfo.height - 1)
675 return GP_RESULT_OUTOFBOUNDS;
683 if (endY > bufInfo.height - 1)
685 endY = bufInfo.height - 1;
688 if ((endY - pt.y) == 0)
690 return GP_RESULT_OUTOFBOUNDS;
693 if (pt.x == bufInfo.width)
699 if ((bufInfo.color32 & 0xFF000000) == 0xFF000000)
703 pFrmbuf32[bufInfo.pixelPerLine * pt.y + pt.x] = bufInfo.color32;
707 else if ((bufInfo.color32 & 0xFF000000) > 0)
711 __DrawHorizontalLineWithOpacity32(pt.x, pt.x, pt.y, bufInfo);
718 SysLog(NID_GRP, "_DrawUnitLineVerticalWithClipping: pFrmbuf32 is invalid!\n");
720 return GP_RESULT_FAIL;
726 SysLog(NID_GRP, "_DrawUnitLineVerticalWithClipping: not support 16 bpp!\n");
728 return GP_RESULT_FAIL;
731 return GP_RESULT_SUCCESS;
735 _CanvasLine::_DrawUnitLineHorizontalWithClipping(int startX, int endX, int y, const _GpBufferInfo& bufInfo)
739 if (bufInfo.bitsPerPixel == 32)
741 unsigned long* pFrmbuf32 = (unsigned long*) bufInfo.pPixels;
747 GP_SWAP(startX, endX);
751 if (bufInfo.isClipBoundsSet)
753 if (pt.y < bufInfo.clipBounds.y || pt.y > bufInfo.clipBounds.y + bufInfo.clipBounds.height - 1)
755 return GP_RESULT_OUTOFBOUNDS;
758 if (pt.x > bufInfo.clipBounds.x + bufInfo.clipBounds.width - 1 || endX < bufInfo.clipBounds.x)
760 return GP_RESULT_OUTOFBOUNDS;
763 if (pt.x < bufInfo.clipBounds.x)
765 pt.x = bufInfo.clipBounds.x;
768 if (endX > bufInfo.clipBounds.x + bufInfo.clipBounds.width - 1)
770 endX = bufInfo.clipBounds.x + bufInfo.clipBounds.width - 1;
775 if (pt.y < 0 || pt.y > bufInfo.height - 1)
777 return GP_RESULT_OUTOFBOUNDS;
780 if (endX < 0 || pt.x > bufInfo.width - 1)
782 return GP_RESULT_OUTOFBOUNDS;
790 if (endX > bufInfo.width - 1)
792 endX = bufInfo.width - 1;
795 if ((endX - pt.x) == 0)
797 return GP_RESULT_OUTOFBOUNDS;
800 if (pt.y == bufInfo.height)
806 if ((bufInfo.color32 & 0xFF000000) == 0xFF000000)
810 pFrmbuf32[bufInfo.pixelPerLine * pt.y + pt.x] = bufInfo.color32;
814 else if ((bufInfo.color32 & 0xFF000000) > 0)
816 __DrawHorizontalLineWithOpacity32(pt.x, endX, pt.y, bufInfo);
821 SysLog(NID_GRP, "_DrawUnitLineHorizontalWithClipping: pFrmbuf32 is null!\n");
823 return GP_RESULT_FAIL;
829 SysLog(NID_GRP, "_DrawUnitLineHorizontalWithClipping: not support 16 bpp!\n");
831 return GP_RESULT_FAIL;
834 return GP_RESULT_SUCCESS;
838 _CanvasLine::_DrawWideLineVerticalWithClipping(int x, int startY, int endY, const _GpBufferInfo& bufInfo)
843 halfLineW = __lineWidth >> 1;
845 if (__lineWidth == 1)
847 if (_DrawUnitLineVerticalWithClipping(x, startY, endY, bufInfo) == GP_RESULT_FAIL)
849 SysLog(NID_GRP, "_DrawUnitLineVerticalWithClipping: _DrawUnitLineVerticalWithClipping() is failed!\n");
851 return GP_RESULT_FAIL;
856 int realEndX = x + halfLineW;
858 if (__lineWidth % 2 == 0)
863 /* bjcho : For fixing y coordinate when the line width is 2 pixel.
868 for (posX = x - halfLineW; posX <= realEndX; posX++)
870 if (_DrawUnitLineVerticalWithClipping(posX, startY, endY, bufInfo) == GP_RESULT_FAIL)
872 SysLog(NID_GRP, "_DrawUnitLineVerticalWithClipping: _DrawUnitLineVerticalWithClipping() is failed!\n");
874 return GP_RESULT_FAIL;
879 return GP_RESULT_SUCCESS;
883 _CanvasLine::_DrawWideLineHorizontalWithClipping(int startX, int endX, int y, const _GpBufferInfo& bufInfo)
888 // Calculate half Width of Line
889 halfLineW = __lineWidth >> 1;
892 if (__lineWidth == 1)
894 if (_DrawUnitLineHorizontalWithClipping(startX, endX, y, bufInfo) == GP_RESULT_FAIL)
896 SysLog(NID_GRP, "_DrawUnitLineHorizontalWithClipping: _DrawUnitLineHorizontalWithClipping() is failed!\n");
898 return GP_RESULT_FAIL;
903 int realEndY = y + halfLineW;
905 if (__lineWidth % 2 == 0)
915 for (posY = y - halfLineW; posY <= realEndY; posY++)
917 if (_DrawUnitLineHorizontalWithClipping(startX, endX, posY, bufInfo) == GP_RESULT_FAIL)
919 SysLog(NID_GRP, "_DrawUnitLineHorizontalWithClipping: _DrawUnitLineHorizontalWithClipping() is failed!\n");
921 return GP_RESULT_FAIL;
926 return GP_RESULT_SUCCESS;
930 _CanvasLine::_DrawPixelWithClipping(int x, int y, const _GpBufferInfo& bufInfo)
932 if (bufInfo.bitsPerPixel == 32)
934 unsigned long* pFrmbuf32 = (unsigned long*) bufInfo.pPixels;
938 if (bufInfo.isClipBoundsSet)
940 if (x < bufInfo.clipBounds.x || x >= bufInfo.clipBounds.x + bufInfo.clipBounds.width)
942 return GP_RESULT_OUTOFBOUNDS;
945 if (y < bufInfo.clipBounds.y || y >= bufInfo.clipBounds.y + bufInfo.clipBounds.height)
947 return GP_RESULT_OUTOFBOUNDS;
952 if (x < 0 || x >= bufInfo.width)
954 return GP_RESULT_OUTOFBOUNDS;
957 if (y < 0 || y >= bufInfo.height)
959 return GP_RESULT_OUTOFBOUNDS;
963 if ((bufInfo.color32 & 0xFF000000) == 0xFF000000)
965 pFrmbuf32[bufInfo.pixelPerLine * y + x] = bufInfo.color32;
967 else if ((bufInfo.color32 & 0xFF000000) > 0)
969 __DrawHorizontalLineWithOpacity32(x, x, y, bufInfo);
974 SysLog(NID_GRP, "_DrawPixelWithClipping: pFrmbuf32 is null!\n");
976 return GP_RESULT_FAIL;
982 SysLog(NID_GRP, "_DrawPixelWithClipping: not support 16 bpp!\n");
984 return GP_RESULT_FAIL;
987 return GP_RESULT_SUCCESS;
991 _CanvasLine::__DrawWideLine(const _GpPoint& startPt, const _GpPoint& endPt, const _GpBufferInfo& bufInfo)
993 _GpResult result = GP_RESULT_FAIL;
995 int halfLineW = __lineWidth >> 1;
997 if (startPt.x == endPt.x && startPt.y == endPt.y)
999 if (bufInfo.bitsPerPixel == 32)
1001 _CanvasEllipse ellipse;
1003 ellipse.SetLineWidth(__lineWidth);
1005 if (ellipse.FillElliepse(startPt.x - halfLineW, startPt.y - halfLineW, __lineWidth, __lineWidth, bufInfo) == E_SUCCESS)
1013 ret = __DrawWideLineWithOpacity32(startPt, endPt, bufInfo);
1014 //ret = _DrawUnitLineSlant(startPt, endPt, bufInfo); // need to check if slantline drawing is slow..
1017 return (result == GP_RESULT_FAIL && ret == false && E_SYSTEM ? false : true);
1021 _CanvasLine::__DrawWideLineWithOpacity32(const _GpPoint& startPt, const _GpPoint& endPt, const _GpBufferInfo& bufInfo)
1024 _GpPoint points[2] =
1026 { startPt.x, startPt.y },
1027 { endPt.x, endPt.y }
1030 ret = __DrawThickContinuousPolyline(2, points, false, bufInfo);
1036 _CanvasLine::__DrawThickContinuousPolyline(int listCount, _GpPoint* pPoints, bool isConnected, const _GpBufferInfo& bufInfo)
1040 float connectedX = 0.0f;
1041 float connectedY = 0.0f;
1044 _GpVertex* pVertex = null;
1045 _GpPoint* pTempPoints = null;
1053 _GpPolygon* pPolygon = new (std::nothrow) _GpPolygon;
1055 if (pPolygon == null)
1067 _GetOrientationUnitVector(pPoints[listCount - 1], pPoints[0], &connectedX, &connectedY);
1072 __GetBrushEndPoint(sox, soy, __lineWidth, &plx, &ply, &prx, &pry);
1074 if (!_AddPolygonVertex(pPolygon, pPoints[0].x + plx, pPoints[0].y + ply, 0))
1076 _FreePolygon(pPolygon);
1081 if (!_AddPolygonVertex(pPolygon, pPoints[0].x + prx, pPoints[0].y + pry, 1))
1083 _FreePolygon(pPolygon);
1090 for (i = 1; i < listCount; i++)
1097 _GetOrientationUnitVector(pPoints[j], pPoints[i], &ox, &oy);
1099 if (j == 0 && !isConnected)
1101 if (!_PatchRoundCap(pPolygon, pPoints[0].x, pPoints[0].y, ox, oy, true))
1103 _FreePolygon(pPolygon);
1110 if (!_PatchJoint(pPolygon, pPoints[j].x, pPoints[j].y, connectedX, connectedY, ox, oy))
1112 _FreePolygon(pPolygon);
1118 ret = _PatchThickContinuousLine(pPolygon, pPoints[j], pPoints[i], ox, oy, 0, 0);
1122 _FreePolygon(pPolygon);
1133 if (!_PatchJoint(pPolygon, pPoints[listCount - 1].x, pPoints[listCount - 1].y, connectedX, connectedY, sox, soy))
1135 _FreePolygon(pPolygon);
1140 if (!_PatchThickContinuousLine(pPolygon, pPoints[listCount - 1], pPoints[0], sox, soy, 0, 0))
1142 _FreePolygon(pPolygon);
1150 if (!_PatchRoundCap(pPolygon, pPoints[listCount - 1].x, pPoints[listCount - 1].y, connectedX, connectedY, false))
1152 _FreePolygon(pPolygon);
1158 pTempPoints = new (std::nothrow) _GpPoint[pPolygon->n];
1160 if (pTempPoints == null)
1162 _FreePolygon(pPolygon);
1167 for (i = 0, pVertex = pPolygon->pFirst; pVertex != null; i++, pVertex = pVertex->pNext)
1169 pTempPoints[i] = pVertex->point;
1172 _FillPolygon(pPolygon->n, pTempPoints, false, bufInfo);
1174 _FreePolygon(pPolygon);
1176 delete[] pTempPoints;
1182 _CanvasLine::DrawPolyLine(int ptCount, _GpPoint* pPoints, const _GpBufferInfo& bufInfo)
1191 ret = _DrawPolyLine(ptCount, pPoints, false, bufInfo);
1193 return (ret ? E_SUCCESS : E_SYSTEM);
1197 _CanvasLine::DrawPolygon(int ptCount, _GpPoint* pPoints, const _GpBufferInfo& bufInfo)
1206 ret = _DrawPolyLine(ptCount, pPoints, true, bufInfo);
1208 return (ret ? E_SUCCESS : E_SYSTEM);
1212 _CanvasLine::__CheckDupVertexForPolygon(int ptCount, _GpPoint* pPoints, bool isConnected) const
1217 while (j < ptCount - 1)
1219 if (pPoints[j].x == pPoints[j + 1].x && pPoints[j].y == pPoints[j + 1].y)
1227 pPoints[i] = pPoints[j];
1236 if (pPoints[ptCount - 1].x != pPoints[0].x || pPoints[ptCount - 1].y != pPoints[0].y)
1238 pPoints[i] = pPoints[ptCount - 1];
1244 pPoints[i] = pPoints[ptCount - 1];
1252 _CanvasLine::_FreePolygon(_GpPolygon* pPolygon) const
1254 _GpVertex* pVertex = null;
1255 _GpVertex* pNext = null;
1257 if (pPolygon == null)
1259 SysLog(NID_GRP, "_FreePolygon: pPolygon is null !\n");
1264 pVertex = pPolygon->pFirst;
1266 while (pVertex != null)
1268 pNext = pVertex->pNext;
1279 _CanvasLine::_FillPolygon(int ptCount, _GpPoint* pPoints, bool isEvenOdd, const _GpBufferInfo& bufInfo)
1281 _GpEdgeTable edgeTable;
1282 _GpEdgeTableEntry anEdgeTableEntry;
1283 _GpEdgeTableEntry* pPrevAet = null;
1284 _GpEdgeTableEntry* pAet = null;
1285 _GpEdgeTableEntry* pWete = null;
1286 _GpScanLineListBlock scanLineListBlock;
1287 _GpScanLineList* pScanLineList = null;
1288 _GpEdgeTableEntry* pBufEte = null;
1293 if (pPoints == null)
1295 SysLog(NID_GRP, "_FillPolygon: pPoints is null!\n");
1300 memset(&edgeTable, 0, sizeof(edgeTable));
1301 memset(&anEdgeTableEntry, 0, sizeof(anEdgeTableEntry));
1302 memset(&scanLineListBlock, 0, sizeof(scanLineListBlock));
1304 pBufEte = new (std::nothrow) _GpEdgeTableEntry[ptCount];
1306 if (pBufEte == null)
1311 if (!_CreateEtAndAet(ptCount, pPoints, &edgeTable, &anEdgeTableEntry, pBufEte, &scanLineListBlock))
1318 pScanLineList = edgeTable.scanLines.pNext;
1325 for (y = edgeTable.minY; y < edgeTable.maxY + stitch; y++)
1327 if (pScanLineList != null && y == pScanLineList->scanLine)
1329 _LoadAet(&anEdgeTableEntry, pScanLineList->pEdgeList);
1330 _ComputeWaet(&anEdgeTableEntry);
1331 pScanLineList = pScanLineList->pNext;
1334 pPrevAet = &anEdgeTableEntry;
1335 pAet = anEdgeTableEntry.pNext;
1342 if (_DrawUnitLineHorizontalWithClipping(pAet->minor, pAet->pWNext->minor + stitch - 1, y, bufInfo) == GP_RESULT_FAIL)
1345 _FreeSllb(scanLineListBlock.pNext);
1350 pWete = pWete->pWNext;
1351 while (pWete != pAet)
1360 if (pAet->maxY == y)
1362 pPrevAet->pNext = pAet->pNext;
1363 pAet = pPrevAet->pNext;
1368 pAet->pBack = pPrevAet;
1373 if (pAet->gradient1 > 0)
1375 if (pAet->direction > 0)
1377 pAet->minor += pAet->gradient1;
1378 pAet->direction += pAet->inc1;
1382 pAet->minor += pAet->gradient;
1383 pAet->direction += pAet->inc2;
1388 if (pAet->direction >= 0)
1390 pAet->minor += pAet->gradient1;
1391 pAet->direction += pAet->inc1;
1395 pAet->minor += pAet->gradient;
1396 pAet->direction += pAet->inc2;
1403 pWete = pWete->pWNext;
1414 if (pAet->maxY == y)
1416 pPrevAet->pNext = pAet->pNext;
1417 pAet = pPrevAet->pNext;
1421 pAet->pBack = pPrevAet;
1426 if (pAet->gradient1 > 0)
1428 if (pAet->direction > 0)
1430 pAet->minor += pAet->gradient1;
1431 pAet->direction += pAet->inc1;
1435 pAet->minor += pAet->gradient;
1436 pAet->direction += pAet->inc2;
1441 if (pAet->direction >= 0)
1443 pAet->minor += pAet->gradient1;
1444 pAet->direction += pAet->inc1;
1448 pAet->minor += pAet->gradient;
1449 pAet->direction += pAet->inc2;
1457 if ((_InsertionSort(&anEdgeTableEntry)) || fixWAet)
1459 _ComputeWaet(&anEdgeTableEntry);
1466 _FreeSllb(scanLineListBlock.pNext);
1472 _CanvasLine::_GetOrientationUnitVector(_GpPoint& startPt, _GpPoint& endPt, float* pOx, float* pOy) const
1476 if (pOx == null || pOy == null)
1481 *pOx = (float) (endPt.x - startPt.x);
1482 *pOy = (float) (endPt.y - startPt.y);
1484 // need to check how to use the math func
1485 len = (float) sqrt((*pOx) * (*pOx) + (*pOy) * (*pOy));
1499 _CanvasLine::_PatchThickContinuousLine(_GpPolygon* pPolygon, _GpPoint& point1, _GpPoint& point2, float ox1, float oy1, float ox2, float oy2) const
1507 if (pPolygon == null)
1512 __GetBrushEndPoint(ox1, oy1, __lineWidth, &plx, &ply, &prx, &pry);
1514 ret = _AddPolygonVertex(pPolygon, point1.x + plx, point1.y + ply, 0);
1521 ret = _AddPolygonVertex(pPolygon, point1.x + prx, point1.y + pry, 1);
1528 // if (ox2 != 0 || oy2 != 0)
1529 if ((!_IsEqual(ox2, 0.0f)) || (!_IsEqual(oy2, 0.0f)))
1531 __GetBrushEndPoint(ox2, oy2, __lineWidth, &plx, &ply, &prx, &pry);
1534 ret = _AddPolygonVertex(pPolygon, point2.x + plx, point2.y + ply, 0);
1541 ret = _AddPolygonVertex(pPolygon, point2.x + prx, point2.y + pry, 1);
1552 _CanvasLine::_AddPolygonVertex(_GpPolygon* pPolygon, int x, int y, int pos) const
1554 if (pPolygon == null)
1559 _GpVertex* pNewVertex = new (std::nothrow) _GpVertex;
1561 if (pNewVertex == null)
1566 pNewVertex->point.x = x;
1567 pNewVertex->point.y = y;
1569 if (pPolygon->n == 0)
1571 pNewVertex->pNext = null;
1572 pPolygon->pFirst = pPolygon->pLast = pNewVertex;
1580 pNewVertex->pNext = pPolygon->pFirst;
1581 pPolygon->pFirst = pNewVertex;
1586 pNewVertex->pNext = null;
1587 pPolygon->pLast->pNext = pNewVertex;
1588 pPolygon->pLast = pNewVertex;
1597 _CanvasLine::__GetBrushEndPoint(float ox, float oy, int w, int* pLeftX, int* pLeftY, int* pRightX, int* pRightY) const
1604 wl = wr = w / 2.f - 0.001f;
1608 wl = wr = (w + 1) / 2.f - 0.001f;
1612 // if (oy == 0.0f && (ox == 1.0f || ox == -1.0f)) // Improve a line-width problem.
1613 if (_IsEqual(oy, 0.0f) && (_IsEqual(ox, 1.0f) || _IsEqual(ox, -1.0f)))
1618 *pLeftX = (int) (wl * oy);
1619 *pLeftY = (int) (-wl * ox);
1621 *pRightX = (int) (-wr * oy);
1622 *pRightY = (int) (wr * ox);
1628 _CanvasLine::_CreateEtAndAet(int ptCount, _GpPoint* pPoints, _GpEdgeTable* pEdgeTable, _GpEdgeTableEntry* pEdgeTableEntry, _GpEdgeTableEntry* pEteBuffer, _GpScanLineListBlock* pSllb) const
1630 _GpPoint* pTop = null;
1631 _GpPoint* pBottom = null;
1632 _GpPoint* pPrevPoint = null;
1633 _GpPoint* pCurrPoint = null;
1644 pEdgeTableEntry->pNext = null;
1645 pEdgeTableEntry->pBack = null;
1646 pEdgeTableEntry->pWNext = null;
1647 pEdgeTableEntry->minor = _MIN_INT;
1649 pEdgeTable->scanLines.pNext = null;
1650 pEdgeTable->maxY = _MIN_INT;
1651 pEdgeTable->minY = _MAX_INT;
1652 pSllb->pNext = null;
1654 pPrevPoint = &pPoints[ptCount - 1];
1656 for (i = 0; i < ptCount; i++)
1658 if (pEdgeTable->maxY < pPoints[i].y)
1660 pEdgeTable->maxY = pPoints[i].y;
1662 if (pEdgeTable->minY > pPoints[i].y)
1664 pEdgeTable->minY = pPoints[i].y;
1670 pCurrPoint = pPoints++;
1672 if (pPrevPoint->y > pCurrPoint->y)
1674 pBottom = pPrevPoint;
1676 pEteBuffer->clockWise = false;
1680 pBottom = pCurrPoint;
1682 pEteBuffer->clockWise = true;
1685 if (pBottom->y != pTop->y)
1687 pEteBuffer->maxY = pBottom->y;
1689 if (pEteBuffer->maxY <= pEdgeTable->maxY)
1691 pEteBuffer->maxY--; // exclude the last scan line
1694 dy = pBottom->y - pTop->y;
1695 pEteBuffer->minor = pTop->x;
1696 dx = pBottom->x - pTop->x;
1700 pEteBuffer->gradient = dx / dy;
1701 pEteBuffer->gradient1 = pEteBuffer->gradient - 1;
1702 pEteBuffer->inc1 = -2 * dx + 2 * dy * pEteBuffer->gradient1;
1703 pEteBuffer->inc2 = -2 * dx + 2 * dy * pEteBuffer->gradient;
1704 pEteBuffer->direction = 2 * pEteBuffer->gradient * dy - 2 * dx - dy;
1708 pEteBuffer->gradient = dx / dy;
1709 pEteBuffer->gradient1 = pEteBuffer->gradient + 1;
1710 pEteBuffer->inc1 = 2 * dx - 2 * dy * pEteBuffer->gradient1;
1711 pEteBuffer->inc2 = 2 * dx - 2 * dy * pEteBuffer->gradient;
1712 pEteBuffer->direction = -2 * pEteBuffer->gradient * dy + 2 * dx - dy;
1715 if (!__InsertEdge(pEdgeTable, pEteBuffer, pTop->y, &pSllb, &isllb))
1723 pPrevPoint = pCurrPoint;
1730 _CanvasLine::_FreeSllb(_GpScanLineListBlock* pScanLineListBlock) const
1732 _GpScanLineListBlock* pTempSlLb = null;
1734 while (pScanLineListBlock != null)
1736 pTempSlLb = pScanLineListBlock->pNext;
1737 delete pScanLineListBlock;
1738 pScanLineListBlock = pTempSlLb;
1745 _CanvasLine::_LoadAet(_GpEdgeTableEntry* pAet, _GpEdgeTableEntry* pEte) const
1747 _GpEdgeTableEntry* pPrevAet = null;
1748 _GpEdgeTableEntry* pTempEte = null;
1755 while ((pAet) && (pAet->minor < pEte->minor))
1761 pTempEte = pEte->pNext;
1769 pEte->pBack = pPrevAet;
1770 pPrevAet->pNext = pEte;
1779 _CanvasLine::_InsertionSort(_GpEdgeTableEntry* pAet) const
1781 _GpEdgeTableEntry* pEteChase = null;
1782 _GpEdgeTableEntry* pEteInsert = null;
1783 _GpEdgeTableEntry* pEteChaseBack = null;
1784 bool isChanged = false;
1793 while (pEteChase->pBack->minor > pAet->minor)
1795 pEteChase = pEteChase->pBack;
1800 if (pEteChase != pEteInsert)
1802 pEteChaseBack = pEteChase->pBack;
1803 pEteInsert->pBack->pNext = pAet;
1807 pAet->pBack = pEteInsert->pBack;
1810 pEteInsert->pNext = pEteChase;
1811 pEteChase->pBack->pNext = pEteInsert;
1812 pEteChase->pBack = pEteInsert;
1813 pEteInsert->pBack = pEteChaseBack;
1822 _CanvasLine::_ComputeWaet(_GpEdgeTableEntry* pAet) const
1824 _GpEdgeTableEntry* pWete = null;
1828 pAet->pWNext = null;
1834 if (pAet->clockWise)
1843 if ((!inside && isInside == 0) || (inside && isInside))
1845 pWete->pWNext = pAet;
1853 pWete->pWNext = null;
1859 _CanvasLine::__InsertEdge(_GpEdgeTable* pEt, _GpEdgeTableEntry* pEte, int scanLine, _GpScanLineListBlock** pSllb, int* pIsllb) const
1861 _GpEdgeTableEntry* pStart = null;
1862 _GpEdgeTableEntry* pPrev = null;
1863 _GpScanLineList* pSll = null;
1864 _GpScanLineList* pPresSll = null;
1865 _GpScanLineListBlock* pTmpSllb = null;
1868 if (pEt == null || pEte == null || pSllb == null || pIsllb == null)
1873 pPresSll = &pEt->scanLines;
1874 pSll = pPresSll->pNext;
1876 while (pSll != null && (pSll->scanLine < scanLine))
1882 if (pSll == null || pSll->scanLine > scanLine)
1884 if (*pIsllb >= _MAX_SLL_BLOCK)
1886 pTmpSllb = new (std::nothrow) _GpScanLineListBlock;
1888 if (pTmpSllb == null)
1890 SysLog(NID_GRP, "__InsertEdge : pTmpSllb allcation is failed!\n");
1891 // SysSetLastError(WMERR_OUT_OF_MEMORY);
1895 (*pSllb)->pNext = pTmpSllb;
1896 pTmpSllb->pNext = null;
1901 pSll = &((*pSllb)->scanLineList[(*pIsllb)]);
1903 pSll->pNext = pPresSll->pNext;
1904 pSll->pEdgeList = null;
1905 pPresSll->pNext = pSll;
1908 pSll->scanLine = scanLine;
1911 pStart = pSll->pEdgeList;
1913 while (pStart != null && pStart->minor < pEte->minor)
1916 pStart = pStart->pNext;
1919 pEte->pNext = pStart;
1923 pPrev->pNext = pEte;
1927 pSll->pEdgeList = pEte;
1934 _CanvasLine::_PatchJoint(_GpPolygon* pPolygon, int x, int y, float ox1, float oy1, float ox2, float oy2) const
1949 cross = ox1 * oy2 - oy1 * ox2;
1951 if ((-0.0001f < cross) && (cross < 0.0001f))
1956 __GetBrushEndPoint(ox1, oy1, __lineWidth, &plx1, &ply1, &prx1, &pry1);
1957 __GetBrushEndPoint(ox2, oy2, __lineWidth, &plx2, &ply2, &prx2, &pry2);
1961 degree0 = (int) (atan2((float) -pry1, (float) prx1) * (180 / _PI));
1962 degree1 = (int) (atan2((float) -pry2, (float) prx2) * (180 / _PI));
1966 degree0 = (int) (atan2((float) -ply2, (float) plx2) * (180 / _PI));
1967 degree1 = (int) (atan2((float) -ply1, (float) plx1) * (180 / _PI));
1975 while (degree0 > 360)
1980 while (degree1 > 360)
1985 while (degree1 < degree0)
1992 __PatchArc(pPolygon, (float) x, (float) y, (float) (__lineWidth / 2 - 1), (float) (__lineWidth / 2 - 1), degree0, degree1, 1);
1996 __PatchArc(pPolygon, (float) x, (float) y, (float) (__lineWidth / 2 - 1), (float) (__lineWidth / 2 - 1), degree0, degree1, 0);
2003 _CanvasLine::_PatchRoundCap(_GpPolygon* pPolygon, int x, int y, float ox, float oy, bool isStart) const
2012 d = (int) (atan2(-oy, ox) * (180 / _PI));
2017 degree1 = d - 90 + 360;
2025 rad = __lineWidth / 2.f - 0.5f;
2027 if (__lineWidth % 2 == 0)
2038 return __PatchArc(pPolygon, fx, fy, rad, rad, degree0, degree1, 1);
2042 _CanvasLine::__PatchArc(_GpPolygon* pPolygon, float x, float y, float w, float h, int degree0, int degree1, int pos) const
2046 _GpFloatPoint* pEllipsePoint = null;
2048 if ((degree0 % 360 == degree1 % 360) && (degree1 - degree0 != 360))
2053 // if (w == 0.f || h == 0.f)
2054 if (_IsEqual(w, 0.0f) || _IsEqual(h, 0.0f))
2059 n = _MakeEllipseArcPointArray(&pEllipsePoint, null, x, y, w, h, degree0, degree1, 0);
2061 if (pEllipsePoint == null)
2068 delete[] pEllipsePoint;
2075 for (i = n - 1; i >= 0; i--)
2077 if (!_AddPolygonVertex(pPolygon, (int) (pEllipsePoint[i].fx + 0.5f), (int) (pEllipsePoint[i].fy), 0))
2079 delete[] pEllipsePoint;
2087 for (i = 0; i < n; i++)
2089 if (!_AddPolygonVertex(pPolygon, (int) (pEllipsePoint[i].fx + 0.5f), (int) (pEllipsePoint[i].fy), 1))
2091 delete[] pEllipsePoint;
2098 delete[] pEllipsePoint;
2104 _CanvasLine::_MakeEllipseArcPointArray(_GpFloatPoint** pPoint, _GpFloatPoint** pNorm, float x, float y, float w, float h, int a1, int a2, int rot) const
2106 const float one_deg = 0.01745329251994329576f;
2124 rot = ((-rot) % 360 + 360) % 360;
2126 degree1 = (float) a1;
2127 degree2 = (float) a2;
2129 r1 = (float) atan2(w * sin(_GP_DEGREE2RADIAN(degree1)), h * cos(_GP_DEGREE2RADIAN(degree1)));
2130 r2 = (float) atan2(w * sin(_GP_DEGREE2RADIAN(degree2)), h * cos(_GP_DEGREE2RADIAN(degree2)));
2137 while (r2 - 0.001f <= r1)
2142 pointCount = (int) ((r2 - r1) / one_deg) + 2;
2144 *pPoint = new (std::nothrow) _GpFloatPoint[pointCount];
2153 *pNorm = new (std::nothrow) _GpFloatPoint[pointCount];
2163 for (r = r1, i = 0, isEnd = false; i < pointCount; r += one_deg, i++)
2171 sinR = (float) sin(r);
2172 cosR = (float) cos(r);
2177 _Rotate2DPoint(t1x, t1y, rot, &t2x, &t2y);
2179 (*pPoint)[i].fx = x + t2x;
2180 (*pPoint)[i].fy = y + t2y;
2187 len = (float) sqrt(t1x * t1x + t1y * t1y);
2189 if (_IsEqual(len, 0.0f))
2199 _Rotate2DPoint(t1x, t1y, rot, &t2x, &t2y);
2201 (*pNorm)[i].fx = t2x;
2202 (*pNorm)[i].fy = t2y;
2216 _CanvasLine::_Rotate2DPoint(float x, float y, long rot, float* pRx, float* pRy) const
2221 s = (float) sin(_GP_DEGREE2RADIAN(float(rot)));
2222 c = (float) cos(_GP_DEGREE2RADIAN(float(rot)));
2224 *pRx = x * c - y * s;
2225 *pRy = y * c + x * s;
2231 _CanvasLine::__DrawHorizontalLineWithOpacity32(int startX, int endX, int y, const _GpBufferInfo& bufInfo)
2233 register unsigned char dstA;
2234 register unsigned char dstR;
2235 register unsigned char dstG;
2236 register unsigned char dstB;
2238 int frmbufP = bufInfo.pixelPerLine;
2240 // doesn't need to check the validity of bound.. maybe it's duplicate...
2241 //if (startX > endX)
2242 // return GP_RESULT_FAIL;
2244 //if (startX < 0 || startX >= frmbufW)
2245 // return GP_RESULT_OUTOFBOUNDS;
2247 //if (endX < 0 || endX >= frmbufW)
2248 // return GP_RESULT_OUTOFBOUNDS;
2250 //if (y < 0 || y >= frmbufH)
2251 // return GP_RESULT_OUTOFBOUNDS;
2253 //if (frmbufW < 1 || frmbufH < 1)
2254 // return GP_RESULT_FAIL;*/
2256 unsigned long* pFrmbuf32 = (unsigned long*) bufInfo.pPixels;
2258 unsigned char srcA = (unsigned char) ((bufInfo.color32 & 0xFF000000) >> 24);
2259 unsigned char srcR = (unsigned char) ((bufInfo.color32 & 0x00FF0000) >> 16);
2260 unsigned char srcG = (unsigned char) ((bufInfo.color32 & 0x0000FF00) >> 8);
2261 unsigned char srcB = (unsigned char) (bufInfo.color32 & 0x000000FF);
2262 unsigned char oneMinusSrcA = 255 - srcA;
2265 register unsigned long* pOffset32 = (pFrmbuf32 + frmbufP * y + startX);
2267 for (int i = 0; i < endX - startX + 1; i++)
2269 dstR = (unsigned char)(*pOffset32 >> 16);
2270 dstG = (unsigned char)(*pOffset32 >> 8);
2271 dstB = (unsigned char)(*pOffset32);
2273 dstR = (unsigned char) ((dstR * oneMinusSrcA + srcR * srcA + 255) >> 8);
2274 dstG = (unsigned char) ((dstG * oneMinusSrcA + srcG * srcA + 255) >> 8);
2275 dstB = (unsigned char) ((dstB * oneMinusSrcA + srcB * srcA + 255) >> 8);
2276 dstA = (((unsigned char)(*pOffset32 >> 24) * oneMinusSrcA + 255) >> 8) + srcA;
2278 *pOffset32++ = (unsigned long)(((unsigned long)dstA << 24) | ((unsigned long)dstR << 16) | ((unsigned long)dstG << 8) | (unsigned long)(dstB));
2282 return GP_RESULT_SUCCESS;
2286 _CanvasLine::_IsInClipRect(int rectX, int rectY, int rectW, int rectH, const _GpBufferInfo& bufInfo) const
2288 if (rectW <= 0 || rectH <= 0)
2293 if (bufInfo.isClipBoundsSet)
2295 if (rectX >= bufInfo.clipBounds.x && (rectX + rectW) <= (bufInfo.clipBounds.x + bufInfo.clipBounds.width) &&
2296 rectY >= bufInfo.clipBounds.y && (rectY + rectH) <= (bufInfo.clipBounds.y + bufInfo.clipBounds.height))
2303 if (rectX >= 0 && (rectX + rectW) <= bufInfo.width && rectY >= 0 && (rectY + rectH) <= bufInfo.height)
2313 _CanvasLine::_SetNotClipFunction(bool isWidelineSet)
2315 pFuncSetPixel = &_CanvasLine::_DrawPixel;
2317 if (__lineWidth == 1 || !isWidelineSet)
2319 pFuncHorizontalLine = &_CanvasLine::_DrawUnitLineHorizontal;
2320 pFuncVerticalLine = &_CanvasLine::_DrawUnitLineVertical;
2322 else if (__lineWidth > 1)
2324 pFuncHorizontalLine = &_CanvasLine::_DrawWideLineHorizontal;
2325 pFuncVerticalLine = &_CanvasLine::_DrawWideLineVertical;
2332 _CanvasLine::_SetClipFunction(bool isWidelineSet) const
2334 pFuncSetPixel = &_CanvasLine::_DrawPixelWithClipping;
2336 if (__lineWidth == 1 || !isWidelineSet)
2338 pFuncHorizontalLine = &_CanvasLine::_DrawUnitLineHorizontalWithClipping;
2339 pFuncVerticalLine = &_CanvasLine::_DrawUnitLineVerticalWithClipping;
2341 else if (__lineWidth > 1)
2343 pFuncHorizontalLine = &_CanvasLine::_DrawUnitLineHorizontalWithClipping;
2344 pFuncVerticalLine = &_CanvasLine::_DrawUnitLineVerticalWithClipping;
2351 _CanvasLine::_DrawPolyLine(int ptCount, _GpPoint* pPoints, bool isConnected, const _GpBufferInfo& bufInfo)
2357 ptCount = __CheckDupVertexForPolygon(ptCount, pPoints, isConnected);
2359 if (__lineWidth < 2 || (bufInfo.color32 & 0xFF000000) == 0xFF000000)
2361 while (++i < ptCount)
2365 if (DrawLine(pPoints[j], pPoints[i], bufInfo) == E_SYSTEM)
2367 SysLog(NID_GRP, "_DrawPolyLine: DrawLine is failed -1!\n");
2375 if (DrawLine(pPoints[i-1], pPoints[0], bufInfo) == E_SYSTEM)
2377 SysLog(NID_GRP, "_DrawPolyLine: DrawLine is failed -2!\n");
2387 ret = __DrawThickContinuousPolyline(ptCount, pPoints, isConnected, bufInfo);
2393 }} // Tizen::Graphics