Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit f14cb3b

Browse files
Merge branch 'main' into roll-expat-2-5
2 parents 5de64c9 + 3d9f485 commit f14cb3b

File tree

20 files changed

+718
-197
lines changed

20 files changed

+718
-197
lines changed

.ci.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ targets:
268268
add_recipes_cq: "true"
269269
cores: "32"
270270
gcs_goldens_bucket: flutter_logs
271+
gclient_custom_vars: >-
272+
{"download_emsdk": True}
271273
dependencies: >-
272274
[
273275
{"dependency": "goldctl", "version": "git_revision:3a77d0b12c697a840ca0c7705208e8622dc94603"}
@@ -407,6 +409,8 @@ targets:
407409
properties:
408410
add_recipes_cq: "true"
409411
gcs_goldens_bucket: flutter_logs
412+
gclient_custom_vars: >-
413+
{"download_emsdk": True}
410414
dependencies: >-
411415
[
412416
{"dependency": "goldctl", "version": "git_revision:3a77d0b12c697a840ca0c7705208e8622dc94603"}
@@ -481,6 +485,8 @@ targets:
481485
- name: Windows Web Engine
482486
recipe: engine/web_engine
483487
properties:
488+
gclient_custom_vars: >-
489+
{"download_emsdk": true}
484490
gcs_goldens_bucket: flutter_logs
485491
timeout: 60
486492
runIf:

DEPS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ allowed_hosts = [
118118
]
119119

120120
deps = {
121-
'src': 'https://github.com/flutter/buildroot.git' + '@' + '4099e11fffa406aaa13be8bd512fe5b0ad6262f6',
121+
'src': 'https://github.com/flutter/buildroot.git' + '@' + 'd13d64086f5e301bd0415eede895b34af220ef42',
122122

123123
# Fuchsia compatibility
124124
#
@@ -686,7 +686,7 @@ deps = {
686686
'packages': [
687687
{
688688
'package': 'fuchsia/sdk/core/mac-amd64',
689-
'version': '5XOj9l5e2wkSpMKT1pLJGtq9_UAQkHV13y-kg9rVNiUC'
689+
'version': 'sa5bVGimNo3JwLV27Wpu8RLzitWUvIeqJtAqcrtplosC'
690690
}
691691
],
692692
'condition': 'host_os == "mac" and not download_fuchsia_sdk',

lib/ui/platform_dispatcher.dart

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,27 @@ class PlatformDispatcher {
750750
_invoke(onAccessibilityFeaturesChanged, _onAccessibilityFeaturesChangedZone,);
751751
}
752752

753+
/// Change the retained semantics data about this platform dispatcher.
754+
///
755+
/// If [semanticsEnabled] is true, the user has requested that this function
756+
/// be called whenever the semantic content of this platform dispatcher
757+
/// changes.
758+
///
759+
/// In either case, this function disposes the given update, which means the
760+
/// semantics update cannot be used further.
761+
@Deprecated('''
762+
In a multi-view world, the platform dispatcher can no longer provide apis
763+
to update semantics since each view will host its own semantics tree.
764+
765+
Semantics updates must be passed to an individual [FlutterView]. To update
766+
semantics, use PlatformDispatcher.instance.views to get a [FlutterView] and
767+
call `updateSemantics`.
768+
''')
769+
void updateSemantics(SemanticsUpdate update) => _updateSemantics(update);
770+
771+
@FfiNative<Void Function(Pointer<Void>)>('PlatformConfigurationNativeApi::UpdateSemantics')
772+
external static void _updateSemantics(SemanticsUpdate update);
773+
753774
/// The system-reported default locale of the device.
754775
///
755776
/// This establishes the language and formatting conventions that application

lib/web_ui/lib/platform_dispatcher.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ abstract class PlatformDispatcher {
8383
VoidCallback? get onAccessibilityFeaturesChanged;
8484
set onAccessibilityFeaturesChanged(VoidCallback? callback);
8585

86+
@Deprecated('''
87+
In a multi-view world, the platform dispatcher can no longer provide apis
88+
to update semantics since each view will host its own semantics tree.
89+
90+
Semantics updates must be passed to an individual [FlutterView]. To update
91+
semantics, use PlatformDispatcher.instance.views to get a [FlutterView] and
92+
call `updateSemantics`.
93+
''')
8694
void updateSemantics(SemanticsUpdate update);
8795

8896
Locale get locale;

lib/web_ui/lib/src/engine/platform_dispatcher.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,22 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher {
690690
_onAccessibilityFeaturesChanged, _onAccessibilityFeaturesChangedZone);
691691
}
692692

693+
/// Change the retained semantics data about this window.
694+
///
695+
/// If [semanticsEnabled] is true, the user has requested that this function
696+
/// be called whenever the semantic content of this window changes.
697+
///
698+
/// In either case, this function disposes the given update, which means the
699+
/// semantics update cannot be used further.
693700
@override
701+
@Deprecated('''
702+
In a multi-view world, the platform dispatcher can no longer provide apis
703+
to update semantics since each view will host its own semantics tree.
704+
705+
Semantics updates must be passed to an individual [FlutterView]. To update
706+
semantics, use PlatformDispatcher.instance.views to get a [FlutterView] and
707+
call `updateSemantics`.
708+
''')
694709
void updateSemantics(ui.SemanticsUpdate update) {
695710
EngineSemanticsOwner.instance.updateSemantics(update);
696711
}

shell/platform/android/platform_view_android_jni_impl.cc

Lines changed: 62 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ static fml::jni::ScopedJavaGlobalRef<jclass>* g_texture_wrapper_class = nullptr;
4949

5050
static fml::jni::ScopedJavaGlobalRef<jclass>* g_java_long_class = nullptr;
5151

52+
static fml::jni::ScopedJavaGlobalRef<jclass>* g_bitmap_class = nullptr;
53+
54+
static fml::jni::ScopedJavaGlobalRef<jclass>* g_bitmap_config_class = nullptr;
55+
5256
// Called By Native
5357

5458
static jmethodID g_flutter_callback_info_constructor = nullptr;
@@ -115,6 +119,12 @@ static jmethodID g_overlay_surface_id_method = nullptr;
115119

116120
static jmethodID g_overlay_surface_surface_method = nullptr;
117121

122+
static jmethodID g_bitmap_create_bitmap_method = nullptr;
123+
124+
static jmethodID g_bitmap_copy_pixels_from_buffer_method = nullptr;
125+
126+
static jmethodID g_bitmap_config_value_of = nullptr;
127+
118128
// Mutators
119129
static fml::jni::ScopedJavaGlobalRef<jclass>* g_mutators_stack_class = nullptr;
120130
static jmethodID g_mutators_stack_init_method = nullptr;
@@ -337,70 +347,31 @@ static jobject GetBitmap(JNIEnv* env, jobject jcaller, jlong shell_holder) {
337347
return nullptr;
338348
}
339349

340-
const SkISize& frame_size = screenshot.frame_size;
341-
jsize pixels_size = frame_size.width() * frame_size.height();
342-
jintArray pixels_array = env->NewIntArray(pixels_size);
343-
if (pixels_array == nullptr) {
344-
return nullptr;
345-
}
346-
347-
jint* pixels = env->GetIntArrayElements(pixels_array, nullptr);
348-
if (pixels == nullptr) {
349-
return nullptr;
350-
}
351-
352-
auto* pixels_src = static_cast<const int32_t*>(screenshot.data->data());
353-
354-
// Our configuration of Skia does not support rendering to the
355-
// BitmapConfig.ARGB_8888 format expected by android.graphics.Bitmap.
356-
// Convert from kRGBA_8888 to kBGRA_8888 (equivalent to ARGB_8888).
357-
for (int i = 0; i < pixels_size; i++) {
358-
int32_t src_pixel = pixels_src[i];
359-
uint8_t* src_bytes = reinterpret_cast<uint8_t*>(&src_pixel);
360-
std::swap(src_bytes[0], src_bytes[2]);
361-
pixels[i] = src_pixel;
362-
}
363-
364-
env->ReleaseIntArrayElements(pixels_array, pixels, 0);
365-
366-
jclass bitmap_class = env->FindClass("android/graphics/Bitmap");
367-
if (bitmap_class == nullptr) {
368-
return nullptr;
369-
}
370-
371-
jmethodID create_bitmap = env->GetStaticMethodID(
372-
bitmap_class, "createBitmap",
373-
"([IIILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;");
374-
if (create_bitmap == nullptr) {
375-
return nullptr;
376-
}
377-
378-
jclass bitmap_config_class = env->FindClass("android/graphics/Bitmap$Config");
379-
if (bitmap_config_class == nullptr) {
380-
return nullptr;
381-
}
382-
383-
jmethodID bitmap_config_value_of = env->GetStaticMethodID(
384-
bitmap_config_class, "valueOf",
385-
"(Ljava/lang/String;)Landroid/graphics/Bitmap$Config;");
386-
if (bitmap_config_value_of == nullptr) {
387-
return nullptr;
388-
}
389-
390350
jstring argb = env->NewStringUTF("ARGB_8888");
391351
if (argb == nullptr) {
392352
return nullptr;
393353
}
394354

395355
jobject bitmap_config = env->CallStaticObjectMethod(
396-
bitmap_config_class, bitmap_config_value_of, argb);
356+
g_bitmap_config_class->obj(), g_bitmap_config_value_of, argb);
397357
if (bitmap_config == nullptr) {
398358
return nullptr;
399359
}
400360

401-
return env->CallStaticObjectMethod(bitmap_class, create_bitmap, pixels_array,
402-
frame_size.width(), frame_size.height(),
403-
bitmap_config);
361+
auto bitmap = env->CallStaticObjectMethod(
362+
g_bitmap_class->obj(), g_bitmap_create_bitmap_method,
363+
screenshot.frame_size.width(), screenshot.frame_size.height(),
364+
bitmap_config);
365+
366+
fml::jni::ScopedJavaLocalRef<jobject> buffer(
367+
env,
368+
env->NewDirectByteBuffer(const_cast<uint8_t*>(screenshot.data->bytes()),
369+
screenshot.data->size()));
370+
371+
env->CallVoidMethod(bitmap, g_bitmap_copy_pixels_from_buffer_method,
372+
buffer.obj());
373+
374+
return bitmap;
404375
}
405376

406377
static void DispatchPlatformMessage(JNIEnv* env,
@@ -945,6 +916,43 @@ bool RegisterApi(JNIEnv* env) {
945916
return false;
946917
}
947918

919+
g_bitmap_class = new fml::jni::ScopedJavaGlobalRef<jclass>(
920+
env, env->FindClass("android/graphics/Bitmap"));
921+
if (g_bitmap_class->is_null()) {
922+
FML_LOG(ERROR) << "Could not locate Bitmap Class";
923+
return false;
924+
}
925+
926+
g_bitmap_create_bitmap_method = env->GetStaticMethodID(
927+
g_bitmap_class->obj(), "createBitmap",
928+
"(IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;");
929+
if (g_bitmap_create_bitmap_method == nullptr) {
930+
FML_LOG(ERROR) << "Could not locate Bitmap.createBitmap method";
931+
return false;
932+
}
933+
934+
g_bitmap_copy_pixels_from_buffer_method = env->GetMethodID(
935+
g_bitmap_class->obj(), "copyPixelsFromBuffer", "(Ljava/nio/Buffer;)V");
936+
if (g_bitmap_copy_pixels_from_buffer_method == nullptr) {
937+
FML_LOG(ERROR) << "Could not locate Bitmap.copyPixelsFromBuffer method";
938+
return false;
939+
}
940+
941+
g_bitmap_config_class = new fml::jni::ScopedJavaGlobalRef<jclass>(
942+
env, env->FindClass("android/graphics/Bitmap$Config"));
943+
if (g_bitmap_config_class->is_null()) {
944+
FML_LOG(ERROR) << "Could not locate Bitmap.Config Class";
945+
return false;
946+
}
947+
948+
g_bitmap_config_value_of = env->GetStaticMethodID(
949+
g_bitmap_config_class->obj(), "valueOf",
950+
"(Ljava/lang/String;)Landroid/graphics/Bitmap$Config;");
951+
if (g_bitmap_config_value_of == nullptr) {
952+
FML_LOG(ERROR) << "Could not locate Bitmap.Config.valueOf method";
953+
return false;
954+
}
955+
948956
return true;
949957
}
950958

0 commit comments

Comments
 (0)