Skip to content

Commit

Permalink
Fix crash on API 33
Browse files Browse the repository at this point in the history
  • Loading branch information
romainguy committed Apr 24, 2023
1 parent 3f75943 commit 5f7db58
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .idea/androidTestResultsUserPreferences.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repositories {
}
dependencies {
implementation 'dev.romainguy:pathway:0.11.0'
implementation 'dev.romainguy:pathway:0.12.0'
}
```

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GROUP=dev.romainguy
VERSION_NAME=0.11.0
VERSION_NAME=0.12.0

SONATYPE_HOST=S01
RELEASE_SIGNING_ENABLED=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ fun compareBitmaps(b1: Bitmap, b2: Bitmap, error: Int = 1) {
}
}

fun valueCountForType(type: PathSegment.Type) = when(type) {
PathSegment.Type.Move -> 2
PathSegment.Type.Line -> 4
PathSegment.Type.Quadratic -> 6
PathSegment.Type.Conic -> 8
PathSegment.Type.Cubic -> 8
PathSegment.Type.Close -> 0
PathSegment.Type.Done -> 0
}

fun assertPathEquals(
expected: Path,
actual: Path,
Expand All @@ -73,7 +83,12 @@ fun assertPathEquals(
while (iterator1.hasNext() && iterator2.hasNext()) {
val type1 = iterator1.next(points1)
val type2 = iterator2.next(points2)

points1.fill(0.0f, valueCountForType(type1))
points2.fill(0.0f, valueCountForType(type2))

assertEquals(type1, type2)

Assert.assertArrayEquals(points1, points2, 1e-10f)
}
}
2 changes: 1 addition & 1 deletion pathway/src/main/cpp/pathway.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static jlong createPathIterator(JNIEnv* env, jclass,
PathIterator::VerbDirection direction;

const uint32_t apiLevel = api_level();
if (apiLevel >= 33) {
if (apiLevel >= 34) {
auto* ref = reinterpret_cast<PathRef34*>(path->pathRef);
points = ref->points;
verbs = ref->verbs;
Expand Down

0 comments on commit 5f7db58

Please sign in to comment.