1 /*
2  * Copyright 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "android/graphics/matrix.h"
18 #include "android_graphics_Matrix.h"
19 
AMatrix_getContents(JNIEnv * env,jobject matrixObj,float values[9])20 bool AMatrix_getContents(JNIEnv* env, jobject matrixObj, float values[9]) {
21     static_assert(SkMatrix::kMScaleX == 0, "SkMatrix unexpected index");
22     static_assert(SkMatrix::kMSkewX ==  1, "SkMatrix unexpected index");
23     static_assert(SkMatrix::kMTransX == 2, "SkMatrix unexpected index");
24     static_assert(SkMatrix::kMSkewY ==  3, "SkMatrix unexpected index");
25     static_assert(SkMatrix::kMScaleY == 4, "SkMatrix unexpected index");
26     static_assert(SkMatrix::kMTransY == 5, "SkMatrix unexpected index");
27     static_assert(SkMatrix::kMPersp0 == 6, "SkMatrix unexpected index");
28     static_assert(SkMatrix::kMPersp1 == 7, "SkMatrix unexpected index");
29     static_assert(SkMatrix::kMPersp2 == 8, "SkMatrix unexpected index");
30 
31     SkMatrix* m = android::android_graphics_Matrix_getSkMatrix(env, matrixObj);
32     if (m != nullptr) {
33         m->get9(values);
34         return true;
35     }
36     return false;
37 }
38