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

1352 : java_object_(java_object) {}

◆ ~PlatformViewAndroidJNIImpl()

flutter::PlatformViewAndroidJNIImpl::~PlatformViewAndroidJNIImpl ( )
overridedefault

Member Function Documentation

◆ applyTransaction()

void flutter::PlatformViewAndroidJNIImpl::applyTransaction ( )
overridevirtual

Implements flutter::PlatformViewAndroidJNI.

Definition at line 2086 of file platform_view_android_jni_impl.cc.

2086 {
2087 JNIEnv* env = fml::jni::AttachCurrentThread();
2088
2089 auto java_object = java_object_.get(env);
2090 if (java_object.is_null()) {
2091 return;
2092 }
2093
2094 env->CallVoidMethod(java_object.obj(), g_apply_transaction_method);
2095
2097}
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 2100 of file platform_view_android_jni_impl.cc.

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

2053 {
2054 JNIEnv* env = fml::jni::AttachCurrentThread();
2055
2056 auto java_object = java_object_.get(env);
2057 if (java_object.is_null()) {
2058 return nullptr;
2059 }
2060
2062 env,
2063 env->CallObjectMethod(java_object.obj(), g_create_transaction_method));
2064 if (transaction.is_null()) {
2065 return nullptr;
2066 }
2068
2069 return impeller::android::GetProcTable().ASurfaceTransaction_fromJava(
2070 env, transaction.obj());
2071}
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 2131 of file platform_view_android_jni_impl.cc.

2131 {
2132 JNIEnv* env = fml::jni::AttachCurrentThread();
2133
2134 auto java_object = java_object_.get(env);
2135 if (java_object.is_null()) {
2136 return;
2137 }
2138
2139 env->CallVoidMethod(java_object.obj(), g_destroy_overlay_surface2_method);
2140
2142}

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

1864 {
1865 JNIEnv* env = fml::jni::AttachCurrentThread();
1866
1867 auto java_object = java_object_.get(env);
1868 if (java_object.is_null()) {
1869 return;
1870 }
1871
1872 env->CallVoidMethod(java_object.obj(), g_on_begin_frame_method);
1873
1875}

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

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

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

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

1922 {
1923 JNIEnv* env = fml::jni::AttachCurrentThread();
1924
1925 auto java_object = java_object_.get(env);
1926 if (java_object.is_null()) {
1927 return;
1928 }
1929
1930 env->CallVoidMethod(java_object.obj(), g_destroy_overlay_surfaces_method);
1931
1933}

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

1850 {
1851 JNIEnv* env = fml::jni::AttachCurrentThread();
1852
1853 auto java_object = java_object_.get(env);
1854 if (java_object.is_null()) {
1855 return;
1856 }
1857
1858 env->CallVoidMethod(java_object.obj(), g_on_display_overlay_surface_method,
1859 surface_id, x, y, width, height);
1860
1862}
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 1877 of file platform_view_android_jni_impl.cc.

1877 {
1878 JNIEnv* env = fml::jni::AttachCurrentThread();
1879
1880 auto java_object = java_object_.get(env);
1881 if (java_object.is_null()) {
1882 return;
1883 }
1884
1885 env->CallVoidMethod(java_object.obj(), g_on_end_frame_method);
1886
1888}

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

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

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

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

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

1518 {
1519 JNIEnv* env = fml::jni::AttachCurrentThread();
1520
1521 auto java_object = java_object_.get(env);
1522 if (java_object.is_null()) {
1523 return;
1524 }
1525
1526 env->CallVoidMethod(java_object.obj(), g_on_first_frame_method);
1527
1529}

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

1531 {
1532 JNIEnv* env = fml::jni::AttachCurrentThread();
1533
1534 auto java_object = java_object_.get(env);
1535 if (java_object.is_null()) {
1536 return;
1537 }
1538
1539 env->CallVoidMethod(java_object.obj(), g_on_engine_restart_method);
1540
1542}

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

1389 {
1390 JNIEnv* env = fml::jni::AttachCurrentThread();
1391
1392 auto java_object = java_object_.get(env);
1393 if (java_object.is_null()) {
1394 return;
1395 }
1396
1398 fml::jni::StringToJavaString(env, locale);
1399
1400 env->CallVoidMethod(java_object.obj(), g_set_application_locale_method,
1401 jlocale.obj());
1402
1404}

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

1407 {
1408 JNIEnv* env = fml::jni::AttachCurrentThread();
1409
1410 auto java_object = java_object_.get(env);
1411 if (java_object.is_null()) {
1412 return;
1413 }
1414
1415 env->CallVoidMethod(java_object.obj(), g_set_semantics_tree_enabled_method,
1416 enabled);
1417
1419}

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

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

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

1472 {
1473 JNIEnv* env = fml::jni::AttachCurrentThread();
1474
1475 auto java_object = java_object_.get(env);
1476 if (java_object.is_null()) {
1477 return;
1478 }
1479
1481 env, env->NewDirectByteBuffer(buffer.data(), buffer.size()));
1483 fml::jni::VectorToStringArray(env, strings);
1484 fml::jni::ScopedJavaLocalRef<jobjectArray> jstring_attribute_args =
1485 fml::jni::VectorToBufferArray(env, string_attribute_args);
1486
1487 env->CallVoidMethod(java_object.obj(), g_update_semantics_method,
1488 direct_buffer.obj(), jstrings.obj(),
1489 jstring_attribute_args.obj());
1490
1492}
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 2017 of file platform_view_android_jni_impl.cc.

2017 {
2018 JNIEnv* env = fml::jni::AttachCurrentThread();
2019
2020 auto java_object = java_object_.get(env);
2021 if (java_object.is_null()) {
2022 return -1;
2023 }
2024
2026 env, env->GetObjectClass(java_object.obj()));
2027 if (clazz.is_null()) {
2028 return -1;
2029 }
2030
2031 jfieldID fid = env->GetStaticFieldID(clazz.obj(), "displayDensity", "F");
2032 return static_cast<double>(env->GetStaticFloatField(clazz.obj(), fid));
2033}

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

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

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

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

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

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

1722 {
1724 JNIEnv* env = fml::jni::AttachCurrentThread();
1725 if (hardware_buffer.is_null()) {
1726 return;
1727 }
1728 env->CallVoidMethod(hardware_buffer.obj(), g_hardware_buffer_close_method);
1730}
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 2393 of file platform_view_android_jni_impl.cc.

2393 {
2394 JNIEnv* env = fml::jni::AttachCurrentThread();
2395
2396 auto java_object = java_object_.get(env);
2397 if (java_object.is_null()) {
2398 return;
2399 }
2400
2401 env->CallVoidMethod(java_object.obj(), g_hide_overlay_surface2_method);
2403}

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

2358 {
2359 JNIEnv* env = fml::jni::AttachCurrentThread();
2360 auto java_object = java_object_.get(env);
2361 if (java_object.is_null()) {
2362 return;
2363 }
2364
2365 env->CallVoidMethod(java_object.obj(), g_hide_platform_view2_method, view_id);
2366}

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

1712 {
1713 JNIEnv* env = fml::jni::AttachCurrentThread();
1714 if (image.is_null()) {
1715 return;
1716 }
1717 env->CallVoidMethod(image.obj(), g_image_close_method);
1719}
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 1695 of file platform_view_android_jni_impl.cc.

1696 {
1698 JNIEnv* env = fml::jni::AttachCurrentThread();
1699 if (image.is_null()) {
1700 // Return null.
1701 return JavaLocalRef();
1702 }
1704 env,
1705 env->CallObjectMethod(image.obj(), g_image_get_hardware_buffer_method));
1706 if (fml::jni::ClearException(env, false)) {
1707 return JavaLocalRef();
1708 }
1709 return r;
1710}
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 1665 of file platform_view_android_jni_impl.cc.

1666 {
1667 JNIEnv* env = fml::jni::AttachCurrentThread();
1668
1669 if (image_producer_texture_entry.is_null()) {
1670 // Return null.
1671 return JavaLocalRef();
1672 }
1673
1674 // Convert the weak reference to ImageTextureEntry into a strong local
1675 // reference.
1676 fml::jni::ScopedJavaLocalRef<jobject> image_producer_texture_entry_local_ref(
1677 env, env->CallObjectMethod(image_producer_texture_entry.obj(),
1679
1680 if (image_producer_texture_entry_local_ref.is_null()) {
1681 // Return null.
1682 return JavaLocalRef();
1683 }
1684
1686 env, env->CallObjectMethod(image_producer_texture_entry_local_ref.obj(),
1688 if (fml::jni::CheckException(env)) {
1689 return r;
1690 }
1691 // Return null.
1692 return JavaLocalRef();
1693}
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 2405 of file platform_view_android_jni_impl.cc.

2406 {
2407 JNIEnv* env = fml::jni::AttachCurrentThread();
2408
2409 auto java_object = java_object_.get(env);
2410 if (java_object.is_null()) {
2411 return;
2412 }
2413
2414 env->CallVoidMethod(java_object.obj(), g_maybe_resize_surface_view, width,
2415 height);
2417}

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

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

2368 {
2369 JNIEnv* env = fml::jni::AttachCurrentThread();
2370
2371 auto java_object = java_object_.get(env);
2372 if (java_object.is_null()) {
2373 return;
2374 }
2375
2376 env->CallVoidMethod(java_object.obj(), g_on_end_frame2_method);
2377
2379}

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

2036 {
2037 JNIEnv* env = fml::jni::AttachCurrentThread();
2038
2039 auto java_object = java_object_.get(env);
2040 if (java_object.is_null()) {
2041 return true;
2042 }
2043
2044 env->CallVoidMethod(java_object.obj(), g_request_dart_deferred_library_method,
2045 loading_unit_id);
2046
2048 return true;
2049}
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 2381 of file platform_view_android_jni_impl.cc.

2381 {
2382 JNIEnv* env = fml::jni::AttachCurrentThread();
2383
2384 auto java_object = java_object_.get(env);
2385 if (java_object.is_null()) {
2386 return;
2387 }
2388
2389 env->CallVoidMethod(java_object.obj(), g_show_overlay_surface2_method);
2391}

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

1546 {
1547 JNIEnv* env = fml::jni::AttachCurrentThread();
1548
1549 if (surface_texture.is_null()) {
1550 return;
1551 }
1552
1553 fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref(
1554 env, env->CallObjectMethod(surface_texture.obj(),
1556
1557 if (surface_texture_local_ref.is_null()) {
1558 return;
1559 }
1560
1561 env->CallVoidMethod(surface_texture_local_ref.obj(),
1563
1565}
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 1643 of file platform_view_android_jni_impl.cc.

1644 {
1645 JNIEnv* env = fml::jni::AttachCurrentThread();
1646
1647 if (surface_texture.is_null()) {
1648 return;
1649 }
1650
1651 fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref(
1652 env, env->CallObjectMethod(surface_texture.obj(),
1654 if (surface_texture_local_ref.is_null()) {
1655 return;
1656 }
1657
1658 env->CallVoidMethod(surface_texture_local_ref.obj(),
1660
1662}
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 1611 of file platform_view_android_jni_impl.cc.

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

1568 {
1569 JNIEnv* env = fml::jni::AttachCurrentThread();
1570
1571 if (surface_texture.is_null()) {
1572 return false;
1573 }
1574
1575 fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref(
1576 env, env->CallObjectMethod(surface_texture.obj(),
1578 if (surface_texture_local_ref.is_null()) {
1579 return false;
1580 }
1581
1582 jboolean shouldUpdate = env->CallBooleanMethod(
1583 surface_texture_local_ref.obj(), g_surface_texture_wrapper_should_update);
1584
1586
1587 return shouldUpdate;
1588}
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 1590 of file platform_view_android_jni_impl.cc.

1591 {
1592 JNIEnv* env = fml::jni::AttachCurrentThread();
1593
1594 if (surface_texture.is_null()) {
1595 return;
1596 }
1597
1598 fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref(
1599 env, env->CallObjectMethod(surface_texture.obj(),
1601 if (surface_texture_local_ref.is_null()) {
1602 return;
1603 }
1604
1605 env->CallVoidMethod(surface_texture_local_ref.obj(),
1607
1609}
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 2073 of file platform_view_android_jni_impl.cc.

2073 {
2074 JNIEnv* env = fml::jni::AttachCurrentThread();
2075
2076 auto java_object = java_object_.get(env);
2077 if (java_object.is_null()) {
2078 return;
2079 }
2080
2081 env->CallVoidMethod(java_object.obj(), g_swap_transaction_method);
2082
2084}

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: