68 jint x, y;
69
70 // Fix for 4298688 - draw(Line) and Polygon omit last pixel
71 // We will need to add a point if we need to close it off or
72 // if we need to fix the endpoint to accommodate the Windows
73 // habit of never drawing the last pixel of a Polyline. Note
74 // that if the polyline is already closed then neither fix
75 // is needed because the last pixel is also the first pixel
76 // and so will be drawn just fine.
77 // Clarification for 4298688 - regression bug 4678208 points
78 // out that we still need to fix the endpoint if the closed
79 // polygon never went anywhere (all vertices on same coordinate).
80 jint mx = xpoints[0];
81 jint my = ypoints[0];
82 BOOL isclosed = (xpoints[npoints-1] == mx && ypoints[npoints-1] == my);
83 if ((close && !isclosed) || fixend) {
84 outpoints++;
85 *pNpoints = outpoints;
86 }
87 if (outpoints > POLYTEMPSIZE) {
88 pPoints = (POINT *) SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, sizeof(POINT), outpoints);
89 }
90 BOOL isempty = fixend;
91 for (int i = 0; i < npoints; i++) {
92 x = xpoints[i];
93 y = ypoints[i];
94 isempty = isempty && (x == mx && y == my);
95 pPoints[i].x = CLAMP(x + transx);
96 pPoints[i].y = CLAMP(y + transy);
97 }
98 if (close && !isclosed) {
99 pPoints[npoints] = pPoints[0];
100 } else if (fixend) {
101 if (!close || isempty) {
102 // Fix for 4298688 - draw(Line) and Polygon omit last pixel
103 // Fix up the last segment by adding another segment after
104 // it that is only 1 pixel long. The first pixel of that
105 // segment will be drawn, but the second pixel is the one
106 // that Windows omits.
107 pPoints[npoints] = pPoints[npoints-1];
108 pPoints[npoints].x++;
|
68 jint x, y;
69
70 // Fix for 4298688 - draw(Line) and Polygon omit last pixel
71 // We will need to add a point if we need to close it off or
72 // if we need to fix the endpoint to accommodate the Windows
73 // habit of never drawing the last pixel of a Polyline. Note
74 // that if the polyline is already closed then neither fix
75 // is needed because the last pixel is also the first pixel
76 // and so will be drawn just fine.
77 // Clarification for 4298688 - regression bug 4678208 points
78 // out that we still need to fix the endpoint if the closed
79 // polygon never went anywhere (all vertices on same coordinate).
80 jint mx = xpoints[0];
81 jint my = ypoints[0];
82 BOOL isclosed = (xpoints[npoints-1] == mx && ypoints[npoints-1] == my);
83 if ((close && !isclosed) || fixend) {
84 outpoints++;
85 *pNpoints = outpoints;
86 }
87 if (outpoints > POLYTEMPSIZE) {
88 try {
89 pPoints = (POINT *) SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, sizeof(POINT), outpoints);
90 } catch (std::bad_alloc&) {
91 return NULL;
92 }
93 }
94 BOOL isempty = fixend;
95 for (int i = 0; i < npoints; i++) {
96 x = xpoints[i];
97 y = ypoints[i];
98 isempty = isempty && (x == mx && y == my);
99 pPoints[i].x = CLAMP(x + transx);
100 pPoints[i].y = CLAMP(y + transy);
101 }
102 if (close && !isclosed) {
103 pPoints[npoints] = pPoints[0];
104 } else if (fixend) {
105 if (!close || isempty) {
106 // Fix for 4298688 - draw(Line) and Polygon omit last pixel
107 // Fix up the last segment by adding another segment after
108 // it that is only 1 pixel long. The first pixel of that
109 // segment will be drawn, but the second pixel is the one
110 // that Windows omits.
111 pPoints[npoints] = pPoints[npoints-1];
112 pPoints[npoints].x++;
|