blob: 654c5fdf65288e5af01e7c5f0f4a10ac17d0c5da [file] [log] [blame]
Clara Bayarri04d72ab2017-01-10 09:31:51 -08001/*
2 * Copyright (C) 2016 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 "FontUtils.h"
18
Derek Sollenbergerc5882c42019-10-25 11:11:32 -040019#include "graphics_jni_helpers.h"
Clara Bayarri04d72ab2017-01-10 09:31:51 -080020
21namespace android {
22namespace {
23
24static struct {
25 jmethodID mGet;
26 jmethodID mSize;
27} gListClassInfo;
28
29static struct {
30 jfieldID mTag;
31 jfieldID mStyleValue;
32} gAxisClassInfo;
33
34} // namespace
35
36jint ListHelper::size() const {
37 return mEnv->CallIntMethod(mList, gListClassInfo.mSize);
38}
39
40jobject ListHelper::get(jint index) const {
41 return mEnv->CallObjectMethod(mList, gListClassInfo.mGet, index);
42}
43
44jint AxisHelper::getTag() const {
45 return mEnv->GetIntField(mAxis, gAxisClassInfo.mTag);
46}
47
48jfloat AxisHelper::getStyleValue() const {
49 return mEnv->GetFloatField(mAxis, gAxisClassInfo.mStyleValue);
50}
51
52void init_FontUtils(JNIEnv* env) {
53 jclass listClass = FindClassOrDie(env, "java/util/List");
54 gListClassInfo.mGet = GetMethodIDOrDie(env, listClass, "get", "(I)Ljava/lang/Object;");
55 gListClassInfo.mSize = GetMethodIDOrDie(env, listClass, "size", "()I");
56
Seigo Nonakaff551152017-03-28 16:16:41 -070057 jclass axisClass = FindClassOrDie(env, "android/graphics/fonts/FontVariationAxis");
Clara Bayarri04d72ab2017-01-10 09:31:51 -080058 gAxisClassInfo.mTag = GetFieldIDOrDie(env, axisClass, "mTag", "I");
59 gAxisClassInfo.mStyleValue = GetFieldIDOrDie(env, axisClass, "mStyleValue", "F");
60}
61
62} // namespace android