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

1346 : java_object_(java_object) {}

◆ ~PlatformViewAndroidJNIImpl()

flutter::PlatformViewAndroidJNIImpl::~PlatformViewAndroidJNIImpl ( )
overridedefault

Member Function Documentation

◆ applyTransaction()

void flutter::PlatformViewAndroidJNIImpl::applyTransaction ( )
overridevirtual

Implements flutter::PlatformViewAndroidJNI.

Definition at line 2080 of file platform_view_android_jni_impl.cc.

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

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

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

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

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 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_begin_frame_method);
1867
1869}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1716 {
1718 JNIEnv* env = fml::jni::AttachCurrentThread();
1719 if (hardware_buffer.is_null()) {
1720 return;
1721 }
1722 env->CallVoidMethod(hardware_buffer.obj(), g_hardware_buffer_close_method);
1724}
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 2387 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_hide_overlay_surface2_method);
2397}

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

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

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

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

1690 {
1692 JNIEnv* env = fml::jni::AttachCurrentThread();
1693 if (image.is_null()) {
1694 // Return null.
1695 return JavaLocalRef();
1696 }
1698 env,
1699 env->CallObjectMethod(image.obj(), g_image_get_hardware_buffer_method));
1700 if (fml::jni::ClearException(env, false)) {
1701 return JavaLocalRef();
1702 }
1703 return r;
1704}
std::nullptr_t JavaLocalRef
static jmethodID g_image_get_hardware_buffer_method
bool ClearException(JNIEnv *env, bool silent)
Definition jni_util.cc:188

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

Referenced by flutter::testing::TEST_F().

◆ ImageProducerTextureEntryAcquireLatestImage()

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

Acquire the latest image available.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1659 of file platform_view_android_jni_impl.cc.

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

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

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

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

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

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

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

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

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

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

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

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

1585 {
1586 JNIEnv* env = fml::jni::AttachCurrentThread();
1587
1588 if (surface_texture.is_null()) {
1589 return;
1590 }
1591
1592 fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref(
1593 env, env->CallObjectMethod(surface_texture.obj(),
1595 if (surface_texture_local_ref.is_null()) {
1596 return;
1597 }
1598
1599 env->CallVoidMethod(surface_texture_local_ref.obj(),
1601
1603}
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 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_swap_transaction_method);
2076
2078}

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: