Lines 72-78
Link Here
|
72 |
* @noreference This field is not intended to be referenced by clients. |
72 |
* @noreference This field is not intended to be referenced by clients. |
73 |
*/ |
73 |
*/ |
74 |
public int /*long*/ handle; |
74 |
public int /*long*/ handle; |
75 |
|
75 |
|
|
|
76 |
// Field to check if BeginDraw method was called in direct2d |
77 |
private boolean isDrawing = false; |
78 |
|
76 |
Drawable drawable; |
79 |
Drawable drawable; |
77 |
GCData data; |
80 |
GCData data; |
78 |
|
81 |
|
Lines 179-188
Link Here
|
179 |
|
182 |
|
180 |
void checkGC(int mask) { |
183 |
void checkGC(int mask) { |
181 |
int state = data.state; |
184 |
int state = data.state; |
|
|
185 |
beginDrawDirect2D(); |
182 |
if ((state & mask) == mask) return; |
186 |
if ((state & mask) == mask) return; |
183 |
state = (state ^ mask) & mask; |
187 |
state = (state ^ mask) & mask; |
184 |
data.state |= mask; |
188 |
data.state |= mask; |
185 |
int /*long*/ gdipGraphics = data.gdipGraphics; |
189 |
int /*long*/ gdipGraphics = data.gdipGraphics; |
|
|
190 |
int /*long*/ renderTarget = data.direct2DRenderTarget; |
191 |
if (OS.IsWin7 && renderTarget != 0) { |
192 |
float width = data.lineWidth; |
193 |
if ((state & FOREGROUND) != 0 || (state & (LINE_WIDTH | LINE_STYLE | LINE_MITERLIMIT | LINE_JOIN | LINE_CAP)) != 0) { |
194 |
// create direct2d solid color brush |
195 |
if (data.direct2DBrush != 0) Gdip.Direct2D_SafeRelease(data.direct2DBrush); |
196 |
data.direct2DBrush = 0; |
197 |
int brush; |
198 |
// use solid brush |
199 |
int foreground = data.foreground; |
200 |
//int rgb = ((foreground >> 16) & 0xFF) | (foreground & 0xFF00) | ((foreground & 0xFF) << 16); |
201 |
//brush = Gdip.Direct2D_SolidBrush_new(rgb); |
202 |
brush = Gdip.Direct2DRenderTarget_SolidBrush(data.direct2DRenderTarget, foreground); |
203 |
if (brush == 0) SWT.error(SWT.ERROR_NO_HANDLES); |
204 |
data.direct2DBrush = brush; |
205 |
} |
206 |
if ((state & LINE_STYLE) != 0) { |
207 |
float[] dashes = null; |
208 |
float dashOffset = 0; |
209 |
int dashStyle = Gdip.DashStyleSolid; |
210 |
switch (data.lineStyle) { |
211 |
case SWT.LINE_SOLID: break; |
212 |
case SWT.LINE_DOT: dashStyle = Gdip.DashStyleDot; if (width == 0) dashes = LINE_DOT_ZERO; break; |
213 |
case SWT.LINE_DASH: dashStyle = Gdip.DashStyleDash; if (width == 0) dashes = LINE_DASH_ZERO; break; |
214 |
case SWT.LINE_DASHDOT: dashStyle = Gdip.DashStyleDashDot; if (width == 0) dashes = LINE_DASHDOT_ZERO; break; |
215 |
case SWT.LINE_DASHDOTDOT: dashStyle = Gdip.DashStyleDashDotDot; if (width == 0) dashes = LINE_DASHDOTDOT_ZERO; break; |
216 |
case SWT.LINE_CUSTOM: { |
217 |
if (data.lineDashes != null) { |
218 |
dashStyle = 5; // custom style |
219 |
dashOffset = data.direct2DDashOffset = data.lineDashesOffset / Math.max (1, width); |
220 |
dashes = new float[data.lineDashes.length * 2]; |
221 |
for (int i = 0; i < data.lineDashes.length; i++) { |
222 |
float dash = data.lineDashes[i] / Math.max (1, width); |
223 |
dashes[i] = dash; |
224 |
dashes[i + data.lineDashes.length] = dash; |
225 |
} |
226 |
data.direct2DDashes = dashes; |
227 |
} |
228 |
} |
229 |
} |
230 |
data.direct2DDashStyle = dashStyle; |
231 |
data.direct2DDashOffset = dashOffset; |
232 |
|
233 |
} |
234 |
if ((state & LINE_MITERLIMIT) != 0) { |
235 |
data.direct2DMiterLimit = data.lineMiterLimit; |
236 |
} |
237 |
if ((state & LINE_JOIN) != 0) { |
238 |
int joinStyle = 0; |
239 |
switch (data.lineJoin) { |
240 |
case SWT.JOIN_MITER: joinStyle = Gdip.LineJoinMiter; break; |
241 |
case SWT.JOIN_BEVEL: joinStyle = Gdip.LineJoinBevel; break; |
242 |
case SWT.JOIN_ROUND: joinStyle = Gdip.LineJoinRound; break; |
243 |
} |
244 |
data.direct2DLineJoin = joinStyle; |
245 |
} |
246 |
if ((state & LINE_CAP) != 0) { |
247 |
int dashCap = Gdip.DashCapFlat, capStyle = 0; |
248 |
switch (data.lineCap) { |
249 |
case SWT.CAP_FLAT: capStyle = Gdip.LineCapFlat; dashCap = Gdip.DashCapSquare; break; |
250 |
case SWT.CAP_ROUND: capStyle = Gdip.LineCapRound; dashCap = Gdip.DashCapRound; break; |
251 |
case SWT.CAP_SQUARE: capStyle = Gdip.LineCapSquare; dashCap = Gdip.DashCapSquare; break; |
252 |
} |
253 |
data.direct2DDashCap = dashCap; |
254 |
data.direct2DEndCap = capStyle; |
255 |
data.direct2DStartCap = capStyle; |
256 |
} |
257 |
data.direct2DStrokeStyle = Gdip.Direct2DStrokeStyle_new( |
258 |
data.direct2DFactory, |
259 |
data.direct2DStrokeStyle, |
260 |
data.direct2DStartCap, |
261 |
data.direct2DEndCap, data.direct2DDashCap, |
262 |
data.direct2DLineJoin, data.direct2DMiterLimit, |
263 |
data.direct2DDashStyle, data.direct2DDashOffset, |
264 |
data.direct2DDashes); |
265 |
if ((state & DRAW_OFFSET) != 0) { |
266 |
data.gdipXOffset = data.gdipYOffset = 0; |
267 |
int /*long*/ matrix = Gdip.Matrix_new(1, 0, 0, 1, 0, 0); |
268 |
PointF point = new PointF(); |
269 |
point.X = point.Y = 1; |
270 |
Gdip.Graphics_GetTransform(gdipGraphics, matrix); |
271 |
Gdip.Matrix_TransformVectors(matrix, point, 1); |
272 |
Gdip.Matrix_delete(matrix); |
273 |
float scaling = point.X; |
274 |
if (scaling < 0) scaling = -scaling; |
275 |
float penWidth = data.lineWidth * scaling; |
276 |
if (penWidth == 0 || ((int)penWidth % 2) == 1) { |
277 |
data.gdipXOffset = 0.5f / scaling; |
278 |
} |
279 |
scaling = point.Y; |
280 |
if (scaling < 0) scaling = -scaling; |
281 |
penWidth = data.lineWidth * scaling; |
282 |
if (penWidth == 0 || ((int)penWidth % 2) == 1) { |
283 |
data.gdipYOffset = 0.5f / scaling; |
284 |
} |
285 |
} |
286 |
} |
186 |
if (gdipGraphics != 0) { |
287 |
if (gdipGraphics != 0) { |
187 |
int /*long*/ pen = data.gdipPen; |
288 |
int /*long*/ pen = data.gdipPen; |
188 |
float width = data.lineWidth; |
289 |
float width = data.lineWidth; |
Lines 644-649
Link Here
|
644 |
*/ |
745 |
*/ |
645 |
void destroy() { |
746 |
void destroy() { |
646 |
boolean gdip = data.gdipGraphics != 0; |
747 |
boolean gdip = data.gdipGraphics != 0; |
|
|
748 |
disposeDirect2D(); |
647 |
disposeGdip(); |
749 |
disposeGdip(); |
648 |
if (gdip && (data.style & SWT.MIRRORED) != 0) { |
750 |
if (gdip && (data.style & SWT.MIRRORED) != 0) { |
649 |
OS.SetLayout(handle, OS.GetLayout(handle) | OS.LAYOUT_RTL); |
751 |
OS.SetLayout(handle, OS.GetLayout(handle) | OS.LAYOUT_RTL); |
Lines 696-701
Link Here
|
696 |
data.gdipFont = data.gdipPen = data.hGDIFont = 0; |
798 |
data.gdipFont = data.gdipPen = data.hGDIFont = 0; |
697 |
} |
799 |
} |
698 |
|
800 |
|
|
|
801 |
void disposeDirect2D() { |
802 |
endDrawDirect2D(); |
803 |
if (data.direct2DBrush != 0) Gdip.Direct2D_SafeRelease(data.direct2DBrush); |
804 |
if (data.direct2DStrokeStyle != 0) Gdip.Direct2D_SafeRelease(data.direct2DStrokeStyle); |
805 |
if (data.direct2DRenderTarget != 0) Gdip.Direct2D_SafeRelease(data.direct2DRenderTarget); |
806 |
if (data.direct2DFactory != 0) Gdip.Direct2D_SafeRelease(data.direct2DFactory); |
807 |
data.direct2DBrush = data.direct2DStrokeStyle = data.direct2DRenderTarget = |
808 |
data.direct2DFactory = data.direct2DStartCap = data.direct2DEndCap = |
809 |
data.direct2DDashCap = data.direct2DLineJoin = data.direct2DDashStyle = 0; |
810 |
data.direct2DMiterLimit = 10.0f; |
811 |
data.direct2DDashOffset = 0.0f; |
812 |
data.direct2DDashes = new float[0]; |
813 |
} |
814 |
|
699 |
/** |
815 |
/** |
700 |
* Draws the outline of a circular or elliptical arc |
816 |
* Draws the outline of a circular or elliptical arc |
701 |
* within the specified rectangular area. |
817 |
* within the specified rectangular area. |
Lines 728-733
Link Here
|
728 |
public void drawArc (int x, int y, int width, int height, int startAngle, int arcAngle) { |
844 |
public void drawArc (int x, int y, int width, int height, int startAngle, int arcAngle) { |
729 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
845 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
730 |
checkGC(DRAW); |
846 |
checkGC(DRAW); |
|
|
847 |
endDrawDirect2D(); |
731 |
if (width < 0) { |
848 |
if (width < 0) { |
732 |
x = x + width; |
849 |
x = x + width; |
733 |
width = -width; |
850 |
width = -width; |
Lines 826-831
Link Here
|
826 |
public void drawFocus (int x, int y, int width, int height) { |
943 |
public void drawFocus (int x, int y, int width, int height) { |
827 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
944 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
828 |
if ((data.uiState & OS.UISF_HIDEFOCUS) != 0) return; |
945 |
if ((data.uiState & OS.UISF_HIDEFOCUS) != 0) return; |
|
|
946 |
endDrawDirect2D(); |
829 |
data.focusDrawn = true; |
947 |
data.focusDrawn = true; |
830 |
int /*long*/ hdc = handle; |
948 |
int /*long*/ hdc = handle; |
831 |
int state = 0; |
949 |
int state = 0; |
Lines 944-949
Link Here
|
944 |
} |
1062 |
} |
945 |
|
1063 |
|
946 |
void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple) { |
1064 |
void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple) { |
|
|
1065 |
// TODO solve problem with drawing on GC created locally (no event.gc) |
1066 |
if (srcImage.memGC.data.direct2DRenderTarget != 0) { |
1067 |
srcImage.memGC.endDrawDirect2D(); |
1068 |
} |
1069 |
endDrawDirect2D(); |
947 |
if (data.gdipGraphics != 0) { |
1070 |
if (data.gdipGraphics != 0) { |
948 |
//TODO - cache bitmap |
1071 |
//TODO - cache bitmap |
949 |
int /*long*/ [] gdipImage = srcImage.createGdipImage(); |
1072 |
int /*long*/ [] gdipImage = srcImage.createGdipImage(); |
Lines 1658-1663
Link Here
|
1658 |
OS.DeleteDC(srcHdc); |
1781 |
OS.DeleteDC(srcHdc); |
1659 |
} |
1782 |
} |
1660 |
|
1783 |
|
|
|
1784 |
void initDirect2D() { |
1785 |
if (!OS.IsWin7 || data.direct2DRenderTarget != 0) return; |
1786 |
data.direct2DFactory = Gdip.Direct2D_CreateFactory(); |
1787 |
data.direct2DRenderTarget = Gdip.Direct2DFactory_CreateDCRenderTarget(data.direct2DFactory); |
1788 |
int width = 0; |
1789 |
int height = 0; |
1790 |
int /*long*/ hwnd = OS.IsWinCE ? data.hwnd : OS.WindowFromDC(handle); |
1791 |
if (hwnd != 0) { |
1792 |
RECT rect = new RECT(); |
1793 |
OS.GetClientRect(hwnd, rect); |
1794 |
width = rect.right - rect.left; |
1795 |
height = rect.bottom - rect.top; |
1796 |
} else { |
1797 |
int /*long*/ hBitmap = OS.GetCurrentObject(handle, OS.OBJ_BITMAP); |
1798 |
BITMAP bm = new BITMAP(); |
1799 |
OS.GetObject(hBitmap, BITMAP.sizeof, bm); |
1800 |
width = bm.bmWidth; |
1801 |
} |
1802 |
Gdip.Direct2DRenderTarget_BindDC(data.direct2DRenderTarget, handle, width, height); |
1803 |
if (data.direct2DBrush == 0) { |
1804 |
int brush; |
1805 |
brush = Gdip.Direct2DRenderTarget_SolidBrush(data.direct2DRenderTarget, 0); |
1806 |
if (brush == 0) SWT.error(SWT.ERROR_NO_HANDLES); |
1807 |
data.direct2DBrush = brush; |
1808 |
} |
1809 |
} |
1810 |
|
1811 |
void beginDrawDirect2D() { |
1812 |
if (isDrawing || !OS.IsWin7) return; |
1813 |
if (data.direct2DRenderTarget == 0) return; |
1814 |
Gdip.Direct2DRenderTarget_BeginDraw(data.direct2DRenderTarget); |
1815 |
isDrawing = true; |
1816 |
} |
1817 |
|
1818 |
void endDrawDirect2D() { |
1819 |
if (!isDrawing || !OS.IsWin7) return; |
1820 |
if (data.direct2DRenderTarget == 0) return; |
1821 |
Gdip.Direct2DRenderTarget_EndDraw(data.direct2DRenderTarget); |
1822 |
isDrawing = false; |
1823 |
} |
1824 |
|
1661 |
/** |
1825 |
/** |
1662 |
* Draws a line, using the foreground color, between the points |
1826 |
* Draws a line, using the foreground color, between the points |
1663 |
* (<code>x1</code>, <code>y1</code>) and (<code>x2</code>, <code>y2</code>). |
1827 |
* (<code>x1</code>, <code>y1</code>) and (<code>x2</code>, <code>y2</code>). |
Lines 1675-1681
Link Here
|
1675 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
1839 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
1676 |
checkGC(DRAW); |
1840 |
checkGC(DRAW); |
1677 |
int /*long*/ gdipGraphics = data.gdipGraphics; |
1841 |
int /*long*/ gdipGraphics = data.gdipGraphics; |
|
|
1842 |
int /*long*/ direct2dRenderTarget = data.direct2DRenderTarget; |
1678 |
if (gdipGraphics != 0) { |
1843 |
if (gdipGraphics != 0) { |
|
|
1844 |
if (OS.IsWin7 && direct2dRenderTarget != 0) { |
1845 |
if (data.direct2DStrokeStyle != 0) { |
1846 |
Gdip.Direct2DRenderTarget_DrawLineStroke(direct2dRenderTarget, data.direct2DBrush, x1, y1, x2, y2, data.direct2DlineWidth, data.direct2DStrokeStyle); |
1847 |
} else { |
1848 |
Gdip.Direct2DRenderTarget_DrawLine(direct2dRenderTarget, data.direct2DBrush, x1, y1, x2, y2, data.direct2DlineWidth); |
1849 |
} |
1850 |
return; |
1851 |
} |
1679 |
Gdip.Graphics_TranslateTransform(gdipGraphics, data.gdipXOffset, data.gdipYOffset, Gdip.MatrixOrderPrepend); |
1852 |
Gdip.Graphics_TranslateTransform(gdipGraphics, data.gdipXOffset, data.gdipYOffset, Gdip.MatrixOrderPrepend); |
1680 |
Gdip.Graphics_DrawLine(gdipGraphics, data.gdipPen, x1, y1, x2, y2); |
1853 |
Gdip.Graphics_DrawLine(gdipGraphics, data.gdipPen, x1, y1, x2, y2); |
1681 |
Gdip.Graphics_TranslateTransform(gdipGraphics, -data.gdipXOffset, -data.gdipYOffset, Gdip.MatrixOrderPrepend); |
1854 |
Gdip.Graphics_TranslateTransform(gdipGraphics, -data.gdipXOffset, -data.gdipYOffset, Gdip.MatrixOrderPrepend); |
Lines 1723-1728
Link Here
|
1723 |
public void drawOval (int x, int y, int width, int height) { |
1896 |
public void drawOval (int x, int y, int width, int height) { |
1724 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
1897 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
1725 |
checkGC(DRAW); |
1898 |
checkGC(DRAW); |
|
|
1899 |
endDrawDirect2D(); |
1726 |
int /*long*/ gdipGraphics = data.gdipGraphics; |
1900 |
int /*long*/ gdipGraphics = data.gdipGraphics; |
1727 |
if (gdipGraphics != 0) { |
1901 |
if (gdipGraphics != 0) { |
1728 |
Gdip.Graphics_TranslateTransform(gdipGraphics, data.gdipXOffset, data.gdipYOffset, Gdip.MatrixOrderPrepend); |
1902 |
Gdip.Graphics_TranslateTransform(gdipGraphics, data.gdipXOffset, data.gdipYOffset, Gdip.MatrixOrderPrepend); |
Lines 1765-1770
Link Here
|
1765 |
if (path.handle == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); |
1939 |
if (path.handle == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); |
1766 |
initGdip(); |
1940 |
initGdip(); |
1767 |
checkGC(DRAW); |
1941 |
checkGC(DRAW); |
|
|
1942 |
endDrawDirect2D(); |
1768 |
int /*long*/ gdipGraphics = data.gdipGraphics; |
1943 |
int /*long*/ gdipGraphics = data.gdipGraphics; |
1769 |
Gdip.Graphics_TranslateTransform(gdipGraphics, data.gdipXOffset, data.gdipYOffset, Gdip.MatrixOrderPrepend); |
1944 |
Gdip.Graphics_TranslateTransform(gdipGraphics, data.gdipXOffset, data.gdipYOffset, Gdip.MatrixOrderPrepend); |
1770 |
Gdip.Graphics_DrawPath(gdipGraphics, data.gdipPen, path.handle); |
1945 |
Gdip.Graphics_DrawPath(gdipGraphics, data.gdipPen, path.handle); |
Lines 1792-1797
Link Here
|
1792 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
1967 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
1793 |
if (data.gdipGraphics != 0) { |
1968 |
if (data.gdipGraphics != 0) { |
1794 |
checkGC(DRAW); |
1969 |
checkGC(DRAW); |
|
|
1970 |
endDrawDirect2D(); |
1795 |
Gdip.Graphics_FillRectangle(data.gdipGraphics, getFgBrush(), x, y, 1, 1); |
1971 |
Gdip.Graphics_FillRectangle(data.gdipGraphics, getFgBrush(), x, y, 1, 1); |
1796 |
return; |
1972 |
return; |
1797 |
} |
1973 |
} |
Lines 1819-1824
Link Here
|
1819 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
1995 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
1820 |
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); |
1996 |
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); |
1821 |
checkGC(DRAW); |
1997 |
checkGC(DRAW); |
|
|
1998 |
endDrawDirect2D(); |
1822 |
int /*long*/ gdipGraphics = data.gdipGraphics; |
1999 |
int /*long*/ gdipGraphics = data.gdipGraphics; |
1823 |
if (gdipGraphics != 0) { |
2000 |
if (gdipGraphics != 0) { |
1824 |
Gdip.Graphics_TranslateTransform(gdipGraphics, data.gdipXOffset, data.gdipYOffset, Gdip.MatrixOrderPrepend); |
2001 |
Gdip.Graphics_TranslateTransform(gdipGraphics, data.gdipXOffset, data.gdipYOffset, Gdip.MatrixOrderPrepend); |
Lines 1864-1869
Link Here
|
1864 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
2041 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
1865 |
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); |
2042 |
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); |
1866 |
checkGC(DRAW); |
2043 |
checkGC(DRAW); |
|
|
2044 |
endDrawDirect2D(); |
1867 |
int /*long*/ gdipGraphics = data.gdipGraphics; |
2045 |
int /*long*/ gdipGraphics = data.gdipGraphics; |
1868 |
if (gdipGraphics != 0) { |
2046 |
if (gdipGraphics != 0) { |
1869 |
Gdip.Graphics_TranslateTransform(gdipGraphics, data.gdipXOffset, data.gdipYOffset, Gdip.MatrixOrderPrepend); |
2047 |
Gdip.Graphics_TranslateTransform(gdipGraphics, data.gdipXOffset, data.gdipYOffset, Gdip.MatrixOrderPrepend); |
Lines 1912-1917
Link Here
|
1912 |
public void drawRectangle (int x, int y, int width, int height) { |
2090 |
public void drawRectangle (int x, int y, int width, int height) { |
1913 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
2091 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
1914 |
checkGC(DRAW); |
2092 |
checkGC(DRAW); |
|
|
2093 |
endDrawDirect2D(); |
1915 |
int /*long*/ gdipGraphics = data.gdipGraphics; |
2094 |
int /*long*/ gdipGraphics = data.gdipGraphics; |
1916 |
if (gdipGraphics != 0) { |
2095 |
if (gdipGraphics != 0) { |
1917 |
if (width < 0) { |
2096 |
if (width < 0) { |
Lines 1988-1993
Link Here
|
1988 |
public void drawRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) { |
2167 |
public void drawRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) { |
1989 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
2168 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
1990 |
checkGC(DRAW); |
2169 |
checkGC(DRAW); |
|
|
2170 |
endDrawDirect2D(); |
1991 |
if (data.gdipGraphics != 0) { |
2171 |
if (data.gdipGraphics != 0) { |
1992 |
drawRoundRectangleGdip(data.gdipGraphics, data.gdipPen, x, y, width, height, arcWidth, arcHeight); |
2172 |
drawRoundRectangleGdip(data.gdipGraphics, data.gdipPen, x, y, width, height, arcWidth, arcHeight); |
1993 |
return; |
2173 |
return; |
Lines 2143-2148
Link Here
|
2143 |
int /*long*/ gdipGraphics = data.gdipGraphics; |
2323 |
int /*long*/ gdipGraphics = data.gdipGraphics; |
2144 |
if (gdipGraphics != 0) { |
2324 |
if (gdipGraphics != 0) { |
2145 |
checkGC(FONT | FOREGROUND | (isTransparent ? 0 : BACKGROUND)); |
2325 |
checkGC(FONT | FOREGROUND | (isTransparent ? 0 : BACKGROUND)); |
|
|
2326 |
endDrawDirect2D(); |
2146 |
drawText(gdipGraphics, string, x, y, isTransparent ? SWT.DRAW_TRANSPARENT : 0, null); |
2327 |
drawText(gdipGraphics, string, x, y, isTransparent ? SWT.DRAW_TRANSPARENT : 0, null); |
2147 |
return; |
2328 |
return; |
2148 |
} |
2329 |
} |
Lines 2154-2159
Link Here
|
2154 |
rop2 = OS.GetROP2(handle); |
2335 |
rop2 = OS.GetROP2(handle); |
2155 |
} |
2336 |
} |
2156 |
checkGC(FONT | FOREGROUND_TEXT | BACKGROUND_TEXT); |
2337 |
checkGC(FONT | FOREGROUND_TEXT | BACKGROUND_TEXT); |
|
|
2338 |
endDrawDirect2D(); |
2157 |
int oldBkMode = OS.SetBkMode(handle, isTransparent ? OS.TRANSPARENT : OS.OPAQUE); |
2339 |
int oldBkMode = OS.SetBkMode(handle, isTransparent ? OS.TRANSPARENT : OS.OPAQUE); |
2158 |
RECT rect = null; |
2340 |
RECT rect = null; |
2159 |
SIZE size = null; |
2341 |
SIZE size = null; |
Lines 2293-2298
Link Here
|
2293 |
int /*long*/ gdipGraphics = data.gdipGraphics; |
2475 |
int /*long*/ gdipGraphics = data.gdipGraphics; |
2294 |
if (gdipGraphics != 0) { |
2476 |
if (gdipGraphics != 0) { |
2295 |
checkGC(FONT | FOREGROUND | ((flags & SWT.DRAW_TRANSPARENT) != 0 ? 0 : BACKGROUND)); |
2477 |
checkGC(FONT | FOREGROUND | ((flags & SWT.DRAW_TRANSPARENT) != 0 ? 0 : BACKGROUND)); |
|
|
2478 |
endDrawDirect2D(); |
2296 |
drawText(gdipGraphics, string, x, y, flags, null); |
2479 |
drawText(gdipGraphics, string, x, y, flags, null); |
2297 |
return; |
2480 |
return; |
2298 |
} |
2481 |
} |
Lines 2642-2648
Link Here
|
2642 |
* @see #hashCode |
2825 |
* @see #hashCode |
2643 |
*/ |
2826 |
*/ |
2644 |
public boolean equals (Object object) { |
2827 |
public boolean equals (Object object) { |
2645 |
return (object == this) || ((object instanceof GC) && (handle == ((GC)object).handle)); |
2828 |
return (object == this) || ((object instanceof GC) && (handle == ((GC)object).handle) && (data.direct2DRenderTarget == ((GC)object).data.direct2DRenderTarget)); |
2646 |
} |
2829 |
} |
2647 |
|
2830 |
|
2648 |
/** |
2831 |
/** |
Lines 2680-2685
Link Here
|
2680 |
public void fillArc (int x, int y, int width, int height, int startAngle, int arcAngle) { |
2863 |
public void fillArc (int x, int y, int width, int height, int startAngle, int arcAngle) { |
2681 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
2864 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
2682 |
checkGC(FILL); |
2865 |
checkGC(FILL); |
|
|
2866 |
endDrawDirect2D(); |
2683 |
if (width < 0) { |
2867 |
if (width < 0) { |
2684 |
x = x + width; |
2868 |
x = x + width; |
2685 |
width = -width; |
2869 |
width = -width; |
Lines 2809-2814
Link Here
|
2809 |
} |
2993 |
} |
2810 |
if (data.gdipGraphics != 0) { |
2994 |
if (data.gdipGraphics != 0) { |
2811 |
initGdip(); |
2995 |
initGdip(); |
|
|
2996 |
endDrawDirect2D(); |
2812 |
PointF p1= new PointF(), p2 = new PointF(); |
2997 |
PointF p1= new PointF(), p2 = new PointF(); |
2813 |
p1.X = x; |
2998 |
p1.X = x; |
2814 |
p1.Y = y; |
2999 |
p1.Y = y; |
Lines 2907-2912
Link Here
|
2907 |
public void fillOval (int x, int y, int width, int height) { |
3092 |
public void fillOval (int x, int y, int width, int height) { |
2908 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
3093 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
2909 |
checkGC(FILL); |
3094 |
checkGC(FILL); |
|
|
3095 |
endDrawDirect2D(); |
2910 |
if (data.gdipGraphics != 0) { |
3096 |
if (data.gdipGraphics != 0) { |
2911 |
Gdip.Graphics_FillEllipse(data.gdipGraphics, data.gdipBrush, x, y, width, height); |
3097 |
Gdip.Graphics_FillEllipse(data.gdipGraphics, data.gdipBrush, x, y, width, height); |
2912 |
return; |
3098 |
return; |
Lines 2944-2949
Link Here
|
2944 |
if (path.handle == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); |
3130 |
if (path.handle == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); |
2945 |
initGdip(); |
3131 |
initGdip(); |
2946 |
checkGC(FILL); |
3132 |
checkGC(FILL); |
|
|
3133 |
endDrawDirect2D(); |
2947 |
int mode = OS.GetPolyFillMode(handle) == OS.WINDING ? Gdip.FillModeWinding : Gdip.FillModeAlternate; |
3134 |
int mode = OS.GetPolyFillMode(handle) == OS.WINDING ? Gdip.FillModeWinding : Gdip.FillModeAlternate; |
2948 |
Gdip.GraphicsPath_SetFillMode(path.handle, mode); |
3135 |
Gdip.GraphicsPath_SetFillMode(path.handle, mode); |
2949 |
Gdip.Graphics_FillPath(data.gdipGraphics, data.gdipBrush, path.handle); |
3136 |
Gdip.Graphics_FillPath(data.gdipGraphics, data.gdipBrush, path.handle); |
Lines 2972-2977
Link Here
|
2972 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
3159 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
2973 |
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); |
3160 |
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); |
2974 |
checkGC(FILL); |
3161 |
checkGC(FILL); |
|
|
3162 |
endDrawDirect2D(); |
2975 |
if (data.gdipGraphics != 0) { |
3163 |
if (data.gdipGraphics != 0) { |
2976 |
int mode = OS.GetPolyFillMode(handle) == OS.WINDING ? Gdip.FillModeWinding : Gdip.FillModeAlternate; |
3164 |
int mode = OS.GetPolyFillMode(handle) == OS.WINDING ? Gdip.FillModeWinding : Gdip.FillModeAlternate; |
2977 |
Gdip.Graphics_FillPolygon(data.gdipGraphics, data.gdipBrush, pointArray, pointArray.length / 2, mode); |
3165 |
Gdip.Graphics_FillPolygon(data.gdipGraphics, data.gdipBrush, pointArray, pointArray.length / 2, mode); |
Lines 3008-3013
Link Here
|
3008 |
public void fillRectangle (int x, int y, int width, int height) { |
3196 |
public void fillRectangle (int x, int y, int width, int height) { |
3009 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
3197 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
3010 |
checkGC(FILL); |
3198 |
checkGC(FILL); |
|
|
3199 |
endDrawDirect2D(); |
3011 |
if (data.gdipGraphics != 0) { |
3200 |
if (data.gdipGraphics != 0) { |
3012 |
if (width < 0) { |
3201 |
if (width < 0) { |
3013 |
x = x + width; |
3202 |
x = x + width; |
Lines 3071-3076
Link Here
|
3071 |
public void fillRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) { |
3260 |
public void fillRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) { |
3072 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
3261 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
3073 |
checkGC(FILL); |
3262 |
checkGC(FILL); |
|
|
3263 |
endDrawDirect2D(); |
3074 |
if (data.gdipGraphics != 0) { |
3264 |
if (data.gdipGraphics != 0) { |
3075 |
fillRoundRectangleGdip(data.gdipGraphics, data.gdipBrush, x, y, width, height, arcWidth, arcHeight); |
3265 |
fillRoundRectangleGdip(data.gdipGraphics, data.gdipBrush, x, y, width, height, arcWidth, arcHeight); |
3076 |
return; |
3266 |
return; |
Lines 3160-3165
Link Here
|
3160 |
public int getAdvanceWidth(char ch) { |
3350 |
public int getAdvanceWidth(char ch) { |
3161 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
3351 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
3162 |
checkGC(FONT); |
3352 |
checkGC(FONT); |
|
|
3353 |
|
3163 |
if (OS.IsWinCE) { |
3354 |
if (OS.IsWinCE) { |
3164 |
SIZE size = new SIZE(); |
3355 |
SIZE size = new SIZE(); |
3165 |
OS.GetTextExtentPoint32W(handle, new char[]{ch}, 1, size); |
3356 |
OS.GetTextExtentPoint32W(handle, new char[]{ch}, 1, size); |
Lines 4075-4080
Link Here
|
4075 |
if (advanced && data.gdipGraphics != 0) return; |
4266 |
if (advanced && data.gdipGraphics != 0) return; |
4076 |
if (advanced) { |
4267 |
if (advanced) { |
4077 |
try { |
4268 |
try { |
|
|
4269 |
initDirect2D(); |
4078 |
initGdip(); |
4270 |
initGdip(); |
4079 |
} catch (SWTException e) {} |
4271 |
} catch (SWTException e) {} |
4080 |
} else { |
4272 |
} else { |
Lines 4134-4139
Link Here
|
4134 |
default: |
4326 |
default: |
4135 |
SWT.error(SWT.ERROR_INVALID_ARGUMENT); |
4327 |
SWT.error(SWT.ERROR_INVALID_ARGUMENT); |
4136 |
} |
4328 |
} |
|
|
4329 |
if (OS.IsWin7) initDirect2D(); |
4137 |
initGdip(); |
4330 |
initGdip(); |
4138 |
Gdip.Graphics_SetSmoothingMode(data.gdipGraphics, mode); |
4331 |
Gdip.Graphics_SetSmoothingMode(data.gdipGraphics, mode); |
4139 |
} |
4332 |
} |
Lines 4618-4623
Link Here
|
4618 |
data.lineDashesOffset = dashOffset; |
4811 |
data.lineDashesOffset = dashOffset; |
4619 |
data.lineMiterLimit = miterLimit; |
4812 |
data.lineMiterLimit = miterLimit; |
4620 |
data.state &= ~mask; |
4813 |
data.state &= ~mask; |
|
|
4814 |
|
4815 |
initDirect2D(); |
4816 |
if (OS.IsWin7 && data.direct2DRenderTarget != 0) { |
4817 |
data.direct2DStartCap = cap; |
4818 |
data.direct2DEndCap = cap; |
4819 |
data.direct2DDashCap = cap; |
4820 |
data.direct2DLineJoin = join; |
4821 |
if (dashes != null) data.direct2DDashes = dashes; |
4822 |
data.direct2DDashOffset = dashOffset; |
4823 |
data.direct2DMiterLimit = miterLimit; |
4824 |
data.direct2DlineWidth = lineWidth; |
4825 |
} |
4621 |
} |
4826 |
} |
4622 |
|
4827 |
|
4623 |
/** |
4828 |
/** |
Lines 4780-4785
Link Here
|
4780 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
4985 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
4781 |
if (data.lineWidth == lineWidth) return; |
4986 |
if (data.lineWidth == lineWidth) return; |
4782 |
data.lineWidth = lineWidth; |
4987 |
data.lineWidth = lineWidth; |
|
|
4988 |
data.direct2DlineWidth = lineWidth; |
4783 |
data.state &= ~(LINE_WIDTH | DRAW_OFFSET); |
4989 |
data.state &= ~(LINE_WIDTH | DRAW_OFFSET); |
4784 |
} |
4990 |
} |
4785 |
|
4991 |
|
Lines 4927-4932
Link Here
|
4927 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
5133 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
4928 |
if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); |
5134 |
if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); |
4929 |
checkGC(FONT); |
5135 |
checkGC(FONT); |
|
|
5136 |
endDrawDirect2D(); |
4930 |
int length = string.length(); |
5137 |
int length = string.length(); |
4931 |
int /*long*/ gdipGraphics = data.gdipGraphics; |
5138 |
int /*long*/ gdipGraphics = data.gdipGraphics; |
4932 |
if (gdipGraphics != 0) { |
5139 |
if (gdipGraphics != 0) { |
Lines 5006-5011
Link Here
|
5006 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
5213 |
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
5007 |
if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); |
5214 |
if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); |
5008 |
checkGC(FONT); |
5215 |
checkGC(FONT); |
|
|
5216 |
endDrawDirect2D(); |
5009 |
int /*long*/ gdipGraphics = data.gdipGraphics; |
5217 |
int /*long*/ gdipGraphics = data.gdipGraphics; |
5010 |
if (gdipGraphics != 0) { |
5218 |
if (gdipGraphics != 0) { |
5011 |
Point size = new Point(0, 0); |
5219 |
Point size = new Point(0, 0); |