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
bc43ce21
Unverified
Commit
bc43ce21
authored
Mar 18, 2021
by
Roman Sedaikin
Committed by
GitHub
Mar 18, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #79 from JetBrains/render_api
Added API to get the current SkiaLayer graphics API.
parents
40cd2b02
c8c45b09
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
11 deletions
+14
-11
App.kt
...kijaInjectSample/src/main/kotlin/SkijaInjectSample/App.kt
+3
-3
SkiaLayer.kt
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/SkiaLayer.kt
+11
-8
No files found.
samples/SkijaInjectSample/src/main/kotlin/SkijaInjectSample/App.kt
View file @
bc43ce21
...
@@ -113,7 +113,7 @@ fun displayScene(renderer: Renderer, width: Int, height: Int, nanoTime: Long, xp
...
@@ -113,7 +113,7 @@ fun displayScene(renderer: Renderer, width: Int, height: Int, nanoTime: Long, xp
val
watchStrokeAA
=
Paint
().
setColor
(
0
xFF000000
.
toInt
()).
setMode
(
PaintMode
.
STROKE
).
setStrokeWidth
(
1f
)
val
watchStrokeAA
=
Paint
().
setColor
(
0
xFF000000
.
toInt
()).
setMode
(
PaintMode
.
STROKE
).
setStrokeWidth
(
1f
)
val
watchFillHover
=
Paint
().
setColor
(
0
xFFE4FF01
.
toInt
())
val
watchFillHover
=
Paint
().
setColor
(
0
xFFE4FF01
.
toInt
())
for
(
x
in
0
..
(
width
-
50
)
step
50
)
{
for
(
x
in
0
..
(
width
-
50
)
step
50
)
{
for
(
y
in
0
..
(
height
-
50
)
step
50
)
{
for
(
y
in
2
0
..
(
height
-
50
)
step
50
)
{
val
hover
=
xpos
>
x
+
0
&&
xpos
<
x
+
50
&&
ypos
>
y
+
0
&&
ypos
<
y
+
50
val
hover
=
xpos
>
x
+
0
&&
xpos
<
x
+
50
&&
ypos
>
y
+
0
&&
ypos
<
y
+
50
val
fill
=
if
(
hover
)
watchFillHover
else
watchFill
val
fill
=
if
(
hover
)
watchFillHover
else
watchFill
val
stroke
=
if
(
x
>
width
/
2
)
watchStrokeAA
else
watchStroke
val
stroke
=
if
(
x
>
width
/
2
)
watchStrokeAA
else
watchStroke
...
@@ -153,9 +153,9 @@ fun displayScene(renderer: Renderer, width: Int, height: Int, nanoTime: Long, xp
...
@@ -153,9 +153,9 @@ fun displayScene(renderer: Renderer, width: Int, height: Int, nanoTime: Long, xp
val
style
=
ParagraphStyle
()
val
style
=
ParagraphStyle
()
val
paragraph
=
ParagraphBuilder
(
style
,
fontCollection
)
val
paragraph
=
ParagraphBuilder
(
style
,
fontCollection
)
.
pushStyle
(
TextStyle
().
setColor
(
0
xFF000000
.
toInt
()))
.
pushStyle
(
TextStyle
().
setColor
(
0
xFF000000
.
toInt
()))
.
addText
(
"
Text
"
)
.
addText
(
"
Graphics API: ${renderer.layer.renderApi}
"
)
.
popStyle
()
.
popStyle
()
.
build
()
.
build
()
paragraph
.
layout
(
Float
.
POSITIVE_INFINITY
)
paragraph
.
layout
(
Float
.
POSITIVE_INFINITY
)
paragraph
.
paint
(
canvas
,
0f
,
0
f
)
paragraph
.
paint
(
canvas
,
5f
,
5
f
)
}
}
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/SkiaLayer.kt
View file @
bc43ce21
...
@@ -73,17 +73,20 @@ open class SkiaLayer(
...
@@ -73,17 +73,20 @@ open class SkiaLayer(
internal
var
redrawer
:
Redrawer
?
=
null
internal
var
redrawer
:
Redrawer
?
=
null
private
var
contextHandler
:
ContextHandler
?
=
null
private
var
contextHandler
:
ContextHandler
?
=
null
private
val
fallbackRenderApiQueue
=
SkikoProperties
.
fallbackRenderApiQueue
.
toMutableList
()
private
val
fallbackRenderApiQueue
=
SkikoProperties
.
fallbackRenderApiQueue
.
toMutableList
()
var
renderApi
:
GraphicsApi
=
fallbackRenderApiQueue
[
0
]
private
set
@Volatile
@Volatile
private
var
picture
:
PictureHolder
?
=
null
private
var
picture
:
PictureHolder
?
=
null
private
val
pictureRecorder
=
PictureRecorder
()
private
val
pictureRecorder
=
PictureRecorder
()
private
val
pictureLock
=
Any
()
private
val
pictureLock
=
Any
()
open
fun
init
()
{
open
fun
init
()
{
backedLayer
.
init
()
backedLayer
.
init
()
val
initialR
enderApi
=
fallbackRenderApiQueue
.
removeAt
(
0
)
r
enderApi
=
fallbackRenderApiQueue
.
removeAt
(
0
)
contextHandler
=
createContextHandler
(
this
,
initialR
enderApi
)
contextHandler
=
createContextHandler
(
this
,
r
enderApi
)
redrawer
=
platformOperations
.
createRedrawer
(
this
,
initialR
enderApi
,
properties
)
redrawer
=
platformOperations
.
createRedrawer
(
this
,
r
enderApi
,
properties
)
isInited
=
true
isInited
=
true
}
}
...
@@ -212,12 +215,12 @@ open class SkiaLayer(
...
@@ -212,12 +215,12 @@ open class SkiaLayer(
}
}
private
fun
fallbackToNextApi
()
{
private
fun
fallbackToNextApi
()
{
val
next
Api
=
fallbackRenderApiQueue
.
removeAt
(
0
)
render
Api
=
fallbackRenderApiQueue
.
removeAt
(
0
)
println
(
"Falling back to $
next
Api rendering..."
)
println
(
"Falling back to $
render
Api rendering..."
)
contextHandler
?.
dispose
()
contextHandler
?.
dispose
()
redrawer
?.
dispose
()
redrawer
?.
dispose
()
contextHandler
=
createContextHandler
(
this
,
next
Api
)
contextHandler
=
createContextHandler
(
this
,
render
Api
)
redrawer
=
platformOperations
.
createRedrawer
(
this
,
next
Api
,
properties
)
redrawer
=
platformOperations
.
createRedrawer
(
this
,
render
Api
,
properties
)
needRedraw
()
repaint
()
}
}
}
}
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