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
2cfab4a4
Commit
2cfab4a4
authored
Apr 27, 2021
by
Roman Sedaikin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added OpenGL (Windows).
parent
f1b93ac7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
41 deletions
+48
-41
App.kt
...kijaInjectSample/src/main/kotlin/SkijaInjectSample/App.kt
+17
-21
OpenGLContextHandler.kt
...otlin/org/jetbrains/skiko/context/OpenGLContextHandler.kt
+31
-20
No files found.
samples/SkijaInjectSample/src/main/kotlin/SkijaInjectSample/App.kt
View file @
2cfab4a4
...
...
@@ -15,6 +15,7 @@ import kotlin.math.cos
import
kotlin.math.sin
fun
main
(
args
:
Array
<
String
>)
{
System
.
setProperty
(
"skiko.renderApi"
,
"OPENGL"
)
repeat
(
1
)
{
createWindow
(
"window $it"
)
}
...
...
@@ -90,31 +91,26 @@ class Renderer(
var
canvas
:
Canvas
?
=
null
override
fun
onRender
(
canvas
:
Canvas
,
width
:
Int
,
height
:
Int
,
nanoTime
:
Long
)
{
// this.canvas = canvas
// val contentScale = layer.contentScale
// canvas.scale(contentScale, contentScale)
// displayScene(this, (width / contentScale).toInt(), (height / contentScale).toInt(), nanoTime)
// layer.needRedraw()
//////////////////////////////////////////////////
this
.
canvas
=
canvas
val
contentScale
=
layer
.
contentScale
canvas
.
scale
(
contentScale
,
contentScale
)
displayScene
(
this
,
(
width
/
contentScale
).
toInt
(),
(
height
/
contentScale
).
toInt
(),
nanoTime
)
// Alpha layers test
val
rectW
=
100f
val
rectH
=
100f
val
left
=
(
width
-
rectW
)
/
2f
val
top
=
(
height
-
rectH
)
/
2f
val
pictureRecorder
=
PictureRecorder
()
val
pictureCanvas
=
pictureRecorder
.
beginRecording
(
Rect
.
makeLTRB
(
0f
,
0f
,
100f
,
100f
)
Rect
.
makeLTRB
(
left
,
top
,
left
+
rectW
,
top
+
rectH
)
)
pictureCanvas
.
drawLine
(
0f
,
0f
,
100f
,
100f
,
Paint
())
pictureCanvas
.
drawLine
(
left
,
top
,
left
+
rectW
,
top
+
rectH
,
Paint
())
val
picture
=
pictureRecorder
.
finishRecordingAsPicture
()
canvas
.
drawPicture
(
picture
,
null
,
Paint
()
// if we replace it by null, everything will be normal
)
canvas
.
drawLine
(
100f
,
0f
,
0f
,
100f
,
Paint
())
//////////////////////////////////////////////////
canvas
.
drawPicture
(
picture
,
null
,
Paint
())
canvas
.
drawLine
(
left
,
top
+
rectH
,
left
+
rectW
,
top
,
Paint
())
layer
.
needRedraw
()
}
}
...
...
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/context/OpenGLContextHandler.kt
View file @
2cfab4a4
...
...
@@ -26,13 +26,24 @@ internal class OpenGLContextHandler(layer: SkiaLayer) : ContextHandler(layer) {
return
true
}
override
fun
initCanvas
()
{
disposeCanvas
()
private
var
currentWidth
=
0
private
var
currentHeight
=
0
private
fun
isSizeChanged
(
width
:
Int
,
height
:
Int
):
Boolean
{
if
(
width
!=
currentWidth
||
height
!=
currentHeight
)
{
currentWidth
=
width
currentHeight
=
height
return
true
}
return
false
}
override
fun
initCanvas
()
{
val
scale
=
layer
.
contentScale
val
w
=
(
layer
.
width
*
scale
).
toInt
().
coerceAtLeast
(
0
)
val
h
=
(
layer
.
height
*
scale
).
toInt
().
coerceAtLeast
(
0
)
if
(
isSizeChanged
(
w
,
h
))
{
disposeCanvas
()
val
gl
=
OpenGLApi
.
instance
val
fbId
=
gl
.
glGetIntegerv
(
gl
.
GL_DRAW_FRAMEBUFFER_BINDING
)
renderTarget
=
makeGLRenderTarget
(
...
...
@@ -43,7 +54,6 @@ internal class OpenGLContextHandler(layer: SkiaLayer) : ContextHandler(layer) {
fbId
,
FramebufferFormat
.
GR_GL_RGBA8
)
surface
=
Surface
.
makeFromBackendRenderTarget
(
context
!!
,
renderTarget
!!
,
...
...
@@ -51,6 +61,7 @@ internal class OpenGLContextHandler(layer: SkiaLayer) : ContextHandler(layer) {
SurfaceColorFormat
.
RGBA_8888
,
ColorSpace
.
getSRGB
()
)
}
canvas
=
surface
!!
.
canvas
}
...
...
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