Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
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. More...
 
void FlutterViewHandlePlatformMessageResponse (int responseId, std::unique_ptr< fml::Mapping > data) override
 Responds to a platform message. The data may be a nullptr. More...
 
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. More...
 
void FlutterViewUpdateCustomAccessibilityActions (std::vector< uint8_t > actions_buffer, std::vector< std::string > strings) override
 Sends new custom accessibility events. More...
 
void FlutterViewOnFirstFrame () override
 Indicates that FlutterView should start painting pixels. More...
 
void FlutterViewOnPreEngineRestart () override
 Indicates that a hot restart is about to happen. More...
 
void SurfaceTextureAttachToGLContext (JavaLocalRef surface_texture, int textureId) override
 Attach the SurfaceTexture to the OpenGL ES context that is current on the calling thread. More...
 
bool SurfaceTextureShouldUpdate (JavaLocalRef surface_texture) override
 Returns true if surface_texture should be updated. More...
 
void SurfaceTextureUpdateTexImage (JavaLocalRef surface_texture) override
 Updates the texture image to the most recent frame from the image stream. More...
 
void SurfaceTextureGetTransformMatrix (JavaLocalRef surface_texture, SkMatrix &transform) override
 Gets the transform matrix from the SurfaceTexture. Then, it updates the transform matrix, so it fill the canvas and preserve the aspect ratio. More...
 
void SurfaceTextureDetachFromGLContext (JavaLocalRef surface_texture) override
 Detaches a SurfaceTexture from the OpenGL ES context. More...
 
JavaLocalRef ImageProducerTextureEntryAcquireLatestImage (JavaLocalRef image_texture_entry) override
 Acquire the latest image available. More...
 
JavaLocalRef ImageGetHardwareBuffer (JavaLocalRef image) override
 Grab the HardwareBuffer from image. More...
 
void ImageClose (JavaLocalRef image) override
 Call close on image. More...
 
void HardwareBufferClose (JavaLocalRef hardware_buffer) override
 Call close on hardware_buffer. More...
 
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. More...
 
void FlutterViewDisplayOverlaySurface (int surface_id, int x, int y, int width, int height) override
 Positions and sizes an overlay surface in hybrid composition. More...
 
void FlutterViewBeginFrame () override
 Initiates a frame if using hybrid composition. More...
 
void FlutterViewEndFrame () override
 Indicates that the current frame ended. It's used to clean up state. More...
 
std::unique_ptr< PlatformViewAndroidJNI::OverlayMetadataFlutterViewCreateOverlaySurface () override
 Instantiates an overlay surface in hybrid composition and provides the necessary metadata to operate the surface in C. More...
 
void FlutterViewDestroyOverlaySurfaces () override
 Destroys the overlay surfaces. More...
 
std::unique_ptr< std::vector< std::string > > FlutterViewComputePlatformResolvedLocale (std::vector< std::string > supported_locales_data) override
 Computes the locale Android would select. More...
 
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
 
- Public Member Functions inherited from flutter::PlatformViewAndroidJNI
virtual ~PlatformViewAndroidJNI ()
 
virtual void FlutterViewHandlePlatformMessage (std::unique_ptr< flutter::PlatformMessage > message, int responseId)=0
 Sends a platform message. The message may be empty. More...
 
virtual void FlutterViewHandlePlatformMessageResponse (int responseId, std::unique_ptr< fml::Mapping > data)=0
 Responds to a platform message. The data may be a nullptr. More...
 
virtual void FlutterViewUpdateSemantics (std::vector< uint8_t > buffer, std::vector< std::string > strings, std::vector< std::vector< uint8_t > > string_attribute_args)=0
 Sends semantics tree updates. More...
 
virtual void FlutterViewUpdateCustomAccessibilityActions (std::vector< uint8_t > actions_buffer, std::vector< std::string > strings)=0
 Sends new custom accessibility events. More...
 
virtual void FlutterViewOnFirstFrame ()=0
 Indicates that FlutterView should start painting pixels. More...
 
virtual void FlutterViewOnPreEngineRestart ()=0
 Indicates that a hot restart is about to happen. More...
 
virtual void SurfaceTextureAttachToGLContext (JavaLocalRef surface_texture, int textureId)=0
 Attach the SurfaceTexture to the OpenGL ES context that is current on the calling thread. More...
 
virtual bool SurfaceTextureShouldUpdate (JavaLocalRef surface_texture)=0
 Returns true if surface_texture should be updated. More...
 
virtual void SurfaceTextureUpdateTexImage (JavaLocalRef surface_texture)=0
 Updates the texture image to the most recent frame from the image stream. More...
 
virtual void SurfaceTextureGetTransformMatrix (JavaLocalRef surface_texture, SkMatrix &transform)=0
 Gets the transform matrix from the SurfaceTexture. Then, it updates the transform matrix, so it fill the canvas and preserve the aspect ratio. More...
 
virtual void SurfaceTextureDetachFromGLContext (JavaLocalRef surface_texture)=0
 Detaches a SurfaceTexture from the OpenGL ES context. More...
 
virtual JavaLocalRef ImageProducerTextureEntryAcquireLatestImage (JavaLocalRef image_texture_entry)=0
 Acquire the latest image available. More...
 
virtual JavaLocalRef ImageGetHardwareBuffer (JavaLocalRef image)=0
 Grab the HardwareBuffer from image. More...
 
virtual void ImageClose (JavaLocalRef image)=0
 Call close on image. More...
 
virtual void HardwareBufferClose (JavaLocalRef hardware_buffer)=0
 Call close on hardware_buffer. More...
 
virtual void FlutterViewOnDisplayPlatformView (int view_id, int x, int y, int width, int height, int viewWidth, int viewHeight, MutatorsStack mutators_stack)=0
 Positions and sizes a platform view if using hybrid composition. More...
 
virtual void FlutterViewDisplayOverlaySurface (int surface_id, int x, int y, int width, int height)=0
 Positions and sizes an overlay surface in hybrid composition. More...
 
virtual void FlutterViewBeginFrame ()=0
 Initiates a frame if using hybrid composition. More...
 
virtual void FlutterViewEndFrame ()=0
 Indicates that the current frame ended. It's used to clean up state. More...
 
virtual std::unique_ptr< PlatformViewAndroidJNI::OverlayMetadataFlutterViewCreateOverlaySurface ()=0
 Instantiates an overlay surface in hybrid composition and provides the necessary metadata to operate the surface in C. More...
 
virtual void FlutterViewDestroyOverlaySurfaces ()=0
 Destroys the overlay surfaces. More...
 
virtual std::unique_ptr< std::vector< std::string > > FlutterViewComputePlatformResolvedLocale (std::vector< std::string > supported_locales_data)=0
 Computes the locale Android would select. More...
 
virtual double GetDisplayRefreshRate ()=0
 
virtual double GetDisplayWidth ()=0
 
virtual double GetDisplayHeight ()=0
 
virtual double GetDisplayDensity ()=0
 
virtual bool RequestDartDeferredLibrary (int loading_unit_id)=0
 
virtual double FlutterViewGetScaledFontSize (double unscaled_font_size, int configuration_id) const =0
 

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

1280 : java_object_(java_object) {}

◆ ~PlatformViewAndroidJNIImpl()

flutter::PlatformViewAndroidJNIImpl::~PlatformViewAndroidJNIImpl ( )
overridedefault

Member Function Documentation

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

1747 {
1749
1750 auto java_object = java_object_.get(env);
1751 if (java_object.is_null()) {
1752 return;
1753 }
1754
1755 env->CallVoidMethod(java_object.obj(), g_on_begin_frame_method);
1756
1758}
ScopedJavaLocalRef< jobject > get(JNIEnv *env) const
Definition: jni_weak_ref.cc:41
#define FML_CHECK(condition)
Definition: logging.h:85
Definition: __init__.py:1
static jmethodID g_on_begin_frame_method
JNIEnv * AttachCurrentThread()
Definition: jni_util.cc:34
bool CheckException(JNIEnv *env)
Definition: jni_util.cc:199

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

1820 {
1822
1823 std::unique_ptr<std::vector<std::string>> out =
1824 std::make_unique<std::vector<std::string>>();
1825
1826 auto java_object = java_object_.get(env);
1827 if (java_object.is_null()) {
1828 return out;
1829 }
1831 fml::jni::VectorToStringArray(env, supported_locales_data);
1832 jobjectArray result = static_cast<jobjectArray>(env->CallObjectMethod(
1834 j_locales_data.obj()));
1835
1837
1838 int length = env->GetArrayLength(result);
1839 for (int i = 0; i < length; i++) {
1840 out->emplace_back(fml::jni::JavaStringToString(
1841 env, static_cast<jstring>(env->GetObjectArrayElement(result, i))));
1842 }
1843 return out;
1844}
GAsyncResult * result
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

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

1774 {
1776
1777 auto java_object = java_object_.get(env);
1778 if (java_object.is_null()) {
1779 return nullptr;
1780 }
1781
1783 env, env->CallObjectMethod(java_object.obj(),
1786
1787 if (overlay.is_null()) {
1788 return std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(0,
1789 nullptr);
1790 }
1791
1792 jint overlay_id =
1793 env->CallIntMethod(overlay.obj(), g_overlay_surface_id_method);
1794
1795 jobject overlay_surface =
1796 env->CallObjectMethod(overlay.obj(), g_overlay_surface_surface_method);
1797
1798 auto overlay_window = fml::MakeRefCounted<AndroidNativeWindow>(
1799 ANativeWindow_fromSurface(env, overlay_surface));
1800
1801 return std::make_unique<PlatformViewAndroidJNI::OverlayMetadata>(
1802 overlay_id, std::move(overlay_window));
1803}
static jmethodID g_create_overlay_surface_method
static jmethodID g_overlay_surface_surface_method
static jmethodID g_overlay_surface_id_method

◆ FlutterViewDestroyOverlaySurfaces()

void flutter::PlatformViewAndroidJNIImpl::FlutterViewDestroyOverlaySurfaces ( )
overridevirtual

Destroys the overlay surfaces.

Note
Must be called from the platform thread.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1805 of file platform_view_android_jni_impl.cc.

1805 {
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_destroy_overlay_surfaces_method);
1814
1816}
static jmethodID g_destroy_overlay_surfaces_method

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

1733 {
1735
1736 auto java_object = java_object_.get(env);
1737 if (java_object.is_null()) {
1738 return;
1739 }
1740
1741 env->CallVoidMethod(java_object.obj(), g_on_display_overlay_surface_method,
1742 surface_id, x, y, width, height);
1743
1745}
double y
double x
static jmethodID g_on_display_overlay_surface_method
int32_t height
int32_t width

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

1760 {
1762
1763 auto java_object = java_object_.get(env);
1764 if (java_object.is_null()) {
1765 return;
1766 }
1767
1768 env->CallVoidMethod(java_object.obj(), g_on_end_frame_method);
1769
1771}
static jmethodID g_on_end_frame_method

◆ FlutterViewGetScaledFontSize()

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

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1347 of file platform_view_android_jni_impl.cc.

1349 {
1351
1352 auto java_object = java_object_.get(env);
1353 if (java_object.is_null()) {
1354 return -3;
1355 }
1356
1357 const jfloat scaledSize =
1358 env->CallFloatMethod(java_object.obj(), g_get_scaled_font_size_method,
1359 (jfloat)font_size, (jint)configuration_id);
1361 return (double)scaledSize;
1362}
SkScalar font_size
static jmethodID g_get_scaled_font_size_method

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

1286 {
1287 // Called from any thread.
1289
1290 auto java_object = java_object_.get(env);
1291 if (java_object.is_null()) {
1292 return;
1293 }
1294
1297
1298 if (message->hasData()) {
1300 env, env->NewDirectByteBuffer(
1301 const_cast<uint8_t*>(message->data().GetMapping()),
1302 message->data().GetSize()));
1303 // Message data is deleted in CleanupMessageData.
1304 fml::MallocMapping mapping = message->releaseData();
1305 env->CallVoidMethod(java_object.obj(), g_handle_platform_message_method,
1306 java_channel.obj(), message_array.obj(), responseId,
1307 reinterpret_cast<jlong>(mapping.Release()));
1308 } else {
1309 env->CallVoidMethod(java_object.obj(), g_handle_platform_message_method,
1310 java_channel.obj(), nullptr, responseId, nullptr);
1311 }
1312
1314}
A Mapping like NonOwnedMapping, but uses Free as its release proc.
Definition: mapping.h:144
uint8_t * Release()
Definition: mapping.cc:155
Win32Message message
static jmethodID g_handle_platform_message_method
ScopedJavaLocalRef< jstring > StringToJavaString(JNIEnv *env, const std::string &u8_string)
Definition: jni_util.cc:86

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

1318 {
1319 // We are on the platform thread. Attempt to get the strong reference to
1320 // the Java object.
1322
1323 auto java_object = java_object_.get(env);
1324 if (java_object.is_null()) {
1325 // The Java object was collected before this message response got to
1326 // it. Drop the response on the floor.
1327 return;
1328 }
1329 if (data == nullptr) { // Empty response.
1330 env->CallVoidMethod(java_object.obj(),
1332 nullptr);
1333 } else {
1334 // Convert the vector to a Java byte array.
1336 env, env->NewDirectByteBuffer(const_cast<uint8_t*>(data->GetMapping()),
1337 data->GetSize()));
1338
1339 env->CallVoidMethod(java_object.obj(),
1341 data_array.obj());
1342 }
1343
1345}
static jmethodID g_handle_platform_message_response_method
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: switches.h:41

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

1655 {
1657 auto java_object = java_object_.get(env);
1658 if (java_object.is_null()) {
1659 return;
1660 }
1661
1662 jobject mutatorsStack = env->NewObject(g_mutators_stack_class->obj(),
1664
1665 std::vector<std::shared_ptr<Mutator>>::const_iterator iter =
1666 mutators_stack.Begin();
1667 while (iter != mutators_stack.End()) {
1668 switch ((*iter)->GetType()) {
1669 case kTransform: {
1670 const SkMatrix& matrix = (*iter)->GetMatrix();
1671 SkScalar matrix_array[9];
1672 matrix.get9(matrix_array);
1674 env, env->NewFloatArray(9));
1675
1676 env->SetFloatArrayRegion(transformMatrix.obj(), 0, 9, matrix_array);
1677 env->CallVoidMethod(mutatorsStack,
1679 transformMatrix.obj());
1680 break;
1681 }
1682 case kClipRect: {
1683 const SkRect& rect = (*iter)->GetRect();
1684 env->CallVoidMethod(
1686 static_cast<int>(rect.left()), static_cast<int>(rect.top()),
1687 static_cast<int>(rect.right()), static_cast<int>(rect.bottom()));
1688 break;
1689 }
1690 case kClipRRect: {
1691 const SkRRect& rrect = (*iter)->GetRRect();
1692 const SkRect& rect = rrect.rect();
1693 const SkVector& upper_left = rrect.radii(SkRRect::kUpperLeft_Corner);
1694 const SkVector& upper_right = rrect.radii(SkRRect::kUpperRight_Corner);
1695 const SkVector& lower_right = rrect.radii(SkRRect::kLowerRight_Corner);
1696 const SkVector& lower_left = rrect.radii(SkRRect::kLowerLeft_Corner);
1697 SkScalar radiis[8] = {
1698 upper_left.x(), upper_left.y(), upper_right.x(), upper_right.y(),
1699 lower_right.x(), lower_right.y(), lower_left.x(), lower_left.y(),
1700 };
1702 env, env->NewFloatArray(8));
1703 env->SetFloatArrayRegion(radiisArray.obj(), 0, 8, radiis);
1704 env->CallVoidMethod(
1706 static_cast<int>(rect.left()), static_cast<int>(rect.top()),
1707 static_cast<int>(rect.right()), static_cast<int>(rect.bottom()),
1708 radiisArray.obj());
1709 break;
1710 }
1711 // TODO(cyanglaz): Implement other mutators.
1712 // https://github.com/flutter/flutter/issues/58426
1713 case kClipPath:
1714 case kOpacity:
1715 case kBackdropFilter:
1716 break;
1717 }
1718 ++iter;
1719 }
1720
1721 env->CallVoidMethod(java_object.obj(), g_on_display_platform_view_method,
1722 view_id, x, y, width, height, viewWidth, viewHeight,
1723 mutatorsStack);
1724
1726}
const SkRect & rect() const
Definition: SkRRect.h:264
SkVector radii(Corner corner) const
Definition: SkRRect.h:271
@ kUpperLeft_Corner
index of top-left corner radii
Definition: SkRRect.h:252
@ kLowerRight_Corner
index of bottom-right corner radii
Definition: SkRRect.h:254
@ kUpperRight_Corner
index of top-right corner radii
Definition: SkRRect.h:253
@ kLowerLeft_Corner
index of bottom-left corner radii
Definition: SkRRect.h:255
float SkScalar
Definition: extension.cpp:12
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
SkRRect rrect
Definition: SkRecords.h:232
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
static jmethodID g_mutators_stack_init_method
static jmethodID g_mutators_stack_push_transform_method
@ kBackdropFilter
static jmethodID g_mutators_stack_push_cliprect_method
static jmethodID g_mutators_stack_push_cliprrect_method
static jmethodID g_on_display_platform_view_method
static fml::jni::ScopedJavaGlobalRef< jclass > * g_mutators_stack_class
constexpr float y() const
Definition: SkPoint_impl.h:187
constexpr float x() const
Definition: SkPoint_impl.h:181

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

1413 {
1415
1416 auto java_object = java_object_.get(env);
1417 if (java_object.is_null()) {
1418 return;
1419 }
1420
1421 env->CallVoidMethod(java_object.obj(), g_on_first_frame_method);
1422
1424}
static jmethodID g_on_first_frame_method

◆ FlutterViewOnPreEngineRestart()

void flutter::PlatformViewAndroidJNIImpl::FlutterViewOnPreEngineRestart ( )
overridevirtual

Indicates that a hot restart is about to happen.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1426 of file platform_view_android_jni_impl.cc.

1426 {
1428
1429 auto java_object = java_object_.get(env);
1430 if (java_object.is_null()) {
1431 return;
1432 }
1433
1434 env->CallVoidMethod(java_object.obj(), g_on_engine_restart_method);
1435
1437}
static jmethodID g_on_engine_restart_method

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

1391 {
1393
1394 auto java_object = java_object_.get(env);
1395 if (java_object.is_null()) {
1396 return;
1397 }
1398
1399 fml::jni::ScopedJavaLocalRef<jobject> direct_actions_buffer(
1400 env,
1401 env->NewDirectByteBuffer(actions_buffer.data(), actions_buffer.size()));
1402
1405
1406 env->CallVoidMethod(java_object.obj(),
1408 direct_actions_buffer.obj(), jstrings.obj());
1409
1411}
static jmethodID g_update_custom_accessibility_actions_method

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

1367 {
1369
1370 auto java_object = java_object_.get(env);
1371 if (java_object.is_null()) {
1372 return;
1373 }
1374
1376 env, env->NewDirectByteBuffer(buffer.data(), buffer.size()));
1379 fml::jni::ScopedJavaLocalRef<jobjectArray> jstring_attribute_args =
1380 fml::jni::VectorToBufferArray(env, string_attribute_args);
1381
1382 env->CallVoidMethod(java_object.obj(), g_update_semantics_method,
1383 direct_buffer.obj(), jstrings.obj(),
1384 jstring_attribute_args.obj());
1385
1387}
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 vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
static jmethodID g_update_semantics_method
ScopedJavaLocalRef< jobjectArray > VectorToBufferArray(JNIEnv *env, const std::vector< std::vector< uint8_t > > &vector)
Definition: jni_util.cc:164

◆ GetDisplayDensity()

double flutter::PlatformViewAndroidJNIImpl::GetDisplayDensity ( )
overridevirtual

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1900 of file platform_view_android_jni_impl.cc.

1900 {
1902
1903 auto java_object = java_object_.get(env);
1904 if (java_object.is_null()) {
1905 return -1;
1906 }
1907
1909 env, env->GetObjectClass(java_object.obj()));
1910 if (clazz.is_null()) {
1911 return -1;
1912 }
1913
1914 jfieldID fid = env->GetStaticFieldID(clazz.obj(), "displayDensity", "F");
1915 return static_cast<double>(env->GetStaticFloatField(clazz.obj(), fid));
1916}

◆ GetDisplayHeight()

double flutter::PlatformViewAndroidJNIImpl::GetDisplayHeight ( )
overridevirtual

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1882 of file platform_view_android_jni_impl.cc.

1882 {
1884
1885 auto java_object = java_object_.get(env);
1886 if (java_object.is_null()) {
1887 return -1;
1888 }
1889
1891 env, env->GetObjectClass(java_object.obj()));
1892 if (clazz.is_null()) {
1893 return -1;
1894 }
1895
1896 jfieldID fid = env->GetStaticFieldID(clazz.obj(), "displayHeight", "F");
1897 return static_cast<double>(env->GetStaticFloatField(clazz.obj(), fid));
1898}

◆ GetDisplayRefreshRate()

double flutter::PlatformViewAndroidJNIImpl::GetDisplayRefreshRate ( )
overridevirtual

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1846 of file platform_view_android_jni_impl.cc.

1846 {
1848
1849 auto java_object = java_object_.get(env);
1850 if (java_object.is_null()) {
1852 }
1853
1855 env, env->GetObjectClass(java_object.obj()));
1856 if (clazz.is_null()) {
1858 }
1859
1860 jfieldID fid = env->GetStaticFieldID(clazz.obj(), "refreshRateFPS", "F");
1861 return static_cast<double>(env->GetStaticFloatField(clazz.obj(), fid));
1862}
static constexpr double kUnknownDisplayRefreshRate
To be used when the display refresh rate is unknown.
Definition: display.h:20

◆ GetDisplayWidth()

double flutter::PlatformViewAndroidJNIImpl::GetDisplayWidth ( )
overridevirtual

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1864 of file platform_view_android_jni_impl.cc.

1864 {
1866
1867 auto java_object = java_object_.get(env);
1868 if (java_object.is_null()) {
1869 return -1;
1870 }
1871
1873 env, env->GetObjectClass(java_object.obj()));
1874 if (clazz.is_null()) {
1875 return -1;
1876 }
1877
1878 jfieldID fid = env->GetStaticFieldID(clazz.obj(), "displayWidth", "F");
1879 return static_cast<double>(env->GetStaticFloatField(clazz.obj(), fid));
1880}

◆ HardwareBufferClose()

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

Call close on hardware_buffer.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1636 of file platform_view_android_jni_impl.cc.

1637 {
1640 if (hardware_buffer.is_null()) {
1641 return;
1642 }
1643 env->CallVoidMethod(hardware_buffer.obj(), g_hardware_buffer_close_method);
1645}
static jmethodID g_hardware_buffer_close_method

◆ ImageClose()

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

Call close on image.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1627 of file platform_view_android_jni_impl.cc.

1627 {
1629 if (image.is_null()) {
1630 return;
1631 }
1632 env->CallVoidMethod(image.obj(), g_image_close_method);
1634}
sk_sp< const SkImage > image
Definition: SkRecords.h:269
static jmethodID g_image_close_method

◆ ImageGetHardwareBuffer()

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

Grab the HardwareBuffer from image.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1612 of file platform_view_android_jni_impl.cc.

1613 {
1616 if (image.is_null()) {
1617 // Return null.
1618 return JavaLocalRef();
1619 }
1621 env,
1622 env->CallObjectMethod(image.obj(), g_image_get_hardware_buffer_method));
1624 return r;
1625}
std::nullptr_t JavaLocalRef
static jmethodID g_image_get_hardware_buffer_method

◆ ImageProducerTextureEntryAcquireLatestImage()

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

Acquire the latest image available.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1585 of file platform_view_android_jni_impl.cc.

1586 {
1588
1589 if (image_producer_texture_entry.is_null()) {
1590 // Return null.
1591 return JavaLocalRef();
1592 }
1593
1594 // Convert the weak reference to ImageTextureEntry into a strong local
1595 // reference.
1596 fml::jni::ScopedJavaLocalRef<jobject> image_producer_texture_entry_local_ref(
1597 env, env->CallObjectMethod(image_producer_texture_entry.obj(),
1599
1600 if (image_producer_texture_entry_local_ref.is_null()) {
1601 // Return null.
1602 return JavaLocalRef();
1603 }
1604
1606 env, env->CallObjectMethod(image_producer_texture_entry_local_ref.obj(),
1609 return r;
1610}
static jmethodID g_acquire_latest_image_method
static jmethodID g_java_weak_reference_get_method

◆ RequestDartDeferredLibrary()

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

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1918 of file platform_view_android_jni_impl.cc.

1919 {
1921
1922 auto java_object = java_object_.get(env);
1923 if (java_object.is_null()) {
1924 return true;
1925 }
1926
1927 env->CallVoidMethod(java_object.obj(), g_request_dart_deferred_library_method,
1928 loading_unit_id);
1929
1931 return true;
1932}
static jmethodID g_request_dart_deferred_library_method

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

1441 {
1443
1444 if (surface_texture.is_null()) {
1445 return;
1446 }
1447
1448 fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref(
1449 env, env->CallObjectMethod(surface_texture.obj(),
1451
1452 if (surface_texture_local_ref.is_null()) {
1453 return;
1454 }
1455
1456 env->CallVoidMethod(surface_texture_local_ref.obj(),
1458
1460}
static jmethodID g_attach_to_gl_context_method

◆ SurfaceTextureDetachFromGLContext()

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

Detaches a SurfaceTexture from the OpenGL ES context.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1563 of file platform_view_android_jni_impl.cc.

1564 {
1566
1567 if (surface_texture.is_null()) {
1568 return;
1569 }
1570
1571 fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref(
1572 env, env->CallObjectMethod(surface_texture.obj(),
1574 if (surface_texture_local_ref.is_null()) {
1575 return;
1576 }
1577
1578 env->CallVoidMethod(surface_texture_local_ref.obj(),
1580
1582}
static jmethodID g_detach_from_gl_context_method

◆ SurfaceTextureGetTransformMatrix()

void flutter::PlatformViewAndroidJNIImpl::SurfaceTextureGetTransformMatrix ( JavaLocalRef  surface_texture,
SkMatrix transform 
)
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 1506 of file platform_view_android_jni_impl.cc.

1508 {
1510
1511 if (surface_texture.is_null()) {
1512 return;
1513 }
1514
1515 fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref(
1516 env, env->CallObjectMethod(surface_texture.obj(),
1518 if (surface_texture_local_ref.is_null()) {
1519 return;
1520 }
1521
1523 env, env->NewFloatArray(16));
1524
1525 env->CallVoidMethod(surface_texture_local_ref.obj(),
1526 g_get_transform_matrix_method, transformMatrix.obj());
1528
1529 float* m = env->GetFloatArrayElements(transformMatrix.obj(), nullptr);
1530
1531 // SurfaceTexture 4x4 Column Major -> Skia 3x3 Row Major
1532
1533 // SurfaceTexture 4x4 (Column Major):
1534 // | m[0] m[4] m[ 8] m[12] |
1535 // | m[1] m[5] m[ 9] m[13] |
1536 // | m[2] m[6] m[10] m[14] |
1537 // | m[3] m[7] m[11] m[15] |
1538
1539 // According to Android documentation, the 4x4 matrix returned should be used
1540 // with texture coordinates in the form (s, t, 0, 1). Since the z component is
1541 // always 0.0, we are free to ignore any element that multiplies with the z
1542 // component. Converting this to a 3x3 matrix is easy:
1543
1544 // SurfaceTexture 3x3 (Column Major):
1545 // | m[0] m[4] m[12] |
1546 // | m[1] m[5] m[13] |
1547 // | m[3] m[7] m[15] |
1548
1549 // Skia (Row Major):
1550 // | m[0] m[1] m[2] |
1551 // | m[3] m[4] m[5] |
1552 // | m[6] m[7] m[8] |
1553
1554 SkScalar matrix3[] = {
1555 m[0], m[4], m[12], //
1556 m[1], m[5], m[13], //
1557 m[3], m[7], m[15], //
1558 };
1559 env->ReleaseFloatArrayElements(transformMatrix.obj(), m, JNI_ABORT);
1560 transform.set9(matrix3);
1561}
static jmethodID g_get_transform_matrix_method
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
Definition: p3.cpp:47

◆ SurfaceTextureShouldUpdate()

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

Returns true if surface_texture should be updated.

Implements flutter::PlatformViewAndroidJNI.

Definition at line 1462 of file platform_view_android_jni_impl.cc.

1463 {
1465
1466 if (surface_texture.is_null()) {
1467 return false;
1468 }
1469
1470 fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref(
1471 env, env->CallObjectMethod(surface_texture.obj(),
1473 if (surface_texture_local_ref.is_null()) {
1474 return false;
1475 }
1476
1477 jboolean shouldUpdate = env->CallBooleanMethod(
1478 surface_texture_local_ref.obj(), g_surface_texture_wrapper_should_update);
1479
1481
1482 return shouldUpdate;
1483}
static jmethodID g_surface_texture_wrapper_should_update

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

1486 {
1488
1489 if (surface_texture.is_null()) {
1490 return;
1491 }
1492
1493 fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref(
1494 env, env->CallObjectMethod(surface_texture.obj(),
1496 if (surface_texture_local_ref.is_null()) {
1497 return;
1498 }
1499
1500 env->CallVoidMethod(surface_texture_local_ref.obj(),
1502
1504}
static jmethodID g_update_tex_image_method

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