Skip to content

Commit f194c20

Browse files
authored
Merge branch 'master' into webparagraph_placeholder_boxes
2 parents aa60c18 + 660dc43 commit f194c20

30 files changed

Lines changed: 1119 additions & 70 deletions

‎DEPS‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ vars = {
1515
'skia_git': 'https://skia.googlesource.com',
1616
'llvm_git': 'https://llvm.googlesource.com',
1717
'dart_ai_rev': '9c96bfe5f091c9451eff5b59c9bffeb2e806b875',
18-
'skia_revision': '9b6ceba4728ddc633c940cd2e3449f0b09b4460f',
18+
'skia_revision': '17f6986c226c46eb03b4f034ac736ddb1781409c',
1919

2020
# Do not download the Emscripten SDK by default.
2121
# This prevents us from downloading the Emscripten toolchain for builds
@@ -55,7 +55,7 @@ vars = {
5555
# updated revision list of existing dependencies. You will need to
5656
# gclient sync before and after update deps to ensure all deps are updated.
5757
# updated revision list of existing dependencies.
58-
'dart_revision': '221363557163c492e0a87fa15ec43e2f94c5e6e6',
58+
'dart_revision': '5933cb486b4aef2f8cf6b9f89a5651c0d5b0955e',
5959

6060
# WARNING: DO NOT EDIT MANUALLY
6161
# The lines between blank lines above and below are generated by a script. See create_updated_flutter_deps.py

‎dev/customer_testing/tests.version‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3cfbc5eab2c2d3bf4ada16848394128f800e0b9b
1+
6fd13ac5a4e3bcfa90e4fcebae41d0da8ae14857

‎engine/src/flutter/impeller/toolkit/android/surface_transaction.cc‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
namespace impeller::android {
1212

1313
SurfaceTransaction::SurfaceTransaction()
14-
: transaction_(
15-
WrappedSurfaceTransaction{GetProcTable().ASurfaceTransaction_create(),
16-
/*owned=*/true}) {}
14+
: transaction_(WrappedSurfaceTransaction{
15+
GetProcTable().ASurfaceTransaction_create(), /*owned=*/true,
16+
/*publish_callback=*/nullptr}) {}
1717

18-
SurfaceTransaction::SurfaceTransaction(ASurfaceTransaction* transaction)
19-
: transaction_(WrappedSurfaceTransaction{transaction, /*owned=*/false}) {}
18+
SurfaceTransaction::SurfaceTransaction(ASurfaceTransaction* transaction,
19+
std::function<void()> publish_callback)
20+
: transaction_(WrappedSurfaceTransaction{transaction, /*owned=*/false,
21+
std::move(publish_callback)}) {}
2022

2123
SurfaceTransaction::~SurfaceTransaction() = default;
2224

@@ -53,7 +55,13 @@ bool SurfaceTransaction::Apply(OnCompleteCallback callback) {
5355
// the Java PlatformViewController and not as a part of the engine render
5456
// loop.
5557
if (!transaction_.get().owned) {
58+
// All native writes into the transaction are done at this point. Hand it
59+
// back to Java, which owns applying it.
60+
std::function<void()> publish_cb = transaction_.get().publish_callback;
5661
transaction_.reset();
62+
if (publish_cb) {
63+
publish_cb();
64+
}
5765
return true;
5866
}
5967

‎engine/src/flutter/impeller/toolkit/android/surface_transaction.h‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ struct WrappedSurfaceTransaction {
2828
/// Java.
2929
bool owned = true;
3030

31-
constexpr bool operator==(const WrappedSurfaceTransaction& other) const {
31+
/// Invoked after all native writes into a borrowed (non-owned) transaction
32+
/// have completed, to hand the transaction back to Java for application.
33+
std::function<void()> publish_callback;
34+
35+
bool operator==(const WrappedSurfaceTransaction& other) const {
3236
return other.tx == tx;
3337
}
3438
};
@@ -63,7 +67,17 @@ class SurfaceTransaction {
6367

6468
SurfaceTransaction& operator=(const SurfaceTransaction&) = delete;
6569

66-
explicit SurfaceTransaction(ASurfaceTransaction* transaction);
70+
//----------------------------------------------------------------------------
71+
/// @brief Wraps a transaction borrowed from Java.
72+
///
73+
/// @param[in] transaction The borrowed transaction.
74+
/// @param[in] publish_callback Invoked from `Apply` once all native writes
75+
/// into the transaction have completed. This
76+
/// is the point at which it is safe for Java to
77+
/// merge, apply, or close the transaction.
78+
///
79+
SurfaceTransaction(ASurfaceTransaction* transaction,
80+
std::function<void()> publish_callback);
6781

6882
bool IsValid() const;
6983

‎engine/src/flutter/impeller/toolkit/android/toolkit_android_unittests.cc‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,33 @@ TEST(ToolkitAndroidTest, CanApplySurfaceTransaction) {
9191
event.Wait();
9292
}
9393

94+
TEST(ToolkitAndroidTest,
95+
BorrowedSurfaceTransactionInvokesPublishCallbackAndFiresOnComplete) {
96+
if (!SurfaceTransaction::IsAvailableOnPlatform()) {
97+
GTEST_SKIP() << "Surface controls are not supported on this platform.";
98+
}
99+
ASurfaceTransaction* raw_tx = GetProcTable().ASurfaceTransaction_create();
100+
ASSERT_NE(raw_tx, nullptr);
101+
102+
bool published = false;
103+
SurfaceTransaction borrowed_tx(raw_tx, [&]() {
104+
// Native wrapper must release its reference before handing the transaction
105+
// back to Java for application/closing.
106+
EXPECT_FALSE(borrowed_tx.IsValid());
107+
published = true;
108+
GetProcTable().ASurfaceTransaction_apply(raw_tx);
109+
GetProcTable().ASurfaceTransaction_delete(raw_tx);
110+
});
111+
ASSERT_TRUE(borrowed_tx.IsValid());
112+
EXPECT_FALSE(published);
113+
114+
fml::AutoResetWaitableEvent on_complete;
115+
ASSERT_TRUE(
116+
borrowed_tx.Apply([&on_complete](auto) { on_complete.Signal(); }));
117+
EXPECT_TRUE(published);
118+
on_complete.Wait();
119+
}
120+
94121
TEST(ToolkitAndroidTest, SurfacControlsAreAvailable) {
95122
if (!SurfaceControl::IsAvailableOnPlatform()) {
96123
GTEST_SKIP() << "Surface controls are not supported on this platform.";

‎engine/src/flutter/lib/ui/painting/image_decoder_impeller.cc‎

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ bool IsWideGamut(const SkColorSpace* color_space) {
7676
return area > kSrgbGamutArea;
7777
}
7878

79+
bool IsHdr(const SkColorSpace* color_space) {
80+
if (!color_space || color_space->isSRGB()) {
81+
return false;
82+
}
83+
skcms_TransferFunction fn;
84+
color_space->transferFn(&fn);
85+
skcms_TFType type = skcms_TransferFunction_getType(&fn);
86+
return type == skcms_TFType_PQ || type == skcms_TFType_PQish ||
87+
type == skcms_TFType_HLG || type == skcms_TFType_HLGish ||
88+
type == skcms_TFType_HLGinvish;
89+
}
90+
7991
absl::StatusOr<ImageDecoderImpeller::ImageInfo> ToImageInfo(
8092
const SkImageInfo& sk_image_format) {
8193
const std::optional<impeller::PixelFormat> pixel_format =
@@ -121,8 +133,10 @@ absl::StatusOr<SkImageInfo> CreateImageInfo(
121133
const SkISize& decode_size,
122134
bool supports_wide_gamut,
123135
ImageDecoder::TargetPixelFormat target_format) {
124-
const bool is_wide_gamut =
125-
supports_wide_gamut ? IsWideGamut(base_image_info.colorSpace()) : false;
136+
const SkColorSpace* color_space = base_image_info.colorSpace();
137+
const bool is_hdr = IsHdr(color_space);
138+
const bool is_extended_range =
139+
supports_wide_gamut && (IsWideGamut(color_space) || is_hdr);
126140
SkAlphaType alpha_type =
127141
ChooseCompatibleAlphaType(base_image_info.alphaType());
128142
if (target_format != ImageDecoder::TargetPixelFormat::kDontCare) {
@@ -135,12 +149,13 @@ absl::StatusOr<SkImageInfo> CreateImageInfo(
135149
.makeColorType(target_skia_color_type.value())
136150
.makeAlphaType(alpha_type)
137151
.makeColorSpace(SkColorSpace::MakeSRGB());
138-
} else if (is_wide_gamut) {
139-
// Use 10-bit for opaque images (less memory: 4 bytes vs 8 bytes per pixel).
140-
// Use F16 for images with alpha channel.
141-
SkColorType color_type = alpha_type == SkAlphaType::kOpaque_SkAlphaType
142-
? kBGR_101010x_XR_SkColorType
143-
: kRGBA_F16_SkColorType;
152+
} else if (is_extended_range) {
153+
// Use 10-bit for opaque SDR images (less memory: 4 bytes vs 8 bytes per
154+
// pixel). Use F16 for HDR images or images with alpha channel.
155+
SkColorType color_type =
156+
(!is_hdr && alpha_type == SkAlphaType::kOpaque_SkAlphaType)
157+
? kBGR_101010x_XR_SkColorType
158+
: kRGBA_F16_SkColorType;
144159
return base_image_info.makeWH(decode_size.width(), decode_size.height())
145160
.makeColorType(color_type)
146161
.makeAlphaType(alpha_type)

‎engine/src/flutter/lib/ui/painting/image_decoder_no_gl_unittests.cc‎

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,5 +447,82 @@ TEST(ImageDecoderNoGLTest, ImpellerUnmultipliedAlphaPng) {
447447
#endif // IMPELLER_SUPPORTS_RENDERING
448448
}
449449

450+
#if IMPELLER_SUPPORTS_RENDERING
451+
void ExpectDecodedFormat(sk_sp<SkColorSpace> color_space,
452+
bool supports_wide_gamut,
453+
impeller::PixelFormat expected_format) {
454+
uint8_t pixel_data[] = {255, 255, 255, 255};
455+
sk_sp<SkData> sk_data = SkData::MakeWithCopy(pixel_data, sizeof(pixel_data));
456+
auto immutable_buffer =
457+
fml::MakeRefCounted<ImmutableBuffer>(std::move(sk_data));
458+
459+
ImageDescriptor::ImageInfo image_info = {
460+
.width = 1,
461+
.height = 1,
462+
.format = ImageDescriptor::PixelFormat::kRGBA8888,
463+
.alpha_type = kOpaque_SkAlphaType,
464+
.color_space = std::move(color_space),
465+
};
466+
auto descriptor = fml::MakeRefCounted<ImageDescriptor>(
467+
immutable_buffer->data(), image_info, sizeof(pixel_data));
468+
469+
std::shared_ptr<impeller::Capabilities> capabilities =
470+
impeller::CapabilitiesBuilder()
471+
.SetSupportsTextureToTextureBlits(true)
472+
.Build();
473+
std::shared_ptr<impeller::Allocator> allocator =
474+
std::make_shared<impeller::TestImpellerAllocator>();
475+
476+
absl::StatusOr<ImageDecoderImpeller::DecompressResult> result =
477+
ImageDecoderImpeller::DecompressTexture(
478+
descriptor.get(), {.target_width = 1, .target_height = 1}, {1, 1},
479+
supports_wide_gamut, capabilities, allocator);
480+
481+
ASSERT_TRUE(result.ok());
482+
EXPECT_EQ(result->image_info.format, expected_format);
483+
}
484+
#endif // IMPELLER_SUPPORTS_RENDERING
485+
486+
TEST(ImageDecoderNoGLTest, ImpellerHdrPqImageDecodesToF16) {
487+
#if IMPELLER_SUPPORTS_RENDERING
488+
ExpectDecodedFormat(
489+
SkColorSpace::MakeRGB(SkNamedTransferFn::kPQ, SkNamedGamut::kRec2020),
490+
/*supports_wide_gamut=*/true, impeller::PixelFormat::kR16G16B16A16Float);
491+
#endif // IMPELLER_SUPPORTS_RENDERING
492+
}
493+
494+
TEST(ImageDecoderNoGLTest, ImpellerHdrHlgImageDecodesToF16) {
495+
#if IMPELLER_SUPPORTS_RENDERING
496+
ExpectDecodedFormat(
497+
SkColorSpace::MakeRGB(SkNamedTransferFn::kHLG, SkNamedGamut::kRec2020),
498+
/*supports_wide_gamut=*/true, impeller::PixelFormat::kR16G16B16A16Float);
499+
#endif // IMPELLER_SUPPORTS_RENDERING
500+
}
501+
502+
TEST(ImageDecoderNoGLTest, ImpellerOpaqueSdrWideGamutDecodesToB10XR) {
503+
#if IMPELLER_SUPPORTS_RENDERING
504+
ExpectDecodedFormat(
505+
SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB, SkNamedGamut::kDisplayP3),
506+
/*supports_wide_gamut=*/true, impeller::PixelFormat::kB10G10R10XR);
507+
#endif // IMPELLER_SUPPORTS_RENDERING
508+
}
509+
510+
TEST(ImageDecoderNoGLTest, ImpellerHdrImageWithoutWideGamutDecodesToF16) {
511+
#if IMPELLER_SUPPORTS_RENDERING
512+
ExpectDecodedFormat(
513+
SkColorSpace::MakeRGB(SkNamedTransferFn::kPQ, SkNamedGamut::kSRGB),
514+
/*supports_wide_gamut=*/true, impeller::PixelFormat::kR16G16B16A16Float);
515+
#endif // IMPELLER_SUPPORTS_RENDERING
516+
}
517+
518+
TEST(ImageDecoderNoGLTest,
519+
ImpellerHdrImageWithoutWideGamutSupportDecodesToRGBA8888) {
520+
#if IMPELLER_SUPPORTS_RENDERING
521+
ExpectDecodedFormat(
522+
SkColorSpace::MakeRGB(SkNamedTransferFn::kPQ, SkNamedGamut::kRec2020),
523+
/*supports_wide_gamut=*/false, impeller::PixelFormat::kR8G8B8A8UNormInt);
524+
#endif // IMPELLER_SUPPORTS_RENDERING
525+
}
526+
450527
} // namespace testing
451528
} // namespace flutter

‎engine/src/flutter/lib/web_ui/lib/src/engine/semantics/focusable.dart‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ class Focusable extends SemanticBehavior {
4747
/// not take the focus. The return value can be used to decide whether to stop
4848
/// searching for a node that should take focus.
4949
bool focusAsRouteDefault() {
50+
if (!semanticsObject.isFocusable) {
51+
return false;
52+
}
5053
_focusManager._lastEvent = AccessibilityFocusManagerEvent.requestedFocus;
5154
owner.element.focusWithoutScroll();
5255
return true;

‎engine/src/flutter/lib/web_ui/lib/src/engine/semantics/label_and_value.dart‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,18 @@ final class DomTextRepresentation extends LabelRepresentationBehavior {
162162
final DomText domText = domDocument.createTextNode(label);
163163
_domText = domText;
164164
semanticsObject.element.appendChild(domText);
165+
166+
// Clip the text to the node's rect. Text that overflows, such as a long
167+
// label wrapping inside a small button, is still hit-tested by the browser
168+
// and would steal taps from nodes underneath it. This is safe because DOM
169+
// text is only used by nodes without children.
170+
semanticsObject.element.style.overflow = 'hidden';
165171
}
166172

167173
@override
168174
void cleanUp() {
169175
_domText?.remove();
176+
semanticsObject.element.style.overflow = 'visible';
170177
}
171178

172179
// DOM text does not introduce extra DOM elements, so focus should go to the

0 commit comments

Comments
 (0)