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

1347 : java_object_(java_object) {}

◆ ~PlatformViewAndroidJNIImpl()

flutter::PlatformViewAndroidJNIImpl::~PlatformViewAndroidJNIImpl ( )
overridedefault

Member Function Documentation

◆ applyTransaction()

void flutter::PlatformViewAndroidJNIImpl::applyTransaction ( )
overridevirtual

Implements flutter::PlatformViewAndroidJNI.

Definition at line 2079 of file platform_view_android_jni_impl.cc.

2079 {
2080 JNIEnv* env = fml::jni::AttachCurrentThread();
2081
2082 auto java_object = java_object_.get(env);
2083 if (java_object.is_null()) {
2084 return;
2085 }
2086
2087 env->CallVoidMethod(java_object.obj(), g_apply_transaction_method);
2088
2090}
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 2093 of file platform_view_android_jni_impl.cc.

2093 {
2094 JNIEnv* env = fml::jni::AttachCurrentThread();
2095
2096 auto java_object = java_object_.get(env);
2097 if (java_object.is_null()) {
2098 return nullptr;
2099 }
2100
2102 env, env->CallObjectMethod(java_object.obj(),
2103 g_create_overlay_surface2_method));
2105
2106 if (overlay.is_null()) {
2107 return std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(0,
2108 nullptr);
2109 }
2110
2111 jint overlay_id =
2112 env->CallIntMethod(overlay.obj(), g_overlay_surface_id_method);
2113
2114 jobject overlay_surface =
2115 env->CallObjectMethod(overlay.obj(), g_overlay_surface_surface_method);
2116
2117 auto overlay_window = fml::MakeRefCounted<AndroidNativeWindow>(
2118 ANativeWindow_fromSurface(env, overlay_surface));
2119
2120 return std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
2121 overlay_id, std::move(overlay_window));
2122}
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 2046 of file platform_view_android_jni_impl.cc.

2046 {
2047 JNIEnv* env = fml::jni::AttachCurrentThread();
2048
2049 auto java_object = java_object_.get(env);
2050 if (java_object.is_null()) {
2051 return nullptr;
2052 }
2053
2055 env,
2056 env->CallObjectMethod(java_object.obj(), g_create_transaction_method));
2057 if (transaction.is_null()) {
2058 return nullptr;
2059 }
2061
2062 return impeller::android::GetProcTable().ASurfaceTransaction_fromJava(
2063 env, transaction.obj());
2064}
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 2124 of file platform_view_android_jni_impl.cc.

2124 {
2125 JNIEnv* env = fml::jni::AttachCurrentThread();
2126
2127 auto java_object = java_object_.get(env);
2128 if (java_object.is_null()) {
2129 return;
2130 }
2131
2132 env->CallVoidMethod(java_object.obj(), g_destroy_overlay_surface2_method);
2133
2135}

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

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

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

1930 {
1931 JNIEnv* env = fml::jni::AttachCurrentThread();
1932
1933 std::unique_ptr<std::vector<std::string>> out =
1934 std::make_unique<std::vector<std::string>>();
1935
1936 auto java_object = java_object_.get(env);
1937 if (java_object.is_null()) {
1938 return out;
1939 }
1941 fml::jni::VectorToStringArray(env, supported_locales_data);
1942 jobjectArray result = static_cast<jobjectArray>(env->CallObjectMethod(
1944 j_locales_data.obj()));
1945
1947
1948 int length = env->GetArrayLength(result);
1949 for (int i = 0; i < length; i++) {
1950 out->emplace_back(fml::jni::JavaStringToString(
1951 env, static_cast<jstring>(env->GetObjectArrayElement(result, i))));
1952 }
1953 return out;
1954}
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 1884 of file platform_view_android_jni_impl.cc.

1884 {
1885 JNIEnv* env = fml::jni::AttachCurrentThread();
1886
1887 auto java_object = java_object_.get(env);
1888 if (java_object.is_null()) {
1889 return nullptr;
1890 }
1891
1893 env, env->CallObjectMethod(java_object.obj(),
1894 g_create_overlay_surface_method));
1896
1897 if (overlay.is_null()) {
1898 return std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(0,
1899 nullptr);
1900 }
1901
1902 jint overlay_id =
1903 env->CallIntMethod(overlay.obj(), g_overlay_surface_id_method);
1904
1905 jobject overlay_surface =
1906 env->CallObjectMethod(overlay.obj(), g_overlay_surface_surface_method);
1907
1908 auto overlay_window = fml::MakeRefCounted<AndroidNativeWindow>(
1909 ANativeWindow_fromSurface(env, overlay_surface));
1910
1911 return std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
1912 overlay_id, std::move(overlay_window));
1913}

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

1915 {
1916 JNIEnv* env = fml::jni::AttachCurrentThread();
1917
1918 auto java_object = java_object_.get(env);
1919 if (java_object.is_null()) {
1920 return;
1921 }
1922
1923 env->CallVoidMethod(java_object.obj(), g_destroy_overlay_surfaces_method);
1924
1926}

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

1843 {
1844 JNIEnv* env = fml::jni::AttachCurrentThread();
1845
1846 auto java_object = java_object_.get(env);
1847 if (java_object.is_null()) {
1848 return;
1849 }
1850
1851 env->CallVoidMethod(java_object.obj(), g_on_display_overlay_surface_method,
1852 surface_id, x, y, width, height);
1853
1855}
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 1870 of file platform_view_android_jni_impl.cc.

1870 {
1871 JNIEnv* env = fml::jni::AttachCurrentThread();
1872
1873 auto java_object = java_object_.get(env);
1874 if (java_object.is_null()) {
1875 return;
1876 }
1877
1878 env->CallVoidMethod(java_object.obj(), g_on_end_frame_method);
1879
1881}

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

1449 {
1450 JNIEnv* env = fml::jni::AttachCurrentThread();
1451
1452 auto java_object = java_object_.get(env);
1453 if (java_object.is_null()) {
1454 return -3;
1455 }
1456
1457 const jfloat scaledSize = env->CallFloatMethod(
1458 java_object.obj(), g_get_scaled_font_size_method,
1459 static_cast<jfloat>(font_size), static_cast<jint>(configuration_id));
1461 return static_cast<double>(scaledSize);
1462}
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 1351 of file platform_view_android_jni_impl.cc.

1353 {
1354 // Called from any thread.
1355 JNIEnv* env = fml::jni::AttachCurrentThread();
1356
1357 auto java_object = java_object_.get(env);
1358 if (java_object.is_null()) {
1359 return;
1360 }
1361
1363 fml::jni::StringToJavaString(env, message->channel());
1364
1365 if (message->hasData()) {
1367 env, env->NewDirectByteBuffer(
1368 const_cast<uint8_t*>(message->data().GetMapping()),
1369 message->data().GetSize()));
1370 // Message data is deleted in CleanupMessageData.
1371 fml::MallocMapping mapping = message->releaseData();
1372 env->CallVoidMethod(java_object.obj(), g_handle_platform_message_method,
1373 java_channel.obj(), message_array.obj(), responseId,
1374 reinterpret_cast<jlong>(mapping.Release()));
1375 } else {
1376 env->CallVoidMethod(java_object.obj(), g_handle_platform_message_method,
1377 java_channel.obj(), nullptr, responseId, nullptr);
1378 }
1379
1381}
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 1416 of file platform_view_android_jni_impl.cc.

1418 {
1419 // We are on the platform thread. Attempt to get the strong reference to
1420 // the Java object.
1421 JNIEnv* env = fml::jni::AttachCurrentThread();
1422
1423 auto java_object = java_object_.get(env);
1424 if (java_object.is_null()) {
1425 // The Java object was collected before this message response got to
1426 // it. Drop the response on the floor.
1427 return;
1428 }
1429 if (data == nullptr) { // Empty response.
1430 env->CallVoidMethod(java_object.obj(),
1431 g_handle_platform_message_response_method, responseId,
1432 nullptr);
1433 } else {
1434 // Convert the vector to a Java byte array.
1436 env, env->NewDirectByteBuffer(const_cast<uint8_t*>(data->GetMapping()),
1437 data->GetSize()));
1438
1439 env->CallVoidMethod(java_object.obj(),
1440 g_handle_platform_message_response_method, responseId,
1441 data_array.obj());
1442 }
1443
1445}
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 1725 of file platform_view_android_jni_impl.cc.

1733 {
1734 JNIEnv* env = fml::jni::AttachCurrentThread();
1735 auto java_object = java_object_.get(env);
1736 if (java_object.is_null()) {
1737 return;
1738 }
1739
1740 jobject mutatorsStack = env->NewObject(g_mutators_stack_class->obj(),
1742
1743 std::vector<std::shared_ptr<Mutator>>::const_iterator iter =
1744 mutators_stack.Begin();
1745 while (iter != mutators_stack.End()) {
1746 switch ((*iter)->GetType()) {
1748 const DlMatrix& matrix = (*iter)->GetMatrix();
1749 DlScalar matrix_array[9]{
1750 matrix.m[0], matrix.m[4], matrix.m[12], //
1751 matrix.m[1], matrix.m[5], matrix.m[13], //
1752 matrix.m[3], matrix.m[7], matrix.m[15],
1753 };
1755 env, env->NewFloatArray(9));
1756
1757 env->SetFloatArrayRegion(transformMatrix.obj(), 0, 9, matrix_array);
1758 env->CallVoidMethod(mutatorsStack,
1760 transformMatrix.obj());
1761 break;
1762 }
1764 const DlRect& rect = (*iter)->GetRect();
1765 env->CallVoidMethod(mutatorsStack,
1767 static_cast<int>(rect.GetLeft()), //
1768 static_cast<int>(rect.GetTop()), //
1769 static_cast<int>(rect.GetRight()), //
1770 static_cast<int>(rect.GetBottom()));
1771 break;
1772 }
1774 const DlRoundRect& rrect = (*iter)->GetRRect();
1775 const DlRect& rect = rrect.GetBounds();
1776 const DlRoundingRadii radii = rrect.GetRadii();
1777 SkScalar radiis[8] = {
1778 radii.top_left.width, radii.top_left.height,
1779 radii.top_right.width, radii.top_right.height,
1780 radii.bottom_right.width, radii.bottom_right.height,
1781 radii.bottom_left.width, radii.bottom_left.height,
1782 };
1784 env, env->NewFloatArray(8));
1785 env->SetFloatArrayRegion(radiisArray.obj(), 0, 8, radiis);
1786 env->CallVoidMethod(mutatorsStack,
1788 static_cast<int>(rect.GetLeft()), //
1789 static_cast<int>(rect.GetTop()), //
1790 static_cast<int>(rect.GetRight()), //
1791 static_cast<int>(rect.GetBottom()), //
1792 radiisArray.obj());
1793 break;
1794 }
1795 case MutatorType::kClipRSE: {
1796 const DlRoundRect& rrect = (*iter)->GetRSEApproximation();
1797 const DlRect& rect = rrect.GetBounds();
1798 const DlRoundingRadii radii = rrect.GetRadii();
1799 SkScalar radiis[8] = {
1800 radii.top_left.width, radii.top_left.height,
1801 radii.top_right.width, radii.top_right.height,
1802 radii.bottom_right.width, radii.bottom_right.height,
1803 radii.bottom_left.width, radii.bottom_left.height,
1804 };
1806 env, env->NewFloatArray(8));
1807 env->SetFloatArrayRegion(radiisArray.obj(), 0, 8, radiis);
1808 env->CallVoidMethod(mutatorsStack,
1810 static_cast<int>(rect.GetLeft()), //
1811 static_cast<int>(rect.GetTop()), //
1812 static_cast<int>(rect.GetRight()), //
1813 static_cast<int>(rect.GetBottom()), //
1814 radiisArray.obj());
1815 break;
1816 }
1817 // TODO(cyanglaz): Implement other mutators.
1818 // https://github.com/flutter/flutter/issues/58426
1826 break;
1827 }
1828 ++iter;
1829 }
1830
1831 env->CallVoidMethod(java_object.obj(), g_on_display_platform_view_method,
1832 view_id, x, y, width, height, viewWidth, viewHeight,
1833 mutatorsStack);
1834
1836}
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 1513 of file platform_view_android_jni_impl.cc.

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

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

1526 {
1527 JNIEnv* env = fml::jni::AttachCurrentThread();
1528
1529 auto java_object = java_object_.get(env);
1530 if (java_object.is_null()) {
1531 return;
1532 }
1533
1534 env->CallVoidMethod(java_object.obj(), g_on_engine_restart_method);
1535
1537}

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

1384 {
1385 JNIEnv* env = fml::jni::AttachCurrentThread();
1386
1387 auto java_object = java_object_.get(env);
1388 if (java_object.is_null()) {
1389 return;
1390 }
1391
1393 fml::jni::StringToJavaString(env, locale);
1394
1395 env->CallVoidMethod(java_object.obj(), g_set_application_locale_method,
1396 jlocale.obj());
1397
1399}

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

1402 {
1403 JNIEnv* env = fml::jni::AttachCurrentThread();
1404
1405 auto java_object = java_object_.get(env);
1406 if (java_object.is_null()) {
1407 return;
1408 }
1409
1410 env->CallVoidMethod(java_object.obj(), g_set_semantics_tree_enabled_method,
1411 enabled);
1412
1414}

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

1491 {
1492 JNIEnv* env = fml::jni::AttachCurrentThread();
1493
1494 auto java_object = java_object_.get(env);
1495 if (java_object.is_null()) {
1496 return;
1497 }
1498
1499 fml::jni::ScopedJavaLocalRef<jobject> direct_actions_buffer(
1500 env,
1501 env->NewDirectByteBuffer(actions_buffer.data(), actions_buffer.size()));
1502
1504 fml::jni::VectorToStringArray(env, strings);
1505
1506 env->CallVoidMethod(java_object.obj(),
1507 g_update_custom_accessibility_actions_method,
1508 direct_actions_buffer.obj(), jstrings.obj());
1509
1511}

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

1467 {
1468 JNIEnv* env = fml::jni::AttachCurrentThread();
1469
1470 auto java_object = java_object_.get(env);
1471 if (java_object.is_null()) {
1472 return;
1473 }
1474
1476 env, env->NewDirectByteBuffer(buffer.data(), buffer.size()));
1478 fml::jni::VectorToStringArray(env, strings);
1479 fml::jni::ScopedJavaLocalRef<jobjectArray> jstring_attribute_args =
1480 fml::jni::VectorToBufferArray(env, string_attribute_args);
1481
1482 env->CallVoidMethod(java_object.obj(), g_update_semantics_method,
1483 direct_buffer.obj(), jstrings.obj(),
1484 jstring_attribute_args.obj());
1485
1487}
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 2010 of file platform_view_android_jni_impl.cc.

2010 {
2011 JNIEnv* env = fml::jni::AttachCurrentThread();
2012
2013 auto java_object = java_object_.get(env);
2014 if (java_object.is_null()) {
2015 return -1;
2016 }
2017
2019 env, env->GetObjectClass(java_object.obj()));
2020 if (clazz.is_null()) {
2021 return -1;
2022 }
2023
2024 jfieldID fid = env->GetStaticFieldID(clazz.obj(), "displayDensity", "F");
2025 return static_cast<double>(env->GetStaticFloatField(clazz.obj(), fid));
2026}

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

1992 {
1993 JNIEnv* env = fml::jni::AttachCurrentThread();
1994
1995 auto java_object = java_object_.get(env);
1996 if (java_object.is_null()) {
1997 return -1;
1998 }
1999
2001 env, env->GetObjectClass(java_object.obj()));
2002 if (clazz.is_null()) {
2003 return -1;
2004 }
2005
2006 jfieldID fid = env->GetStaticFieldID(clazz.obj(), "displayHeight", "F");
2007 return static_cast<double>(env->GetStaticFloatField(clazz.obj(), fid));
2008}

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

1956 {
1957 JNIEnv* env = fml::jni::AttachCurrentThread();
1958
1959 auto java_object = java_object_.get(env);
1960 if (java_object.is_null()) {
1962 }
1963
1965 env, env->GetObjectClass(java_object.obj()));
1966 if (clazz.is_null()) {
1968 }
1969
1970 jfieldID fid = env->GetStaticFieldID(clazz.obj(), "refreshRateFPS", "F");
1971 return static_cast<double>(env->GetStaticFloatField(clazz.obj(), fid));
1972}
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 1974 of file platform_view_android_jni_impl.cc.

1974 {
1975 JNIEnv* env = fml::jni::AttachCurrentThread();
1976
1977 auto java_object = java_object_.get(env);
1978 if (java_object.is_null()) {
1979 return -1;
1980 }
1981
1983 env, env->GetObjectClass(java_object.obj()));
1984 if (clazz.is_null()) {
1985 return -1;
1986 }
1987
1988 jfieldID fid = env->GetStaticFieldID(clazz.obj(), "displayWidth", "F");
1989 return static_cast<double>(env->GetStaticFloatField(clazz.obj(), fid));
1990}

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

1715 {
1717 JNIEnv* env = fml::jni::AttachCurrentThread();
1718 if (hardware_buffer.is_null()) {
1719 return;
1720 }
1721 env->CallVoidMethod(hardware_buffer.obj(), g_hardware_buffer_close_method);
1723}
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 2386 of file platform_view_android_jni_impl.cc.

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

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

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

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

1705 {
1706 JNIEnv* env = fml::jni::AttachCurrentThread();
1707 if (image.is_null()) {
1708 return;
1709 }
1710 env->CallVoidMethod(image.obj(), g_image_close_method);
1712}
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 1690 of file platform_view_android_jni_impl.cc.

1691 {
1693 JNIEnv* env = fml::jni::AttachCurrentThread();
1694 if (image.is_null()) {
1695 // Return null.
1696 return JavaLocalRef();
1697 }
1699 env,
1700 env->CallObjectMethod(image.obj(), g_image_get_hardware_buffer_method));
1702 return r;
1703}
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 1660 of file platform_view_android_jni_impl.cc.

1661 {
1662 JNIEnv* env = fml::jni::AttachCurrentThread();
1663
1664 if (image_producer_texture_entry.is_null()) {
1665 // Return null.
1666 return JavaLocalRef();
1667 }
1668
1669 // Convert the weak reference to ImageTextureEntry into a strong local
1670 // reference.
1671 fml::jni::ScopedJavaLocalRef<jobject> image_producer_texture_entry_local_ref(
1672 env, env->CallObjectMethod(image_producer_texture_entry.obj(),
1674
1675 if (image_producer_texture_entry_local_ref.is_null()) {
1676 // Return null.
1677 return JavaLocalRef();
1678 }
1679
1681 env, env->CallObjectMethod(image_producer_texture_entry_local_ref.obj(),
1683 if (fml::jni::CheckException(env)) {
1684 return r;
1685 }
1686 // Return null.
1687 return JavaLocalRef();
1688}
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 2398 of file platform_view_android_jni_impl.cc.

2399 {
2400 JNIEnv* env = fml::jni::AttachCurrentThread();
2401
2402 auto java_object = java_object_.get(env);
2403 if (java_object.is_null()) {
2404 return;
2405 }
2406
2407 env->CallVoidMethod(java_object.obj(), g_maybe_resize_surface_view, width,
2408 height);
2410}

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

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

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

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

2029 {
2030 JNIEnv* env = fml::jni::AttachCurrentThread();
2031
2032 auto java_object = java_object_.get(env);
2033 if (java_object.is_null()) {
2034 return true;
2035 }
2036
2037 env->CallVoidMethod(java_object.obj(), g_request_dart_deferred_library_method,
2038 loading_unit_id);
2039
2041 return true;
2042}
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 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_show_overlay_surface2_method);
2384}

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

1541 {
1542 JNIEnv* env = fml::jni::AttachCurrentThread();
1543
1544 if (surface_texture.is_null()) {
1545 return;
1546 }
1547
1548 fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref(
1549 env, env->CallObjectMethod(surface_texture.obj(),
1551
1552 if (surface_texture_local_ref.is_null()) {
1553 return;
1554 }
1555
1556 env->CallVoidMethod(surface_texture_local_ref.obj(),
1558
1560}
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 1638 of file platform_view_android_jni_impl.cc.

1639 {
1640 JNIEnv* env = fml::jni::AttachCurrentThread();
1641
1642 if (surface_texture.is_null()) {
1643 return;
1644 }
1645
1646 fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref(
1647 env, env->CallObjectMethod(surface_texture.obj(),
1649 if (surface_texture_local_ref.is_null()) {
1650 return;
1651 }
1652
1653 env->CallVoidMethod(surface_texture_local_ref.obj(),
1655
1657}
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 1606 of file platform_view_android_jni_impl.cc.

1607 {
1608 JNIEnv* env = fml::jni::AttachCurrentThread();
1609
1610 if (surface_texture.is_null()) {
1611 return {};
1612 }
1613
1614 fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref(
1615 env, env->CallObjectMethod(surface_texture.obj(),
1617 if (surface_texture_local_ref.is_null()) {
1618 return {};
1619 }
1620
1622 env, env->NewFloatArray(16));
1623
1624 env->CallVoidMethod(surface_texture_local_ref.obj(),
1625 g_get_transform_matrix_method, transformMatrix.obj());
1627
1628 float* m = env->GetFloatArrayElements(transformMatrix.obj(), nullptr);
1629
1630 static_assert(sizeof(SkScalar) == sizeof(float));
1631 const auto transform = SkM44::ColMajor(m);
1632
1633 env->ReleaseFloatArrayElements(transformMatrix.obj(), m, JNI_ABORT);
1634
1635 return transform;
1636}
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 1562 of file platform_view_android_jni_impl.cc.

1563 {
1564 JNIEnv* env = fml::jni::AttachCurrentThread();
1565
1566 if (surface_texture.is_null()) {
1567 return false;
1568 }
1569
1570 fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref(
1571 env, env->CallObjectMethod(surface_texture.obj(),
1573 if (surface_texture_local_ref.is_null()) {
1574 return false;
1575 }
1576
1577 jboolean shouldUpdate = env->CallBooleanMethod(
1578 surface_texture_local_ref.obj(), g_surface_texture_wrapper_should_update);
1579
1581
1582 return shouldUpdate;
1583}
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 1585 of file platform_view_android_jni_impl.cc.

1586 {
1587 JNIEnv* env = fml::jni::AttachCurrentThread();
1588
1589 if (surface_texture.is_null()) {
1590 return;
1591 }
1592
1593 fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref(
1594 env, env->CallObjectMethod(surface_texture.obj(),
1596 if (surface_texture_local_ref.is_null()) {
1597 return;
1598 }
1599
1600 env->CallVoidMethod(surface_texture_local_ref.obj(),
1602
1604}
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 2066 of file platform_view_android_jni_impl.cc.

2066 {
2067 JNIEnv* env = fml::jni::AttachCurrentThread();
2068
2069 auto java_object = java_object_.get(env);
2070 if (java_object.is_null()) {
2071 return;
2072 }
2073
2074 env->CallVoidMethod(java_object.obj(), g_swap_transaction_method);
2075
2077}

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: