aboutsummaryrefslogtreecommitdiff
path: root/shadows/framework/src/main/java/org/robolectric/shadows/ShadowNativeMatrix.java
blob: e840968dbea01b46fcc0251015db7f7417acf801 (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
package org.robolectric.shadows;

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

import android.graphics.Matrix;
import android.graphics.RectF;
import java.util.List;
import java.util.Map;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.nativeruntime.DefaultNativeRuntimeLoader;
import org.robolectric.nativeruntime.MatrixNatives;

/** Shadow for {@link Matrix} that is backed by native code */
@Implements(value = Matrix.class, minSdk = O, isInAndroidSdk = false)
public class ShadowNativeMatrix extends ShadowMatrix {

  @Implementation(minSdk = LOLLIPOP, maxSdk = N_MR1)
  protected static long native_create(long nSrcOrZero) {
    return nCreate(nSrcOrZero);
  }

  @Implementation(minSdk = O)
  protected static long nCreate(long nSrcOrZero) {
    DefaultNativeRuntimeLoader.injectAndLoad();
    return MatrixNatives.nCreate(nSrcOrZero);
  }

  @Implementation(minSdk = O)
  protected static long nGetNativeFinalizer() {
    return MatrixNatives.nGetNativeFinalizer();
  }

  @Implementation(minSdk = O)
  protected static boolean nSetRectToRect(long nObject, RectF src, RectF dst, int stf) {
    return MatrixNatives.nSetRectToRect(nObject, src, dst, stf);
  }

  @Implementation(minSdk = O)
  protected static boolean nSetPolyToPoly(
      long nObject, float[] src, int srcIndex, float[] dst, int dstIndex, int pointCount) {
    return MatrixNatives.nSetPolyToPoly(nObject, src, srcIndex, dst, dstIndex, pointCount);
  }

  @Implementation(minSdk = O)
  protected static void nMapPoints(
      long nObject,
      float[] dst,
      int dstIndex,
      float[] src,
      int srcIndex,
      int ptCount,
      boolean isPts) {
    MatrixNatives.nMapPoints(nObject, dst, dstIndex, src, srcIndex, ptCount, isPts);
  }

  @Implementation(minSdk = O)
  protected static boolean nMapRect(long nObject, RectF dst, RectF src) {
    return MatrixNatives.nMapRect(nObject, dst, src);
  }

  @Implementation(minSdk = O)
  protected static void nGetValues(long nObject, float[] values) {
    MatrixNatives.nGetValues(nObject, values);
  }

  @Implementation(minSdk = O)
  protected static void nSetValues(long nObject, float[] values) {
    MatrixNatives.nSetValues(nObject, values);
  }

  @Implementation(minSdk = O)
  protected static boolean nIsIdentity(long nObject) {
    return MatrixNatives.nIsIdentity(nObject);
  }

  @Implementation(minSdk = O)
  protected static boolean nIsAffine(long nObject) {
    return MatrixNatives.nIsAffine(nObject);
  }

  @Implementation(minSdk = O)
  protected static boolean nRectStaysRect(long nObject) {
    return MatrixNatives.nRectStaysRect(nObject);
  }

  @Implementation(minSdk = O)
  protected static void nReset(long nObject) {
    MatrixNatives.nReset(nObject);
  }

  @Implementation(minSdk = O)
  protected static void nSet(long nObject, long nOther) {
    MatrixNatives.nSet(nObject, nOther);
  }

  @Implementation(minSdk = O)
  protected static void nSetTranslate(long nObject, float dx, float dy) {
    MatrixNatives.nSetTranslate(nObject, dx, dy);
  }

  @Implementation(minSdk = O)
  protected static void nSetScale(long nObject, float sx, float sy, float px, float py) {
    MatrixNatives.nSetScale(nObject, sx, sy, px, py);
  }

  @Implementation(minSdk = O)
  protected static void nSetScale(long nObject, float sx, float sy) {
    MatrixNatives.nSetScale(nObject, sx, sy);
  }

  @Implementation(minSdk = O)
  protected static void nSetRotate(long nObject, float degrees, float px, float py) {
    MatrixNatives.nSetRotate(nObject, degrees, px, py);
  }

  @Implementation(minSdk = O)
  protected static void nSetRotate(long nObject, float degrees) {
    MatrixNatives.nSetRotate(nObject, degrees);
  }

  @Implementation(minSdk = O)
  protected static void nSetSinCos(
      long nObject, float sinValue, float cosValue, float px, float py) {
    MatrixNatives.nSetSinCos(nObject, sinValue, cosValue, px, py);
  }

  @Implementation(minSdk = O)
  protected static void nSetSinCos(long nObject, float sinValue, float cosValue) {
    MatrixNatives.nSetSinCos(nObject, sinValue, cosValue);
  }

  @Implementation(minSdk = O)
  protected static void nSetSkew(long nObject, float kx, float ky, float px, float py) {
    MatrixNatives.nSetSkew(nObject, kx, ky, px, py);
  }

  @Implementation(minSdk = O)
  protected static void nSetSkew(long nObject, float kx, float ky) {
    MatrixNatives.nSetSkew(nObject, kx, ky);
  }

  @Implementation(minSdk = O)
  protected static void nSetConcat(long nObject, long nA, long nB) {
    MatrixNatives.nSetConcat(nObject, nA, nB);
  }

  @Implementation(minSdk = O)
  protected static void nPreTranslate(long nObject, float dx, float dy) {
    MatrixNatives.nPreTranslate(nObject, dx, dy);
  }

  @Implementation(minSdk = O)
  protected static void nPreScale(long nObject, float sx, float sy, float px, float py) {
    MatrixNatives.nPreScale(nObject, sx, sy, px, py);
  }

  @Implementation(minSdk = O)
  protected static void nPreScale(long nObject, float sx, float sy) {
    MatrixNatives.nPreScale(nObject, sx, sy);
  }

  @Implementation(minSdk = O)
  protected static void nPreRotate(long nObject, float degrees, float px, float py) {
    MatrixNatives.nPreRotate(nObject, degrees, px, py);
  }

  @Implementation(minSdk = O)
  protected static void nPreRotate(long nObject, float degrees) {
    MatrixNatives.nPreRotate(nObject, degrees);
  }

  @Implementation(minSdk = O)
  protected static void nPreSkew(long nObject, float kx, float ky, float px, float py) {
    MatrixNatives.nPreSkew(nObject, kx, ky, px, py);
  }

  @Implementation(minSdk = O)
  protected static void nPreSkew(long nObject, float kx, float ky) {
    MatrixNatives.nPreSkew(nObject, kx, ky);
  }

  @Implementation(minSdk = O)
  protected static void nPreConcat(long nObject, long nOtherMatrix) {
    MatrixNatives.nPreConcat(nObject, nOtherMatrix);
  }

  @Implementation(minSdk = O)
  protected static void nPostTranslate(long nObject, float dx, float dy) {
    MatrixNatives.nPostTranslate(nObject, dx, dy);
  }

  @Implementation(minSdk = O)
  protected static void nPostScale(long nObject, float sx, float sy, float px, float py) {
    MatrixNatives.nPostScale(nObject, sx, sy, px, py);
  }

  @Implementation(minSdk = O)
  protected static void nPostScale(long nObject, float sx, float sy) {
    MatrixNatives.nPostScale(nObject, sx, sy);
  }

  @Implementation(minSdk = O)
  protected static void nPostRotate(long nObject, float degrees, float px, float py) {
    MatrixNatives.nPostRotate(nObject, degrees, px, py);
  }

  @Implementation(minSdk = O)
  protected static void nPostRotate(long nObject, float degrees) {
    MatrixNatives.nPostRotate(nObject, degrees);
  }

  @Implementation(minSdk = O)
  protected static void nPostSkew(long nObject, float kx, float ky, float px, float py) {
    MatrixNatives.nPostSkew(nObject, kx, ky, px, py);
  }

  @Implementation(minSdk = O)
  protected static void nPostSkew(long nObject, float kx, float ky) {
    MatrixNatives.nPostSkew(nObject, kx, ky);
  }

  @Implementation(minSdk = O)
  protected static void nPostConcat(long nObject, long nOtherMatrix) {
    MatrixNatives.nPostConcat(nObject, nOtherMatrix);
  }

  @Implementation(minSdk = O)
  protected static boolean nInvert(long nObject, long nInverse) {
    return MatrixNatives.nInvert(nObject, nInverse);
  }

  @Implementation(minSdk = O)
  protected static float nMapRadius(long nObject, float radius) {
    return MatrixNatives.nMapRadius(nObject, radius);
  }

  @Implementation(minSdk = O)
  protected static boolean nEquals(long nA, long nB) {
    return MatrixNatives.nEquals(nA, nB);
  }

  @Override
  public List<String> getPreOperations() {
    throw new UnsupportedOperationException("Legacy ShadowMatrix APIs are not supported");
  }

  @Override
  public List<String> getPostOperations() {
    throw new UnsupportedOperationException("Legacy ShadowMatrix APIs are not supported");
  }

  @Override
  public Map<String, String> getSetOperations() {
    throw new UnsupportedOperationException("Legacy ShadowMatrix APIs are not supported");
  }

  @Override
  public String getDescription() {
    throw new UnsupportedOperationException("Legacy ShadowMatrix APIs are not supported");
  }
}