Flutter Engine
flutter::PlatformViewAndroidJNIImpl Class Referencefinal

Concrete implementation of PlatformViewAndroidJNI that is compiled with the Android toolchain. More...

#include <platform_view_android_jni_impl.h>

Inheritance diagram for flutter::PlatformViewAndroidJNIImpl:
flutter::PlatformViewAndroidJNI

Public Member Functions

 PlatformViewAndroidJNIImpl (fml::jni::JavaObjectWeakGlobalRef java_object)
 
 ~PlatformViewAndroidJNIImpl () override
 
void FlutterViewHandlePlatformMessage (fml::RefPtr< flutter::PlatformMessage > message, int responseId) override
 Sends a platform message. The message may be empty. More...
 
void FlutterViewHandlePlatformMessageResponse (int responseId, std::unique_ptr< fml::Mapping > data) override
 Responds to a platform message. The data may be a nullptr. More...
 
void FlutterViewUpdateSemantics (std::vector< uint8_t > buffer, std::vector< std::string > strings) override
 Sends semantics tree updates. More...
 
void FlutterViewUpdateCustomAccessibilityActions (std::vector< uint8_t > actions_buffer, std::vector< std::string > strings) override
 Sends new custom accessibility events. More...
 
void FlutterViewOnFirstFrame () override
 Indicates that FlutterView should start painting pixels. More...
 
void FlutterViewOnPreEngineRestart () override
 Indicates that a hot restart is about to happen. More...
 
void SurfaceTextureAttachToGLContext (JavaWeakGlobalRef surface_texture, int textureId) override
 Attach the SurfaceTexture to the OpenGL ES context that is current on the calling thread. More...
 
void SurfaceTextureUpdateTexImage (JavaWeakGlobalRef surface_texture) override
 Updates the texture image to the most recent frame from the image stream. More...
 
void SurfaceTextureGetTransformMatrix (JavaWeakGlobalRef surface_texture, SkMatrix &transform) override
 Gets the transform matrix from the SurfaceTexture. Then, it updates the transform matrix, so it fill the canvas and preserve the aspect ratio. More...
 
void SurfaceTextureDetachFromGLContext (JavaWeakGlobalRef surface_texture) override
 Detaches a SurfaceTexture from the OpenGL ES context. More...
 
void FlutterViewOnDisplayPlatformView (int view_id, int x, int y, int width, int height, int viewWidth, int viewHeight, MutatorsStack mutators_stack) override
 Positions and sizes a platform view if using hybrid composition. More...
 
void FlutterViewDisplayOverlaySurface (int surface_id, int x, int y, int width, int height) override
 Positions and sizes an overlay surface in hybrid composition. More...
 
void FlutterViewBeginFrame () override
 Initiates a frame if using hybrid composition. More...
 
void FlutterViewEndFrame () override
 Indicates that the current frame ended. It's used to clean up state. More...
 
std::unique_ptr< PlatformViewAndroidJNI::OverlayMetadataFlutterViewCreateOverlaySurface () override
 Instantiates an overlay surface in hybrid composition and provides the necessary metadata to operate the surface in C. More...
 
void FlutterViewDestroyOverlaySurfaces () override
 Destroys the overlay surfaces. More...
 
std::unique_ptr< std::vector< std::string > > FlutterViewComputePlatformResolvedLocale (std::vector< std::string > supported_locales_data) override
 Computes the locale Android would select. More...
 
double GetDisplayRefreshRate () override
 
- Public Member Functions inherited from flutter::PlatformViewAndroidJNI
virtual ~PlatformViewAndroidJNI ()
 

Detailed Description

Concrete implementation of PlatformViewAndroidJNI that is compiled with the Android toolchain.

Definition at line 17 of file platform_view_android_jni_impl.h.

Constructor & Destructor Documentation

◆ PlatformViewAndroidJNIImpl()

flutter::PlatformViewAndroidJNIImpl::PlatformViewAndroidJNIImpl ( fml::jni::JavaObjectWeakGlobalRef  java_object)

Definition at line 913 of file platform_view_android_jni_impl.cc.

References ~PlatformViewAndroidJNIImpl().

915  : java_object_(java_object) {}

◆ ~PlatformViewAndroidJNIImpl()

flutter::PlatformViewAndroidJNIImpl::~PlatformViewAndroidJNIImpl ( )
overridedefault

Member Function Documentation

◆ FlutterViewBeginFrame()

void flutter::PlatformViewAndroidJNIImpl::FlutterViewBeginFrame ( )
overridevirtual

Initiates a frame if using hybrid composition.

Note
Must be called from the platform thread.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1221 of file platform_view_android_jni_impl.cc.

References fml::jni::AttachCurrentThread(), FML_CHECK, flutter::g_on_begin_frame_method, and fml::jni::JavaObjectWeakGlobalRef::get().

1221  {
1222  JNIEnv* env = fml::jni::AttachCurrentThread();
1223 
1224  auto java_object = java_object_.get(env);
1225  if (java_object.is_null()) {
1226  return;
1227  }
1228 
1229  env->CallVoidMethod(java_object.obj(), g_on_begin_frame_method);
1230 
1231  FML_CHECK(CheckException(env));
1232 }
static jmethodID g_on_begin_frame_method
ScopedJavaLocalRef< jobject > get(JNIEnv *env) const
Definition: jni_weak_ref.cc:41
#define FML_CHECK(condition)
Definition: logging.h:68
JNIEnv * AttachCurrentThread()
Definition: jni_util.cc:26

◆ FlutterViewComputePlatformResolvedLocale()

std::unique_ptr< std::vector< std::string > > flutter::PlatformViewAndroidJNIImpl::FlutterViewComputePlatformResolvedLocale ( std::vector< std::string >  supported_locales_data)
overridevirtual

Computes the locale Android would select.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1293 of file platform_view_android_jni_impl.cc.

References fml::jni::AttachCurrentThread(), FML_CHECK, flutter::g_compute_platform_resolved_locale_method, fml::jni::JavaObjectWeakGlobalRef::get(), fml::jni::JavaStringToString(), length, fml::jni::JavaRef< T >::obj(), and fml::jni::VectorToStringArray().

1294  {
1295  JNIEnv* env = fml::jni::AttachCurrentThread();
1296 
1297  std::unique_ptr<std::vector<std::string>> out =
1298  std::make_unique<std::vector<std::string>>();
1299 
1300  auto java_object = java_object_.get(env);
1301  if (java_object.is_null()) {
1302  return out;
1303  }
1305  fml::jni::VectorToStringArray(env, supported_locales_data);
1306  jobjectArray result = static_cast<jobjectArray>(env->CallObjectMethod(
1307  java_object.obj(), g_compute_platform_resolved_locale_method,
1308  j_locales_data.obj()));
1309 
1310  FML_CHECK(CheckException(env));
1311 
1312  int length = env->GetArrayLength(result);
1313  for (int i = 0; i < length; i++) {
1314  out->emplace_back(fml::jni::JavaStringToString(
1315  env, static_cast<jstring>(env->GetObjectArrayElement(result, i))));
1316  }
1317  return out;
1318 }
ScopedJavaLocalRef< jobjectArray > VectorToStringArray(JNIEnv *env, const std::vector< std::string > &vector)
Definition: jni_util.cc:110
ScopedJavaLocalRef< jobject > get(JNIEnv *env) const
Definition: jni_weak_ref.cc:41
size_t length
static jmethodID g_compute_platform_resolved_locale_method
#define FML_CHECK(condition)
Definition: logging.h:68
JNIEnv * AttachCurrentThread()
Definition: jni_util.cc:26
std::string JavaStringToString(JNIEnv *env, jstring str)
Definition: jni_util.cc:58

◆ FlutterViewCreateOverlaySurface()

std::unique_ptr< PlatformViewAndroidJNI::OverlayMetadata > flutter::PlatformViewAndroidJNIImpl::FlutterViewCreateOverlaySurface ( )
overridevirtual

Instantiates an overlay surface in hybrid composition and provides the necessary metadata to operate the surface in C.

Note
Must be called from the platform thread.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1248 of file platform_view_android_jni_impl.cc.

References fml::jni::AttachCurrentThread(), FML_CHECK, flutter::g_create_overlay_surface_method, flutter::g_overlay_surface_id_method, flutter::g_overlay_surface_surface_method, fml::jni::JavaObjectWeakGlobalRef::get(), and fml::jni::JavaRef< T >::obj().

1248  {
1249  JNIEnv* env = fml::jni::AttachCurrentThread();
1250 
1251  auto java_object = java_object_.get(env);
1252  if (java_object.is_null()) {
1253  return nullptr;
1254  }
1255 
1257  env, env->CallObjectMethod(java_object.obj(),
1259  FML_CHECK(CheckException(env));
1260 
1261  if (overlay.is_null()) {
1262  return std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(0,
1263  nullptr);
1264  }
1265 
1266  jint overlay_id =
1267  env->CallIntMethod(overlay.obj(), g_overlay_surface_id_method);
1268 
1269  jobject overlay_surface =
1270  env->CallObjectMethod(overlay.obj(), g_overlay_surface_surface_method);
1271 
1272  auto overlay_window = fml::MakeRefCounted<AndroidNativeWindow>(
1273  ANativeWindow_fromSurface(env, overlay_surface));
1274 
1275  return std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
1276  overlay_id, std::move(overlay_window));
1277 }
static jmethodID g_overlay_surface_surface_method
static jmethodID g_create_overlay_surface_method
ScopedJavaLocalRef< jobject > get(JNIEnv *env) const
Definition: jni_weak_ref.cc:41
static jmethodID g_overlay_surface_id_method
#define FML_CHECK(condition)
Definition: logging.h:68
JNIEnv * AttachCurrentThread()
Definition: jni_util.cc:26

◆ FlutterViewDestroyOverlaySurfaces()

void flutter::PlatformViewAndroidJNIImpl::FlutterViewDestroyOverlaySurfaces ( )
overridevirtual

Destroys the overlay surfaces.

Note
Must be called from the platform thread.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1279 of file platform_view_android_jni_impl.cc.

References fml::jni::AttachCurrentThread(), FML_CHECK, flutter::g_destroy_overlay_surfaces_method, and fml::jni::JavaObjectWeakGlobalRef::get().

1279  {
1280  JNIEnv* env = fml::jni::AttachCurrentThread();
1281 
1282  auto java_object = java_object_.get(env);
1283  if (java_object.is_null()) {
1284  return;
1285  }
1286 
1287  env->CallVoidMethod(java_object.obj(), g_destroy_overlay_surfaces_method);
1288 
1289  FML_CHECK(CheckException(env));
1290 }
static jmethodID g_destroy_overlay_surfaces_method
ScopedJavaLocalRef< jobject > get(JNIEnv *env) const
Definition: jni_weak_ref.cc:41
#define FML_CHECK(condition)
Definition: logging.h:68
JNIEnv * AttachCurrentThread()
Definition: jni_util.cc:26

◆ FlutterViewDisplayOverlaySurface()

void flutter::PlatformViewAndroidJNIImpl::FlutterViewDisplayOverlaySurface ( int  surface_id,
int  x,
int  y,
int  width,
int  height 
)
overridevirtual

Positions and sizes an overlay surface in hybrid composition.

Note
Must be called from the platform thread.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1202 of file platform_view_android_jni_impl.cc.

References fml::jni::AttachCurrentThread(), FML_CHECK, flutter::g_on_display_overlay_surface_method, fml::jni::JavaObjectWeakGlobalRef::get(), height, and width.

1207  {
1208  JNIEnv* env = fml::jni::AttachCurrentThread();
1209 
1210  auto java_object = java_object_.get(env);
1211  if (java_object.is_null()) {
1212  return;
1213  }
1214 
1215  env->CallVoidMethod(java_object.obj(), g_on_display_overlay_surface_method,
1216  surface_id, x, y, width, height);
1217 
1218  FML_CHECK(CheckException(env));
1219 }
ScopedJavaLocalRef< jobject > get(JNIEnv *env) const
Definition: jni_weak_ref.cc:41
int32_t height
int32_t width
#define FML_CHECK(condition)
Definition: logging.h:68
JNIEnv * AttachCurrentThread()
Definition: jni_util.cc:26
static jmethodID g_on_display_overlay_surface_method

◆ FlutterViewEndFrame()

void flutter::PlatformViewAndroidJNIImpl::FlutterViewEndFrame ( )
overridevirtual

Indicates that the current frame ended. It's used to clean up state.

Note
Must be called from the platform thread.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1234 of file platform_view_android_jni_impl.cc.

References fml::jni::AttachCurrentThread(), FML_CHECK, flutter::g_on_end_frame_method, and fml::jni::JavaObjectWeakGlobalRef::get().

1234  {
1235  JNIEnv* env = fml::jni::AttachCurrentThread();
1236 
1237  auto java_object = java_object_.get(env);
1238  if (java_object.is_null()) {
1239  return;
1240  }
1241 
1242  env->CallVoidMethod(java_object.obj(), g_on_end_frame_method);
1243 
1244  FML_CHECK(CheckException(env));
1245 }
ScopedJavaLocalRef< jobject > get(JNIEnv *env) const
Definition: jni_weak_ref.cc:41
static jmethodID g_on_end_frame_method
#define FML_CHECK(condition)
Definition: logging.h:68
JNIEnv * AttachCurrentThread()
Definition: jni_util.cc:26

◆ FlutterViewHandlePlatformMessage()

void flutter::PlatformViewAndroidJNIImpl::FlutterViewHandlePlatformMessage ( fml::RefPtr< flutter::PlatformMessage message,
int  responseId 
)
overridevirtual

Sends a platform message. The message may be empty.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 919 of file platform_view_android_jni_impl.cc.

References fml::jni::AttachCurrentThread(), flutter::PlatformMessage::channel(), flutter::PlatformMessage::data(), FML_CHECK, flutter::g_handle_platform_message_method, fml::jni::JavaObjectWeakGlobalRef::get(), flutter::PlatformMessage::hasData(), fml::jni::JavaRef< T >::obj(), and fml::jni::StringToJavaString().

921  {
922  JNIEnv* env = fml::jni::AttachCurrentThread();
923 
924  auto java_object = java_object_.get(env);
925  if (java_object.is_null()) {
926  return;
927  }
928 
930  fml::jni::StringToJavaString(env, message->channel());
931 
932  if (message->hasData()) {
934  env, env->NewByteArray(message->data().size()));
935  env->SetByteArrayRegion(
936  message_array.obj(), 0, message->data().size(),
937  reinterpret_cast<const jbyte*>(message->data().data()));
938  env->CallVoidMethod(java_object.obj(), g_handle_platform_message_method,
939  java_channel.obj(), message_array.obj(), responseId);
940  } else {
941  env->CallVoidMethod(java_object.obj(), g_handle_platform_message_method,
942  java_channel.obj(), nullptr, responseId);
943  }
944 
945  FML_CHECK(CheckException(env));
946 }
ScopedJavaLocalRef< jstring > StringToJavaString(JNIEnv *env, const std::string &u8_string)
Definition: jni_util.cc:78
const std::vector< uint8_t > & data() const
static jmethodID g_handle_platform_message_method
const std::string & channel() const
ScopedJavaLocalRef< jobject > get(JNIEnv *env) const
Definition: jni_weak_ref.cc:41
#define FML_CHECK(condition)
Definition: logging.h:68
JNIEnv * AttachCurrentThread()
Definition: jni_util.cc:26

◆ FlutterViewHandlePlatformMessageResponse()

void flutter::PlatformViewAndroidJNIImpl::FlutterViewHandlePlatformMessageResponse ( int  responseId,
std::unique_ptr< fml::Mapping data 
)
overridevirtual

Responds to a platform message. The data may be a nullptr.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 948 of file platform_view_android_jni_impl.cc.

References fml::jni::AttachCurrentThread(), FML_CHECK, flutter::g_handle_platform_message_response_method, fml::jni::JavaObjectWeakGlobalRef::get(), and fml::jni::JavaRef< T >::obj().

950  {
951  // We are on the platform thread. Attempt to get the strong reference to
952  // the Java object.
953  JNIEnv* env = fml::jni::AttachCurrentThread();
954 
955  auto java_object = java_object_.get(env);
956  if (java_object.is_null()) {
957  // The Java object was collected before this message response got to
958  // it. Drop the response on the floor.
959  return;
960  }
961  if (data == nullptr) { // Empty response.
962  env->CallVoidMethod(java_object.obj(),
964  nullptr);
965  } else {
966  // Convert the vector to a Java byte array.
968  env, env->NewByteArray(data->GetSize()));
969  env->SetByteArrayRegion(data_array.obj(), 0, data->GetSize(),
970  reinterpret_cast<const jbyte*>(data->GetMapping()));
971 
972  env->CallVoidMethod(java_object.obj(),
974  data_array.obj());
975  }
976 
977  FML_CHECK(CheckException(env));
978 }
ScopedJavaLocalRef< jobject > get(JNIEnv *env) const
Definition: jni_weak_ref.cc:41
#define FML_CHECK(condition)
Definition: logging.h:68
JNIEnv * AttachCurrentThread()
Definition: jni_util.cc:26
static jmethodID g_handle_platform_message_response_method

◆ FlutterViewOnDisplayPlatformView()

void flutter::PlatformViewAndroidJNIImpl::FlutterViewOnDisplayPlatformView ( int  view_id,
int  x,
int  y,
int  width,
int  height,
int  viewWidth,
int  viewHeight,
MutatorsStack  mutators_stack 
)
overridevirtual

Positions and sizes a platform view if using hybrid composition.

Note
Must be called from the platform thread.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1142 of file platform_view_android_jni_impl.cc.

References fml::jni::AttachCurrentThread(), flutter::MutatorsStack::Begin(), flutter::clip_path, flutter::clip_rect, flutter::clip_rrect, flutter::MutatorsStack::End(), FML_CHECK, flutter::g_mutators_stack_init_method, flutter::g_on_display_platform_view_method, fml::jni::JavaObjectWeakGlobalRef::get(), height, fml::jni::JavaRef< T >::obj(), flutter::opacity, flutter::transform, and width.

1150  {
1151  JNIEnv* env = fml::jni::AttachCurrentThread();
1152  auto java_object = java_object_.get(env);
1153  if (java_object.is_null()) {
1154  return;
1155  }
1156 
1157  jobject mutatorsStack = env->NewObject(g_mutators_stack_class->obj(),
1159 
1160  std::vector<std::shared_ptr<Mutator>>::const_iterator iter =
1161  mutators_stack.Begin();
1162  while (iter != mutators_stack.End()) {
1163  switch ((*iter)->GetType()) {
1164  case transform: {
1165  const SkMatrix& matrix = (*iter)->GetMatrix();
1166  SkScalar matrix_array[9];
1167  matrix.get9(matrix_array);
1169  env, env->NewFloatArray(9));
1170 
1171  env->SetFloatArrayRegion(transformMatrix.obj(), 0, 9, matrix_array);
1172  env->CallVoidMethod(mutatorsStack,
1174  transformMatrix.obj());
1175  break;
1176  }
1177  case clip_rect: {
1178  const SkRect& rect = (*iter)->GetRect();
1179  env->CallVoidMethod(
1181  static_cast<int>(rect.left()), static_cast<int>(rect.top()),
1182  static_cast<int>(rect.right()), static_cast<int>(rect.bottom()));
1183  break;
1184  }
1185  // TODO(cyanglaz): Implement other mutators.
1186  // https://github.com/flutter/flutter/issues/58426
1187  case clip_rrect:
1188  case clip_path:
1189  case opacity:
1190  break;
1191  }
1192  ++iter;
1193  }
1194 
1195  env->CallVoidMethod(java_object.obj(), g_on_display_platform_view_method,
1196  view_id, x, y, width, height, viewWidth, viewHeight,
1197  mutatorsStack);
1198 
1199  FML_CHECK(CheckException(env));
1200 }
static fml::jni::ScopedJavaGlobalRef< jclass > * g_mutators_stack_class
static jmethodID g_mutators_stack_push_cliprect_method
static jmethodID g_mutators_stack_init_method
static jmethodID g_mutators_stack_push_transform_method
ScopedJavaLocalRef< jobject > get(JNIEnv *env) const
Definition: jni_weak_ref.cc:41
static jmethodID g_on_display_platform_view_method
int32_t height
int32_t width
#define FML_CHECK(condition)
Definition: logging.h:68
JNIEnv * AttachCurrentThread()
Definition: jni_util.cc:26

◆ FlutterViewOnFirstFrame()

void flutter::PlatformViewAndroidJNIImpl::FlutterViewOnFirstFrame ( )
overridevirtual

Indicates that FlutterView should start painting pixels.

Note
Must be called from the platform thread.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1025 of file platform_view_android_jni_impl.cc.

References fml::jni::AttachCurrentThread(), FML_CHECK, flutter::g_on_first_frame_method, and fml::jni::JavaObjectWeakGlobalRef::get().

1025  {
1026  JNIEnv* env = fml::jni::AttachCurrentThread();
1027 
1028  auto java_object = java_object_.get(env);
1029  if (java_object.is_null()) {
1030  return;
1031  }
1032 
1033  env->CallVoidMethod(java_object.obj(), g_on_first_frame_method);
1034 
1035  FML_CHECK(CheckException(env));
1036 }
static jmethodID g_on_first_frame_method
ScopedJavaLocalRef< jobject > get(JNIEnv *env) const
Definition: jni_weak_ref.cc:41
#define FML_CHECK(condition)
Definition: logging.h:68
JNIEnv * AttachCurrentThread()
Definition: jni_util.cc:26

◆ FlutterViewOnPreEngineRestart()

void flutter::PlatformViewAndroidJNIImpl::FlutterViewOnPreEngineRestart ( )
overridevirtual

Indicates that a hot restart is about to happen.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1038 of file platform_view_android_jni_impl.cc.

References fml::jni::AttachCurrentThread(), FML_CHECK, flutter::g_on_engine_restart_method, and fml::jni::JavaObjectWeakGlobalRef::get().

1038  {
1039  JNIEnv* env = fml::jni::AttachCurrentThread();
1040 
1041  auto java_object = java_object_.get(env);
1042  if (java_object.is_null()) {
1043  return;
1044  }
1045 
1046  env->CallVoidMethod(java_object.obj(), g_on_engine_restart_method);
1047 
1048  FML_CHECK(CheckException(env));
1049 }
ScopedJavaLocalRef< jobject > get(JNIEnv *env) const
Definition: jni_weak_ref.cc:41
static jmethodID g_on_engine_restart_method
#define FML_CHECK(condition)
Definition: logging.h:68
JNIEnv * AttachCurrentThread()
Definition: jni_util.cc:26

◆ FlutterViewUpdateCustomAccessibilityActions()

void flutter::PlatformViewAndroidJNIImpl::FlutterViewUpdateCustomAccessibilityActions ( std::vector< uint8_t >  actions_buffer,
std::vector< std::string >  strings 
)
overridevirtual

Sends new custom accessibility events.

Note
Must be called from the platform thread.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1001 of file platform_view_android_jni_impl.cc.

References fml::jni::AttachCurrentThread(), FML_CHECK, flutter::g_update_custom_accessibility_actions_method, fml::jni::JavaObjectWeakGlobalRef::get(), fml::jni::JavaRef< T >::obj(), and fml::jni::VectorToStringArray().

1003  {
1004  JNIEnv* env = fml::jni::AttachCurrentThread();
1005 
1006  auto java_object = java_object_.get(env);
1007  if (java_object.is_null()) {
1008  return;
1009  }
1010 
1011  fml::jni::ScopedJavaLocalRef<jobject> direct_actions_buffer(
1012  env,
1013  env->NewDirectByteBuffer(actions_buffer.data(), actions_buffer.size()));
1014 
1016  fml::jni::VectorToStringArray(env, strings);
1017 
1018  env->CallVoidMethod(java_object.obj(),
1020  direct_actions_buffer.obj(), jstrings.obj());
1021 
1022  FML_CHECK(CheckException(env));
1023 }
ScopedJavaLocalRef< jobjectArray > VectorToStringArray(JNIEnv *env, const std::vector< std::string > &vector)
Definition: jni_util.cc:110
static jmethodID g_update_custom_accessibility_actions_method
ScopedJavaLocalRef< jobject > get(JNIEnv *env) const
Definition: jni_weak_ref.cc:41
#define FML_CHECK(condition)
Definition: logging.h:68
JNIEnv * AttachCurrentThread()
Definition: jni_util.cc:26

◆ FlutterViewUpdateSemantics()

void flutter::PlatformViewAndroidJNIImpl::FlutterViewUpdateSemantics ( std::vector< uint8_t >  buffer,
std::vector< std::string >  strings 
)
overridevirtual

Sends semantics tree updates.

Note
Must be called from the platform thread.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 980 of file platform_view_android_jni_impl.cc.

References fml::jni::AttachCurrentThread(), FML_CHECK, flutter::g_update_semantics_method, fml::jni::JavaObjectWeakGlobalRef::get(), fml::jni::JavaRef< T >::obj(), and fml::jni::VectorToStringArray().

982  {
983  JNIEnv* env = fml::jni::AttachCurrentThread();
984 
985  auto java_object = java_object_.get(env);
986  if (java_object.is_null()) {
987  return;
988  }
989 
991  env, env->NewDirectByteBuffer(buffer.data(), buffer.size()));
993  fml::jni::VectorToStringArray(env, strings);
994 
995  env->CallVoidMethod(java_object.obj(), g_update_semantics_method,
996  direct_buffer.obj(), jstrings.obj());
997 
998  FML_CHECK(CheckException(env));
999 }
ScopedJavaLocalRef< jobjectArray > VectorToStringArray(JNIEnv *env, const std::vector< std::string > &vector)
Definition: jni_util.cc:110
static jmethodID g_update_semantics_method
ScopedJavaLocalRef< jobject > get(JNIEnv *env) const
Definition: jni_weak_ref.cc:41
#define FML_CHECK(condition)
Definition: logging.h:68
JNIEnv * AttachCurrentThread()
Definition: jni_util.cc:26

◆ GetDisplayRefreshRate()

double flutter::PlatformViewAndroidJNIImpl::GetDisplayRefreshRate ( )
overridevirtual

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1320 of file platform_view_android_jni_impl.cc.

References fml::jni::AttachCurrentThread(), fml::jni::JavaObjectWeakGlobalRef::get(), and flutter::kUnknownDisplayRefreshRate.

1320  {
1321  JNIEnv* env = fml::jni::AttachCurrentThread();
1322 
1323  auto java_object = java_object_.get(env);
1324  if (java_object.is_null()) {
1326  }
1327 
1328  jclass clazz = env->GetObjectClass(java_object.obj());
1329  if (clazz == nullptr) {
1331  }
1332 
1333  jfieldID fid = env->GetStaticFieldID(clazz, "refreshRateFPS", "F");
1334  return static_cast<double>(env->GetStaticFloatField(clazz, fid));
1335 }
static constexpr double kUnknownDisplayRefreshRate
To be used when the display refresh rate is unknown.
Definition: display.h:17
ScopedJavaLocalRef< jobject > get(JNIEnv *env) const
Definition: jni_weak_ref.cc:41
JNIEnv * AttachCurrentThread()
Definition: jni_util.cc:26

◆ SurfaceTextureAttachToGLContext()

void flutter::PlatformViewAndroidJNIImpl::SurfaceTextureAttachToGLContext ( JavaWeakGlobalRef  surface_texture,
int  textureId 
)
overridevirtual

Attach the SurfaceTexture to the OpenGL ES context that is current on the calling thread.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1051 of file platform_view_android_jni_impl.cc.

References fml::jni::AttachCurrentThread(), FML_CHECK, flutter::g_attach_to_gl_context_method, and fml::jni::JavaRef< T >::obj().

1053  {
1054  JNIEnv* env = fml::jni::AttachCurrentThread();
1055 
1056  fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref =
1057  surface_texture.get(env);
1058  if (surface_texture_local_ref.is_null()) {
1059  return;
1060  }
1061 
1062  env->CallVoidMethod(surface_texture_local_ref.obj(),
1063  g_attach_to_gl_context_method, textureId);
1064 
1065  FML_CHECK(CheckException(env));
1066 }
static jmethodID g_attach_to_gl_context_method
#define FML_CHECK(condition)
Definition: logging.h:68
JNIEnv * AttachCurrentThread()
Definition: jni_util.cc:26

