| 172 | } |
| 173 | |
| 174 | jobject ToPAGLayerJavaObject(JNIEnv* env, std::shared_ptr<pag::PAGLayer> pagLayer) { |
| 175 | if (env == nullptr || pagLayer == nullptr) { |
| 176 | return nullptr; |
| 177 | } |
| 178 | jobject layerObject = nullptr; |
| 179 | switch (pagLayer->layerType()) { |
| 180 | case pag::LayerType::Shape: { |
| 181 | static Global<jclass> PAGLayer_Class = env->FindClass("org/libpag/PAGShapeLayer"); |
| 182 | static auto PAGLayer_Constructor = env->GetMethodID(PAGLayer_Class.get(), "<init>", "(J)V"); |
| 183 | layerObject = env->NewObject(PAGLayer_Class.get(), PAGLayer_Constructor, |
| 184 | reinterpret_cast<jlong>(new JPAGLayerHandle(pagLayer))); |
| 185 | break; |
| 186 | } |
| 187 | case pag::LayerType::Solid: { |
| 188 | static Global<jclass> PAGLayer_Class = env->FindClass("org/libpag/PAGSolidLayer"); |
| 189 | static auto PAGLayer_Constructor = env->GetMethodID(PAGLayer_Class.get(), "<init>", "(J)V"); |
| 190 | layerObject = env->NewObject(PAGLayer_Class.get(), PAGLayer_Constructor, |
| 191 | reinterpret_cast<jlong>(new JPAGLayerHandle(pagLayer))); |
| 192 | break; |
| 193 | } |
| 194 | case pag::LayerType::PreCompose: { |
| 195 | if (std::static_pointer_cast<pag::PAGComposition>(pagLayer)->isPAGFile()) { |
| 196 | static Global<jclass> PAGLayer_Class = env->FindClass("org/libpag/PAGFile"); |
| 197 | static auto PAGLayer_Constructor = env->GetMethodID(PAGLayer_Class.get(), "<init>", "(J)V"); |
| 198 | layerObject = env->NewObject(PAGLayer_Class.get(), PAGLayer_Constructor, |
| 199 | reinterpret_cast<jlong>(new JPAGLayerHandle(pagLayer))); |
| 200 | } else { |
| 201 | static Global<jclass> PAGLayer_Class = env->FindClass("org/libpag/PAGComposition"); |
| 202 | static auto PAGLayer_Constructor = env->GetMethodID(PAGLayer_Class.get(), "<init>", "(J)V"); |
| 203 | layerObject = env->NewObject(PAGLayer_Class.get(), PAGLayer_Constructor, |
| 204 | reinterpret_cast<jlong>(new JPAGLayerHandle(pagLayer))); |
| 205 | } |
| 206 | |
| 207 | break; |
| 208 | } |
| 209 | case pag::LayerType::Text: { |
| 210 | static Global<jclass> PAGLayer_Class = env->FindClass("org/libpag/PAGTextLayer"); |
| 211 | static auto PAGLayer_Constructor = env->GetMethodID(PAGLayer_Class.get(), "<init>", "(J)V"); |
| 212 | layerObject = env->NewObject(PAGLayer_Class.get(), PAGLayer_Constructor, |
| 213 | reinterpret_cast<jlong>(new JPAGLayerHandle(pagLayer))); |
| 214 | break; |
| 215 | } |
| 216 | case pag::LayerType::Image: { |
| 217 | static Global<jclass> PAGLayer_Class = env->FindClass("org/libpag/PAGImageLayer"); |
| 218 | static auto PAGLayer_Constructor = env->GetMethodID(PAGLayer_Class.get(), "<init>", "(J)V"); |
| 219 | layerObject = env->NewObject(PAGLayer_Class.get(), PAGLayer_Constructor, |
| 220 | reinterpret_cast<jlong>(new JPAGLayerHandle(pagLayer))); |
| 221 | break; |
| 222 | } |
| 223 | default: { |
| 224 | static Global<jclass> PAGLayer_Class = env->FindClass("org/libpag/PAGLayer"); |
| 225 | static auto PAGLayer_Constructor = env->GetMethodID(PAGLayer_Class.get(), "<init>", "(J)V"); |
| 226 | layerObject = env->NewObject(PAGLayer_Class.get(), PAGLayer_Constructor, |
| 227 | reinterpret_cast<jlong>(new JPAGLayerHandle(pagLayer))); |
| 228 | break; |
| 229 | } |
| 230 | } |
| 231 | return layerObject; |
no test coverage detected