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_CanvasGpArc.cpp
20 * @brief This is the implementation file for _CanvasArc class.
28 #include <FBaseSysLog.h>
29 #include "FGrp_CanvasGpPrimitive.h"
32 using namespace Tizen::Base;
33 using namespace Tizen::Graphics;
38 const int _ARC_DELTA_SOLID_LINE = 4;
39 const int _ARC_DELTA_DOT_LINE = 1;
40 const int _MAX_ARC_OUTLINE_POINTS = 20000;
41 const int _MAX_STACK_COUNT = 200;
43 const float _SINE_TABLE[] = // 91 items
45 (float) 0.000000, (float) 0.017452, (float) 0.034899, (float) 0.052336, (float) 0.069756,
46 (float) 0.087156, (float) 0.104528, (float) 0.121869, (float) 0.139173, (float) 0.156434,
47 (float) 0.173648, (float) 0.190809, (float) 0.207912, (float) 0.224951, (float) 0.241922,
48 (float) 0.258819, (float) 0.275637, (float) 0.292372, (float) 0.309017, (float) 0.325568,
49 (float) 0.342020, (float) 0.358368, (float) 0.374607, (float) 0.390731, (float) 0.406737,
50 (float) 0.422618, (float) 0.438371, (float) 0.453990, (float) 0.469471, (float) 0.484810,
51 (float) 0.500000, (float) 0.515038, (float) 0.529919, (float) 0.544639, (float) 0.559193,
52 (float) 0.573576, (float) 0.587785, (float) 0.601815, (float) 0.615661, (float) 0.629320,
53 (float) 0.642788, (float) 0.656059, (float) 0.669131, (float) 0.681998, (float) 0.694658,
54 (float) 0.707107, (float) 0.719340, (float) 0.731354, (float) 0.743145, (float) 0.754709,
55 (float) 0.766044, (float) 0.777146, (float) 0.788011, (float) 0.798635, (float) 0.809017,
56 (float) 0.819152, (float) 0.829037, (float) 0.838670, (float) 0.848048, (float) 0.857167,
57 (float) 0.866025, (float) 0.874620, (float) 0.882948, (float) 0.891006, (float) 0.898794,
58 (float) 0.906308, (float) 0.913545, (float) 0.920505, (float) 0.927184, (float) 0.933580,
59 (float) 0.939693, (float) 0.945518, (float) 0.951056, (float) 0.956305, (float) 0.961262,
60 (float) 0.965926, (float) 0.970296, (float) 0.974370, (float) 0.978148, (float) 0.981627,
61 (float) 0.984808, (float) 0.987688, (float) 0.990268, (float) 0.992546, (float) 0.994522,
62 (float) 0.996195, (float) 0.997564, (float) 0.998630, (float) 0.999391, (float) 0.999848,
68 namespace Tizen { namespace Graphics
72 _CanvasArc::SetLineWidth(int lineWidth)
74 __lineWidth = lineWidth;
80 _CanvasArc::GetLineWidth(void) const
86 _CanvasArc::DrawArc(int rectX, int rectY, int rectW, int rectH, int startAngle, int endAngle, ArcStyle arcType, const _GpBufferInfo& bufInfo)
101 bool isEllipse = false;
102 bool isClipped = true;
104 _GpPoint* pPoints = null;
108 _CanvasEllipse ellipse;
111 if (rectW < 1 || rectH < 1)
116 if (startAngle < 0 || endAngle < 0)
121 if (arcType < ARC_STYLE_ONLY || arcType > ARC_STYLE_FILLED_CHORD)
126 ellipse.SetLineWidth(__lineWidth);
127 line.SetLineWidth(__lineWidth);
129 if (rectW == 1 && rectH == 1)
131 return (line._DrawPixelWithClipping(rectX, rectY, bufInfo) == GP_RESULT_FAIL ? E_SYSTEM : E_SUCCESS);
134 if ((bufInfo.bitsPerPixel == 32 && (bufInfo.color32 & 0xFF000000) != 0xFF000000) || (rectW > 1200) || (rectH > 1200))
140 case ARC_STYLE_CHORD:
141 return __Draw32BitArc(rectX, rectY, rectW, rectH, startAngle, endAngle, arcType, bufInfo) ? E_SUCCESS : E_SYSTEM;
142 case ARC_STYLE_FILLED_PIE:
143 case ARC_STYLE_FILLED_CHORD:
144 // ret = __WmDraw32BitsFilledArc(gc, rectX, rectY, rectW, rectH, startAngle, endAngle, arcType);
151 if (startAngle == endAngle)
153 if (arcType == ARC_STYLE_FILLED_CHORD)
155 // Even width, height
167 radiusX = rectW >> 1;
168 radiusY = rectH >> 1;
171 centerX = rectX + radiusX;
172 centerY = rectY + radiusY;
174 x = (int) (radiusX * __Cosine(startAngle) + 0.5);
175 y = (int) (radiusY * __Sine(startAngle) + 0.5);
177 return (line._DrawPixelWithClipping(centerX + x, centerY + y, bufInfo) == GP_RESULT_FAIL ? E_SYSTEM : E_SUCCESS);
180 else if (GP_ABS(endAngle - startAngle) % 360 == 0)
185 pPoints = new (std::nothrow) _GpPoint[_MAX_ARC_OUTLINE_POINTS];
189 SysLog(NID_GRP, "DrawArc: Memory allocation is failed!\n");
194 memset(pPoints, 0, sizeof(pPoints[0]) * _MAX_ARC_OUTLINE_POINTS);
197 if (startAngle > endAngle)
199 GP_SWAP(startAngle, endAngle);
203 halfLineW = (__lineWidth + 1) >> 1;
205 if (line._IsInClipRect(rectX - halfLineW, rectY - halfLineW, rectW + (halfLineW << 1), rectH + (halfLineW << 1), bufInfo))
208 line._SetNotClipFunction(true);
211 // Even width, height
223 radiusX = rectW >> 1;
224 radiusY = rectH >> 1;
227 centerX = rectX + radiusX;
228 centerY = rectY + radiusY;
230 if (arcType == ARC_STYLE_FILLED_PIE || arcType == ARC_STYLE_FILLED_CHORD)
235 __GetArcVertices(radiusX, radiusY, startAngle, &x, &y);
240 if (arcType >= ARC_STYLE_ONLY && arcType <= ARC_STYLE_CHORD)
244 int halfLineW = __lineWidth >> 1;
246 for (theta = startAngle; theta <= endAngle; theta += _ARC_DELTA_SOLID_LINE)
248 if (theta + _ARC_DELTA_SOLID_LINE >= endAngle)
253 __GetArcVertices(radiusX, radiusY, theta, &x, &y);
255 if (GP_ABS(x - preX) >= 2 || GP_ABS(y - preY) >= 2)
257 _GpPoint startPoint = { centerX + preX, centerY - preY };
258 _GpPoint endPoint = { centerX + x, centerY - y };
260 line.DrawLine(startPoint, endPoint, bufInfo);
264 ellipse.FillElliepse(centerX + x - halfLineW, centerY - y - halfLineW, __lineWidth, __lineWidth, bufInfo);
271 if (theta < endAngle + _ARC_DELTA_SOLID_LINE)
273 __GetArcVertices(radiusX, radiusY, theta, &x, &y);
275 if (GP_ABS(x - preX) >= 2 || GP_ABS(y - preY) >= 2)
277 _GpPoint startPoint = { centerX + preX, centerY - preY };
278 _GpPoint endPoint = { centerX + x, centerY - y };
280 line.DrawLine(startPoint, endPoint, bufInfo);
284 ellipse.FillElliepse(centerX + x - halfLineW, centerY - y - halfLineW, __lineWidth, __lineWidth, bufInfo);
290 for (theta = startAngle; theta <= endAngle; theta += _ARC_DELTA_SOLID_LINE)
292 if (theta + _ARC_DELTA_SOLID_LINE >= endAngle)
297 __GetArcVertices(radiusX, radiusY, theta, &x, &y);
299 _GpPoint tempPoint1 = { centerX + preX, centerY - preY };
300 _GpPoint tempPoint2 = { centerX + x, centerY - y };
302 line._DrawUnitLineSlant(tempPoint1, tempPoint2, bufInfo);
308 if (theta < endAngle + _ARC_DELTA_SOLID_LINE)
310 __GetArcVertices(radiusX, radiusY, endAngle, &x, &y);
312 _GpPoint tempPoint1 = { centerX + preX, centerY - preY };
313 _GpPoint tempPoint2 = { centerX + x, centerY - y };
315 line._DrawUnitLineSlant(tempPoint1, tempPoint2, bufInfo);
321 for (theta = startAngle; theta <= endAngle; theta += _ARC_DELTA_SOLID_LINE)
323 if (theta + _ARC_DELTA_SOLID_LINE >= endAngle)
328 __GetArcVertices(radiusX, radiusY, theta, &x, &y);
329 __SaveLine(centerX + preX, centerY - preY, centerX + x, centerY - y, pPoints, &pixelCount);
335 if (theta < endAngle + _ARC_DELTA_SOLID_LINE)
337 __GetArcVertices(radiusX, radiusY, endAngle, &x, &y);
338 __SaveLine(centerX + preX, centerY - preY, centerX + x, centerY - y, pPoints, &pixelCount);
344 case ARC_STYLE_FILLED_PIE:
345 if (isEllipse == null)
347 __GetArcVertices(radiusX, radiusY, startAngle, &x, &y);
348 __SaveLine(centerX, centerY, centerX + x, centerY - y, pPoints, &pixelCount);
350 __GetArcVertices(radiusX, radiusY, endAngle, &x, &y);
351 __SaveLine(centerX, centerY, centerX + x, centerY - y, pPoints, &pixelCount);
353 __FillArcWithEvenOdd(pPoints, pixelCount, isClipped, bufInfo);
357 if (isEllipse == null)
359 _GpPoint startPoint = { centerX, centerY };
362 __GetArcVertices(radiusX, radiusY, startAngle, &x, &y);
364 _GpPoint endPoint = { centerX + x, centerY - y };
368 line.DrawLine(startPoint, endPoint, bufInfo);
372 line._DrawUnitLineSlant(startPoint, endPoint, bufInfo);
377 __GetArcVertices(radiusX, radiusY, endAngle, &x, &y);
379 _GpPoint endPoint = { centerX + x, centerY - y };
383 line.DrawLine(startPoint, endPoint, bufInfo);
387 line._DrawUnitLineSlant(startPoint, endPoint, bufInfo);
394 case ARC_STYLE_FILLED_CHORD:
395 if (isEllipse == null)
397 __GetArcVertices(radiusX, radiusY, startAngle, &x, &y);
398 __GetArcVertices(radiusX, radiusY, endAngle, &x1, &y1);
400 __SaveLine(centerX + x, centerY - y, centerX + x1, centerY - y1, pPoints, &pixelCount);
402 __FillArcWithEvenOdd(pPoints, pixelCount, isClipped, bufInfo);
405 case ARC_STYLE_CHORD:
406 if (isEllipse == null)
408 __GetArcVertices(radiusX, radiusY, startAngle, &x, &y);
409 __GetArcVertices(radiusX, radiusY, endAngle, &x1, &y1);
411 _GpPoint startPoint = { centerX + x, centerY - y };
412 _GpPoint endPoint = { centerX + x1, centerY - y1 };
416 line.DrawLine(startPoint, endPoint, bufInfo);
420 line._DrawUnitLineSlant(startPoint, endPoint, bufInfo);
430 if (arcType == ARC_STYLE_FILLED_PIE || arcType == ARC_STYLE_FILLED_CHORD)
441 _CanvasArc::__GetArcVertices(int radiusX, int radiusY, int theta, int* pX, int* pY) const
453 degree = (float) theta;
455 r = (float) atan2(radiusX * sin(_GP_DEGREE2RADIAN(degree)), radiusY * cos(_GP_DEGREE2RADIAN(degree)));
462 sinR = (float) sin(r);
463 cosR = (float) cos(r);
465 t1x = radiusX * cosR;
466 t1y = radiusY * sinR;
468 line._Rotate2DPoint(t1x, t1y, 0, &t2x, &t2y);
477 _CanvasArc::__Sine(int degree) const
483 return _SINE_TABLE[degree];
485 else if (degree <= 180)
487 return _SINE_TABLE[180 - degree];
489 else if (degree <= 270)
491 return -_SINE_TABLE[degree - 180];
495 return -_SINE_TABLE[360 - degree];
500 _CanvasArc::__Cosine(int degree) const
502 return __Sine(degree + 90);
506 _CanvasArc::__SaveLine(int x1, int y1, int x2, int y2, _GpPoint* pPoints, int* pPixelCount) const
508 if ((x1 == x2) && (y1 == y2))
514 return true; // Horizontal Line
549 pointCount = *pPixelCount;
553 for (y = startY; y != endY + incdec; y += incdec)
555 if (pointCount < _MAX_ARC_OUTLINE_POINTS)
557 pPoints[pointCount].x = x1;
558 pPoints[pointCount].y = y;
563 SysLog(NID_GRP, "__SaveLine: buffer overflow!\n");
570 for (y = startY; y != endY + incdec; y += incdec)
572 tmpX = ((y - y1) * dx) / dy;
575 if (pointCount < _MAX_ARC_OUTLINE_POINTS)
577 pPoints[pointCount].x = x;
578 pPoints[pointCount].y = y;
583 SysLog(NID_GRP, "__SaveLine: buffer overflow!\n");
588 *pPixelCount = pointCount;
595 _CanvasArc::__FillArcWithEvenOdd(_GpPoint* pPoints, int pixelCount, bool clip, const _GpBufferInfo& bufInfo) const
618 line.SetLineWidth(__lineWidth);
622 if (bufInfo.isClipBoundsSet)
624 clipX = bufInfo.clipBounds.x;
625 clipY = bufInfo.clipBounds.y;
626 clipEndX = clipX + bufInfo.clipBounds.width - 1;
627 clipEndY = clipY + bufInfo.clipBounds.height - 1;
633 clipEndX = bufInfo.width - 1;
634 clipEndY = bufInfo.height - 1;
639 __QuickSort(pPoints, 0, pixelCount - 1);
642 for (i = 0; i < pixelCount - 1; )
646 x2 = pPoints[i + 1].x;
647 y2 = pPoints[i + 1].y;
655 if (x1 < clipX || x1 > clipEndX)
660 if (y1 < clipY || y1 > clipEndY)
666 line._DrawPixel(x1, y1, bufInfo);
678 if (y1 < clipY || y1 > clipEndY)
683 if (x2 < clipX || x1 > clipEndX)
699 // draw primitive line
700 line._DrawUnitLineHorizontal(x1, x2, y1, bufInfo);
705 else // Exception handling
715 _CanvasArc::__QuickSort(_GpPoint* pPoints, int left, int right) const
717 GpArcStack stack[_MAX_STACK_COUNT];
720 GpArcDiffResult result;
723 register int top = 1;
735 stack[top].left = left;
736 stack[top].right = right;
739 left = stack[top].left;
746 right = stack[top--].right;
757 pivot = pPoints[((left + right) >> 1)];
762 if (pPoints[i].y > pivot.y)
764 result = DIFF_RESULT_GREAT;
766 else if (pPoints[i].y == pivot.y)
768 if (pPoints[i].x > pivot.x)
770 result = DIFF_RESULT_GREAT;
772 else if (pPoints[i].x == pivot.x)
774 result = DIFF_RESULT_EQUAL;
778 result = DIFF_RESULT_LITTLE;
783 result = DIFF_RESULT_LITTLE;
786 if (result == DIFF_RESULT_LITTLE)
798 if (pPoints[j].y > pivot.y)
800 result = DIFF_RESULT_GREAT;
802 else if (pPoints[j].y == pivot.y)
804 if (pPoints[j].x > pivot.x)
806 result = DIFF_RESULT_GREAT;
808 else if (pPoints[j].x == pivot.x)
810 result = DIFF_RESULT_EQUAL;
814 result = DIFF_RESULT_LITTLE;
819 result = DIFF_RESULT_LITTLE;
822 if (result == DIFF_RESULT_GREAT)
835 pPoints[i] = pPoints[j];
843 if (j - left < right - i)
847 if (top >= _MAX_STACK_COUNT - 1)
852 stack[++top].left = i;
853 stack[top].right = right;
861 if (top >= _MAX_STACK_COUNT - 1)
866 stack[++top].left = left;
867 stack[top].right = j;
872 while (left < right);
879 _CanvasArc::__Draw32BitArc(int rectX, int rectY, int rectW, int rectH, int d0, int d1, ArcStyle arcType, const _GpBufferInfo& bufInfo)
890 if ((rectW <= 0) || (rectH <= 0))
895 if ((d0 % 360 == d1 % 360) && (d1 - d0 != 360))
900 dx = (rectW + 1) % 2;
901 dy = (rectH + 1) % 2;
903 rx = (float) (rectW / 2 - dx);
904 ry = (float) (rectH / 2 - dy);
916 centerX = (float) (rectX) + rx;
917 centerY = (float) (rectY) + ry;
919 cx = (int) (centerX);
920 cy = (int) (centerY);
924 _GpFloatPoint* pEllipsePoint = null;
927 _GpPoint* pPoints = null;
928 bool isConnected = false;
931 n = line._MakeEllipseArcPointArray(&pEllipsePoint, null, centerX, centerY, rx, ry, d0, d1, 0);
935 SysLog(NID_GRP, "__Draw32BitArc: _MakeEllipseArcPointArray is failed!\n");
939 delete[] pEllipsePoint;
945 pPoints = new (std::nothrow) _GpPoint[n + 1];
949 SysLog(NID_GRP, "__Draw32BitArc: Memory allocation is failed!\n");
953 delete[] pEllipsePoint;
959 for (i = 0; i < n; i++)
961 pPoints[i].x = (int) pEllipsePoint[i].fx;
962 pPoints[i].y = (int) pEllipsePoint[i].fy;
972 case ARC_STYLE_CHORD:
982 SysLog(NID_GRP, "__Draw32BitArc: Invalid arc [%d]type - 1!\n", arcType);
983 delete[] pEllipsePoint;
989 line._DrawPolyLine(n, pPoints, isConnected, bufInfo);
991 delete[] pEllipsePoint;
1000 case ARC_STYLE_ONLY:
1001 if (!__DrawThickContinuousArc(cx, cy, rectW / 2, rectH / 2, d0, d1, bufInfo))
1003 SysLog(NID_GRP, "__Draw32BitArc: __DrawThickContinuousArc is failed!\n");
1009 if (!__DrawThickContinuousPie(cx, cy, rectW / 2, rectH / 2, d0, d1, bufInfo))
1011 SysLog(NID_GRP, "__Draw32BitArc: __DrawThickContinuousPie is failed!\n");
1016 case ARC_STYLE_CHORD:
1017 if (!__DrawThickContinuousChord(cx, cy, rectW / 2, rectH / 2, d0, d1, bufInfo))
1019 SysLog(NID_GRP, "__Draw32BitArc: __DrawThickContinuousChord is failed!\n");
1025 SysLog(NID_GRP, "__Draw32BitArc: Invalid arc [%d]type - 2!\n", arcType);
1035 _CanvasArc::__DrawThickContinuousArc(int cx, int cy, int halfW, int halfH, int d0, int d1, const _GpBufferInfo& bufInfo) const
1037 int ellipsePointCount;
1040 _GpFloatPoint* pEllipsePoint = null;
1041 _GpFloatPoint* pEpNormal = null;
1044 _GpPolygon* pPolygon = null;
1045 _GpPoint* pTempPoints = null;
1046 _GpVertex* pVertex = null;
1049 float radiusX = (float) halfW;
1050 float radiusY = (float) halfH;
1052 float centerX = (float) cx;
1053 float centerY = (float) cy;
1055 line.SetLineWidth(__lineWidth);
1056 ellipsePointCount = line._MakeEllipseArcPointArray(&pEllipsePoint, &pEpNormal, centerX, centerY, radiusX, radiusY, d0, d1, 0);
1058 if (ellipsePointCount < 2 || pEllipsePoint == null || pEpNormal == null)
1060 SysLog(NID_GRP, "__DrawThickContinuousArc: _MakeEllipseArcPointArray is failed!\n");
1062 delete[] pEllipsePoint;
1068 _CalcLeftRightWidth(&wl, &wr);
1070 pPolygon = new (std::nothrow) _GpPolygon;
1072 if (pPolygon == null)
1074 SysLog(NID_GRP, "__DrawThickContinuousArc: _CreatePolygon is failed!\n");
1076 delete[] pEllipsePoint;
1082 if (!line._PatchRoundCap(pPolygon, (int) pEllipsePoint[0].fx, (int) pEllipsePoint[0].fy, pEpNormal[0].fy, -pEpNormal[0].fx, true))
1084 SysLog(NID_GRP, "__DrawThickContinuousArc: _PatchRoundCap is failed - 1!\n");
1086 line._FreePolygon(pPolygon);
1088 delete[] pEllipsePoint;
1094 for (i = 0; i < ellipsePointCount; i++)
1096 result = line._AddPolygonVertex(pPolygon, (int) (pEllipsePoint[i].fx - (pEpNormal[i].fx * wl)), (int) (pEllipsePoint[i].fy - (pEpNormal[i].fy * wl)), 0);
1100 SysLog(NID_GRP, "__DrawThickContinuousArc: _AddPolygonVertex is failed - 1!\n");
1101 line._FreePolygon(pPolygon);
1103 delete[] pEllipsePoint;
1109 result = line._AddPolygonVertex(pPolygon, (int) (pEllipsePoint[i].fx + (pEpNormal[i].fx * wr)), (int) (pEllipsePoint[i].fy + (pEpNormal[i].fy * wr)), 1);
1113 SysLog(NID_GRP, "__DrawThickContinuousArc: _AddPolygonVertex is failed - 1!\n");
1114 line._FreePolygon(pPolygon);
1116 delete[] pEllipsePoint;
1123 i = ellipsePointCount - 1;
1125 if (!line._PatchRoundCap(pPolygon, (int) pEllipsePoint[i].fx, (int) pEllipsePoint[i].fy, pEpNormal[i].fy, -pEpNormal[i].fx, false))
1127 SysLog(NID_GRP, "__DrawThickContinuousArc: _PatchRoundCap is failed - 2!\n");
1128 line._FreePolygon(pPolygon);
1130 delete[] pEllipsePoint;
1137 delete[] pEllipsePoint;
1138 pEllipsePoint = null;
1143 pTempPoints = new (std::nothrow) _GpPoint[pPolygon->n];
1145 if (pTempPoints == null)
1147 SysLog(NID_GRP, "__DrawThickContinuousArc: Memory allocation is failed - 2!\n");
1148 line._FreePolygon(pPolygon);
1153 for (i = 0, pVertex = pPolygon->pFirst; pVertex != null; i++, pVertex = pVertex->pNext)
1155 pTempPoints[i] = pVertex->point;
1158 line._FillPolygon(pPolygon->n, pTempPoints, false, bufInfo);
1160 line._FreePolygon(pPolygon);
1162 delete[] pTempPoints;
1168 _CanvasArc::__DrawThickContinuousPie(int cx, int cy, int halfW, int halfH, int d0, int d1, const _GpBufferInfo& bufInfo) const
1170 int ellipsePointCount;
1173 _GpFloatPoint* pEllipsePoint = null;
1174 _GpFloatPoint* pEpNormal = null;
1181 _GpPolygon* pPolygon = null;
1182 _GpVertex* pVertex = null;
1183 _GpPoint* pTempPoints = null;
1186 float radiusX = (float) halfW;
1187 float radiusY = (float) halfH;
1189 float centerX = (float) cx;
1190 float centerY = (float) cy;
1192 line.SetLineWidth(__lineWidth);
1193 ellipsePointCount = line._MakeEllipseArcPointArray(&pEllipsePoint, &pEpNormal, centerX, centerY, radiusX, radiusY, d0, d1, 0);
1195 if (ellipsePointCount < 2 || pEllipsePoint == null || pEpNormal == null)
1197 SysLog(NID_GRP, "__DrawThickContinuousPie: _MakeEllipseArcPointArray is failed!\n");
1199 delete[] pEllipsePoint;
1205 _CalcLeftRightWidth(&wl, &wr);
1207 pPolygon = new (std::nothrow) _GpPolygon;
1209 if (pPolygon == null)
1211 SysLog(NID_GRP, "__DrawThickContinuousPie: _CreatePolygon is failed!\n");
1213 delete[] pEllipsePoint;
1219 if (!line._PatchRoundCap(pPolygon, (int) pEllipsePoint[0].fx, (int) pEllipsePoint[0].fy, pEpNormal[0].fy, -pEpNormal[0].fx, true))
1221 SysLog(NID_GRP, "__DrawThickContinuousPie: _PatchRoundCap is failed - 1!\n");
1223 line._FreePolygon(pPolygon);
1225 delete[] pEllipsePoint;
1231 for (i = 0; i < ellipsePointCount; i++)
1233 result = line._AddPolygonVertex(pPolygon, (int) (pEllipsePoint[i].fx - (pEpNormal[i].fx * wl)), (int) (pEllipsePoint[i].fy - (pEpNormal[i].fy * wl)), 0);
1237 SysLog(NID_GRP, "__DrawThickContinuousPie: _AddPolygonVertex is failed - 1!\n");
1239 line._FreePolygon(pPolygon);
1241 delete[] pEllipsePoint;
1247 result = line._AddPolygonVertex(pPolygon, (int) (pEllipsePoint[i].fx + (pEpNormal[i].fx * wr)), (int) (pEllipsePoint[i].fy + (pEpNormal[i].fy * wr)), 1);
1251 SysLog(NID_GRP, "__DrawThickContinuousPie: _AddPolygonVertex is failed - 2!\n");
1253 line._FreePolygon(pPolygon);
1255 delete[] pEllipsePoint;
1262 i = ellipsePointCount - 1;
1264 _GpPoint pt1 = { (int) pEllipsePoint[i].fx, (int) pEllipsePoint[i].fy };
1265 _GpPoint pt2 = { cx, cy };
1267 line._GetOrientationUnitVector(pt1, pt2, &ox, &oy);
1269 result = line._PatchJoint(pPolygon, (int) pEllipsePoint[i].fx, (int) pEllipsePoint[i].fy, pEpNormal[i].fy, -pEpNormal[i].fx, ox, oy);
1273 SysLog(NID_GRP, "__DrawThickContinuousPie: _PatchJoint is failed -1!\n");
1275 line._FreePolygon(pPolygon);
1277 delete[] pEllipsePoint;
1283 pt1.x = (int) pEllipsePoint[i].fx;
1284 pt1.y = (int) pEllipsePoint[i].fy;
1288 result = line._PatchThickContinuousLine(pPolygon, pt1, pt2, ox, oy, 0, 0);
1292 SysLog(NID_GRP, "__DrawThickContinuousPie: _PatchThickContinuousLine is failed -1!\n");
1294 line._FreePolygon(pPolygon);
1296 delete[] pEllipsePoint;
1304 pt2.x = (int) pEllipsePoint[0].fx;
1305 pt2.y = (int) pEllipsePoint[0].fy;
1307 line._GetOrientationUnitVector(pt1, pt2, &qx, &qy);
1309 result = line._PatchJoint(pPolygon, cx, cy, ox, oy, qx, qy);
1313 SysLog(NID_GRP, "__DrawThickContinuousPie: _PatchJoint is failed-2!\n");
1315 line._FreePolygon(pPolygon);
1317 delete[] pEllipsePoint;
1325 pt2.x = (int) pEllipsePoint[0].fx;
1326 pt2.y = (int) pEllipsePoint[0].fy;
1328 result = line._PatchThickContinuousLine(pPolygon, pt1, pt2, qx, qy, 0, 0);
1332 SysLog(NID_GRP, "__DrawThickContinuousPie: _PatchThickContinuousLine is failed-2!\n");
1334 line._FreePolygon(pPolygon);
1336 delete[] pEllipsePoint;
1342 result = line._PatchJoint(pPolygon, (int) pEllipsePoint[0].fx, (int) pEllipsePoint[0].fy, qx, qy, pEpNormal[0].fy, -pEpNormal[0].fx);
1346 SysLog(NID_GRP, "__DrawThickContinuousPie: _PatchJoint is failed-3!\n");
1348 line._FreePolygon(pPolygon);
1350 delete[] pEllipsePoint;
1356 result = line._AddPolygonVertex(pPolygon, (int) (pEllipsePoint[0].fx + (pEpNormal[0].fx * wl)), (int) (pEllipsePoint[0].fy + (pEpNormal[0].fy * wl)), 0);
1360 SysLog(NID_GRP, "__DrawThickContinuousPie: _AddPolygonVertex is failed - 3!\n");
1362 line._FreePolygon(pPolygon);
1364 delete[] pEllipsePoint;
1370 result = line._AddPolygonVertex(pPolygon, (int) (pEllipsePoint[0].fx + (pEpNormal[0].fx * wr)), (int) (pEllipsePoint[0].fy + (pEpNormal[0].fy * wr)), 1);
1374 SysLog(NID_GRP, "__DrawThickContinuousPie: _AddPolygonVertex is failed - 4!\n");
1376 line._FreePolygon(pPolygon);
1378 delete[] pEllipsePoint;
1384 delete[] pEllipsePoint;
1385 pEllipsePoint = null;
1390 pTempPoints = new (std::nothrow) _GpPoint[pPolygon->n];
1392 if (pTempPoints == null)
1394 SysLog(NID_GRP, "__DrawThickContinuousPie: Memory allocation is failed - 2!\n");
1395 line._FreePolygon(pPolygon);
1399 for (i = 0, pVertex = pPolygon->pFirst; pVertex != null; i++, pVertex = pVertex->pNext)
1401 pTempPoints[i].x = pVertex->point.x;
1402 pTempPoints[i].y = pVertex->point.y;
1405 line._FillPolygon(pPolygon->n, pTempPoints, false, bufInfo);
1407 line._FreePolygon(pPolygon);
1409 delete[] pTempPoints;
1415 _CanvasArc::__DrawThickContinuousChord(int cx, int cy, int halfW, int halfH, int d0, int d1, const _GpBufferInfo& bufInfo) const
1417 int ellipsePointCount;
1419 _GpFloatPoint* pEllipsePoint = null;
1420 _GpFloatPoint* pEpNormal = null;
1425 _GpPolygon* pPolygon = null;
1426 _GpPoint* pTempPoints = null;
1427 _GpVertex* pVertex = null;
1432 float radiusX = (float) halfW;
1433 float radiusY = (float) halfH;
1435 float centerX = (float) cx;
1436 float centerY = (float) cy;
1438 line.SetLineWidth(__lineWidth);
1439 ellipsePointCount = line._MakeEllipseArcPointArray(&pEllipsePoint, &pEpNormal, centerX, centerY, radiusX, radiusY, d0, d1, 0);
1441 if (ellipsePointCount < 2 || pEllipsePoint == null || pEpNormal == null)
1443 SysLog(NID_GRP, "__DrawThickContinuousChord: _MakeEllipseArcPointArray is failed!\n");
1445 delete[] pEllipsePoint;
1451 _CalcLeftRightWidth(&wl, &wr);
1453 pPolygon = new (std::nothrow) _GpPolygon;
1455 if (pPolygon == null)
1457 SysLog(NID_GRP, "__DrawThickContinuousChord: _CreatePolygon is failed!\n");
1459 delete[] pEllipsePoint;
1465 if (!line._PatchRoundCap(pPolygon, (int) pEllipsePoint[0].fx, (int) pEllipsePoint[0].fy, pEpNormal[0].fy, -pEpNormal[0].fx, true))
1467 SysLog(NID_GRP, "__DrawThickContinuousChord: _PatchRoundCap is failed - 1!\n");
1469 line._FreePolygon(pPolygon);
1471 delete[] pEllipsePoint;
1477 for (i = 0; i < ellipsePointCount; i++)
1479 result = line._AddPolygonVertex(pPolygon, (int) (pEllipsePoint[i].fx - (pEpNormal[i].fx * wl)), (int) (pEllipsePoint[i].fy - (pEpNormal[i].fy * wl)), 0);
1483 SysLog(NID_GRP, "__DrawThickContinuousChord: _AddPolygonVertex is failed - 1!\n");
1485 line._FreePolygon(pPolygon);
1487 delete[] pEllipsePoint;
1493 result = line._AddPolygonVertex(pPolygon, (int) (pEllipsePoint[i].fx + (pEpNormal[i].fx * wr)), (int) (pEllipsePoint[i].fy + (pEpNormal[i].fy * wr)), 1);
1497 SysLog(NID_GRP, "__DrawThickContinuousChord: _AddPolygonVertex is failed - 1!\n");
1499 line._FreePolygon(pPolygon);
1501 delete[] pEllipsePoint;
1508 if ((d0 % 360) != (d1 % 360))
1510 i = ellipsePointCount - 1;
1512 _GpPoint pt1 = { (int) pEllipsePoint[i].fx, (int) pEllipsePoint[i].fy };
1513 _GpPoint pt2 = { (int) pEllipsePoint[0].fx, (int) pEllipsePoint[0].fy };
1515 line._GetOrientationUnitVector(pt1, pt2, &ox, &oy);
1517 result = line._PatchJoint(pPolygon, (int) pEllipsePoint[i].fx, (int) pEllipsePoint[i].fy, pEpNormal[i].fy, -pEpNormal[i].fx, ox, oy);
1521 SysLog(NID_GRP, "__DrawThickContinuousChord: _PatchJoint is failed - 1!\n");
1523 line._FreePolygon(pPolygon);
1525 delete[] pEllipsePoint;
1531 pt1.x = (int) pEllipsePoint[i].fx;
1532 pt1.y = (int) pEllipsePoint[i].fy;
1533 pt2.x = (int) pEllipsePoint[0].fx;
1534 pt2.y = (int) pEllipsePoint[0].fy;
1536 result = line._PatchThickContinuousLine(pPolygon, pt1, pt2, ox, oy, 0, 0);
1540 SysLog(NID_GRP, "__DrawThickContinuousChord: _PatchJoint is failed - 1!\n");
1542 line._FreePolygon(pPolygon);
1544 delete[] pEllipsePoint;
1550 result = line._PatchJoint(pPolygon, (int) pEllipsePoint[0].fx, (int) pEllipsePoint[0].fy, ox, oy, pEpNormal[0].fy, -pEpNormal[0].fx);
1554 SysLog(NID_GRP, "__DrawThickContinuousChord: _PatchJoint is failed - 2!\n");
1556 line._FreePolygon(pPolygon);
1558 delete[] pEllipsePoint;
1564 result = line._AddPolygonVertex(pPolygon, (int) (pEllipsePoint[0].fx + (pEpNormal[0].fx * wl)), (int) (pEllipsePoint[0].fy + (pEpNormal[0].fy * wl)), 0);
1568 SysLog(NID_GRP, "__DrawThickContinuousChord: _AddPolygonVertex is failed - 2!\n");
1570 line._FreePolygon(pPolygon);
1572 delete[] pEllipsePoint;
1578 result = line._AddPolygonVertex(pPolygon, (int) (pEllipsePoint[0].fx + (pEpNormal[0].fx * wr)), (int) (pEllipsePoint[0].fy + (pEpNormal[0].fy * wr)), 1);
1582 SysLog(NID_GRP, "__DrawThickContinuousChord: _AddPolygonVertex is failed - 3!\n");
1584 line._FreePolygon(pPolygon);
1586 delete[] pEllipsePoint;
1593 delete[] pEllipsePoint;
1594 pEllipsePoint = null;
1599 pTempPoints = new (std::nothrow) _GpPoint[pPolygon->n];
1601 if (pTempPoints == null)
1603 SysLog(NID_GRP, "__DrawThickContinuousChord: Memory allocation is failed!\n");
1604 line._FreePolygon(pPolygon);
1609 for (i = 0, pVertex = pPolygon->pFirst; pVertex != null; i++, pVertex = pVertex->pNext)
1611 pTempPoints[i].x = pVertex->point.x;
1612 pTempPoints[i].y = pVertex->point.y;
1615 line._FillPolygon(pPolygon->n, pTempPoints, false, bufInfo);
1617 line._FreePolygon(pPolygon);
1619 delete[] pTempPoints;
1625 _CanvasArc::_CalcLeftRightWidth(float* pWidthLeft, float* pWidthRight) const
1627 if (__lineWidth % 2 == 0)
1629 *pWidthRight = __lineWidth / 2.0f;
1630 *pWidthLeft = *pWidthRight - 1.0f;
1634 *pWidthLeft = *pWidthRight = (__lineWidth - 1) / 2.0f;
1640 }} // Tizen::Graphics