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
93367672
Unverified
Commit
93367672
authored
Sep 22, 2021
by
alexander-gorshenev
Committed by
GitHub
Sep 22, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed assert in Canvas::drawVertices (#208)
Added a test for Canvas::drawVertices
parent
d53b7857
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
2 deletions
+55
-2
Canvas.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/Canvas.kt
+10
-2
CanvasTest.kt
skiko/src/jvmTest/kotlin/org/jetbrains/skiko/CanvasTest.kt
+45
-0
org_jetbrains_skiko_CanvasTest_drawVertices.png
...ots/macos/org_jetbrains_skiko_CanvasTest_drawVertices.png
+0
-0
org_jetbrains_skiko_CanvasTest_drawVertices.png
...ows_linux/org_jetbrains_skiko_CanvasTest_drawVertices.png
+0
-0
No files found.
skiko/src/commonMain/kotlin/org/jetbrains/skia/Canvas.kt
View file @
93367672
...
@@ -852,8 +852,16 @@ open class Canvas internal constructor(ptr: NativePointer, managed: Boolean, int
...
@@ -852,8 +852,16 @@ open class Canvas internal constructor(ptr: NativePointer, managed: Boolean, int
mode
:
BlendMode
,
mode
:
BlendMode
,
paint
:
Paint
paint
:
Paint
):
Canvas
{
):
Canvas
{
require
(
colors
==
null
||
colors
.
size
==
positions
.
size
)
{
"Expected colors.length == positions.length, got: "
+
colors
!!
.
size
+
" != "
+
positions
.
size
}
require
(
positions
.
size
%
2
==
0
)
{
require
(
texCoords
==
null
||
texCoords
.
size
==
positions
.
size
)
{
"Expected texCoords.length == positions.length, got: "
+
texCoords
!!
.
size
+
" != "
+
positions
.
size
}
"Expected even number of positions: ${positions.size}"
}
val
points
=
positions
.
size
/
2
require
(
colors
==
null
||
colors
.
size
==
points
)
{
"Expected colors.length == positions.length / 2, got: "
+
colors
!!
.
size
+
" != "
+
points
}
require
(
texCoords
==
null
||
texCoords
.
size
==
positions
.
size
)
{
"Expected texCoords.length == positions.length, got: "
+
texCoords
!!
.
size
+
" != "
+
positions
.
size
}
Stats
.
onNativeCall
()
Stats
.
onNativeCall
()
interopScope
{
interopScope
{
_nDrawVertices
(
_nDrawVertices
(
...
...
skiko/src/jvmTest/kotlin/org/jetbrains/skiko/CanvasTest.kt
0 → 100644
View file @
93367672
package
org.jetbrains.skiko
import
org.jetbrains.skia.*
import
org.jetbrains.skiko.util.ScreenshotTestRule
import
org.junit.Rule
import
org.junit.Test
class
CanvasTest
{
@get
:
Rule
val
screenshots
=
ScreenshotTestRule
()
@Test
fun
drawVertices
()
{
val
surface
=
Surface
.
makeRasterN32Premul
(
16
,
16
)
val
positions
=
Point
.
flattenArray
(
arrayOf
(
Point
(
0f
,
0f
),
Point
(
16f
,
0f
),
Point
(
8f
,
8f
),
Point
(
16f
,
8f
),
Point
(
0f
,
16f
),
Point
(
16f
,
16f
),
)
)
!!
val
colors
=
listOf
(
Color
.
RED
,
Color
.
GREEN
,
Color
.
BLUE
,
Color
.
CYAN
,
Color
.
MAGENTA
,
Color
.
YELLOW
).
toIntArray
()
val
indices
=
shortArrayOf
(
0
,
1
,
2
,
3
,
4
,
5
)
surface
.
canvas
.
drawVertices
(
VertexMode
.
TRIANGLES
,
positions
,
colors
,
positions
,
indices
,
BlendMode
.
SRC_OVER
,
Paint
()
)
screenshots
.
assert
(
surface
.
makeImageSnapshot
())
}
}
skiko/src/jvmTest/screenshots/macos/org_jetbrains_skiko_CanvasTest_drawVertices.png
0 → 100644
View file @
93367672
286 Bytes
skiko/src/jvmTest/screenshots/windows_linux/org_jetbrains_skiko_CanvasTest_drawVertices.png
0 → 100644
View file @
93367672
286 Bytes
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