Flutter Engine
 
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 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
 
- 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 1326 of file platform_view_android_jni_impl.cc.

1328 : java_object_(java_object) {}

◆ ~PlatformViewAndroidJNIImpl()

flutter::PlatformViewAndroidJNIImpl::~PlatformViewAndroidJNIImpl ( )
overridedefault

Member Function Documentation

◆ applyTransaction()

void flutter::PlatformViewAndroidJNIImpl::applyTransaction ( )
overridevirtual

Implements flutter::PlatformViewAndroidJNI.

Definition at line 2041 of file platform_view_android_jni_impl.cc.

2041 {
2042 JNIEnv* env = fml::jni::AttachCurrentThread();
2043
2044 auto java_object = java_object_.get(env);
2045 if (java_object.is_null()) {
2046 return;
2047 }
2048
2049 env->CallVoidMethod(java_object.obj(), g_apply_transaction_method);
2050
2052}
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 2055 of file platform_view_android_jni_impl.cc.

2055 {
2056 JNIEnv* env = fml::jni::AttachCurrentThread();
2057
2058 auto java_object = java_object_.get(env);
2059 if (java_object.is_null()) {
2060 return nullptr;
2061 }
2062
2064 env, env->CallObjectMethod(java_object.obj(),
2065 g_create_overlay_surface2_method));
2067
2068 if (overlay.is_null()) {
2069 return std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(0,
2070 nullptr);
2071 }
2072
2073 jint overlay_id =
2074 env->CallIntMethod(overlay.obj(), g_overlay_surface_id_method);
2075
2076 jobject overlay_surface =
2077 env->CallObjectMethod(overlay.obj(), g_overlay_surface_surface_method);
2078
2079 auto overlay_window = fml::MakeRefCounted<AndroidNativeWindow>(
2080 ANativeWindow_fromSurface(env, overlay_surface));
2081
2082 return std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
2083 overlay_id, std::move(overlay_window));
2084}
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 2008 of file platform_view_android_jni_impl.cc.

2008 {
2009 JNIEnv* env = fml::jni::AttachCurrentThread();
2010
2011 auto java_object = java_object_.get(env);
2012 if (java_object.is_null()) {
2013 return nullptr;
2014 }
2015
2017 env,
2018 env->CallObjectMethod(java_object.obj(), g_create_transaction_method));
2019 if (transaction.is_null()) {
2020 return nullptr;
2021 }
2023
2024 return impeller::android::GetProcTable().ASurfaceTransaction_fromJava(
2025 env, transaction.obj());
2026}
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 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_destroy_overlay_surface2_method);
2095
2097}

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

1819 {
1820 JNIEnv* env = fml::jni::AttachCurrentThread();
1821
1822 auto java_object = java_object_.get(env);
1823 if (java_object.is_null()) {
1824 return;
1825 }
1826
1827 env->CallVoidMethod(java_object.obj(), g_on_begin_frame_method);
1828
1830}

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

1892 {
1893 JNIEnv* env = fml::jni::AttachCurrentThread();
1894
1895 std::unique_ptr<std::vector<std::string>> out =
1896 std::make_unique<std::vector<std::string>>();
1897
1898 auto java_object = java_object_.get(env);
1899 if (java_object.is_null()) {
1900 return out;
1901 }
1903 fml::jni::VectorToStringArray(env, supported_locales_data);
1904 jobjectArray result = static_cast<jobjectArray>(env->CallObjectMethod(
1906 j_locales_data.obj()));
1907
1909
1910 int length = env->GetArrayLength(result);
1911 for (int i = 0; i < length; i++) {
1912 out->emplace_back(fml::jni::JavaStringToString(
1913 env, static_cast<jstring>(env->GetObjectArrayElement(result, i))));
1914 }
1915 return out;
1916}
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 1846 of file platform_view_android_jni_impl.cc.

