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

Commit e3fd50e

Browse files
authored
Merge branch 'main' into deprecatedMember
2 parents 983766f + b1dbb43 commit e3fd50e

File tree

10 files changed

+125
-32
lines changed

10 files changed

+125
-32
lines changed

common/config.gni

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ declare_args() {
2828
#TODO(cyanglaz): Remove above comment about test flag when the entire iOS embedder supports app extension
2929
#https://github.com/flutter/flutter/issues/124289
3030
darwin_extension_safe = false
31+
32+
# Whether binary size optimizations with the assumption that Impeller is the
33+
# only supported rendering engine are enabled.
34+
#
35+
# See [go/slimpeller-dashboard](https://github.com/orgs/flutter/projects/21)
36+
# for details.
37+
slimpeller = false
3138
}
3239

3340
# feature_defines_list ---------------------------------------------------------
@@ -62,6 +69,10 @@ if (flutter_runtime_mode == "debug") {
6269
feature_defines_list += [ "FLUTTER_RUNTIME_MODE=0" ]
6370
}
6471

72+
if (slimpeller) {
73+
feature_defines_list += [ "SLIMPELLER=1" ]
74+
}
75+
6576
if (is_ios || is_mac) {
6677
flutter_cflags_objc = [
6778
"-Werror=overriding-method-mismatch",

impeller/aiks/aiks_unittests.cc

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3073,6 +3073,42 @@ TEST_P(AiksTest, MipmapGenerationWorksCorrectly) {
30733073
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
30743074
}
30753075

3076+
TEST_P(AiksTest, DrawAtlasPlusWideGamut) {
3077+
if (GetParam() != PlaygroundBackend::kMetal) {
3078+
GTEST_SKIP_("This backend doesn't yet support wide gamut.");
3079+
}
3080+
3081+
EXPECT_EQ(GetContext()->GetCapabilities()->GetDefaultColorFormat(),
3082+
PixelFormat::kR16G16B16A16Float);
3083+
3084+
// Draws the image as four squares stiched together.
3085+
auto atlas =
3086+
std::make_shared<Image>(CreateTextureForFixture("bay_bridge.jpg"));
3087+
auto size = atlas->GetSize();
3088+
// Divide image into four quadrants.
3089+
Scalar half_width = size.width / 2;
3090+
Scalar half_height = size.height / 2;
3091+
std::vector<Rect> texture_coordinates = {
3092+
Rect::MakeLTRB(0, 0, half_width, half_height),
3093+
Rect::MakeLTRB(half_width, 0, size.width, half_height),
3094+
Rect::MakeLTRB(0, half_height, half_width, size.height),
3095+
Rect::MakeLTRB(half_width, half_height, size.width, size.height)};
3096+
// Position quadrants adjacent to eachother.
3097+
std::vector<Matrix> transforms = {
3098+
Matrix::MakeTranslation({0, 0, 0}),
3099+
Matrix::MakeTranslation({half_width, 0, 0}),
3100+
Matrix::MakeTranslation({0, half_height, 0}),
3101+
Matrix::MakeTranslation({half_width, half_height, 0})};
3102+
std::vector<Color> colors = {Color::Red(), Color::Green(), Color::Blue(),
3103+
Color::Yellow()};
3104+
3105+
Canvas canvas;
3106+
canvas.DrawAtlas(atlas, transforms, texture_coordinates, colors,
3107+
BlendMode::kPlus, {}, std::nullopt, {});
3108+
3109+
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
3110+
}
3111+
30763112
} // namespace testing
30773113
} // namespace impeller
30783114

impeller/entity/shaders/blending/porter_duff_blend.frag

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ f16vec4 Sample(f16sampler2D texture_sampler, vec2 texture_coords) {
3636
return IPHalfSampleDecal(texture_sampler, texture_coords);
3737
}
3838

39+
float16_t ClampAlpha(float16_t alpha) {
40+
float16_t min = 0.0hf;
41+
float16_t max = 1.0hf;
42+
return clamp(alpha, min, max);
43+
}
44+
3945
void main() {
4046
f16vec4 dst =
4147
texture(texture_sampler_dst, v_texture_coords) * frag_info.input_alpha;
@@ -45,4 +51,9 @@ void main() {
4551
dst * (frag_info.dst_coeff + src.a * frag_info.dst_coeff_src_alpha +
4652
src * frag_info.dst_coeff_src_color);
4753
frag_color *= frag_info.output_alpha;
54+
// This currently needs a clamp so that floating point textures blend
55+
// correctly in wide gamut. Remove if we switch to a fixed point extended
56+
// range format.
57+
// See https://github.com/flutter/flutter/issues/145933 .
58+
frag_color.a = ClampAlpha(frag_color.a);
4859
}

impeller/tools/malioc.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8434,8 +8434,8 @@
84348434
"varying"
84358435
],
84368436
"longest_path_cycles": [
8437-
0.21875,
8438-
0.21875,
8437+
0.234375,
8438+
0.234375,
84398439
0.0,
84408440
0.0,
84418441
0.0,
@@ -8455,8 +8455,8 @@
84558455
"varying"
84568456
],
84578457
"shortest_path_cycles": [
8458-
0.21875,
8459-
0.21875,
8458+
0.234375,
8459+
0.234375,
84608460
0.0,
84618461
0.0,
84628462
0.0,
@@ -8467,8 +8467,8 @@
84678467
"varying"
84688468
],
84698469
"total_cycles": [
8470-
0.21875,
8471-
0.21875,
8470+
0.234375,
8471+
0.234375,
84728472
0.0,
84738473
0.0,
84748474
0.0,

lib/web_ui/lib/src/engine/skwasm/skwasm_impl/paragraph.dart

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ class SkwasmLineMetrics extends SkwasmObjectWrapper<RawLineMetrics> implements u
7777

7878
@override
7979
int get lineNumber => lineMetricsGetLineNumber(handle);
80+
81+
int get startIndex => lineMetricsGetStartIndex(handle);
82+
int get endIndex => lineMetricsGetEndIndex(handle);
8083
}
8184

8285
class SkwasmParagraph extends SkwasmObjectWrapper<RawParagraph> implements ui.Paragraph {
@@ -243,15 +246,13 @@ class SkwasmParagraph extends SkwasmObjectWrapper<RawParagraph> implements ui.Pa
243246

244247
@override
245248
ui.TextRange getLineBoundary(ui.TextPosition position) {
246-
final int lineNumber = paragraphGetLineNumberAt(handle, position.offset);
247-
final LineMetricsHandle metricsHandle =
248-
paragraphGetLineMetricsAtIndex(handle, lineNumber);
249-
final ui.TextRange range = ui.TextRange(
250-
start: lineMetricsGetStartIndex(metricsHandle),
251-
end: lineMetricsGetEndIndex(metricsHandle),
252-
);
253-
lineMetricsDispose(metricsHandle);
254-
return range;
249+
final int offset = position.offset;
250+
for (final SkwasmLineMetrics metrics in computeLineMetrics()) {
251+
if (offset >= metrics.startIndex && offset <= metrics.endIndex) {
252+
return ui.TextRange(start: metrics.startIndex, end: metrics.endIndex);
253+
}
254+
}
255+
return ui.TextRange.empty;
255256
}
256257

257258
@override

lib/web_ui/test/ui/paragraph_builder_test.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,19 @@ Future<void> testMain() async {
5959
expect(upstreamWordBoundary, const TextRange(start: 0, end: 5));
6060
});
6161

62+
test('getLineBoundary at the last character position gives correct results', () {
63+
final ParagraphBuilder builder = ParagraphBuilder(ParagraphStyle());
64+
builder.addText('hello world');
65+
66+
final Paragraph paragraph = builder.build();
67+
paragraph.layout(const ParagraphConstraints(width: double.infinity));
68+
69+
final TextRange lineBoundary = paragraph.getLineBoundary(const TextPosition(
70+
offset: 11,
71+
));
72+
expect(lineBoundary, const TextRange(start: 0, end: 11));
73+
});
74+
6275
test('build and layout a paragraph with an empty addText', () {
6376
final ParagraphBuilder builder = ParagraphBuilder(ParagraphStyle());
6477
builder.addText('');

testing/impeller_golden_tests_output.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ impeller_Play_AiksTest_DrawAdvancedBlendPartlyOffscreen_Vulkan.png
436436
impeller_Play_AiksTest_DrawAtlasAdvancedAndTransform_Metal.png
437437
impeller_Play_AiksTest_DrawAtlasAdvancedAndTransform_OpenGLES.png
438438
impeller_Play_AiksTest_DrawAtlasAdvancedAndTransform_Vulkan.png
439+
impeller_Play_AiksTest_DrawAtlasPlusWideGamut_Metal.png
439440
impeller_Play_AiksTest_DrawAtlasWithColorAdvancedAndTransform_Metal.png
440441
impeller_Play_AiksTest_DrawAtlasWithColorAdvancedAndTransform_OpenGLES.png
441442
impeller_Play_AiksTest_DrawAtlasWithColorAdvancedAndTransform_Vulkan.png

testing/scenario_app/android/app/src/main/java/dev/flutter/scenarios/TestActivity.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@
99
import android.os.Bundle;
1010
import android.os.Handler;
1111
import android.os.Looper;
12+
import android.view.Window;
1213
import androidx.annotation.NonNull;
1314
import androidx.annotation.Nullable;
15+
import androidx.core.view.WindowCompat;
16+
import androidx.core.view.WindowInsetsCompat;
17+
import androidx.core.view.WindowInsetsControllerCompat;
1418
import io.flutter.FlutterInjector;
1519
import io.flutter.embedding.engine.FlutterShellArgs;
1620
import io.flutter.embedding.engine.loader.FlutterLoader;
@@ -25,6 +29,7 @@ public abstract class TestActivity extends TestableFlutterActivity {
2529
@Override
2630
protected void onCreate(@Nullable Bundle savedInstanceState) {
2731
super.onCreate(savedInstanceState);
32+
hideSystemBars(getWindow());
2833
testFlutterLoaderCallbackWhenInitializedTwice();
2934
}
3035

@@ -104,4 +109,13 @@ protected void testFlutterLoaderCallbackWhenInitializedTwice() {
104109
}
105110
});
106111
}
112+
113+
private static void hideSystemBars(Window window) {
114+
final WindowInsetsControllerCompat insetController =
115+
WindowCompat.getInsetsController(window, window.getDecorView());
116+
assert insetController != null;
117+
insetController.setSystemBarsBehavior(
118+
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
119+
insetController.hide(WindowInsetsCompat.Type.systemBars());
120+
}
107121
}

testing/scenario_app/bin/run_android_tests.dart

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -298,23 +298,17 @@ Future<void> _run({
298298
});
299299

300300
await step('Configuring emulator...', () async {
301-
final List<List<String>> adbShellCommands = <List<String>> [
302-
// Try to close all OS popups in the emulator, like "System UI stopped working".
303-
<String>['am', 'broadcast', '-a', 'android.intent.action.CLOSE_SYSTEM_DIALOGS'],
304-
305-
// Don't show "this is how you exit fullscreen mode".
306-
<String>['settings', 'put', 'secure', 'immersive_mode_confirmations', 'confirmed'],
307-
308-
// Hide all system bars.
309-
<String>['settings', 'put', 'global', 'policy_control', 'immersive.full=*'],
310-
];
311-
312-
// Run all the commands.
313-
for (final List<String> command in adbShellCommands) {
314-
final int exitCode = await pm.runAndForward(<String>[adb.path, 'shell', ...command]);
315-
if (exitCode != 0) {
316-
panic(<String>['could not run command: ${command.join(' ')}']);
317-
}
301+
final int exitCode = await pm.runAndForward(<String>[
302+
adb.path,
303+
'shell',
304+
'settings',
305+
'put',
306+
'secure',
307+
'immersive_mode_confirmations',
308+
'confirmed',
309+
]);
310+
if (exitCode != 0) {
311+
panic(<String>['could not configure emulator']);
318312
}
319313
});
320314

tools/gn

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ def get_out_dir(args):
6868
if args.darwin_extension_safe:
6969
target_dir.append('extension_safe')
7070

71+
if args.slimpeller:
72+
target_dir.append('slimpeller')
73+
7174
if args.target_dir != '':
7275
target_dir = [args.target_dir]
7376

@@ -1260,6 +1263,15 @@ def parse_args(args):
12601263
help='Do not run GN. Instead configure the Impeller cmake example build.',
12611264
)
12621265

1266+
parser.add_argument(
1267+
'--slimpeller',
1268+
default=False,
1269+
action='store_true',
1270+
help='Enable optimizations that attempt to reduce binary size of the ' +
1271+
'Flutter engine by assuming only the Impeller rendering engine is supported.' +
1272+
'See [go/slimpeller-dashboard](https://github.com/orgs/flutter/projects/21) for details.'
1273+
)
1274+
12631275
# Sanitizers.
12641276
parser.add_argument('--asan', default=False, action='store_true')
12651277
parser.add_argument('--lsan', default=False, action='store_true')

0 commit comments

Comments
 (0)