Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
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 (const fml::jni::JavaObjectWeakGlobalRef &java_object)
 
 ~PlatformViewAndroidJNIImpl () override
 
void FlutterViewHandlePlatformMessage (std::unique_ptr< flutter::PlatformMessage > message, int responseId) override
 Sends a platform message. The message may be empty.
 
void FlutterViewHandlePlatformMessageResponse (int responseId, std::unique_ptr< fml::Mapping > data) override
 Responds to a platform message. The data may be a nullptr.
 
void FlutterViewUpdateSemantics (std::vector< uint8_t > buffer, std::vector< std::string > strings, std::vector< std::vector< uint8_t > > string_attribute_args) override
 Sends semantics tree updates.
 
void FlutterViewSetApplicationLocale (std::string locale) override
 Set application locale to a given language.
 
void FlutterViewUpdateCustomAccessibilityActions (std::vector< uint8_t > actions_buffer, std::vector< std::string > strings) override
 Sends new custom accessibility events.
 
void FlutterViewOnFirstFrame () override
 Indicates that FlutterView should start painting pixels.
 
void FlutterViewOnPreEngineRestart () override
 Indicates that a hot restart is about to happen.
 
void FlutterViewSetSemanticsTreeEnabled (bool enabled) override
 Enables or disables the semantics tree.
 
void SurfaceTextureAttachToGLContext (JavaLocalRef surface_texture, int textureId) override
 Attach the SurfaceTexture to the OpenGL ES context that is current on the calling thread.
 
bool SurfaceTextureShouldUpdate (JavaLocalRef surface_texture) override
 Returns true if surface_texture should be updated.
 
void SurfaceTextureUpdateTexImage (JavaLocalRef surface_texture) override
 Updates the texture image to the most recent frame from the image stream.
 
SkM44 SurfaceTextureGetTransformMatrix (JavaLocalRef surface_texture) override
 Gets the transform matrix from the SurfaceTexture. Then, it updates the transform matrix, so it fill the canvas and preserve the aspect ratio.
 
void SurfaceTextureDetachFromGLContext (JavaLocalRef surface_texture) override
 Detaches a SurfaceTexture from the OpenGL ES context.
 
JavaLocalRef ImageProducerTextureEntryAcquireLatestImage (JavaLocalRef image_texture_entry) override
 Acquire the latest image available.
 
JavaLocalRef ImageGetHardwareBuffer (JavaLocalRef image) override
 Grab the HardwareBuffer from image.
 
void ImageClose (JavaLocalRef image) override
 Call close on image.
 
void HardwareBufferClose (JavaLocalRef hardware_buffer) override
 Call close on hardware_buffer.
 
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.
 
void FlutterViewDisplayOverlaySurface (int surface_id, int x, int y, int width, int height) override
 Positions and sizes an overlay surface in hybrid composition.
 
void FlutterViewBeginFrame () override
 Initiates a frame if using hybrid composition.
 
void FlutterViewEndFrame () override
 Indicates that the current frame ended. It's used to clean up state.
 
std::unique_ptr< PlatformViewAndroidJNI::OverlayMetadataFlutterViewCreateOverlaySurface () override
 Instantiates an overlay surface in hybrid composition and provides the necessary metadata to operate the surface in C.
 
void FlutterViewDestroyOverlaySurfaces () override
 Destroys the overlay surfaces.
 
std::unique_ptr< std::vector< std::string > > FlutterViewComputePlatformResolvedLocale (std::vector< std::string > supported_locales_data) override
 Computes the locale Android would select.
 
double GetDisplayRefreshRate () override
 
double GetDisplayWidth () override
 
double GetDisplayHeight () override
 
double GetDisplayDensity () override
 
bool RequestDartDeferredLibrary (int loading_unit_id) override
 
double FlutterViewGetScaledFontSize (double unscaled_font_size, int configuration_id) const override
 
ASurfaceTransaction * createTransaction () override
 
void swapTransaction () override
 
void applyTransaction () override
 
std::unique_ptr< PlatformViewAndroidJNI::OverlayMetadatacreateOverlaySurface2 () override
 
void destroyOverlaySurface2 () override
 
void onDisplayPlatformView2 (int32_t view_id, int32_t x, int32_t y, int32_t width, int32_t height, int32_t viewWidth, int32_t viewHeight, MutatorsStack mutators_stack) override
 
void hidePlatformView2 (int32_t view_id) override
 
void showOverlaySurface2 () override
 
void hideOverlaySurface2 () override
 
void onEndFrame2 () override
 
void MaybeResizeSurfaceView (int32_t width, int32_t height) const 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 ( const fml::jni::JavaObjectWeakGlobalRef java_object)
explicit

Definition at line 1333 of file platform_view_android_jni_impl.cc.

1335 : java_object_(java_object) {}

◆ ~PlatformViewAndroidJNIImpl()

flutter::PlatformViewAndroidJNIImpl::~PlatformViewAndroidJNIImpl ( )
overridedefault

Member Function Documentation

◆ applyTransaction()

void flutter::PlatformViewAndroidJNIImpl::applyTransaction ( )
overridevirtual

Implements flutter::PlatformViewAndroidJNI.

Definition at line 2067 of file platform_view_android_jni_impl.cc.

2067 {
2068 JNIEnv* env = fml::jni::AttachCurrentThread();
2069
2070 auto java_object = java_object_.get(env);
2071 if (java_object.is_null()) {
2072 return;
2073 }
2074
2075 env->CallVoidMethod(java_object.obj(), g_apply_transaction_method);
2076
2078}
ScopedJavaLocalRef< jobject > get(JNIEnv *env) const
#define FML_CHECK(condition)
Definition logging.h:104
JNIEnv * AttachCurrentThread()
Definition jni_util.cc:34
bool CheckException(JNIEnv *env)
Definition jni_util.cc:199

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

◆ createOverlaySurface2()

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

Implements flutter::PlatformViewAndroidJNI.

Definition at line 2081 of file platform_view_android_jni_impl.cc.

2081 {
2082 JNIEnv* env = fml::jni::AttachCurrentThread();
2083
2084 auto java_object = java_object_.get(env);
2085 if (java_object.is_null()) {
2086 return nullptr;
2087 }
2088
2090 env, env->CallObjectMethod(java_object.obj(),
2091 g_create_overlay_surface2_method));
2093
2094 if (overlay.is_null()) {
2095 return std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(0,
2096 nullptr);
2097 }
2098
2099 jint overlay_id =
2100 env->CallIntMethod(overlay.obj(), g_overlay_surface_id_method);
2101
2102 jobject overlay_surface =
2103 env->CallObjectMethod(overlay.obj(), g_overlay_surface_surface_method);
2104
2105 auto overlay_window = fml::MakeRefCounted<AndroidNativeWindow>(
2106 ANativeWindow_fromSurface(env, overlay_surface));
2107
2108 return std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
2109 overlay_id, std::move(overlay_window));
2110}
static jmethodID g_overlay_surface_surface_method
static jmethodID g_overlay_surface_id_method

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

◆ createTransaction()

ASurfaceTransaction * flutter::PlatformViewAndroidJNIImpl::createTransaction ( )
overridevirtual

Implements flutter::PlatformViewAndroidJNI.

Definition at line 2034 of file platform_view_android_jni_impl.cc.

2034 {
2035 JNIEnv* env = fml::jni::AttachCurrentThread();
2036
2037 auto java_object = java_object_.get(env);
2038 if (java_object.is_null()) {
2039 return nullptr;
2040 }
2041
2043 env,
2044 env->CallObjectMethod(java_object.obj(), g_create_transaction_method));
2045 if (transaction.is_null()) {
2046 return nullptr;
2047 }
2049
2050 return impeller::android::GetProcTable().ASurfaceTransaction_fromJava(
2051 env, transaction.obj());
2052}
const ProcTable & GetProcTable()
Definition proc_table.cc:12

References fml::jni::AttachCurrentThread(), fml::jni::CheckException(), FML_CHECK, fml::jni::JavaObjectWeakGlobalRef::get(), impeller::android::GetProcTable(), and fml::jni::JavaRef< T >::obj().

◆ destroyOverlaySurface2()

void flutter::PlatformViewAndroidJNIImpl::destroyOverlaySurface2 ( )
overridevirtual

Implements flutter::PlatformViewAndroidJNI.

Definition at line 2112 of file platform_view_android_jni_impl.cc.

2112 {
2113 JNIEnv* env = fml::jni::AttachCurrentThread();
2114
2115 auto java_object = java_object_.get(env);
2116 if (java_object.is_null()) {
2117 return;
2118 }
2119
2120 env->CallVoidMethod(java_object.obj(), g_destroy_overlay_surface2_method);
2121
2123}

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

◆ 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 1845 of file platform_view_android_jni_impl.cc.

1845 {
1846 JNIEnv* env = fml::jni::AttachCurrentThread();
1847
1848 auto java_object = java_object_.get(env);
1849 if (java_object.is_null()) {
1850 return;
1851 }
1852
1853 env->CallVoidMethod(java_object.obj(), g_on_begin_frame_method);
1854
1856}

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

◆ 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 1917 of file platform_view_android_jni_impl.cc.

1918 {
1919 JNIEnv* env = fml::jni::AttachCurrentThread();
1920
1921 std::unique_ptr<std::vector<std::string>> out =
1922 std::make_unique<std::vector<std::string>>();
1923
1924 auto java_object = java_object_.get(env);
1925 if (java_object.is_null()) {
1926 return out;
1927 }
1929 fml::jni::VectorToStringArray(env, supported_locales_data);
1930 jobjectArray result = static_cast<jobjectArray>(env->CallObjectMethod(
1932 j_locales_data.obj()));
1933
1935
1936 int length = env->GetArrayLength(result);
1937 for (int i = 0; i < length; i++) {
1938 out->emplace_back(fml::jni::JavaStringToString(
1939 env, static_cast<jstring>(env->GetObjectArrayElement(result, i))));
1940 }
1941 return out;
1942}
size_t length
static jmethodID g_compute_platform_resolved_locale_method
std::string JavaStringToString(JNIEnv *env, jstring str)
Definition jni_util.cc:70
ScopedJavaLocalRef< jobjectArray > VectorToStringArray(JNIEnv *env, const std::vector< std::string > &vector)
Definition jni_util.cc:147

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

◆ 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 1872 of file platform_view_android_jni_impl.cc.

1872 {
1873 JNIEnv* env = fml::jni::AttachCurrentThread();
1874
1875 auto java_object = java_object_.get(env);
1876 if (java_object.is_null()) {
1877 return nullptr;
1878 }
1879
1881 env, env->CallObjectMethod(java_object.obj(),
1882 g_create_overlay_surface_method));
1884
1885 if (overlay.is_null()) {
1886 return std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(0,
1887 nullptr);
1888 }
1889
1890 jint overlay_id =
1891 env->CallIntMethod(overlay.obj(), g_overlay_surface_id_method);
1892
1893 jobject overlay_surface =
1894 env->CallObjectMethod(overlay.obj(), g_overlay_surface_surface_method);
1895
1896 auto overlay_window = fml::MakeRefCounted<AndroidNativeWindow>(
1897 ANativeWindow_fromSurface(env, overlay_surface));
1898
1899 return std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
1900 overlay_id, std::move(overlay_window));
1901}

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

◆ FlutterViewDestroyOverlaySurfaces()

void flutter::PlatformViewAndroidJNIImpl::FlutterViewDestroyOverlaySurfaces ( )
overridevirtual

Destroys the overlay surfaces.

Note
Must be called from the platform thread.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1903 of file platform_view_android_jni_impl.cc.

1903 {
1904 JNIEnv* env = fml::jni::AttachCurrentThread();
1905
1906 auto java_object = java_object_.get(env);
1907 if (java_object.is_null()) {
1908 return;
1909 }
1910
1911 env->CallVoidMethod(java_object.obj(), g_destroy_overlay_surfaces_method);
1912
1914}

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

◆ 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 1826 of file platform_view_android_jni_impl.cc.

1831 {
1832 JNIEnv* env = fml::jni::AttachCurrentThread();
1833
1834 auto java_object = java_object_.get(env);
1835 if (java_object.is_null()) {
1836 return;
1837 }
1838
1839 env->CallVoidMethod(java_object.obj(), g_on_display_overlay_surface_method,
1840 surface_id, x, y, width, height);
1841
1843}
int32_t x
double y
int32_t height
int32_t width

References fml::jni::AttachCurrentThread(), fml::jni::CheckException(), FML_CHECK, fml::jni::JavaObjectWeakGlobalRef::get(), height, width, x, and y.

◆ 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 1858 of file platform_view_android_jni_impl.cc.

1858 {
1859 JNIEnv* env = fml::jni::AttachCurrentThread();
1860
1861 auto java_object = java_object_.get(env);
1862 if (java_object.is_null()) {
1863 return;
1864 }
1865
1866 env->CallVoidMethod(java_object.obj(), g_on_end_frame_method);
1867
1869}

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

◆ FlutterViewGetScaledFontSize()

double flutter::PlatformViewAndroidJNIImpl::FlutterViewGetScaledFontSize ( double  unscaled_font_size,
int  configuration_id 
) const
overridevirtual

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1435 of file platform_view_android_jni_impl.cc.

1437 {
1438 JNIEnv* env = fml::jni::AttachCurrentThread();
1439
1440 auto java_object = java_object_.get(env);
1441 if (java_object.is_null()) {
1442 return -3;
1443 }
1444
1445 const jfloat scaledSize = env->CallFloatMethod(
1446 java_object.obj(), g_get_scaled_font_size_method,
1447 static_cast<jfloat>(font_size), static_cast<jint>(configuration_id));
1449 return static_cast<double>(scaledSize);
1450}
Scalar font_size

References fml::jni::AttachCurrentThread(), fml::jni::CheckException(), FML_CHECK, font_size, and fml::jni::JavaObjectWeakGlobalRef::get().

◆ FlutterViewHandlePlatformMessage()

void flutter::PlatformViewAndroidJNIImpl::FlutterViewHandlePlatformMessage ( std::unique_ptr< flutter::PlatformMessage message,
int  responseId 
)
overridevirtual

Sends a platform message. The message may be empty.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1339 of file platform_view_android_jni_impl.cc.

1341 {
1342 // Called from any thread.
1343 JNIEnv* env = fml::jni::AttachCurrentThread();
1344
1345 auto java_object = java_object_.get(env);
1346 if (java_object.is_null()) {
1347 return;
1348 }
1349
1351 fml::jni::StringToJavaString(env, message->channel());
1352
1353 if (message->hasData()) {
1355 env, env->NewDirectByteBuffer(
1356 const_cast<uint8_t*>(message->data().GetMapping()),
1357 message->data().GetSize()));
1358 // Message data is deleted in CleanupMessageData.
1359 fml::MallocMapping mapping = message->releaseData();
1360 env->CallVoidMethod(java_object.obj(), g_handle_platform_message_method,
1361 java_channel.obj(), message_array.obj(), responseId,
1362 reinterpret_cast<jlong>(mapping.Release()));
1363 } else {
1364 env->CallVoidMethod(java_object.obj(), g_handle_platform_message_method,
1365 java_channel.obj(), nullptr, responseId, nullptr);
1366 }
1367
1369}
A Mapping like NonOwnedMapping, but uses Free as its release proc.
Definition mapping.h:144
uint8_t * Release()
Definition mapping.cc:155
const char * message
ScopedJavaLocalRef< jstring > StringToJavaString(JNIEnv *env, const std::string &u8_string)
Definition jni_util.cc:86

References fml::jni::AttachCurrentThread(), fml::jni::CheckException(), FML_CHECK, fml::jni::JavaObjectWeakGlobalRef::get(), message, fml::jni::JavaRef< T >::obj(), fml::MallocMapping::Release(), and fml::jni::StringToJavaString().

◆ 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 1404 of file platform_view_android_jni_impl.cc.

1406 {
1407 // We are on the platform thread. Attempt to get the strong reference to
1408 // the Java object.
1409 JNIEnv* env = fml::jni::AttachCurrentThread();
1410
1411 auto java_object = java_object_.get(env);
1412 if (java_object.is_null()) {
1413 // The Java object was collected before this message response got to
1414 // it. Drop the response on the floor.
1415 return;
1416 }
1417 if (data == nullptr) { // Empty response.
1418 env->CallVoidMethod(java_object.obj(),
1419 g_handle_platform_message_response_method, responseId,
1420 nullptr);
1421 } else {
1422 // Convert the vector to a Java byte array.
1424 env, env->NewDirectByteBuffer(const_cast<uint8_t*>(data->GetMapping()),
1425 data->GetSize()));
1426
1427 env->CallVoidMethod(java_object.obj(),
1428 g_handle_platform_message_response_method, responseId,
1429 data_array.obj());
1430 }
1431
1433}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switch_defs.h:36

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

◆ 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 1713 of file platform_view_android_jni_impl.cc.

1721 {
1722 JNIEnv* env = fml::jni::AttachCurrentThread();
1723 auto java_object = java_object_.get(env);
1724 if (java_object.is_null()) {
1725 return;
1726 }
1727
1728 jobject mutatorsStack = env->NewObject(g_mutators_stack_class->obj(),
1730
1731 std::vector<std::shared_ptr<Mutator>>::const_iterator iter =
1732 mutators_stack.Begin();
1733 while (iter != mutators_stack.End()) {
1734 switch ((*iter)->GetType()) {
1736 const DlMatrix& matrix = (*iter)->GetMatrix();
1737 DlScalar matrix_array[9]{
1738 matrix.m[0], matrix.m[4], matrix.m[12], //
1739 matrix.m[1], matrix.m[5], matrix.m[13], //
1740 matrix.m[3], matrix.m[7], matrix.m[15],
1741 };
1743 env, env->NewFloatArray(9));
1744
1745 env->SetFloatArrayRegion(transformMatrix.obj(), 0, 9, matrix_array);
1746 env->CallVoidMethod(mutatorsStack,
1748 transformMatrix.obj());
1749 break;
1750 }
1752 const DlRect& rect = (*iter)->GetRect();
1753 env->CallVoidMethod(mutatorsStack,
1755 static_cast<int>(rect.GetLeft()), //
1756 static_cast<int>(rect.GetTop()), //
1757 static_cast<int>(rect.GetRight()), //
1758 static_cast<int>(rect.GetBottom()));
1759 break;
1760 }
1762 const DlRoundRect& rrect = (*iter)->GetRRect();
1763 const DlRect& rect = rrect.GetBounds();
1764 const DlRoundingRadii radii = rrect.GetRadii();
1765 SkScalar radiis[8] = {
1766 radii.top_left.width, radii.top_left.height,
1767 radii.top_right.width, radii.top_right.height,
1768 radii.bottom_right.width, radii.bottom_right.height,
1769 radii.bottom_left.width, radii.bottom_left.height,
1770 };
1772 env, env->NewFloatArray(8));
1773 env->SetFloatArrayRegion(radiisArray.obj(), 0, 8, radiis);
1774 env->CallVoidMethod(mutatorsStack,
1776 static_cast<int>(rect.GetLeft()), //
1777 static_cast<int>(rect.GetTop()), //
1778 static_cast<int>(rect.GetRight()), //
1779 static_cast<int>(rect.GetBottom()), //
1780 radiisArray.obj());
1781 break;
1782 }
1783 case MutatorType::kClipRSE: {
1784 const DlRoundRect& rrect = (*iter)->GetRSEApproximation();
1785 const DlRect& rect = rrect.GetBounds();
1786 const DlRoundingRadii radii = rrect.GetRadii();
1787 SkScalar radiis[8] = {
1788 radii.top_left.width, radii.top_left.height,
1789 radii.top_right.width, radii.top_right.height,
1790 radii.bottom_right.width, radii.bottom_right.height,
1791 radii.bottom_left.width, radii.bottom_left.height,
1792 };
1794 env, env->NewFloatArray(8));
1795 env->SetFloatArrayRegion(radiisArray.obj(), 0, 8, radiis);
1796 env->CallVoidMethod(mutatorsStack,
1798 static_cast<int>(rect.GetLeft()), //
1799 static_cast<int>(rect.GetTop()), //
1800 static_cast<int>(rect.GetRight()), //
1801 static_cast<int>(rect.GetBottom()), //
1802 radiisArray.obj());
1803 break;
1804 }
1805 // TODO(cyanglaz): Implement other mutators.
1806 // https://github.com/flutter/flutter/issues/58426
1814 break;
1815 }
1816 ++iter;
1817 }
1818
1819 env->CallVoidMethod(java_object.obj(), g_on_display_platform_view_method,
1820 view_id, x, y, width, height, viewWidth, viewHeight,
1821 mutatorsStack);
1822
1824}
G_BEGIN_DECLS FlutterViewId view_id
impeller::Scalar DlScalar
static jmethodID g_mutators_stack_init_method
impeller::RoundingRadii DlRoundingRadii
impeller::RoundRect DlRoundRect
impeller::Matrix DlMatrix
impeller::Rect DlRect
static jmethodID g_mutators_stack_push_transform_method
static jmethodID g_mutators_stack_push_cliprect_method
static jmethodID g_mutators_stack_push_cliprrect_method
static fml::jni::ScopedJavaGlobalRef< jclass > * g_mutators_stack_class
Scalar m[16]
Definition matrix.h:39
Type width
Definition size.h:28

References fml::jni::AttachCurrentThread(), flutter::MutatorsStack::Begin(), impeller::RoundingRadii::bottom_left, impeller::RoundingRadii::bottom_right, fml::jni::CheckException(), flutter::MutatorsStack::End(), FML_CHECK, flutter::g_mutators_stack_class, flutter::g_mutators_stack_init_method, flutter::g_mutators_stack_push_cliprect_method, flutter::g_mutators_stack_push_cliprrect_method, flutter::g_mutators_stack_push_transform_method, fml::jni::JavaObjectWeakGlobalRef::get(), impeller::TRect< T >::GetBottom(), impeller::RoundRect::GetBounds(), impeller::TRect< T >::GetLeft(), impeller::RoundRect::GetRadii(), impeller::TRect< T >::GetRight(), impeller::TRect< T >::GetTop(), impeller::TSize< T >::height, height, flutter::kBackdropClipPath, flutter::kBackdropClipRect, flutter::kBackdropClipRRect, flutter::kBackdropClipRSuperellipse, flutter::kBackdropFilter, flutter::kClipPath, flutter::kClipRect, flutter::kClipRRect, flutter::kClipRSE, flutter::kOpacity, flutter::kTransform, impeller::Matrix::m, fml::jni::JavaRef< T >::obj(), impeller::RoundingRadii::top_left, impeller::RoundingRadii::top_right, view_id, impeller::TSize< T >::width, width, x, and y.

◆ 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 1501 of file platform_view_android_jni_impl.cc.

1501 {
1502 JNIEnv* env = fml::jni::AttachCurrentThread();
1503
1504 auto java_object = java_object_.get(env);
1505 if (java_object.is_null()) {
1506 return;
1507 }
1508
1509 env->CallVoidMethod(java_object.obj(), g_on_first_frame_method);
1510
1512}

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

◆ FlutterViewOnPreEngineRestart()

void flutter::PlatformViewAndroidJNIImpl::FlutterViewOnPreEngineRestart ( )
overridevirtual

Indicates that a hot restart is about to happen.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1514 of file platform_view_android_jni_impl.cc.

1514 {
1515 JNIEnv* env = fml::jni::AttachCurrentThread();
1516
1517 auto java_object = java_object_.get(env);
1518 if (java_object.is_null()) {
1519 return;
1520 }
1521
1522 env->CallVoidMethod(java_object.obj(), g_on_engine_restart_method);
1523
1525}

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

◆ FlutterViewSetApplicationLocale()

void flutter::PlatformViewAndroidJNIImpl::FlutterViewSetApplicationLocale ( std::string  locale)
overridevirtual

Set application locale to a given language.

Note
Must be called from the platform thread.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1371 of file platform_view_android_jni_impl.cc.

1372 {
1373 JNIEnv* env = fml::jni::AttachCurrentThread();
1374
1375 auto java_object = java_object_.get(env);
1376 if (java_object.is_null()) {
1377 return;
1378 }
1379
1381 fml::jni::StringToJavaString(env, locale);
1382
1383 env->CallVoidMethod(java_object.obj(), g_set_application_locale_method,
1384 jlocale.obj());
1385
1387}

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

◆ FlutterViewSetSemanticsTreeEnabled()

void flutter::PlatformViewAndroidJNIImpl::FlutterViewSetSemanticsTreeEnabled ( bool  enabled)
overridevirtual

Enables or disables the semantics tree.

Note
Must be called from the platform thread.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1389 of file platform_view_android_jni_impl.cc.

1390 {
1391 JNIEnv* env = fml::jni::AttachCurrentThread();
1392
1393 auto java_object = java_object_.get(env);
1394 if (java_object.is_null()) {
1395 return;
1396 }
1397
1398 env->CallVoidMethod(java_object.obj(), g_set_semantics_tree_enabled_method,
1399 enabled);
1400
1402}

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

◆ 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 1477 of file platform_view_android_jni_impl.cc.

1479 {
1480 JNIEnv* env = fml::jni::AttachCurrentThread();
1481
1482 auto java_object = java_object_.get(env);
1483 if (java_object.is_null()) {
1484 return;
1485 }
1486
1487 fml::jni::ScopedJavaLocalRef<jobject> direct_actions_buffer(
1488 env,
1489 env->NewDirectByteBuffer(actions_buffer.data(), actions_buffer.size()));
1490
1492 fml::jni::VectorToStringArray(env, strings);
1493
1494 env->CallVoidMethod(java_object.obj(),
1495 g_update_custom_accessibility_actions_method,
1496 direct_actions_buffer.obj(), jstrings.obj());
1497
1499}

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

◆ FlutterViewUpdateSemantics()

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

Sends semantics tree updates.

Note
Must be called from the platform thread.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1452 of file platform_view_android_jni_impl.cc.

1455 {
1456 JNIEnv* env = fml::jni::AttachCurrentThread();
1457
1458 auto java_object = java_object_.get(env);
1459 if (java_object.is_null()) {
1460 return;
1461 }
1462
1464 env, env->NewDirectByteBuffer(buffer.data(), buffer.size()));
1466 fml::jni::VectorToStringArray(env, strings);
1467 fml::jni::ScopedJavaLocalRef<jobjectArray> jstring_attribute_args =
1468 fml::jni::VectorToBufferArray(env, string_attribute_args);
1469
1470 env->CallVoidMethod(java_object.obj(), g_update_semantics_method,
1471 direct_buffer.obj(), jstrings.obj(),
1472 jstring_attribute_args.obj());
1473
1475}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set profile Make the profiler discard new samples once the profiler sample buffer is full When this flag is not the profiler sample buffer is used as a ring buffer
Definition switch_defs.h:98
ScopedJavaLocalRef< jobjectArray > VectorToBufferArray(JNIEnv *env, const std::vector< std::vector< uint8_t > > &vector)
Definition jni_util.cc:164

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

◆ GetDisplayDensity()

double flutter::PlatformViewAndroidJNIImpl::GetDisplayDensity ( )
overridevirtual

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1998 of file platform_view_android_jni_impl.cc.

1998 {
1999 JNIEnv* env = fml::jni::AttachCurrentThread();
2000
2001 auto java_object = java_object_.get(env);
2002 if (java_object.is_null()) {
2003 return -1;
2004 }
2005
2007 env, env->GetObjectClass(java_object.obj()));
2008 if (clazz.is_null()) {
2009 return -1;
2010 }
2011
2012 jfieldID fid = env->GetStaticFieldID(clazz.obj(), "displayDensity", "F");
2013 return static_cast<double>(env->GetStaticFloatField(clazz.obj(), fid));
2014}

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

◆ GetDisplayHeight()

double flutter::PlatformViewAndroidJNIImpl::GetDisplayHeight ( )
overridevirtual

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1980 of file platform_view_android_jni_impl.cc.

1980 {
1981 JNIEnv* env = fml::jni::AttachCurrentThread();
1982
1983 auto java_object = java_object_.get(env);
1984 if (java_object.is_null()) {
1985 return -1;
1986 }
1987
1989 env, env->GetObjectClass(java_object.obj()));
1990 if (clazz.is_null()) {
1991 return -1;
1992 }
1993
1994 jfieldID fid = env->GetStaticFieldID(clazz.obj(), "displayHeight", "F");
1995 return static_cast<double>(env->GetStaticFloatField(clazz.obj(), fid));
1996}

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

◆ GetDisplayRefreshRate()

double flutter::PlatformViewAndroidJNIImpl::GetDisplayRefreshRate ( )
overridevirtual

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1944 of file platform_view_android_jni_impl.cc.

1944 {
1945 JNIEnv* env = fml::jni::AttachCurrentThread();
1946
1947 auto java_object = java_object_.get(env);
1948 if (java_object.is_null()) {
1950 }
1951
1953 env, env->GetObjectClass(java_object.obj()));
1954 if (clazz.is_null()) {
1956 }
1957
1958 jfieldID fid = env->GetStaticFieldID(clazz.obj(), "refreshRateFPS", "F");
1959 return static_cast<double>(env->GetStaticFloatField(clazz.obj(), fid));
1960}
static constexpr double kUnknownDisplayRefreshRate
To be used when the display refresh rate is unknown.
Definition display.h:20

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

◆ GetDisplayWidth()

double flutter::PlatformViewAndroidJNIImpl::GetDisplayWidth ( )
overridevirtual

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1962 of file platform_view_android_jni_impl.cc.

1962 {
1963 JNIEnv* env = fml::jni::AttachCurrentThread();
1964
1965 auto java_object = java_object_.get(env);
1966 if (java_object.is_null()) {
1967 return -1;
1968 }
1969
1971 env, env->GetObjectClass(java_object.obj()));
1972 if (clazz.is_null()) {
1973 return -1;
1974 }
1975
1976 jfieldID fid = env->GetStaticFieldID(clazz.obj(), "displayWidth", "F");
1977 return static_cast<double>(env->GetStaticFloatField(clazz.obj(), fid));
1978}

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

◆ HardwareBufferClose()

void flutter::PlatformViewAndroidJNIImpl::HardwareBufferClose ( JavaLocalRef  hardware_buffer)
overridevirtual

Call close on hardware_buffer.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1702 of file platform_view_android_jni_impl.cc.

1703 {
1705 JNIEnv* env = fml::jni::AttachCurrentThread();
1706 if (hardware_buffer.is_null()) {
1707 return;
1708 }
1709 env->CallVoidMethod(hardware_buffer.obj(), g_hardware_buffer_close_method);
1711}
static jmethodID g_hardware_buffer_close_method

References fml::jni::AttachCurrentThread(), fml::jni::CheckException(), FML_CHECK, and flutter::g_hardware_buffer_close_method.

◆ hideOverlaySurface2()

void flutter::PlatformViewAndroidJNIImpl::hideOverlaySurface2 ( )
overridevirtual

Implements flutter::PlatformViewAndroidJNI.

Definition at line 2374 of file platform_view_android_jni_impl.cc.

2374 {
2375 JNIEnv* env = fml::jni::AttachCurrentThread();
2376
2377 auto java_object = java_object_.get(env);
2378 if (java_object.is_null()) {
2379 return;
2380 }
2381
2382 env->CallVoidMethod(java_object.obj(), g_hide_overlay_surface2_method);
2384}

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

◆ hidePlatformView2()

void flutter::PlatformViewAndroidJNIImpl::hidePlatformView2 ( int32_t  view_id)
overridevirtual

Implements flutter::PlatformViewAndroidJNI.

Definition at line 2339 of file platform_view_android_jni_impl.cc.

2339 {
2340 JNIEnv* env = fml::jni::AttachCurrentThread();
2341 auto java_object = java_object_.get(env);
2342 if (java_object.is_null()) {
2343 return;
2344 }
2345
2346 env->CallVoidMethod(java_object.obj(), g_hide_platform_view2_method, view_id);
2347}

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

◆ ImageClose()

void flutter::PlatformViewAndroidJNIImpl::ImageClose ( JavaLocalRef  image)
overridevirtual

Call close on image.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1693 of file platform_view_android_jni_impl.cc.

1693 {
1694 JNIEnv* env = fml::jni::AttachCurrentThread();
1695 if (image.is_null()) {
1696 return;
1697 }
1698 env->CallVoidMethod(image.obj(), g_image_close_method);
1700}
FlutterVulkanImage * image
static jmethodID g_image_close_method

References fml::jni::AttachCurrentThread(), fml::jni::CheckException(), FML_CHECK, flutter::g_image_close_method, and image.

◆ ImageGetHardwareBuffer()

JavaLocalRef flutter::PlatformViewAndroidJNIImpl::ImageGetHardwareBuffer ( JavaLocalRef  image)
overridevirtual

Grab the HardwareBuffer from image.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1678 of file platform_view_android_jni_impl.cc.

1679 {
1681 JNIEnv* env = fml::jni::AttachCurrentThread();
1682 if (image.is_null()) {
1683 // Return null.
1684 return JavaLocalRef();
1685 }
1687 env,
1688 env->CallObjectMethod(image.obj(), g_image_get_hardware_buffer_method));
1690 return r;
1691}
std::nullptr_t JavaLocalRef
static jmethodID g_image_get_hardware_buffer_method

References fml::jni::AttachCurrentThread(), fml::jni::CheckException(), FML_CHECK, flutter::g_image_get_hardware_buffer_method, and image.

◆ ImageProducerTextureEntryAcquireLatestImage()

JavaLocalRef flutter::PlatformViewAndroidJNIImpl::ImageProducerTextureEntryAcquireLatestImage ( JavaLocalRef  image_texture_entry)
overridevirtual

Acquire the latest image available.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1648 of file platform_view_android_jni_impl.cc.

1649 {
1650 JNIEnv* env = fml::jni::AttachCurrentThread();
1651
1652 if (image_producer_texture_entry.is_null()) {
1653 // Return null.
1654 return JavaLocalRef();
1655 }
1656
1657 // Convert the weak reference to ImageTextureEntry into a strong local
1658 // reference.
1659 fml::jni::ScopedJavaLocalRef<jobject> image_producer_texture_entry_local_ref(
1660 env, env->CallObjectMethod(image_producer_texture_entry.obj(),
1662
1663 if (image_producer_texture_entry_local_ref.is_null()) {
1664 // Return null.
1665 return JavaLocalRef();
1666 }
1667
1669 env, env->CallObjectMethod(image_producer_texture_entry_local_ref.obj(),
1671 if (fml::jni::CheckException(env)) {
1672 return r;
1673 }
1674 // Return null.
1675 return JavaLocalRef();
1676}
static jmethodID g_acquire_latest_image_method
static jmethodID g_java_weak_reference_get_method

References fml::jni::AttachCurrentThread(), fml::jni::CheckException(), flutter::g_acquire_latest_image_method, flutter::g_java_weak_reference_get_method, and fml::jni::JavaRef< T >::obj().

◆ MaybeResizeSurfaceView()

void flutter::PlatformViewAndroidJNIImpl::MaybeResizeSurfaceView ( int32_t  width,
int32_t  height 
) const
overridevirtual

Implements flutter::PlatformViewAndroidJNI.

Definition at line 2386 of file platform_view_android_jni_impl.cc.

2387 {
2388 JNIEnv* env = fml::jni::AttachCurrentThread();
2389
2390 auto java_object = java_object_.get(env);
2391 if (java_object.is_null()) {
2392 return;
2393 }
2394
2395 env->CallVoidMethod(java_object.obj(), g_maybe_resize_surface_view, width,
2396 height);
2398}

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

◆ onDisplayPlatformView2()

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

Implements flutter::PlatformViewAndroidJNI.

Definition at line 2198 of file platform_view_android_jni_impl.cc.

2206 {
2207 JNIEnv* env = fml::jni::AttachCurrentThread();
2208 auto java_object = java_object_.get(env);
2209 if (java_object.is_null()) {
2210 return;
2211 }
2212
2213 jobject mutatorsStack = env->NewObject(g_mutators_stack_class->obj(),
2215
2216 std::vector<std::shared_ptr<Mutator>>::const_iterator iter =
2217 mutators_stack.Begin();
2218 while (iter != mutators_stack.End()) {
2219 switch ((*iter)->GetType()) {
2221 const DlMatrix& matrix = (*iter)->GetMatrix();
2222 DlScalar matrix_array[9]{
2223 matrix.m[0], matrix.m[4], matrix.m[12], //
2224 matrix.m[1], matrix.m[5], matrix.m[13], //
2225 matrix.m[3], matrix.m[7], matrix.m[15],
2226 };
2228 env, env->NewFloatArray(9));
2229
2230 env->SetFloatArrayRegion(transformMatrix.obj(), 0, 9, matrix_array);
2231 env->CallVoidMethod(mutatorsStack,
2233 transformMatrix.obj());
2234 break;
2235 }
2237 const DlRect& rect = (*iter)->GetRect();
2238 env->CallVoidMethod(mutatorsStack,
2240 static_cast<int>(rect.GetLeft()), //
2241 static_cast<int>(rect.GetTop()), //
2242 static_cast<int>(rect.GetRight()), //
2243 static_cast<int>(rect.GetBottom()));
2244 break;
2245 }
2247 const DlRoundRect& rrect = (*iter)->GetRRect();
2248 const DlRect& rect = rrect.GetBounds();
2249 const DlRoundingRadii& radii = rrect.GetRadii();
2250 SkScalar radiis[8] = {
2251 radii.top_left.width, radii.top_left.height,
2252 radii.top_right.width, radii.top_right.height,
2253 radii.bottom_right.width, radii.bottom_right.height,
2254 radii.bottom_left.width, radii.bottom_left.height,
2255 };
2257 env, env->NewFloatArray(8));
2258 env->SetFloatArrayRegion(radiisArray.obj(), 0, 8, radiis);
2259 env->CallVoidMethod(mutatorsStack,
2261 static_cast<int>(rect.GetLeft()), //
2262 static_cast<int>(rect.GetTop()), //
2263 static_cast<int>(rect.GetRight()), //
2264 static_cast<int>(rect.GetBottom()), //
2265 radiisArray.obj());
2266 break;
2267 }
2268 case MutatorType::kClipRSE: {
2269 const DlRoundRect& rrect = (*iter)->GetRSEApproximation();
2270 const DlRect& rect = rrect.GetBounds();
2271 const DlRoundingRadii& radii = rrect.GetRadii();
2272 SkScalar radiis[8] = {
2273 radii.top_left.width, radii.top_left.height,
2274 radii.top_right.width, radii.top_right.height,
2275 radii.bottom_right.width, radii.bottom_right.height,
2276 radii.bottom_left.width, radii.bottom_left.height,
2277 };
2279 env, env->NewFloatArray(8));
2280 env->SetFloatArrayRegion(radiisArray.obj(), 0, 8, radiis);
2281 env->CallVoidMethod(mutatorsStack,
2283 static_cast<int>(rect.GetLeft()), //
2284 static_cast<int>(rect.GetTop()), //
2285 static_cast<int>(rect.GetRight()), //
2286 static_cast<int>(rect.GetBottom()), //
2287 radiisArray.obj());
2288 break;
2289 }
2290 case MutatorType::kOpacity: {
2291 float opacity = (*iter)->GetAlphaFloat();
2292 env->CallVoidMethod(mutatorsStack, g_mutators_stack_push_opacity_method,
2293 opacity);
2294 break;
2295 }
2297 auto& dlPath = (*iter)->GetPath();
2298 // The layer mutator mechanism should have already caught and
2299 // redirected these simplified path cases, which is important because
2300 // the conics they generate (in the case of oval and rrect) will
2301 // not match the results of an impeller path conversion very closely.
2302 FML_DCHECK(!dlPath.IsRect());
2303 FML_DCHECK(!dlPath.IsOval());
2304 FML_DCHECK(!dlPath.IsRoundRect());
2305
2306 // Define and populate an Android Path with data from the DlPath
2307 AndroidPathReceiver receiver(env);
2308 receiver.SetFillType(dlPath.GetFillType());
2309
2310 // TODO(flar): https://github.com/flutter/flutter/issues/164808
2311 // Need to convert the fill type to the Android enum and
2312 // call setFillType on the path...
2313 dlPath.Dispatch(receiver);
2314
2315 env->CallVoidMethod(mutatorsStack,
2317 receiver.TakePath());
2318 break;
2319 }
2320 // TODO(cyanglaz): Implement other mutators.
2321 // https://github.com/flutter/flutter/issues/58426
2327 break;
2328 }
2329 ++iter;
2330 }
2331
2332 env->CallVoidMethod(java_object.obj(), g_on_display_platform_view2_method,
2333 view_id, x, y, width, height, viewWidth, viewHeight,
2334 mutatorsStack);
2335
2337}
#define FML_DCHECK(condition)
Definition logging.h:122
static jmethodID g_mutators_stack_push_clippath_method
static jmethodID g_mutators_stack_push_opacity_method

References fml::jni::AttachCurrentThread(), flutter::MutatorsStack::Begin(), impeller::RoundingRadii::bottom_left, impeller::RoundingRadii::bottom_right, fml::jni::CheckException(), flutter::MutatorsStack::End(), FML_CHECK, FML_DCHECK, flutter::g_mutators_stack_class, flutter::g_mutators_stack_init_method, flutter::g_mutators_stack_push_clippath_method, flutter::g_mutators_stack_push_cliprect_method, flutter::g_mutators_stack_push_cliprrect_method, flutter::g_mutators_stack_push_opacity_method, flutter::g_mutators_stack_push_transform_method, fml::jni::JavaObjectWeakGlobalRef::get(), impeller::TRect< T >::GetBottom(), impeller::RoundRect::GetBounds(), impeller::TRect< T >::GetLeft(), impeller::RoundRect::GetRadii(), impeller::TRect< T >::GetRight(), impeller::TRect< T >::GetTop(), impeller::TSize< T >::height, height, flutter::kBackdropClipPath, flutter::kBackdropClipRect, flutter::kBackdropClipRRect, flutter::kBackdropClipRSuperellipse, flutter::kBackdropFilter, flutter::kClipPath, flutter::kClipRect, flutter::kClipRRect, flutter::kClipRSE, flutter::kOpacity, flutter::kTransform, impeller::Matrix::m, fml::jni::JavaRef< T >::obj(), impeller::RoundingRadii::top_left, impeller::RoundingRadii::top_right, view_id, impeller::TSize< T >::width, width, x, and y.

◆ onEndFrame2()

void flutter::PlatformViewAndroidJNIImpl::onEndFrame2 ( )
overridevirtual

Implements flutter::PlatformViewAndroidJNI.

Definition at line 2349 of file platform_view_android_jni_impl.cc.

2349 {
2350 JNIEnv* env = fml::jni::AttachCurrentThread();
2351
2352 auto java_object = java_object_.get(env);
2353 if (java_object.is_null()) {
2354 return;
2355 }
2356
2357 env->CallVoidMethod(java_object.obj(), g_on_end_frame2_method);
2358
2360}

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

◆ RequestDartDeferredLibrary()

bool flutter::PlatformViewAndroidJNIImpl::RequestDartDeferredLibrary ( int  loading_unit_id)
overridevirtual

Implements flutter::PlatformViewAndroidJNI.

Definition at line 2016 of file platform_view_android_jni_impl.cc.

2017 {
2018 JNIEnv* env = fml::jni::AttachCurrentThread();
2019
2020 auto java_object = java_object_.get(env);
2021 if (java_object.is_null()) {
2022 return true;
2023 }
2024
2025 env->CallVoidMethod(java_object.obj(), g_request_dart_deferred_library_method,
2026 loading_unit_id);
2027
2029 return true;
2030}
static jmethodID g_request_dart_deferred_library_method

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

◆ showOverlaySurface2()

void flutter::PlatformViewAndroidJNIImpl::showOverlaySurface2 ( )
overridevirtual

Implements flutter::PlatformViewAndroidJNI.

Definition at line 2362 of file platform_view_android_jni_impl.cc.

2362 {
2363 JNIEnv* env = fml::jni::AttachCurrentThread();
2364
2365 auto java_object = java_object_.get(env);
2366 if (java_object.is_null()) {
2367 return;
2368 }
2369
2370 env->CallVoidMethod(java_object.obj(), g_show_overlay_surface2_method);
2372}

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

◆ SurfaceTextureAttachToGLContext()

void flutter::PlatformViewAndroidJNIImpl::SurfaceTextureAttachToGLContext ( JavaLocalRef  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 1527 of file platform_view_android_jni_impl.cc.

1529 {
1530 JNIEnv* env = fml::jni::AttachCurrentThread();
1531
1532 if (surface_texture.is_null()) {
1533 return;
1534 }
1535
1536 fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref(
1537 env, env->CallObjectMethod(surface_texture.obj(),
1539
1540 if (surface_texture_local_ref.is_null()) {
1541 return;
1542 }
1543
1544 env->CallVoidMethod(surface_texture_local_ref.obj(),
1546
1548}
static jmethodID g_attach_to_gl_context_method

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

◆ SurfaceTextureDetachFromGLContext()

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

Detaches a SurfaceTexture from the OpenGL ES context.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1626 of file platform_view_android_jni_impl.cc.

1627 {
1628 JNIEnv* env = fml::jni::AttachCurrentThread();
1629
1630 if (surface_texture.is_null()) {
1631 return;
1632 }
1633
1634 fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref(
1635 env, env->CallObjectMethod(surface_texture.obj(),
1637 if (surface_texture_local_ref.is_null()) {
1638 return;
1639 }
1640
1641 env->CallVoidMethod(surface_texture_local_ref.obj(),
1643
1645}
static jmethodID g_detach_from_gl_context_method

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

◆ SurfaceTextureGetTransformMatrix()

SkM44 flutter::PlatformViewAndroidJNIImpl::SurfaceTextureGetTransformMatrix ( JavaLocalRef  surface_texture)
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 1594 of file platform_view_android_jni_impl.cc.

1595 {
1596 JNIEnv* env = fml::jni::AttachCurrentThread();
1597
1598 if (surface_texture.is_null()) {
1599 return {};
1600 }
1601
1602 fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref(
1603 env, env->CallObjectMethod(surface_texture.obj(),
1605 if (surface_texture_local_ref.is_null()) {
1606 return {};
1607 }
1608
1610 env, env->NewFloatArray(16));
1611
1612 env->CallVoidMethod(surface_texture_local_ref.obj(),
1613 g_get_transform_matrix_method, transformMatrix.obj());
1615
1616 float* m = env->GetFloatArrayElements(transformMatrix.obj(), nullptr);
1617
1618 static_assert(sizeof(SkScalar) == sizeof(float));
1619 const auto transform = SkM44::ColMajor(m);
1620
1621 env->ReleaseFloatArrayElements(transformMatrix.obj(), m, JNI_ABORT);
1622
1623 return transform;
1624}
static jmethodID g_get_transform_matrix_method

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

◆ SurfaceTextureShouldUpdate()

bool flutter::PlatformViewAndroidJNIImpl::SurfaceTextureShouldUpdate ( JavaLocalRef  surface_texture)
overridevirtual

Returns true if surface_texture should be updated.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1550 of file platform_view_android_jni_impl.cc.

1551 {
1552 JNIEnv* env = fml::jni::AttachCurrentThread();
1553
1554 if (surface_texture.is_null()) {
1555 return false;
1556 }
1557
1558 fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref(
1559 env, env->CallObjectMethod(surface_texture.obj(),
1561 if (surface_texture_local_ref.is_null()) {
1562 return false;
1563 }
1564
1565 jboolean shouldUpdate = env->CallBooleanMethod(
1566 surface_texture_local_ref.obj(), g_surface_texture_wrapper_should_update);
1567
1569
1570 return shouldUpdate;
1571}
static jmethodID g_surface_texture_wrapper_should_update

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

◆ SurfaceTextureUpdateTexImage()

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

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

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1573 of file platform_view_android_jni_impl.cc.

1574 {
1575 JNIEnv* env = fml::jni::AttachCurrentThread();
1576
1577 if (surface_texture.is_null()) {
1578 return;
1579 }
1580
1581 fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref(
1582 env, env->CallObjectMethod(surface_texture.obj(),
1584 if (surface_texture_local_ref.is_null()) {
1585 return;
1586 }
1587
1588 env->CallVoidMethod(surface_texture_local_ref.obj(),
1590
1592}
static jmethodID g_update_tex_image_method

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

◆ swapTransaction()

void flutter::PlatformViewAndroidJNIImpl::swapTransaction ( )
overridevirtual

Implements flutter::PlatformViewAndroidJNI.

Definition at line 2054 of file platform_view_android_jni_impl.cc.

2054 {
2055 JNIEnv* env = fml::jni::AttachCurrentThread();
2056
2057 auto java_object = java_object_.get(env);
2058 if (java_object.is_null()) {
2059 return;
2060 }
2061
2062 env->CallVoidMethod(java_object.obj(), g_swap_transaction_method);
2063
2065}

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


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