1846 {
1847 JNIEnv* env = fml::jni::AttachCurrentThread();
1848
1849 auto java_object = java_object_.get(env);
1850 if (java_object.is_null()) {
1851 return nullptr;
1852 }
1853
1855 env, env->CallObjectMethod(java_object.obj(),
1856 g_create_overlay_surface_method));
1858
1859 if (overlay.is_null()) {
1860 return std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(0,
1861 nullptr);
1862 }
1863
1864 jint overlay_id =
1865 env->CallIntMethod(overlay.obj(), g_overlay_surface_id_method);
1866
1867 jobject overlay_surface =
1868 env->CallObjectMethod(overlay.obj(), g_overlay_surface_surface_method);
1869
1870 auto overlay_window = fml::MakeRefCounted<AndroidNativeWindow>(
1871 ANativeWindow_fromSurface(env, overlay_surface));
1872
1873 return std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
1874 overlay_id, std::move(overlay_window));
1875}

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 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_destroy_overlay_surfaces_method);
1886
1888}

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

1805 {
1806 JNIEnv* env = fml::jni::AttachCurrentThread();
1807
1808 auto java_object = java_object_.get(env);
1809 if (java_object.is_null()) {
1810 return;
1811 }
1812
1813 env->CallVoidMethod(java_object.obj(), g_on_display_overlay_surface_method,
1814 surface_id, x, y, width, height);
1815
1817}
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 1832 of file platform_view_android_jni_impl.cc.

1832 {
1833 JNIEnv* env = fml::jni::AttachCurrentThread();
1834
1835 auto java_object = java_object_.get(env);
1836 if (java_object.is_null()) {
1837 return;
1838 }
1839
1840 env->CallVoidMethod(java_object.obj(), g_on_end_frame_method);
1841
1843}

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

1415 {
1416 JNIEnv* env = fml::jni::AttachCurrentThread();
1417
1418 auto java_object = java_object_.get(env);
1419 if (java_object.is_null()) {
1420 return -3;
1421 }
1422
1423 const jfloat scaledSize = env->CallFloatMethod(
1424 java_object.obj(), g_get_scaled_font_size_method,
1425 static_cast<jfloat>(font_size), static_cast<jint>(configuration_id));
1427 return static_cast<double>(scaledSize);
1428}
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 1332 of file platform_view_android_jni_impl.cc.

1334 {
1335 // Called from any thread.
1336 JNIEnv* env = fml::jni::AttachCurrentThread();
1337
1338 auto java_object = java_object_.get(env);
1339 if (java_object.is_null()) {
1340 return;
1341 }
1342
1344 fml::jni::StringToJavaString(env, message->channel());
1345
1346 if (message->hasData()) {
1348 env, env->NewDirectByteBuffer(
1349 const_cast<uint8_t*>(message->data().GetMapping()),
1350 message->data().GetSize()));
1351 // Message data is deleted in CleanupMessageData.
1352 fml::MallocMapping mapping = message->releaseData();
1353 env->CallVoidMethod(java_object.obj(), g_handle_platform_message_method,
1354 java_channel.obj(), message_array.obj(), responseId,
1355 reinterpret_cast<jlong>(mapping.Release()));
1356 } else {
1357 env->CallVoidMethod(java_object.obj(), g_handle_platform_message_method,
1358 java_channel.obj(), nullptr, responseId, nullptr);
1359 }
1360
1362}
A Mapping like NonOwnedMapping, but uses Free as its release proc.
Definition mapping.h:144
uint8_t * Release()
Definition mapping.cc:155
G_BEGIN_DECLS GBytes * 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 1382 of file platform_view_android_jni_impl.cc.

1384 {
1385 // We are on the platform thread. Attempt to get the strong reference to
1386 // the Java object.
1387 JNIEnv* env = fml::jni::AttachCurrentThread();
1388
1389 auto java_object = java_object_.get(env);
1390 if (java_object.is_null()) {
1391 // The Java object was collected before this message response got to
1392 // it. Drop the response on the floor.
1393 return;
1394 }
1395 if (data == nullptr) { // Empty response.
1396 env->CallVoidMethod(java_object.obj(),
1397 g_handle_platform_message_response_method, responseId,
1398 nullptr);
1399 } else {
1400 // Convert the vector to a Java byte array.
1402 env, env->NewDirectByteBuffer(const_cast<uint8_t*>(data->GetMapping()),
1403 data->GetSize()));
1404
1405 env->CallVoidMethod(java_object.obj(),
1406 g_handle_platform_message_response_method, responseId,
1407 data_array.obj());
1408 }
1409
1411}
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 1691 of file platform_view_android_jni_impl.cc.

1699 {
1700 JNIEnv* env = fml::jni::AttachCurrentThread();
1701 auto java_object = java_object_.get(env);
1702 if (java_object.is_null()) {
1703 return;
1704 }
1705
1706 jobject mutatorsStack = env->NewObject(g_mutators_stack_class->obj(),
1708
1709 std::vector<std::shared_ptr<Mutator>>::const_iterator iter =
1710 mutators_stack.Begin();
1711 while (iter != mutators_stack.End()) {
1712 switch ((*iter)->GetType()) {
1714 const DlMatrix& matrix = (*iter)->GetMatrix();
1715 DlScalar matrix_array[9]{
1716 matrix.m[0], matrix.m[4], matrix.m[12], //
1717 matrix.m[1], matrix.m[5], matrix.m[13], //
1718 matrix.m[3], matrix.m[7], matrix.m[15],
1719 };
1721 env, env->NewFloatArray(9));
1722
1723 env->SetFloatArrayRegion(transformMatrix.obj(), 0, 9, matrix_array);
1724 env->CallVoidMethod(mutatorsStack,
1726 transformMatrix.obj());
1727 break;
1728 }
1730 const DlRect& rect = (*iter)->GetRect();
1731 env->CallVoidMethod(mutatorsStack,
1733 static_cast<int>(rect.GetLeft()), //
1734 static_cast<int>(rect.GetTop()), //
1735 static_cast<int>(rect.GetRight()), //
1736 static_cast<int>(rect.GetBottom()));
1737 break;
1738 }
1740 const DlRoundRect& rrect = (*iter)->GetRRect();
1741 const DlRect& rect = rrect.GetBounds();
1742 const DlRoundingRadii radii = rrect.GetRadii();
1743 SkScalar radiis[8] = {
1744 radii.top_left.width, radii.top_left.height,
1745 radii.top_right.width, radii.top_right.height,
1746 radii.bottom_right.width, radii.bottom_right.height,
1747 radii.bottom_left.width, radii.bottom_left.height,
1748 };
1750 env, env->NewFloatArray(8));
1751 env->SetFloatArrayRegion(radiisArray.obj(), 0, 8, radiis);
1752 env->CallVoidMethod(mutatorsStack,
1754 static_cast<int>(rect.GetLeft()), //
1755 static_cast<int>(rect.GetTop()), //
1756 static_cast<int>(rect.GetRight()), //
1757 static_cast<int>(rect.GetBottom()), //
1758 radiisArray.obj());
1759 break;
1760 }
1761 case MutatorType::kClipRSE: {
1762 const DlRoundRect& rrect = (*iter)->GetRSEApproximation();
1763 const DlRect& rect = rrect.GetBounds();
1764 const DlRoundingRadii radii = rrect.GetRadii();
1765 SkScalar radiis[8] = {
1766 radii.top_left.width, radii.top_left.height,
1767 radii.top_right.width, radii.top_right.height,
1768 radii.bottom_right.width, radii.bottom_right.height,
1769 radii.bottom_left.width, radii.bottom_left.height,
1770 };
1772 env, env->NewFloatArray(8));
1773 env->SetFloatArrayRegion(radiisArray.obj(), 0, 8, radiis);
1774 env->CallVoidMethod(mutatorsStack,
1776 static_cast<int>(rect.GetLeft()), //
1777 static_cast<int>(rect.GetTop()), //
1778 static_cast<int>(rect.GetRight()), //
1779 static_cast<int>(rect.GetBottom()), //
1780 radiisArray.obj());
1781 break;
1782 }
1783 // TODO(cyanglaz): Implement other mutators.
1784 // https://github.com/flutter/flutter/issues/58426
1788 break;
1789 }
1790 ++iter;
1791 }
1792
1793 env->CallVoidMethod(java_object.obj(), g_on_display_platform_view_method,
1794 view_id, x, y, width, height, viewWidth, viewHeight,
1795 mutatorsStack);
1796
1798}
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::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 1479 of file platform_view_android_jni_impl.cc.

1479 {
1480 JNIEnv* env = fml::jni::AttachCurrentThread();
1481
1482 auto java_object = java_object_.get(env);
1483 if (java_object.is_null()) {
1484 return;
1485 }
1486
1487 env->CallVoidMethod(java_object.obj(), g_on_first_frame_method);
1488
1490}

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

1492 {
1493 JNIEnv* env = fml::jni::AttachCurrentThread();
1494
1495 auto java_object = java_object_.get(env);
1496 if (java_object.is_null()) {
1497 return;
1498 }
1499
1500 env->CallVoidMethod(java_object.obj(), g_on_engine_restart_method);
1501
1503}

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

1365 {
1366 JNIEnv* env = fml::jni::AttachCurrentThread();
1367
1368 auto java_object = java_object_.get(env);
1369 if (java_object.is_null()) {
1370 return;
1371 }
1372
1374 fml::jni::StringToJavaString(env, locale);
1375
1376 env->CallVoidMethod(java_object.obj(), g_set_application_locale_method,
1377 jlocale.obj());
1378
1380}

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

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

1457 {
1458 JNIEnv* env = fml::jni::AttachCurrentThread();
1459
1460 auto java_object = java_object_.get(env);
1461 if (java_object.is_null()) {
1462 return;
1463 }
1464
1465 fml::jni::ScopedJavaLocalRef<jobject> direct_actions_buffer(
1466 env,
1467 env->NewDirectByteBuffer(actions_buffer.data(), actions_buffer.size()));
1468
1470 fml::jni::VectorToStringArray(env, strings);
1471
1472 env->CallVoidMethod(java_object.obj(),
1473 g_update_custom_accessibility_actions_method,
1474 direct_actions_buffer.obj(), jstrings.obj());
1475
1477}

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

1433 {
1434 JNIEnv* env = fml::jni::AttachCurrentThread();
1435
1436 auto java_object = java_object_.get(env);
1437 if (java_object.is_null()) {
1438 return;
1439 }
1440
1442 env, env->NewDirectByteBuffer(buffer.data(), buffer.size()));
1444 fml::jni::VectorToStringArray(env, strings);
1445 fml::jni::ScopedJavaLocalRef<jobjectArray> jstring_attribute_args =
1446 fml::jni::VectorToBufferArray(env, string_attribute_args);
1447
1448 env->CallVoidMethod(java_object.obj(), g_update_semantics_method,
1449 direct_buffer.obj(), jstrings.obj(),
1450 jstring_attribute_args.obj());
1451
1453}
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 1972 of file platform_view_android_jni_impl.cc.

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

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

1954 {
1955 JNIEnv* env = fml::jni::AttachCurrentThread();
1956
1957 auto java_object = java_object_.get(env);
1958 if (java_object.is_null()) {
1959 return -1;
1960 }
1961
1963 env, env->GetObjectClass(java_object.obj()));
1964 if (clazz.is_null()) {
1965 return -1;
1966 }
1967
1968 jfieldID fid = env->GetStaticFieldID(clazz.obj(), "displayHeight", "F");
1969 return static_cast<double>(env->GetStaticFloatField(clazz.obj(), fid));
1970}

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

1918 {
1919 JNIEnv* env = fml::jni::AttachCurrentThread();
1920
1921 auto java_object = java_object_.get(env);
1922 if (java_object.is_null()) {
1924 }
1925
1927 env, env->GetObjectClass(java_object.obj()));
1928 if (clazz.is_null()) {
1930 }
1931
1932 jfieldID fid = env->GetStaticFieldID(clazz.obj(), "refreshRateFPS", "F");
1933 return static_cast<double>(env->GetStaticFloatField(clazz.obj(), fid));
1934}
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 1936 of file platform_view_android_jni_impl.cc.

1936 {
1937 JNIEnv* env = fml::jni::AttachCurrentThread();
1938
1939 auto java_object = java_object_.get(env);
1940 if (java_object.is_null()) {
1941 return -1;
1942 }
1943
1945 env, env->GetObjectClass(java_object.obj()));
1946 if (clazz.is_null()) {
1947 return -1;
1948 }
1949
1950 jfieldID fid = env->GetStaticFieldID(clazz.obj(), "displayWidth", "F");
1951 return static_cast<double>(env->GetStaticFloatField(clazz.obj(), fid));
1952}

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

1681 {
1683 JNIEnv* env = fml::jni::AttachCurrentThread();
1684 if (hardware_buffer.is_null()) {
1685 return;
1686 }
1687 env->CallVoidMethod(hardware_buffer.obj(), g_hardware_buffer_close_method);
1689}
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 2344 of file platform_view_android_jni_impl.cc.

2344 {
2345 JNIEnv* env = fml::jni::AttachCurrentThread();
2346
2347 auto java_object = java_object_.get(env);
2348 if (java_object.is_null()) {
2349 return;
2350 }
2351
2352 env->CallVoidMethod(java_object.obj(), g_hide_overlay_surface2_method);
2354}

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

2309 {
2310 JNIEnv* env = fml::jni::AttachCurrentThread();
2311 auto java_object = java_object_.get(env);
2312 if (java_object.is_null()) {
2313 return;
2314 }
2315
2316 env->CallVoidMethod(java_object.obj(), g_hide_platform_view2_method, view_id);
2317}

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

1671 {
1672 JNIEnv* env = fml::jni::AttachCurrentThread();
1673 if (image.is_null()) {
1674 return;
1675 }
1676 env->CallVoidMethod(image.obj(), g_image_close_method);
1678}
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 1656 of file platform_view_android_jni_impl.cc.

1657 {
1659 JNIEnv* env = fml::jni::AttachCurrentThread();
1660 if (image.is_null()) {
1661 // Return null.
1662 return JavaLocalRef();
1663 }
1665 env,
1666 env->CallObjectMethod(image.obj(), g_image_get_hardware_buffer_method));
1668 return r;
1669}
std::nullptr_t JavaLocalRef
static jmethodID g_image_get_hardware_buffer_method

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

◆ ImageProducerTextureEntryAcquireLatestImage()

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

Acquire the latest image available.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1626 of file platform_view_android_jni_impl.cc.

1627 {
1628 JNIEnv* env = fml::jni::AttachCurrentThread();
1629
1630 if (image_producer_texture_entry.is_null()) {
1631 // Return null.
1632 return JavaLocalRef();
1633 }
1634
1635 // Convert the weak reference to ImageTextureEntry into a strong local
1636 // reference.
1637 fml::jni::ScopedJavaLocalRef<jobject> image_producer_texture_entry_local_ref(
1638 env, env->CallObjectMethod(image_producer_texture_entry.obj(),
1640
1641 if (image_producer_texture_entry_local_ref.is_null()) {
1642 // Return null.
1643 return JavaLocalRef();
1644 }
1645
1647 env, env->CallObjectMethod(image_producer_texture_entry_local_ref.obj(),
1649 if (fml::jni::CheckException(env)) {
1650 return r;
1651 }
1652 // Return null.
1653 return JavaLocalRef();
1654}
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().

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

2180 {
2181 JNIEnv* env = fml::jni::AttachCurrentThread();
2182 auto java_object = java_object_.get(env);
2183 if (java_object.is_null()) {
2184 return;
2185 }
2186
2187 jobject mutatorsStack = env->NewObject(g_mutators_stack_class->obj(),
2189
2190 std::vector<std::shared_ptr<Mutator>>::const_iterator iter =
2191 mutators_stack.Begin();
2192 while (iter != mutators_stack.End()) {
2193 switch ((*iter)->GetType()) {
2195 const DlMatrix& matrix = (*iter)->GetMatrix();
2196 DlScalar matrix_array[9]{
2197 matrix.m[0], matrix.m[4], matrix.m[12], //
2198 matrix.m[1], matrix.m[5], matrix.m[13], //
2199 matrix.m[3], matrix.m[7], matrix.m[15],
2200 };
2202 env, env->NewFloatArray(9));
2203
2204 env->SetFloatArrayRegion(transformMatrix.obj(), 0, 9, matrix_array);
2205 env->CallVoidMethod(mutatorsStack,
2207 transformMatrix.obj());
2208 break;
2209 }
2211 const DlRect& rect = (*iter)->GetRect();
2212 env->CallVoidMethod(mutatorsStack,
2214 static_cast<int>(rect.GetLeft()), //
2215 static_cast<int>(rect.GetTop()), //
2216 static_cast<int>(rect.GetRight()), //
2217 static_cast<int>(rect.GetBottom()));
2218 break;
2219 }
2221 const DlRoundRect& rrect = (*iter)->GetRRect();
2222 const DlRect& rect = rrect.GetBounds();
2223 const DlRoundingRadii& radii = rrect.GetRadii();
2224 SkScalar radiis[8] = {
2225 radii.top_left.width, radii.top_left.height,
2226 radii.top_right.width, radii.top_right.height,
2227 radii.bottom_right.width, radii.bottom_right.height,
2228 radii.bottom_left.width, radii.bottom_left.height,
2229 };
2231 env, env->NewFloatArray(8));
2232 env->SetFloatArrayRegion(radiisArray.obj(), 0, 8, radiis);
2233 env->CallVoidMethod(mutatorsStack,
2235 static_cast<int>(rect.GetLeft()), //
2236 static_cast<int>(rect.GetTop()), //
2237 static_cast<int>(rect.GetRight()), //
2238 static_cast<int>(rect.GetBottom()), //
2239 radiisArray.obj());
2240 break;
2241 }
2242 case MutatorType::kClipRSE: {
2243 const DlRoundRect& rrect = (*iter)->GetRSEApproximation();
2244 const DlRect& rect = rrect.GetBounds();
2245 const DlRoundingRadii& radii = rrect.GetRadii();
2246 SkScalar radiis[8] = {
2247 radii.top_left.width, radii.top_left.height,
2248 radii.top_right.width, radii.top_right.height,
2249 radii.bottom_right.width, radii.bottom_right.height,
2250 radii.bottom_left.width, radii.bottom_left.height,
2251 };
2253 env, env->NewFloatArray(8));
2254 env->SetFloatArrayRegion(radiisArray.obj(), 0, 8, radiis);
2255 env->CallVoidMethod(mutatorsStack,
2257 static_cast<int>(rect.GetLeft()), //
2258 static_cast<int>(rect.GetTop()), //
2259 static_cast<int>(rect.GetRight()), //
2260 static_cast<int>(rect.GetBottom()), //
2261 radiisArray.obj());
2262 break;
2263 }
2264 case MutatorType::kOpacity: {
2265 float opacity = (*iter)->GetAlphaFloat();
2266 env->CallVoidMethod(mutatorsStack, g_mutators_stack_push_opacity_method,
2267 opacity);
2268 break;
2269 }
2271 auto& dlPath = (*iter)->GetPath();
2272 // The layer mutator mechanism should have already caught and
2273 // redirected these simplified path cases, which is important because
2274 // the conics they generate (in the case of oval and rrect) will
2275 // not match the results of an impeller path conversion very closely.
2276 FML_DCHECK(!dlPath.IsRect());
2277 FML_DCHECK(!dlPath.IsOval());
2278 FML_DCHECK(!dlPath.IsRoundRect());
2279
2280 // Define and populate an Android Path with data from the DlPath
2281 AndroidPathReceiver receiver(env);
2282 receiver.SetFillType(dlPath.GetFillType());
2283
2284 // TODO(flar): https://github.com/flutter/flutter/issues/164808
2285 // Need to convert the fill type to the Android enum and
2286 // call setFillType on the path...
2287 dlPath.Dispatch(receiver);
2288
2289 env->CallVoidMethod(mutatorsStack,
2291 receiver.TakePath());
2292 break;
2293 }
2294 // TODO(cyanglaz): Implement other mutators.
2295 // https://github.com/flutter/flutter/issues/58426
2297 break;
2298 }
2299 ++iter;
2300 }
2301
2302 env->CallVoidMethod(java_object.obj(), g_on_display_platform_view2_method,
2303 view_id, x, y, width, height, viewWidth, viewHeight,
2304 mutatorsStack);
2305
2307}
#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::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 2319 of file platform_view_android_jni_impl.cc.

2319 {
2320 JNIEnv* env = fml::jni::AttachCurrentThread();
2321
2322 auto java_object = java_object_.get(env);
2323 if (java_object.is_null()) {
2324 return;
2325 }
2326
2327 env->CallVoidMethod(java_object.obj(), g_on_end_frame2_method);
2328
2330}

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

1991 {
1992 JNIEnv* env = fml::jni::AttachCurrentThread();
1993
1994 auto java_object = java_object_.get(env);
1995 if (java_object.is_null()) {
1996 return true;
1997 }
1998
1999 env->CallVoidMethod(java_object.obj(), g_request_dart_deferred_library_method,
2000 loading_unit_id);
2001
2003 return true;
2004}
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 2332 of file platform_view_android_jni_impl.cc.

2332 {
2333 JNIEnv* env = fml::jni::AttachCurrentThread();
2334
2335 auto java_object = java_object_.get(env);
2336 if (java_object.is_null()) {
2337 return;
2338 }
2339
2340 env->CallVoidMethod(java_object.obj(), g_show_overlay_surface2_method);
2342}

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

1507 {
1508 JNIEnv* env = fml::jni::AttachCurrentThread();
1509
1510 if (surface_texture.is_null()) {
1511 return;
1512 }
1513
1514 fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref(
1515 env, env->CallObjectMethod(surface_texture.obj(),
1517
1518 if (surface_texture_local_ref.is_null()) {
1519 return;
1520 }
1521
1522 env->CallVoidMethod(surface_texture_local_ref.obj(),
1524
1526}
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 1604 of file platform_view_android_jni_impl.cc.

1605 {
1606 JNIEnv* env = fml::jni::AttachCurrentThread();
1607
1608 if (surface_texture.is_null()) {
1609 return;
1610 }
1611
1612 fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref(
1613 env, env->CallObjectMethod(surface_texture.obj(),
1615 if (surface_texture_local_ref.is_null()) {
1616 return;
1617 }
1618
1619 env->CallVoidMethod(surface_texture_local_ref.obj(),
1621
1623}
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 1572 of file platform_view_android_jni_impl.cc.

1573 {
1574 JNIEnv* env = fml::jni::AttachCurrentThread();
1575
1576 if (surface_texture.is_null()) {
1577 return {};
1578 }
1579
1580 fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref(
1581 env, env->CallObjectMethod(surface_texture.obj(),
1583 if (surface_texture_local_ref.is_null()) {
1584 return {};
1585 }
1586
1588 env, env->NewFloatArray(16));
1589
1590 env->CallVoidMethod(surface_texture_local_ref.obj(),
1591 g_get_transform_matrix_method, transformMatrix.obj());
1593
1594 float* m = env->GetFloatArrayElements(transformMatrix.obj(), nullptr);
1595
1596 static_assert(sizeof(SkScalar) == sizeof(float));
1597 const auto transform = SkM44::ColMajor(m);
1598
1599 env->ReleaseFloatArrayElements(transformMatrix.obj(), m, JNI_ABORT);
1600
1601 return transform;
1602}
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 1528 of file platform_view_android_jni_impl.cc.

1529 {
1530 JNIEnv* env = fml::jni::AttachCurrentThread();
1531
1532 if (surface_texture.is_null()) {
1533 return false;
1534 }
1535
1536 fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref(
1537 env, env->CallObjectMethod(surface_texture.obj(),
1539 if (surface_texture_local_ref.is_null()) {
1540 return false;
1541 }
1542
1543 jboolean shouldUpdate = env->CallBooleanMethod(
1544 surface_texture_local_ref.obj(), g_surface_texture_wrapper_should_update);
1545
1547
1548 return shouldUpdate;
1549}
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 1551 of file platform_view_android_jni_impl.cc.

1552 {
1553 JNIEnv* env = fml::jni::AttachCurrentThread();
1554
1555 if (surface_texture.is_null()) {
1556 return;
1557 }
1558
1559 fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref(
1560 env, env->CallObjectMethod(surface_texture.obj(),
1562 if (surface_texture_local_ref.is_null()) {
1563 return;
1564 }
1565
1566 env->CallVoidMethod(surface_texture_local_ref.obj(),
1568
1570}
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 2028 of file platform_view_android_jni_impl.cc.

2028 {
2029 JNIEnv* env = fml::jni::AttachCurrentThread();
2030
2031 auto java_object = java_object_.get(env);
2032 if (java_object.is_null()) {
2033 return;
2034 }
2035
2036 env->CallVoidMethod(java_object.obj(), g_swap_transaction_method);
2037
2039}

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: