View | Details | Raw Unified | Return to bug 300403 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse SWT PI/win32/library/gdip.cpp (-1 / +187 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 12-20 Link Here
12
#include "swt.h"
12
#include "swt.h"
13
#include "gdip_structs.h"
13
#include "gdip_structs.h"
14
#include "gdip_stats.h"
14
#include "gdip_stats.h"
15
#include <d2d1.h>
16
#include <d2d1helper.h>
15
17
16
#define Gdip_NATIVE(func) Java_org_eclipse_swt_internal_gdip_Gdip_##func
18
#define Gdip_NATIVE(func) Java_org_eclipse_swt_internal_gdip_Gdip_##func
17
19
20
#ifndef NO_Direct2DRenderTarget_1Rotate
21
extern "C" JNIEXPORT void JNICALL Gdip_NATIVE(Direct2DRenderTarget_1Rotate)(JNIEnv *env, jclass that, jintLong m_pDCRT, jfloat angle);
22
JNIEXPORT void JNICALL Gdip_NATIVE(Direct2DRenderTarget_1Rotate)
23
	(JNIEnv *env, jclass that, jintLong m_pDCRT, jfloat angle)
24
{
25
	((ID2D1DCRenderTarget*)m_pDCRT)->SetTransform(
26
	        D2D1::Matrix3x2F::Rotation(
27
	            angle,
28
	            D2D1::Point2F(0, 0))
29
	        );
30
}
31
#endif
32
33
#ifndef NO_Direct2D_RenderTarget_1Scale
34
extern "C" JNIEXPORT void JNICALL Gdip_NATIVE(Direct2DRenderTarget_1Scale)(JNIEnv *env, jclass that, jintLong m_pDCRT, jfloat sizeX, jfloat sizeY);
35
JNIEXPORT void JNICALL Gdip_NATIVE(Direct2DRenderTarget_1Scale)
36
	(JNIEnv *env, jclass that, jintLong m_pDCRT, jfloat sizeX, jfloat sizeY)
37
{
38
	((ID2D1DCRenderTarget*)m_pDCRT)->SetTransform(
39
	        D2D1::Matrix3x2F::Scale(
40
	            D2D1::Size(sizeX, sizeY),
41
	            D2D1::Point2F(0, 0))
42
	        );
43
}
44
#endif
45
46
#ifndef NO_Direct2D_RenderTarget_1Screw
47
extern "C" JNIEXPORT void JNICALL Gdip_NATIVE(Direct2DRenderTarget_1Screw)(JNIEnv *env, jclass that, jintLong m_pDCRT, jfloat angleX, jfloat angleY);
48
JNIEXPORT void JNICALL Gdip_NATIVE(Direct2DRenderTarget_1Screw)
49
	(JNIEnv *env, jclass that, jintLong m_pDCRT, jfloat angleX, jfloat angleY)
50
{
51
	((ID2D1DCRenderTarget*)m_pDCRT)->SetTransform(
52
	        D2D1::Matrix3x2F::Skew(
53
	        	angleX,
54
	            angleY,
55
	            D2D1::Point2F(0, 0))
56
	        );
57
}
58
#endif
59
60
#ifndef NO_Direct2D_RenderTarget_1Translation
61
extern "C" JNIEXPORT void JNICALL Gdip_NATIVE(Direct2DRenderTarget_1Translation)(JNIEnv *env, jclass that, jintLong m_pDCRT, jfloat moveX, jfloat moveY);
62
JNIEXPORT void JNICALL Gdip_NATIVE(Direct2DRenderTarget_1Translation)
63
	(JNIEnv *env, jclass that, jintLong m_pDCRT, jfloat moveX, jfloat moveY)
64
{
65
	((ID2D1DCRenderTarget*)m_pDCRT)->SetTransform(D2D1::Matrix3x2F::Translation(moveX, moveY));
66
}
67
#endif
68
69
#ifndef NO_Direct2D_1SafeRelease
70
extern "C" JNIEXPORT void JNICALL Gdip_NATIVE(Direct2D_1SafeRelease)(JNIEnv *env, jclass that, jintLong ppInterfaceToRelease);
71
JNIEXPORT void JNICALL Gdip_NATIVE(Direct2D_1SafeRelease)
72
	(JNIEnv *env, jclass that, jintLong ppInterfaceToRelease)
73
{
74
	if (((IUnknown*)ppInterfaceToRelease) != NULL)
75
	{
76
		((IUnknown*)ppInterfaceToRelease)->Release();
77
		ppInterfaceToRelease = NULL;
78
	}
79
}
80
#endif
81
82
#ifndef NO_Direct2DStrokeStyle_1new
83
extern "C" JNIEXPORT jintLong JNICALL Gdip_NATIVE(Direct2DStrokeStyle_1new)(JNIEnv *env, jclass that, jintLong m_pD2DFactory, jintLong strokeStyle, jint startCap, jint endCap, jint dashCap, jint lineJoin, jfloat miterLimit, jint dashStyle, jfloat dashOffset, jfloatArray dashes);
84
JNIEXPORT jintLong JNICALL Gdip_NATIVE(Direct2DStrokeStyle_1new)
85
	(JNIEnv *env, jclass that, jintLong m_pD2DFactory, jintLong strokeStyle, jint startCap, jint endCap, jint dashCap, jint lineJoin, jfloat miterLimit, jint dashStyle, jfloat dashOffset, jfloatArray dashes)
86
{
87
	jfloat *lparg1=NULL;
88
	ID2D1StrokeStyle* m_strokeStyle;
89
	lparg1 = env->GetFloatArrayElements(dashes, NULL);
90
	//if (dashes) if ((lparg1 = env->GetFloatArrayElements(dashes, NULL)) == NULL) goto fail;
91
	((ID2D1Factory*)m_pD2DFactory)->CreateStrokeStyle(
92
		D2D1::StrokeStyleProperties(
93
				(D2D1_CAP_STYLE)startCap,
94
				(D2D1_CAP_STYLE)endCap,
95
				(D2D1_CAP_STYLE)dashCap,
96
				(D2D1_LINE_JOIN)lineJoin,
97
				miterLimit,
98
				(D2D1_DASH_STYLE)dashStyle,
99
				dashOffset),
100
				0,
101
				0,
102
		&m_strokeStyle
103
		);
104
105
	if (dashes && lparg1) env->ReleaseFloatArrayElements(dashes, lparg1, 0);
106
	return (jintLong)m_strokeStyle;
107
}
108
#endif
109
110
#ifndef NO_Direct2D_1CreateFactory
111
extern "C" JNIEXPORT jintLong JNICALL Gdip_NATIVE(Direct2D_1CreateFactory)(JNIEnv *env, jclass that);
112
JNIEXPORT jintLong JNICALL Gdip_NATIVE(Direct2D_1CreateFactory)
113
	(JNIEnv *env, jclass that)
114
{
115
	ID2D1Factory* m_pD2DFactory;
116
	D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &m_pD2DFactory);
117
	return (jintLong)m_pD2DFactory;
118
}
119
#endif
120
121
#ifndef NO_Direct2DFactory_1CreateDCRenderTarget
122
extern "C" JNIEXPORT jintLong JNICALL Gdip_NATIVE(Direct2DFactory_1CreateDCRenderTarget)(JNIEnv *env, jclass that, jintLong m_pD2DFactory);
123
JNIEXPORT jintLong JNICALL Gdip_NATIVE(Direct2DFactory_1CreateDCRenderTarget)
124
	(JNIEnv *env, jclass that,  jintLong m_pD2DFactory)
125
{
126
	D2D1_RENDER_TARGET_PROPERTIES props = D2D1::RenderTargetProperties(
127
				D2D1_RENDER_TARGET_TYPE_DEFAULT,
128
				D2D1::PixelFormat(
129
					DXGI_FORMAT_B8G8R8A8_UNORM,
130
					D2D1_ALPHA_MODE_IGNORE),
131
				0,
132
				0,
133
				D2D1_RENDER_TARGET_USAGE_NONE,
134
				D2D1_FEATURE_LEVEL_DEFAULT
135
				);
136
137
	ID2D1DCRenderTarget* m_pDCRT;
138
	((ID2D1Factory*)m_pD2DFactory)->CreateDCRenderTarget(&props, &m_pDCRT);
139
	return (jintLong)m_pDCRT;
140
}
141
#endif
142
143
#ifndef NO_Direct2DRenderTarget_1BindDC
144
extern "C" JNIEXPORT void JNICALL Gdip_NATIVE(Direct2DRenderTarget_1BindDC)(JNIEnv *env, jclass that, jintLong m_pDCRT, jintLong hdc, jint width, jint height);
145
JNIEXPORT void JNICALL Gdip_NATIVE(Direct2DRenderTarget_1BindDC)
146
	(JNIEnv *env, jclass that, jintLong m_pDCRT, jintLong hdc, jint width, jint height)
147
{
148
	RECT rect;
149
	rect.top = 0;
150
	rect.bottom = (int)height;
151
	rect.left = 0;
152
	rect.right = (int)width;
153
	((ID2D1DCRenderTarget*)m_pDCRT)->BindDC((HDC)hdc, &rect);
154
}
155
#endif
156
157
#ifndef NO_Direct2DRenderTarget_1BeginDraw
158
extern "C" JNIEXPORT void JNICALL Gdip_NATIVE(Direct2DRenderTarget_1BeginDraw)(JNIEnv *env, jclass that, jintLong m_pDCRT);
159
JNIEXPORT void JNICALL Gdip_NATIVE(Direct2DRenderTarget_1BeginDraw)
160
	(JNIEnv *env, jclass that, jintLong m_pDCRT)
161
{
162
	((ID2D1DCRenderTarget*)m_pDCRT)->BeginDraw();
163
}
164
#endif
165
166
#ifndef NO_Direct2DRenderTarget_1SolidBrush
167
extern "C" JNIEXPORT jintLong JNICALL Gdip_NATIVE(Direct2DRenderTarget_1SolidBrush)(JNIEnv *env, jclass that, jintLong m_pDCRT, jint color);
168
JNIEXPORT jintLong JNICALL Gdip_NATIVE(Direct2DRenderTarget_1SolidBrush)
169
	(JNIEnv *env, jclass that, jintLong m_pDCRT, jint color)
170
{
171
	ID2D1SolidColorBrush* brush;
172
	((ID2D1DCRenderTarget*)m_pDCRT)->CreateSolidColorBrush(D2D1::ColorF(color), &brush);
173
	return (jintLong)brush;
174
}
175
#endif
176
177
#ifndef NO_Direct2DRenderTarget_1DrawLine
178
extern "C" JNIEXPORT void JNICALL Gdip_NATIVE(Direct2DRenderTarget_1DrawLine)(JNIEnv *env, jclass that, jintLong m_pDCRT, jintLong brush, jfloat x0, jfloat y0, jfloat x1, jfloat y1, jfloat lineWidth);
179
JNIEXPORT void JNICALL Gdip_NATIVE(Direct2DRenderTarget_1DrawLine)
180
	(JNIEnv *env, jclass that, jintLong m_pDCRT, jintLong brush, jfloat x0, jfloat y0, jfloat x1, jfloat y1, jfloat lineWidth)
181
{
182
	((ID2D1DCRenderTarget*)m_pDCRT)->DrawLine(D2D1::Point2F(x0, y0), D2D1::Point2F(x1, y1), (ID2D1SolidColorBrush*)brush, lineWidth);
183
}
184
#endif
185
186
#ifndef NO_Direct2DRenderTarget_1DrawLineStroke
187
extern "C" JNIEXPORT void JNICALL Gdip_NATIVE(Direct2DRenderTarget_1DrawLineStroke)(JNIEnv *env, jclass that, jintLong m_pDCRT, jintLong brush, jfloat x0, jfloat y0, jfloat x1, jfloat y1, jfloat lineWidth, jintLong stroke);
188
JNIEXPORT void JNICALL Gdip_NATIVE(Direct2DRenderTarget_1DrawLineStroke)
189
	(JNIEnv *env, jclass that, jintLong m_pDCRT, jintLong brush, jfloat x0, jfloat y0, jfloat x1, jfloat y1, jfloat lineWidth, jintLong stroke)
190
{
191
	((ID2D1DCRenderTarget*)m_pDCRT)->DrawLine(D2D1::Point2F(x0, y0), D2D1::Point2F(x1, y1), (ID2D1SolidColorBrush*)brush, lineWidth, (ID2D1StrokeStyle*)stroke);
192
}
193
#endif
194
195
#ifndef NO_Direct2DRenderTarget_1EndDraw
196
extern "C" JNIEXPORT void JNICALL Gdip_NATIVE(Direct2DRenderTarget_1EndDraw)(JNIEnv *env, jclass that, jintLong m_pDCRT);
197
JNIEXPORT void JNICALL Gdip_NATIVE(Direct2DRenderTarget_1EndDraw)
198
	(JNIEnv *env, jclass that, jintLong m_pDCRT)
199
{
200
	((ID2D1DCRenderTarget*)m_pDCRT)->EndDraw();
201
}
202
#endif
203
18
#ifndef NO_BitmapData_1delete
204
#ifndef NO_BitmapData_1delete
19
extern "C" JNIEXPORT void JNICALL Gdip_NATIVE(BitmapData_1delete)(JNIEnv *env, jclass that, jintLong arg0);
205
extern "C" JNIEXPORT void JNICALL Gdip_NATIVE(BitmapData_1delete)(JNIEnv *env, jclass that, jintLong arg0);
20
JNIEXPORT void JNICALL Gdip_NATIVE(BitmapData_1delete)
206
JNIEXPORT void JNICALL Gdip_NATIVE(BitmapData_1delete)
(-)Eclipse SWT PI/win32/library/gdip_stats.cpp (-3 / +17 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 14-21 Link Here
14
14
15
#ifdef NATIVE_STATS
15
#ifdef NATIVE_STATS
16
16
17
int Gdip_nativeFunctionCount = 186;
17
int Gdip_nativeFunctionCount = 200;
18
int Gdip_nativeFunctionCallCount[186];
18
int Gdip_nativeFunctionCallCount[200];
19
char * Gdip_nativeFunctionNames[] = {
19
char * Gdip_nativeFunctionNames[] = {
20
	"BitmapData_1delete",
20
	"BitmapData_1delete",
21
	"BitmapData_1new",
21
	"BitmapData_1new",
Lines 45-50 Link Here
45
	"ColorPalette_1sizeof",
45
	"ColorPalette_1sizeof",
46
	"Color_1delete",
46
	"Color_1delete",
47
	"Color_1new",
47
	"Color_1new",
48
	"Direct2DFactory_1CreateDCRenderTarget",
49
	"Direct2DRenderTarget_1BeginDraw",
50
	"Direct2DRenderTarget_1BindDC",
51
	"Direct2DRenderTarget_1DrawLine",
52
	"Direct2DRenderTarget_1DrawLineStroke",
53
	"Direct2DRenderTarget_1EndDraw",
54
	"Direct2DRenderTarget_1Rotate",
55
	"Direct2DRenderTarget_1Scale",
56
	"Direct2DRenderTarget_1Screw",
57
	"Direct2DRenderTarget_1SolidBrush",
58
	"Direct2DRenderTarget_1Translation",
59
	"Direct2DStrokeStyle_1new",
60
	"Direct2D_1CreateFactory",
61
	"Direct2D_1SafeRelease",
48
	"FontFamily_1GetFamilyName",
62
	"FontFamily_1GetFamilyName",
49
	"FontFamily_1IsAvailable",
63
	"FontFamily_1IsAvailable",
50
	"FontFamily_1delete",
64
	"FontFamily_1delete",
(-)Eclipse SWT PI/win32/library/gdip_stats.h (-1 / +15 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 53-58 Link Here
53
	ColorPalette_1sizeof_FUNC,
53
	ColorPalette_1sizeof_FUNC,
54
	Color_1delete_FUNC,
54
	Color_1delete_FUNC,
55
	Color_1new_FUNC,
55
	Color_1new_FUNC,
56
	Direct2DFactory_1CreateDCRenderTarget_FUNC,
57
	Direct2DRenderTarget_1BeginDraw_FUNC,
58
	Direct2DRenderTarget_1BindDC_FUNC,
59
	Direct2DRenderTarget_1DrawLine_FUNC,
60
	Direct2DRenderTarget_1DrawLineStroke_FUNC,
61
	Direct2DRenderTarget_1EndDraw_FUNC,
62
	Direct2DRenderTarget_1Rotate_FUNC,
63
	Direct2DRenderTarget_1Scale_FUNC,
64
	Direct2DRenderTarget_1Screw_FUNC,
65
	Direct2DRenderTarget_1SolidBrush_FUNC,
66
	Direct2DRenderTarget_1Translation_FUNC,
67
	Direct2DStrokeStyle_1new_FUNC,
68
	Direct2D_1CreateFactory_FUNC,
69
	Direct2D_1SafeRelease_FUNC,
56
	FontFamily_1GetFamilyName_FUNC,
70
	FontFamily_1GetFamilyName_FUNC,
57
	FontFamily_1IsAvailable_FUNC,
71
	FontFamily_1IsAvailable_FUNC,
58
	FontFamily_1delete_FUNC,
72
	FontFamily_1delete_FUNC,
(-)Eclipse SWT PI/win32/org/eclipse/swt/internal/gdip/Gdip.java (+88 lines)
Lines 36-41 Link Here
36
	public static final int FillModeAlternate = 0;
36
	public static final int FillModeAlternate = 0;
37
	public static final int FillModeWinding = 1;
37
	public static final int FillModeWinding = 1;
38
	public static final int DashCapFlat = 0;
38
	public static final int DashCapFlat = 0;
39
	public static final int DashCapSquare = 1;
39
	public static final int DashCapRound = 2;
40
	public static final int DashCapRound = 2;
40
	public static final int DashCapTriangle = 3;
41
	public static final int DashCapTriangle = 3;
41
	public static final int DashStyleSolid = 0;
42
	public static final int DashStyleSolid = 0;
Lines 161-166 Link Here
161
 * @param hicon cast=(HICON)
162
 * @param hicon cast=(HICON)
162
 */
163
 */
163
public static final native int /*long*/ Bitmap_new(int /*long*/ hicon);
164
public static final native int /*long*/ Bitmap_new(int /*long*/ hicon);
165
166
/**
167
 * @method flags=cpp no_gen
168
 */
169
public static final native int Direct2D_CreateFactory();
170
171
/**
172
 * @method flags=cpp no_gen
173
 * @param m_pD2DFactory cast=(ID2D1Factory)
174
 */
175
public static final native int Direct2DFactory_CreateDCRenderTarget(int /*long*/ m_pD2DFactory);
176
177
/**
178
 * @method flags=cpp no_gen
179
 * @param m_pDCRT cast=(ID2D1DCRenderTarget)
180
 * @param hdc cast=(HDC)
181
 */
182
public static final native void Direct2DRenderTarget_BindDC(int /*long*/ m_pDCRT, int /*long*/ hdc, int width, int height);
183
184
/**
185
 * @method flags=cpp no_gen
186
 * @param m_pDCRT cast=(ID2D1DCRenderTarget)
187
 */
188
public static final native void Direct2DRenderTarget_BeginDraw(int /*long*/ m_pDCRT);
189
190
/**
191
 * @method flags=cpp no_gen
192
 * @param m_pDCRT cast=(ID2D1DCRenderTarget)
193
 */
194
public static final native int Direct2DRenderTarget_SolidBrush(int /*long*/ m_pDCRT, int color);
195
196
/**
197
 * @method flags=cpp no_gen
198
 * @param m_pDCRT cast=(ID2D1DCRenderTarget)
199
 */
200
public static final native void Direct2DRenderTarget_Rotate(int /*long*/ m_pDCRT, float angle);
201
202
/**
203
 * @method flags=cpp no_gen
204
 * @param m_pDCRT cast=(ID2D1DCRenderTarget)
205
 */
206
public static final native void Direct2DRenderTarget_Scale(int /*long*/ m_pDCRT, float sizeX, float sizeY);
207
208
/**
209
 * @method flags=cpp no_gen
210
 * @param m_pDCRT cast=(ID2D1DCRenderTarget)
211
 */
212
public static final native void Direct2DRenderTarget_Screw(int /*long*/ m_pDCRT, float angleX, float angleY);
213
214
/**
215
 * @method flags=cpp no_gen
216
 * @param m_pDCRT cast=(ID2D1DCRenderTarget)
217
 */
218
public static final native void Direct2DRenderTarget_Translation(int /*long*/ m_pDCRT, float moveX, float moveY);
219
220
/**
221
 * @method flags=cpp no_gen
222
 * @param m_pDCRT cast=(ID2D1DCRenderTarget)
223
 */
224
public static final native int Direct2DStrokeStyle_new(int /*long*/ factory, int /*long*/ strokeStyle, int direct2D_startCap, int endCap, int dashCap, int lineJoin, float miterLimit, int dashStyle, float dashOffset, float[] dashes);
225
226
/**
227
 * @method flags=cpp no_gen
228
 * @param m_pDCRT cast=(ID2D1DCRenderTarget)
229
 */
230
public static final native void Direct2D_SafeRelease(int /*long*/ ppInterfaceToRelease);
231
232
/**
233
 * @method flags=cpp no_gen
234
 * @param m_pDCRT cast=(ID2D1DCRenderTarget)
235
 * @param brush cast=(ID2D1SolidColorBrush)
236
 */
237
public static final native void Direct2DRenderTarget_DrawLine(int /*long*/ m_pDCRT, int /*long*/ brush, float x0, float y0, float x1, float y1, float width);
238
239
/**
240
 * @method flags=cpp no_gen
241
 * @param m_pDCRT cast=(ID2D1DCRenderTarget)
242
 * @param brush cast=(ID2D1SolidColorBrush)
243
 */
244
public static final native void Direct2DRenderTarget_DrawLineStroke(int /*long*/ m_pDCRT, int /*long*/ brush, float x0, float y0, float x1, float y1, float width, int /*long*/ stroke);
245
246
/**
247
 * @method flags=cpp no_gen
248
 * @param m_pDCRT cast=(ID2D1DCRenderTarget)
249
 */
250
public static final native void Direct2DRenderTarget_EndDraw(int /*long*/ m_pDCRT);
251
164
/**
252
/**
165
 * @method flags=new
253
 * @method flags=new
166
 * @param format cast=(PixelFormat)
254
 * @param format cast=(PixelFormat)
(-)Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java (+4 lines)
Lines 25-30 Link Here
25
	public static final boolean IsWin95;
25
	public static final boolean IsWin95;
26
	public static final boolean IsWinNT;
26
	public static final boolean IsWinNT;
27
	public static final boolean IsWinCE;
27
	public static final boolean IsWinCE;
28
	public static final boolean IsWin7;
28
	public static final boolean IsPPC;
29
	public static final boolean IsPPC;
29
	public static final boolean IsHPC;
30
	public static final boolean IsHPC;
30
	public static final boolean IsSP;
31
	public static final boolean IsSP;
Lines 89-94 Link Here
89
		WIN32_MINOR = info.dwMinorVersion;
90
		WIN32_MINOR = info.dwMinorVersion;
90
		WIN32_VERSION = VERSION (WIN32_MAJOR, WIN32_MINOR);
91
		WIN32_VERSION = VERSION (WIN32_MAJOR, WIN32_MINOR);
91
		IsUnicode = !IsWin32s && !IsWin95;
92
		IsUnicode = !IsWin32s && !IsWin95;
93
		
94
		/* Check if it is Windows 7 to provide Direct2D support */
95
		IsWin7 = OS.WIN32_VERSION >= OS.VERSION (6, 1) ? true : false;
92
96
93
		/* Load the manifest to force the XP Theme */
97
		/* Load the manifest to force the XP Theme */
94
		if (System.getProperty (NO_MANIFEST) == null) {
98
		if (System.getProperty (NO_MANIFEST) == null) {
(-)Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java (-2 / +210 lines)
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);
(-)Eclipse SWT/win32/org/eclipse/swt/graphics/GCData.java (+14 lines)
Lines 61-64 Link Here
61
	public float gdipXOffset, gdipYOffset;
61
	public float gdipXOffset, gdipYOffset;
62
	public int uiState = 0;
62
	public int uiState = 0;
63
	public boolean focusDrawn;
63
	public boolean focusDrawn;
64
	
65
	public int /*long*/ direct2DRenderTarget;
66
	int /*long*/ direct2DBrush;
67
	int /*long*/ direct2DStrokeStyle;
68
	int /*long*/ direct2DFactory;
69
	float direct2DlineWidth = 1;
70
	int direct2DStartCap =  0;
71
	int direct2DEndCap =  0;
72
	int direct2DDashCap =  0;
73
	int direct2DLineJoin =  0;
74
	float direct2DMiterLimit = 10.0f;
75
	int direct2DDashStyle =  0;
76
    float direct2DDashOffset = 0.0f;
77
    float[] direct2DDashes = new float[0];
64
}
78
}

Return to bug 300403