Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
skiko
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liuqiang
skiko
Commits
53de0626
Commit
53de0626
authored
Feb 03, 2021
by
Igor Demin
Committed by
Igor Demin
Feb 03, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JNI refactoring. Extract reinterpret_cast/static_cast to helper functions
parent
44e81329
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
51 additions
and
51 deletions
+51
-51
awt_jni.cc
skiko/src/jvmMain/cpp/common/awt_jni.cc
+14
-13
jni_helpers.h
skiko/src/jvmMain/cpp/common/jni_helpers.h
+7
-0
drawlayer.cc
skiko/src/jvmMain/cpp/linux/drawlayer.cc
+3
-4
redrawer.cc
skiko/src/jvmMain/cpp/linux/redrawer.cc
+16
-17
drawlayer.cc
skiko/src/jvmMain/cpp/windows/drawlayer.cc
+2
-3
redrawer.cc
skiko/src/jvmMain/cpp/windows/redrawer.cc
+9
-10
drawlayer.m
skiko/src/jvmMain/objectiveC/macos/drawlayer.m
+0
-2
redrawer.m
skiko/src/jvmMain/objectiveC/macos/redrawer.m
+0
-2
No files found.
skiko/src/jvmMain/cpp/common/awt_jni.cc
View file @
53de0626
#include <cstdint>
#include <cstdint>
#include <jawt_md.h>
#include <jawt_md.h>
#include "jni_helpers.h"
extern
"C"
jboolean
Skiko_GetAWT
(
JNIEnv
*
env
,
JAWT
*
awt
);
extern
"C"
jboolean
Skiko_GetAWT
(
JNIEnv
*
env
,
JAWT
*
awt
);
...
@@ -17,53 +18,53 @@ extern "C"
...
@@ -17,53 +18,53 @@ extern "C"
}
}
else
else
{
{
return
static_cast
<
jlong
>
(
reinterpret_cast
<
uintptr_t
>
(
awt
)
);
return
toJavaPointer
(
awt
);
}
}
}
}
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skiko_AWTKt_getDrawingSurface
(
JNIEnv
*
env
,
jobject
obj
,
jlong
awtPtr
,
jobject
layer
)
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skiko_AWTKt_getDrawingSurface
(
JNIEnv
*
env
,
jobject
obj
,
jlong
awtPtr
,
jobject
layer
)
{
{
JAWT
*
awt
=
reinterpret_cast
<
JAWT
*>
(
static_cast
<
uintptr_t
>
(
awtPtr
)
);
JAWT
*
awt
=
fromJavaPointer
<
JAWT
*>
(
awtPtr
);
JAWT_DrawingSurface
*
ds
=
awt
->
GetDrawingSurface
(
env
,
layer
);
JAWT_DrawingSurface
*
ds
=
awt
->
GetDrawingSurface
(
env
,
layer
);
return
static_cast
<
jlong
>
(
reinterpret_cast
<
uintptr_t
>
(
ds
)
);
return
toJavaPointer
(
ds
);
}
}
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skiko_AWTKt_freeDrawingSurface
(
JNIEnv
*
env
,
jobject
obj
,
jlong
awtPtr
,
jlong
drawingSurfacePtr
)
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skiko_AWTKt_freeDrawingSurface
(
JNIEnv
*
env
,
jobject
obj
,
jlong
awtPtr
,
jlong
drawingSurfacePtr
)
{
{
JAWT
*
awt
=
reinterpret_cast
<
JAWT
*>
(
static_cast
<
uintptr_t
>
(
awtPtr
)
);
JAWT
*
awt
=
fromJavaPointer
<
JAWT
*>
(
awtPtr
);
JAWT_DrawingSurface
*
ds
=
reinterpret_cast
<
JAWT_DrawingSurface
*>
(
static_cast
<
uintptr_t
>
(
drawingSurfacePtr
)
);
JAWT_DrawingSurface
*
ds
=
fromJavaPointer
<
JAWT_DrawingSurface
*>
(
drawingSurfacePtr
);
awt
->
FreeDrawingSurface
(
ds
);
awt
->
FreeDrawingSurface
(
ds
);
}
}
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skiko_AWTKt_lockDrawingSurface
(
JNIEnv
*
env
,
jobject
obj
,
jlong
drawingSurfacePtr
)
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skiko_AWTKt_lockDrawingSurface
(
JNIEnv
*
env
,
jobject
obj
,
jlong
drawingSurfacePtr
)
{
{
JAWT_DrawingSurface
*
ds
=
reinterpret_cast
<
JAWT_DrawingSurface
*>
(
static_cast
<
uintptr_t
>
(
drawingSurfacePtr
)
);
JAWT_DrawingSurface
*
ds
=
fromJavaPointer
<
JAWT_DrawingSurface
*>
(
drawingSurfacePtr
);
ds
->
Lock
(
ds
);
ds
->
Lock
(
ds
);
}
}
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skiko_AWTKt_unlockDrawingSurface
(
JNIEnv
*
env
,
jobject
obj
,
jlong
drawingSurfacePtr
)
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skiko_AWTKt_unlockDrawingSurface
(
JNIEnv
*
env
,
jobject
obj
,
jlong
drawingSurfacePtr
)
{
{
JAWT_DrawingSurface
*
ds
=
reinterpret_cast
<
JAWT_DrawingSurface
*>
(
static_cast
<
uintptr_t
>
(
drawingSurfacePtr
)
);
JAWT_DrawingSurface
*
ds
=
fromJavaPointer
<
JAWT_DrawingSurface
*>
(
drawingSurfacePtr
);
ds
->
Unlock
(
ds
);
ds
->
Unlock
(
ds
);
}
}
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skiko_AWTKt_getDrawingSurfaceInfo
(
JNIEnv
*
env
,
jobject
obj
,
jlong
drawingSurfacePtr
)
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skiko_AWTKt_getDrawingSurfaceInfo
(
JNIEnv
*
env
,
jobject
obj
,
jlong
drawingSurfacePtr
)
{
{
JAWT_DrawingSurface
*
ds
=
reinterpret_cast
<
JAWT_DrawingSurface
*>
(
static_cast
<
uintptr_t
>
(
drawingSurfacePtr
)
);
JAWT_DrawingSurface
*
ds
=
fromJavaPointer
<
JAWT_DrawingSurface
*>
(
drawingSurfacePtr
);
JAWT_DrawingSurfaceInfo
*
dsi
=
ds
->
GetDrawingSurfaceInfo
(
ds
);
JAWT_DrawingSurfaceInfo
*
dsi
=
ds
->
GetDrawingSurfaceInfo
(
ds
);
return
static_cast
<
jlong
>
(
reinterpret_cast
<
uintptr_t
>
(
dsi
)
);
return
toJavaPointer
(
dsi
);
}
}
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skiko_AWTKt_freeDrawingSurfaceInfo
(
JNIEnv
*
env
,
jobject
obj
,
jlong
drawingSurfacePtr
,
jlong
drawingSurfaceInfoPtr
)
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skiko_AWTKt_freeDrawingSurfaceInfo
(
JNIEnv
*
env
,
jobject
obj
,
jlong
drawingSurfacePtr
,
jlong
drawingSurfaceInfoPtr
)
{
{
JAWT_DrawingSurface
*
ds
=
reinterpret_cast
<
JAWT_DrawingSurface
*>
(
static_cast
<
uintptr_t
>
(
drawingSurfacePtr
)
);
JAWT_DrawingSurface
*
ds
=
fromJavaPointer
<
JAWT_DrawingSurface
*>
(
drawingSurfacePtr
);
JAWT_DrawingSurfaceInfo
*
dsi
=
reinterpret_cast
<
JAWT_DrawingSurfaceInfo
*>
(
static_cast
<
uintptr_t
>
(
drawingSurfaceInfoPtr
)
);
JAWT_DrawingSurfaceInfo
*
dsi
=
fromJavaPointer
<
JAWT_DrawingSurfaceInfo
*>
(
drawingSurfaceInfoPtr
);
ds
->
FreeDrawingSurfaceInfo
(
dsi
);
ds
->
FreeDrawingSurfaceInfo
(
dsi
);
}
}
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skiko_AWTKt_getPlatformInfo
(
JNIEnv
*
env
,
jobject
obj
,
jlong
drawingSurfaceInfoPtr
)
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skiko_AWTKt_getPlatformInfo
(
JNIEnv
*
env
,
jobject
obj
,
jlong
drawingSurfaceInfoPtr
)
{
{
JAWT_DrawingSurfaceInfo
*
dsi
=
reinterpret_cast
<
JAWT_DrawingSurfaceInfo
*>
(
static_cast
<
uintptr_t
>
(
drawingSurfaceInfoPtr
)
);
JAWT_DrawingSurfaceInfo
*
dsi
=
fromJavaPointer
<
JAWT_DrawingSurfaceInfo
*>
(
drawingSurfaceInfoPtr
);
return
static_cast
<
jlong
>
(
reinterpret_cast
<
uintptr_t
>
(
dsi
->
platformInfo
)
);
return
toJavaPointer
(
dsi
->
platformInfo
);
}
}
}
}
\ No newline at end of file
skiko/src/jvmMain/cpp/common/jni_helpers.h
0 → 100644
View file @
53de0626
#pragma once
template
<
typename
T
>
T
fromJavaPointer
(
jlong
ptr
)
{
return
reinterpret_cast
<
T
>
(
static_cast
<
uintptr_t
>
(
ptr
));
}
template
<
typename
T
>
jlong
toJavaPointer
(
T
ptr
)
{
return
static_cast
<
jlong
>
(
reinterpret_cast
<
uintptr_t
>
(
ptr
));
}
\ No newline at end of file
skiko/src/jvmMain/cpp/linux/drawlayer.cc
View file @
53de0626
...
@@ -7,11 +7,10 @@
...
@@ -7,11 +7,10 @@
#include <cstdlib>
#include <cstdlib>
#include <unistd.h>
#include <unistd.h>
#include <stdio.h>
#include <stdio.h>
#include "../common/jni_helpers.h"
typedef
GLXContext
(
*
glXCreateContextAttribsARBProc
)(
Display
*
,
GLXFBConfig
,
GLXContext
,
Bool
,
const
int
*
);
typedef
GLXContext
(
*
glXCreateContextAttribsARBProc
)(
Display
*
,
GLXFBConfig
,
GLXContext
,
Bool
,
const
int
*
);
extern
"C"
jboolean
Skiko_GetAWT
(
JNIEnv
*
env
,
JAWT
*
awt
);
extern
"C"
extern
"C"
{
{
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skiko_HardwareLayer_nativeInit
(
JNIEnv
*
env
,
jobject
canvas
,
jlong
platformInfoPtr
)
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skiko_HardwareLayer_nativeInit
(
JNIEnv
*
env
,
jobject
canvas
,
jlong
platformInfoPtr
)
...
@@ -24,7 +23,7 @@ extern "C"
...
@@ -24,7 +23,7 @@ extern "C"
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skiko_HardwareLayer_getWindowHandle
(
JNIEnv
*
env
,
jobject
canvas
,
jlong
platformInfoPtr
)
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skiko_HardwareLayer_getWindowHandle
(
JNIEnv
*
env
,
jobject
canvas
,
jlong
platformInfoPtr
)
{
{
JAWT_X11DrawingSurfaceInfo
*
dsi_x11
=
reinterpret_cast
<
JAWT_X11DrawingSurfaceInfo
*>
(
static_cast
<
uintptr_t
>
(
platformInfoPtr
)
);
JAWT_X11DrawingSurfaceInfo
*
dsi_x11
=
fromJavaPointer
<
JAWT_X11DrawingSurfaceInfo
*>
(
platformInfoPtr
);
return
(
jlong
)
dsi_x11
->
drawable
;
return
(
jlong
)
dsi_x11
->
drawable
;
}
}
...
@@ -52,7 +51,7 @@ extern "C"
...
@@ -52,7 +51,7 @@ extern "C"
JNIEXPORT
jfloat
JNICALL
Java_org_jetbrains_skiko_PlatformOperationsKt_linuxGetDpiScaleNative
(
JNIEnv
*
env
,
jobject
properties
,
jlong
platformInfoPtr
)
JNIEXPORT
jfloat
JNICALL
Java_org_jetbrains_skiko_PlatformOperationsKt_linuxGetDpiScaleNative
(
JNIEnv
*
env
,
jobject
properties
,
jlong
platformInfoPtr
)
{
{
JAWT_X11DrawingSurfaceInfo
*
dsi_x11
=
reinterpret_cast
<
JAWT_X11DrawingSurfaceInfo
*>
(
static_cast
<
uintptr_t
>
(
platformInfoPtr
)
);
JAWT_X11DrawingSurfaceInfo
*
dsi_x11
=
fromJavaPointer
<
JAWT_X11DrawingSurfaceInfo
*>
(
platformInfoPtr
);
return
(
float
)
getDpiScaleByDisplay
(
dsi_x11
->
display
);
return
(
float
)
getDpiScaleByDisplay
(
dsi_x11
->
display
);
}
}
}
// extern "C"
}
// extern "C"
\ No newline at end of file
skiko/src/jvmMain/cpp/linux/redrawer.cc
View file @
53de0626
...
@@ -7,31 +7,30 @@
...
@@ -7,31 +7,30 @@
#include <cstdlib>
#include <cstdlib>
#include <unistd.h>
#include <unistd.h>
#include <stdio.h>
#include <stdio.h>
#include "../common/jni_helpers.h"
typedef
GLXContext
(
*
glXCreateContextAttribsARBProc
)(
Display
*
,
GLXFBConfig
,
GLXContext
,
Bool
,
const
int
*
);
typedef
GLXContext
(
*
glXCreateContextAttribsARBProc
)(
Display
*
,
GLXFBConfig
,
GLXContext
,
Bool
,
const
int
*
);
extern
"C"
jboolean
Skiko_GetAWT
(
JNIEnv
*
env
,
JAWT
*
awt
);
extern
"C"
extern
"C"
{
{
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skiko_redrawer_LinuxOpenGLRedrawerKt_getDisplay
(
JNIEnv
*
env
,
jobject
redrawer
,
jlong
platformInfoPtr
)
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skiko_redrawer_LinuxOpenGLRedrawerKt_getDisplay
(
JNIEnv
*
env
,
jobject
redrawer
,
jlong
platformInfoPtr
)
{
{
JAWT_X11DrawingSurfaceInfo
*
dsi_x11
=
reinterpret_cast
<
JAWT_X11DrawingSurfaceInfo
*>
(
static_cast
<
uintptr_t
>
(
platformInfoPtr
)
);
JAWT_X11DrawingSurfaceInfo
*
dsi_x11
=
fromJavaPointer
<
JAWT_X11DrawingSurfaceInfo
*>
(
platformInfoPtr
);
Display
*
display
=
dsi_x11
->
display
;
Display
*
display
=
dsi_x11
->
display
;
return
static_cast
<
jlong
>
(
reinterpret_cast
<
uintptr_t
>
(
display
)
);
return
toJavaPointer
(
display
);
}
}
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skiko_redrawer_LinuxOpenGLRedrawerKt_getWindow
(
JNIEnv
*
env
,
jobject
redrawer
,
jlong
platformInfoPtr
)
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skiko_redrawer_LinuxOpenGLRedrawerKt_getWindow
(
JNIEnv
*
env
,
jobject
redrawer
,
jlong
platformInfoPtr
)
{
{
JAWT_X11DrawingSurfaceInfo
*
dsi_x11
=
reinterpret_cast
<
JAWT_X11DrawingSurfaceInfo
*>
(
static_cast
<
uintptr_t
>
(
platformInfoPtr
)
);
JAWT_X11DrawingSurfaceInfo
*
dsi_x11
=
fromJavaPointer
<
JAWT_X11DrawingSurfaceInfo
*>
(
platformInfoPtr
);
Window
window
=
dsi_x11
->
drawable
;
Window
window
=
dsi_x11
->
drawable
;
return
static_cast
<
jlong
>
(
reinterpret_cast
<
uintptr_t
>
(
window
)
);
return
toJavaPointer
(
window
);
}
}
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skiko_redrawer_LinuxOpenGLRedrawerKt_setSwapInterval
(
JNIEnv
*
env
,
jobject
redrawer
,
jlong
displayPtr
,
jlong
windowPtr
,
jint
interval
)
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skiko_redrawer_LinuxOpenGLRedrawerKt_setSwapInterval
(
JNIEnv
*
env
,
jobject
redrawer
,
jlong
displayPtr
,
jlong
windowPtr
,
jint
interval
)
{
{
Display
*
display
=
reinterpret_cast
<
Display
*>
(
static_cast
<
uintptr_t
>
(
displayPtr
)
);
Display
*
display
=
fromJavaPointer
<
Display
*>
(
displayPtr
);
Window
window
=
reinterpret_cast
<
Window
>
(
static_cast
<
uintptr_t
>
(
windowPtr
)
);
Window
window
=
fromJavaPointer
<
Window
>
(
windowPtr
);
// according to:
// according to:
// https://opengl.gpuinfo.org/listreports.php?extension=GLX_EXT_swap_control
// https://opengl.gpuinfo.org/listreports.php?extension=GLX_EXT_swap_control
...
@@ -63,35 +62,35 @@ extern "C"
...
@@ -63,35 +62,35 @@ extern "C"
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skiko_redrawer_LinuxOpenGLRedrawerKt_swapBuffers
(
JNIEnv
*
env
,
jobject
redrawer
,
jlong
displayPtr
,
jlong
windowPtr
)
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skiko_redrawer_LinuxOpenGLRedrawerKt_swapBuffers
(
JNIEnv
*
env
,
jobject
redrawer
,
jlong
displayPtr
,
jlong
windowPtr
)
{
{
Display
*
display
=
reinterpret_cast
<
Display
*>
(
static_cast
<
uintptr_t
>
(
displayPtr
)
);
Display
*
display
=
fromJavaPointer
<
Display
*>
(
displayPtr
);
Window
window
=
reinterpret_cast
<
Window
>
(
static_cast
<
uintptr_t
>
(
windowPtr
)
);
Window
window
=
fromJavaPointer
<
Window
>
(
windowPtr
);
glXSwapBuffers
(
display
,
window
);
glXSwapBuffers
(
display
,
window
);
}
}
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skiko_redrawer_LinuxOpenGLRedrawerKt_makeCurrent
(
JNIEnv
*
env
,
jobject
redrawer
,
jlong
displayPtr
,
jlong
windowPtr
,
jlong
contextPtr
)
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skiko_redrawer_LinuxOpenGLRedrawerKt_makeCurrent
(
JNIEnv
*
env
,
jobject
redrawer
,
jlong
displayPtr
,
jlong
windowPtr
,
jlong
contextPtr
)
{
{
Display
*
display
=
reinterpret_cast
<
Display
*>
(
static_cast
<
uintptr_t
>
(
displayPtr
)
);
Display
*
display
=
fromJavaPointer
<
Display
*>
(
displayPtr
);
Window
window
=
reinterpret_cast
<
Window
>
(
static_cast
<
uintptr_t
>
(
windowPtr
)
);
Window
window
=
fromJavaPointer
<
Window
>
(
windowPtr
);
GLXContext
*
context
=
reinterpret_cast
<
GLXContext
*>
(
static_cast
<
uintptr_t
>
(
contextPtr
)
);
GLXContext
*
context
=
fromJavaPointer
<
GLXContext
*>
(
contextPtr
);
glXMakeCurrent
(
display
,
window
,
*
context
);
glXMakeCurrent
(
display
,
window
,
*
context
);
}
}
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skiko_redrawer_LinuxOpenGLRedrawerKt_createContext
(
JNIEnv
*
env
,
jobject
redrawer
,
jlong
displayPtr
)
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skiko_redrawer_LinuxOpenGLRedrawerKt_createContext
(
JNIEnv
*
env
,
jobject
redrawer
,
jlong
displayPtr
)
{
{
Display
*
display
=
reinterpret_cast
<
Display
*>
(
static_cast
<
uintptr_t
>
(
displayPtr
)
);
Display
*
display
=
fromJavaPointer
<
Display
*>
(
displayPtr
);
GLint
att
[]
=
{
GLX_RGBA
,
GLX_DOUBLEBUFFER
,
True
,
None
};
GLint
att
[]
=
{
GLX_RGBA
,
GLX_DOUBLEBUFFER
,
True
,
None
};
XVisualInfo
*
vi
=
glXChooseVisual
(
display
,
0
,
att
);
XVisualInfo
*
vi
=
glXChooseVisual
(
display
,
0
,
att
);
GLXContext
*
context
=
new
GLXContext
(
glXCreateContext
(
display
,
vi
,
NULL
,
GL_TRUE
));
GLXContext
*
context
=
new
GLXContext
(
glXCreateContext
(
display
,
vi
,
NULL
,
GL_TRUE
));
return
static_cast
<
jlong
>
(
reinterpret_cast
<
uintptr_t
>
(
context
)
);
return
toJavaPointer
(
context
);
}
}
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skiko_redrawer_LinuxOpenGLRedrawerKt_destroyContext
(
JNIEnv
*
env
,
jobject
redrawer
,
jlong
displayPtr
,
jlong
contextPtr
)
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skiko_redrawer_LinuxOpenGLRedrawerKt_destroyContext
(
JNIEnv
*
env
,
jobject
redrawer
,
jlong
displayPtr
,
jlong
contextPtr
)
{
{
Display
*
display
=
reinterpret_cast
<
Display
*>
(
static_cast
<
uintptr_t
>
(
displayPtr
)
);
Display
*
display
=
fromJavaPointer
<
Display
*>
(
displayPtr
);
GLXContext
*
context
=
reinterpret_cast
<
GLXContext
*>
(
static_cast
<
uintptr_t
>
(
contextPtr
)
);
GLXContext
*
context
=
fromJavaPointer
<
GLXContext
*>
(
contextPtr
);
glXDestroyContext
(
display
,
*
context
);
glXDestroyContext
(
display
,
*
context
);
delete
context
;
delete
context
;
...
...
skiko/src/jvmMain/cpp/windows/drawlayer.cc
View file @
53de0626
#define WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#include <jawt_md.h>
#include <jawt_md.h>
#include "../common/jni_helpers.h"
extern
"C"
jboolean
Skiko_GetAWT
(
JNIEnv
*
env
,
JAWT
*
awt
);
extern
"C"
extern
"C"
{
{
...
@@ -15,7 +14,7 @@ extern "C"
...
@@ -15,7 +14,7 @@ extern "C"
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skiko_HardwareLayer_getWindowHandle
(
JNIEnv
*
env
,
jobject
canvas
,
jlong
platformInfoPtr
)
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skiko_HardwareLayer_getWindowHandle
(
JNIEnv
*
env
,
jobject
canvas
,
jlong
platformInfoPtr
)
{
{
JAWT_Win32DrawingSurfaceInfo
*
dsi_win
=
reinterpret_cast
<
JAWT_Win32DrawingSurfaceInfo
*>
(
static_cast
<
uintptr_t
>
(
platformInfoPtr
)
);
JAWT_Win32DrawingSurfaceInfo
*
dsi_win
=
fromJavaPointer
<
JAWT_Win32DrawingSurfaceInfo
*>
(
platformInfoPtr
);
return
(
jlong
)
dsi_win
->
hwnd
;
return
(
jlong
)
dsi_win
->
hwnd
;
}
}
}
// extern "C"
}
// extern "C"
\ No newline at end of file
skiko/src/jvmMain/cpp/windows/redrawer.cc
View file @
53de0626
...
@@ -3,14 +3,13 @@
...
@@ -3,14 +3,13 @@
#include <gl/GL.h>
#include <gl/GL.h>
#include <jawt_md.h>
#include <jawt_md.h>
#include <dwmapi.h>
#include <dwmapi.h>
#include "../common/jni_helpers.h"
extern
"C"
jboolean
Skiko_GetAWT
(
JNIEnv
*
env
,
JAWT
*
awt
);
extern
"C"
extern
"C"
{
{
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skiko_redrawer_WindowsOpenGLRedrawerKt_getDevice
(
JNIEnv
*
env
,
jobject
redrawer
,
jlong
platformInfoPtr
)
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skiko_redrawer_WindowsOpenGLRedrawerKt_getDevice
(
JNIEnv
*
env
,
jobject
redrawer
,
jlong
platformInfoPtr
)
{
{
JAWT_Win32DrawingSurfaceInfo
*
dsi_win
=
reinterpret_cast
<
JAWT_Win32DrawingSurfaceInfo
*>
(
static_cast
<
uintptr_t
>
(
platformInfoPtr
)
);
JAWT_Win32DrawingSurfaceInfo
*
dsi_win
=
fromJavaPointer
<
JAWT_Win32DrawingSurfaceInfo
*>
(
platformInfoPtr
);
HWND
hwnd
=
dsi_win
->
hwnd
;
HWND
hwnd
=
dsi_win
->
hwnd
;
HDC
device
=
GetDC
(
hwnd
);
HDC
device
=
GetDC
(
hwnd
);
...
@@ -27,7 +26,7 @@ extern "C"
...
@@ -27,7 +26,7 @@ extern "C"
SetPixelFormat
(
device
,
iPixelFormat
,
&
pixFormatDscr
);
SetPixelFormat
(
device
,
iPixelFormat
,
&
pixFormatDscr
);
DescribePixelFormat
(
device
,
iPixelFormat
,
sizeof
(
PIXELFORMATDESCRIPTOR
),
&
pixFormatDscr
);
DescribePixelFormat
(
device
,
iPixelFormat
,
sizeof
(
PIXELFORMATDESCRIPTOR
),
&
pixFormatDscr
);
return
static_cast
<
jlong
>
(
reinterpret_cast
<
uintptr_t
>
(
device
)
);
return
toJavaPointer
(
device
);
}
}
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skiko_redrawer_WindowsOpenGLRedrawerKt_setSwapInterval
(
JNIEnv
*
env
,
jobject
redrawer
,
jint
interval
)
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skiko_redrawer_WindowsOpenGLRedrawerKt_setSwapInterval
(
JNIEnv
*
env
,
jobject
redrawer
,
jint
interval
)
...
@@ -44,26 +43,26 @@ extern "C"
...
@@ -44,26 +43,26 @@ extern "C"
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skiko_redrawer_WindowsOpenGLRedrawerKt_swapBuffers
(
JNIEnv
*
env
,
jobject
redrawer
,
jlong
devicePtr
)
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skiko_redrawer_WindowsOpenGLRedrawerKt_swapBuffers
(
JNIEnv
*
env
,
jobject
redrawer
,
jlong
devicePtr
)
{
{
HDC
device
=
reinterpret_cast
<
HDC
>
(
static_cast
<
uintptr_t
>
(
devicePtr
)
);
HDC
device
=
fromJavaPointer
<
HDC
>
(
devicePtr
);
SwapBuffers
(
device
);
SwapBuffers
(
device
);
}
}
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skiko_redrawer_WindowsOpenGLRedrawerKt_makeCurrent
(
JNIEnv
*
env
,
jobject
redrawer
,
jlong
devicePtr
,
jlong
contextPtr
)
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skiko_redrawer_WindowsOpenGLRedrawerKt_makeCurrent
(
JNIEnv
*
env
,
jobject
redrawer
,
jlong
devicePtr
,
jlong
contextPtr
)
{
{
HDC
device
=
reinterpret_cast
<
HDC
>
(
static_cast
<
uintptr_t
>
(
devicePtr
)
);
HDC
device
=
fromJavaPointer
<
HDC
>
(
devicePtr
);
HGLRC
context
=
reinterpret_cast
<
HGLRC
>
(
static_cast
<
uintptr_t
>
(
contextPtr
)
);
HGLRC
context
=
fromJavaPointer
<
HGLRC
>
(
contextPtr
);
wglMakeCurrent
(
device
,
context
);
wglMakeCurrent
(
device
,
context
);
}
}
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skiko_redrawer_WindowsOpenGLRedrawerKt_createContext
(
JNIEnv
*
env
,
jobject
redrawer
,
jlong
devicePtr
)
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skiko_redrawer_WindowsOpenGLRedrawerKt_createContext
(
JNIEnv
*
env
,
jobject
redrawer
,
jlong
devicePtr
)
{
{
HDC
device
=
reinterpret_cast
<
HDC
>
(
static_cast
<
uintptr_t
>
(
devicePtr
)
);
HDC
device
=
fromJavaPointer
<
HDC
>
(
devicePtr
);
return
static_cast
<
jlong
>
(
reinterpret_cast
<
uintptr_t
>
(
wglCreateContext
(
device
)
));
return
toJavaPointer
(
wglCreateContext
(
device
));
}
}
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skiko_redrawer_WindowsOpenGLRedrawerKt_deleteContext
(
JNIEnv
*
env
,
jobject
redrawer
,
jlong
contextPtr
)
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skiko_redrawer_WindowsOpenGLRedrawerKt_deleteContext
(
JNIEnv
*
env
,
jobject
redrawer
,
jlong
contextPtr
)
{
{
HGLRC
context
=
reinterpret_cast
<
HGLRC
>
(
static_cast
<
uintptr_t
>
(
contextPtr
)
);
HGLRC
context
=
fromJavaPointer
<
HGLRC
>
(
contextPtr
);
wglDeleteContext
(
context
);
wglDeleteContext
(
context
);
}
}
...
...
skiko/src/jvmMain/objectiveC/macos/drawlayer.m
View file @
53de0626
...
@@ -79,8 +79,6 @@ LayerHandler * findByObject(JNIEnv *env, jobject object)
...
@@ -79,8 +79,6 @@ LayerHandler * findByObject(JNIEnv *env, jobject object)
return
NULL
;
return
NULL
;
}
}
extern
jboolean
Skiko_GetAWT
(
JNIEnv
*
env
,
JAWT
*
awt
);
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skiko_HardwareLayer_nativeInit
(
JNIEnv
*
env
,
jobject
canvas
,
jlong
platformInfoPtr
)
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skiko_HardwareLayer_nativeInit
(
JNIEnv
*
env
,
jobject
canvas
,
jlong
platformInfoPtr
)
{
{
if
(
layerStorage
==
nil
)
if
(
layerStorage
==
nil
)
...
...
skiko/src/jvmMain/objectiveC/macos/redrawer.m
View file @
53de0626
...
@@ -7,8 +7,6 @@
...
@@ -7,8 +7,6 @@
#import <QuartzCore/QuartzCore.h>
#import <QuartzCore/QuartzCore.h>
#import <OpenGL/gl3.h>
#import <OpenGL/gl3.h>
extern
jboolean
Skiko_GetAWT
(
JNIEnv
*
env
,
JAWT
*
awt
);
JavaVM
*
jvm
=
NULL
;
JavaVM
*
jvm
=
NULL
;
@interface
AWTGLLayer
:
CAOpenGLLayer
@interface
AWTGLLayer
:
CAOpenGLLayer
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment