Commit 3ade5832 authored by Roman Sedaikin's avatar Roman Sedaikin

Fixed some performance issues in Windows OS.

parent 23758260
...@@ -22,6 +22,7 @@ public: ...@@ -22,6 +22,7 @@ public:
jobject windowRef; jobject windowRef;
HGLRC context; HGLRC context;
HWND handler; HWND handler;
HDC device;
void update() void update()
{ {
...@@ -32,6 +33,7 @@ public: ...@@ -32,6 +33,7 @@ public:
{ {
context = NULL; context = NULL;
handler = NULL; handler = NULL;
device = NULL;
} }
private: private:
...@@ -41,47 +43,19 @@ private: ...@@ -41,47 +43,19 @@ private:
{ {
JNIEnv *env; JNIEnv *env;
jvm->GetEnv((void **)&env, JNI_VERSION_10); jvm->GetEnv((void **)&env, JNI_VERSION_10);
JAWT awt;
JAWT_DrawingSurface *ds = NULL;
JAWT_DrawingSurfaceInfo *dsi = NULL;
jboolean result = JNI_FALSE;
jint lock = 0;
JAWT_Win32DrawingSurfaceInfo *dsi_win;
awt.version = (jint)JAWT_VERSION_9;
result = Skiko_GetAWT(env, &awt);
if (result == JNI_FALSE)
{
fprintf(stderr, "JAWT_GetAWT failed! Result is JNI_FALSE\n");
return;
}
ds = awt.GetDrawingSurface(env, windowRef); wglMakeCurrent(device, context);
lock = ds->Lock(ds); jclass wndClass = env->GetObjectClass(windowRef);
dsi = ds->GetDrawingSurfaceInfo(ds); jmethodID drawMethod = env->GetMethodID(wndClass, "draw", "()V");
dsi_win = (JAWT_Win32DrawingSurfaceInfo *)dsi->platformInfo; if (NULL == drawMethod)
HWND hwnd = dsi_win->hwnd;
HDC hdc = GetDC(hwnd);
if (dsi != NULL)
{ {
jvm->AttachCurrentThread((void **)&env, NULL); fprintf(stderr, "The method Window.draw() not found!\n");
return;
wglMakeCurrent(hdc, context);
jclass wndClass = env->GetObjectClass(windowRef);
jmethodID drawMethod = env->GetMethodID(wndClass, "draw", "()V");
if (NULL == drawMethod)
{
fprintf(stderr, "The method Window.draw() not found!\n");
return;
}
env->CallVoidMethod(windowRef, drawMethod);
glFinish();
SwapBuffers(hdc);
} }
ds->FreeDrawingSurfaceInfo(dsi); env->CallVoidMethod(windowRef, drawMethod);
ds->Unlock(ds); glFinish();
awt.FreeDrawingSurface(ds); wglMakeCurrent(device, NULL);
SwapBuffers(device);
} }
} }
}; };
...@@ -197,7 +171,7 @@ extern "C" ...@@ -197,7 +171,7 @@ extern "C"
dsi_win = (JAWT_Win32DrawingSurfaceInfo *)dsi->platformInfo; dsi_win = (JAWT_Win32DrawingSurfaceInfo *)dsi->platformInfo;
HWND hwnd = dsi_win->hwnd; HWND hwnd = dsi_win->hwnd;
HDC wndHandler = GetDC(hwnd); HDC device = GetDC(hwnd);
if (dsi != NULL) if (dsi != NULL)
{ {
...@@ -208,10 +182,10 @@ extern "C" ...@@ -208,10 +182,10 @@ extern "C"
pixFormatDscr.iPixelType = PFD_TYPE_RGBA; pixFormatDscr.iPixelType = PFD_TYPE_RGBA;
pixFormatDscr.cColorBits = 32; pixFormatDscr.cColorBits = 32;
int iPixelFormat = ChoosePixelFormat(wndHandler, &pixFormatDscr); int iPixelFormat = ChoosePixelFormat(device, &pixFormatDscr);
SetPixelFormat(wndHandler, iPixelFormat, &pixFormatDscr); SetPixelFormat(device, iPixelFormat, &pixFormatDscr);
DescribePixelFormat(wndHandler, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pixFormatDscr); DescribePixelFormat(device, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pixFormatDscr);
context = wglCreateContext(wndHandler); context = wglCreateContext(device);
LayersSet *layer = new LayersSet(); LayersSet *layer = new LayersSet();
windowsSet->insert(layer); windowsSet->insert(layer);
...@@ -221,6 +195,7 @@ extern "C" ...@@ -221,6 +195,7 @@ extern "C"
layer->windowRef = windowRef; layer->windowRef = windowRef;
layer->context = context; layer->context = context;
layer->handler = hwnd; layer->handler = hwnd;
layer->device = device;
} }
ds->FreeDrawingSurfaceInfo(dsi); ds->FreeDrawingSurfaceInfo(dsi);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment