aboutsummaryrefslogtreecommitdiff
path: root/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativePathParser.java
blob: 1b6ccd5498d855d440973ab69f0b4f2676e639ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package org.robolectric.shadows;

import static android.os.Build.VERSION_CODES.O;

import android.util.PathParser;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.nativeruntime.DefaultNativeRuntimeLoader;
import org.robolectric.nativeruntime.PathParserNatives;
import org.robolectric.shadows.ShadowNativePathParser.Picker;
import org.robolectric.versioning.AndroidVersions.U;

/** Shadow for {@link PathParser} that is backed by native code */
@Implements(
    value = PathParser.class,
    minSdk = O,
    shadowPicker = Picker.class,
    isInAndroidSdk = false,
    callNativeMethodsByDefault = true)
public class ShadowNativePathParser {

  static {
    DefaultNativeRuntimeLoader.injectAndLoad();
  }

  @Implementation(minSdk = O, maxSdk = U.SDK_INT)
  protected static void nParseStringForPath(long pathPtr, String pathString, int stringLength) {
    PathParserNatives.nParseStringForPath(pathPtr, pathString, stringLength);
  }

  @Implementation(minSdk = O, maxSdk = U.SDK_INT)
  protected static long nCreatePathDataFromString(String pathString, int stringLength) {
    return PathParserNatives.nCreatePathDataFromString(pathString, stringLength);
  }

  @Implementation(minSdk = O, maxSdk = U.SDK_INT)
  protected static void nCreatePathFromPathData(long outPathPtr, long pathData) {
    PathParserNatives.nCreatePathFromPathData(outPathPtr, pathData);
  }

  @Implementation(minSdk = O, maxSdk = U.SDK_INT)
  protected static long nCreateEmptyPathData() {
    return PathParserNatives.nCreateEmptyPathData();
  }

  @Implementation(minSdk = O, maxSdk = U.SDK_INT)
  protected static long nCreatePathData(long nativePtr) {
    return PathParserNatives.nCreatePathData(nativePtr);
  }

  @Implementation(minSdk = O, maxSdk = U.SDK_INT)
  protected static boolean nInterpolatePathData(
      long outDataPtr, long fromDataPtr, long toDataPtr, float fraction) {
    return PathParserNatives.nInterpolatePathData(outDataPtr, fromDataPtr, toDataPtr, fraction);
  }

  @Implementation(minSdk = O, maxSdk = U.SDK_INT)
  protected static void nFinalize(long nativePtr) {
    PathParserNatives.nFinalize(nativePtr);
  }

  @Implementation(minSdk = O, maxSdk = U.SDK_INT)
  protected static boolean nCanMorph(long fromDataPtr, long toDataPtr) {
    return PathParserNatives.nCanMorph(fromDataPtr, toDataPtr);
  }

  @Implementation(minSdk = O, maxSdk = U.SDK_INT)
  protected static void nSetPathData(long outDataPtr, long fromDataPtr) {
    PathParserNatives.nSetPathData(outDataPtr, fromDataPtr);
  }

  /** Shadow picker for {@link PathParser}. */
  public static final class Picker extends GraphicsShadowPicker<Object> {
    public Picker() {
      super(ShadowPathParser.class, ShadowNativePathParser.class);
    }
  }
}