◆ SurfaceTextureDetachFromGLContext()

void flutter::PlatformViewAndroidJNIImpl::SurfaceTextureDetachFromGLContext ( JavaWeakGlobalRef  surface_texture)
overridevirtual

Detaches a SurfaceTexture from the OpenGL ES context.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1126 of file platform_view_android_jni_impl.cc.

References fml::jni::AttachCurrentThread(), FML_CHECK, flutter::g_detach_from_gl_context_method, and fml::jni::JavaRef< T >::obj().

1127  {
1128  JNIEnv* env = fml::jni::AttachCurrentThread();
1129 
1130  fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref =
1131  surface_texture.get(env);
1132  if (surface_texture_local_ref.is_null()) {
1133  return;
1134  }
1135 
1136  env->CallVoidMethod(surface_texture_local_ref.obj(),
1138 
1139  FML_CHECK(CheckException(env));
1140 }
static jmethodID g_detach_from_gl_context_method
#define FML_CHECK(condition)
Definition: logging.h:68
JNIEnv * AttachCurrentThread()
Definition: jni_util.cc:26

◆ SurfaceTextureGetTransformMatrix()

void flutter::PlatformViewAndroidJNIImpl::SurfaceTextureGetTransformMatrix ( JavaWeakGlobalRef  surface_texture,
SkMatrix &  transform 
)
overridevirtual

Gets the transform matrix from the SurfaceTexture. Then, it updates the transform matrix, so it fill the canvas and preserve the aspect ratio.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1096 of file platform_view_android_jni_impl.cc.

References fml::jni::AttachCurrentThread(), FML_CHECK, flutter::g_get_transform_matrix_method, fml::jni::JavaRef< T >::obj(), and flutter::ScaleToFill().

1098  {
1099  JNIEnv* env = fml::jni::AttachCurrentThread();
1100 
1101  fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref =
1102  surface_texture.get(env);
1103  if (surface_texture_local_ref.is_null()) {
1104  return;
1105  }
1106 
1108  env, env->NewFloatArray(16));
1109 
1110  env->CallVoidMethod(surface_texture_local_ref.obj(),
1111  g_get_transform_matrix_method, transformMatrix.obj());
1112  FML_CHECK(CheckException(env));
1113 
1114  float* m = env->GetFloatArrayElements(transformMatrix.obj(), nullptr);
1115  float scaleX = m[0], scaleY = m[5];
1116  const SkSize scaled = ScaleToFill(scaleX, scaleY);
1117  SkScalar matrix3[] = {
1118  scaled.fWidth, m[1], m[2], //
1119  m[4], scaled.fHeight, m[6], //
1120  m[8], m[9], m[10], //
1121  };
1122  env->ReleaseFloatArrayElements(transformMatrix.obj(), m, JNI_ABORT);
1123  transform.set9(matrix3);
1124 }
static jmethodID g_get_transform_matrix_method
#define FML_CHECK(condition)
Definition: logging.h:68
SkSize ScaleToFill(float scaleX, float scaleY)
JNIEnv * AttachCurrentThread()
Definition: jni_util.cc:26

◆ SurfaceTextureUpdateTexImage()

void flutter::PlatformViewAndroidJNIImpl::SurfaceTextureUpdateTexImage ( JavaWeakGlobalRef  surface_texture)
overridevirtual

Updates the texture image to the most recent frame from the image stream.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1068 of file platform_view_android_jni_impl.cc.

References fml::jni::AttachCurrentThread(), FML_CHECK, flutter::g_update_tex_image_method, and fml::jni::JavaRef< T >::obj().

1069  {
1070  JNIEnv* env = fml::jni::AttachCurrentThread();
1071 
1072  fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref =
1073  surface_texture.get(env);
1074  if (surface_texture_local_ref.is_null()) {
1075  return;
1076  }
1077 
1078  env->CallVoidMethod(surface_texture_local_ref.obj(),
1080 
1081  FML_CHECK(CheckException(env));
1082 }
static jmethodID g_update_tex_image_method
#define FML_CHECK(condition)
Definition: logging.h:68
JNIEnv * AttachCurrentThread()
Definition: jni_util.cc:26

The documentation for this class was generated from the following files: