@@ -1367,7 +1367,7 @@ TEST_F(DisplayListTest, SaveLayerFalseWithSrcBlendSupportsGroupOpacity) {
1367
1367
DisplayListBuilder builder;
1368
1368
// This empty draw rect will not actually be inserted into the stream,
1369
1369
// but the Src blend mode will be synchronized as an attribute. The
1370
- // saveLayer following it should not use that attribute to base its
1370
+ // SaveLayer following it should not use that attribute to base its
1371
1371
// decisions about group opacity and the draw rect after that comes
1372
1372
// with its own compatible blend mode.
1373
1373
builder.DrawRect (SkRect{0 , 0 , 0 , 0 },
@@ -1416,7 +1416,7 @@ TEST_F(DisplayListTest, SaveLayerBoundsSnapshotsImageFilter) {
1416
1416
DlPaint save_paint;
1417
1417
builder.SaveLayer (nullptr , &save_paint);
1418
1418
builder.DrawRect (SkRect{50 , 50 , 100 , 100 }, DlPaint ());
1419
- // This image filter should be ignored since it was not set before saveLayer
1419
+ // This image filter should be ignored since it was not set before SaveLayer
1420
1420
// And the rect drawn with it will not contribute any more area to the bounds
1421
1421
DlPaint draw_paint;
1422
1422
draw_paint.setImageFilter (&kTestBlurImageFilter1 );
@@ -2510,7 +2510,7 @@ TEST_F(DisplayListTest, RTreeOfSaveLayerFilterScene) {
2510
2510
builder.DrawRect (SkRect{10 , 10 , 20 , 20 }, default_paint);
2511
2511
builder.SaveLayer (nullptr , &filter_paint);
2512
2512
// the following rectangle will be expanded to 50,50,60,60
2513
- // by the saveLayer filter during the restore operation
2513
+ // by the SaveLayer filter during the restore operation
2514
2514
builder.DrawRect (SkRect{53 , 53 , 57 , 57 }, default_paint);
2515
2515
builder.Restore ();
2516
2516
auto display_list = builder.Build ();
@@ -3272,7 +3272,7 @@ TEST_F(DisplayListTest, RTreeOfClippedSaveLayerFilterScene) {
3272
3272
builder.ClipRect (SkRect{50 , 50 , 60 , 60 }, ClipOp::kIntersect , false );
3273
3273
builder.SaveLayer (nullptr , &filter_paint);
3274
3274
// the following rectangle will be expanded to 23,23,87,87
3275
- // by the saveLayer filter during the restore operation
3275
+ // by the SaveLayer filter during the restore operation
3276
3276
// but it will then be clipped to 50,50,60,60
3277
3277
builder.DrawRect (SkRect{53 , 53 , 57 , 57 }, default_paint);
3278
3278
builder.Restore ();
@@ -3862,7 +3862,7 @@ TEST_F(DisplayListTest, TransformResetSaveLayerBoundsComputationOfSimpleRect) {
3862
3862
builder.SaveLayer (nullptr , nullptr );
3863
3863
builder.TransformReset ();
3864
3864
builder.Scale (20 .0f , 20 .0f );
3865
- // Net local transform for saveLayer is Scale(2, 2)
3865
+ // Net local transform for SaveLayer is Scale(2, 2)
3866
3866
{ //
3867
3867
builder.DrawRect (rect, DlPaint ());
3868
3868
}
@@ -4451,7 +4451,7 @@ TEST_F(DisplayListTest, MaxBlendModeInsideComplexSaveLayers) {
4451
4451
builder.Restore ();
4452
4452
4453
4453
// Double check that kModulate is the max blend mode for the first
4454
- // saveLayer operations
4454
+ // SaveLayer operations
4455
4455
auto expect = std::max (DlBlendMode::kModulate , DlBlendMode::kSrc );
4456
4456
ASSERT_EQ (expect, DlBlendMode::kModulate );
4457
4457
@@ -4487,8 +4487,8 @@ TEST_F(DisplayListTest, BackdropDetectionSimpleSaveLayer) {
4487
4487
auto dl = builder.Build ();
4488
4488
4489
4489
EXPECT_TRUE (dl->root_has_backdrop_filter ());
4490
- // The saveLayer itself, though, does not have the contains backdrop
4491
- // flag set because its content does not contain a saveLayer with backdrop
4490
+ // The SaveLayer itself, though, does not have the contains backdrop
4491
+ // flag set because its content does not contain a SaveLayer with backdrop
4492
4492
SAVE_LAYER_EXPECTOR (expector);
4493
4493
expector.addExpectation (
4494
4494
SaveLayerOptions::kNoAttributes .with_can_distribute_opacity ());
@@ -5948,5 +5948,132 @@ TEST_F(DisplayListTest, RecordSingleLargeDisplayListOperation) {
5948
5948
EXPECT_TRUE (!!builder.Build ());
5949
5949
}
5950
5950
5951
+ TEST_F (DisplayListTest, DisplayListDetectsRuntimeEffect) {
5952
+ const auto runtime_effect = DlRuntimeEffect::MakeSkia (
5953
+ SkRuntimeEffect::MakeForShader (
5954
+ SkString (" vec4 main(vec2 p) { return vec4(0); }" ))
5955
+ .effect );
5956
+ auto color_source = DlColorSource::MakeRuntimeEffect (
5957
+ runtime_effect, {}, std::make_shared<std::vector<uint8_t >>());
5958
+ auto image_filter = DlImageFilter::MakeRuntimeEffect (
5959
+ runtime_effect, {}, std::make_shared<std::vector<uint8_t >>());
5960
+
5961
+ {
5962
+ // Default - no runtime effects, supports group opacity
5963
+ DisplayListBuilder builder;
5964
+ DlPaint paint;
5965
+
5966
+ builder.DrawRect (DlRect::MakeLTRB (0 , 0 , 50 , 50 ), paint);
5967
+ EXPECT_TRUE (builder.Build ()->can_apply_group_opacity ());
5968
+ }
5969
+
5970
+ {
5971
+ // Draw with RTE color source does not support group opacity
5972
+ DisplayListBuilder builder;
5973
+ DlPaint paint;
5974
+
5975
+ paint.setColorSource (color_source);
5976
+ builder.DrawRect (DlRect::MakeLTRB (0 , 0 , 50 , 50 ), paint);
5977
+
5978
+ EXPECT_FALSE (builder.Build ()->can_apply_group_opacity ());
5979
+ }
5980
+
5981
+ {
5982
+ // Draw with RTE image filter does not support group opacity
5983
+ DisplayListBuilder builder;
5984
+ DlPaint paint;
5985
+
5986
+ paint.setImageFilter (image_filter);
5987
+ builder.DrawRect (DlRect::MakeLTRB (0 , 0 , 50 , 50 ), paint);
5988
+
5989
+ EXPECT_FALSE (builder.Build ()->can_apply_group_opacity ());
5990
+ }
5991
+
5992
+ {
5993
+ // Draw with RTE color source inside SaveLayer does not support group
5994
+ // opacity on the SaveLayer, but does support it on the DisplayList
5995
+ DisplayListBuilder builder;
5996
+ DlPaint paint;
5997
+
5998
+ builder.SaveLayer (nullptr , nullptr );
5999
+ paint.setColorSource (color_source);
6000
+ builder.DrawRect (DlRect::MakeLTRB (0 , 0 , 50 , 50 ), paint);
6001
+ builder.Restore ();
6002
+
6003
+ auto display_list = builder.Build ();
6004
+ EXPECT_TRUE (display_list->can_apply_group_opacity ());
6005
+
6006
+ SAVE_LAYER_EXPECTOR (expector);
6007
+ expector.addExpectation ([](const SaveLayerOptions& options) {
6008
+ return !options.can_distribute_opacity ();
6009
+ });
6010
+ display_list->Dispatch (expector);
6011
+ }
6012
+
6013
+ {
6014
+ // Draw with RTE image filter inside SaveLayer does not support group
6015
+ // opacity on the SaveLayer, but does support it on the DisplayList
6016
+ DisplayListBuilder builder;
6017
+ DlPaint paint;
6018
+
6019
+ builder.SaveLayer (nullptr , nullptr );
6020
+ paint.setImageFilter (image_filter);
6021
+ builder.DrawRect (DlRect::MakeLTRB (0 , 0 , 50 , 50 ), paint);
6022
+ builder.Restore ();
6023
+
6024
+ auto display_list = builder.Build ();
6025
+ EXPECT_TRUE (display_list->can_apply_group_opacity ());
6026
+
6027
+ SAVE_LAYER_EXPECTOR (expector);
6028
+ expector.addExpectation ([](const SaveLayerOptions& options) {
6029
+ return !options.can_distribute_opacity ();
6030
+ });
6031
+ display_list->Dispatch (expector);
6032
+ }
6033
+
6034
+ {
6035
+ // Draw with RTE color source inside nested saveLayers does not support
6036
+ // group opacity on the inner SaveLayer, but does support it on the
6037
+ // outer SaveLayer and the DisplayList
6038
+ DisplayListBuilder builder;
6039
+ DlPaint paint;
6040
+
6041
+ builder.SaveLayer (nullptr , nullptr );
6042
+
6043
+ builder.SaveLayer (nullptr , nullptr );
6044
+ paint.setColorSource (color_source);
6045
+ builder.DrawRect (DlRect::MakeLTRB (0 , 0 , 50 , 50 ), paint);
6046
+ paint.setColorSource (nullptr );
6047
+ builder.Restore ();
6048
+
6049
+ builder.SaveLayer (nullptr , nullptr );
6050
+ paint.setImageFilter (image_filter);
6051
+ // Make sure these DrawRects are non-overlapping otherwise the outer
6052
+ // SaveLayer and DisplayList will be incompatible due to overlaps
6053
+ builder.DrawRect (DlRect::MakeLTRB (60 , 60 , 100 , 100 ), paint);
6054
+ paint.setImageFilter (nullptr );
6055
+ builder.Restore ();
6056
+
6057
+ builder.Restore ();
6058
+ auto display_list = builder.Build ();
6059
+ EXPECT_TRUE (display_list->can_apply_group_opacity ());
6060
+
6061
+ SAVE_LAYER_EXPECTOR (expector);
6062
+ expector.addExpectation ([](const SaveLayerOptions& options) {
6063
+ // outer SaveLayer supports group opacity
6064
+ return options.can_distribute_opacity ();
6065
+ });
6066
+ expector.addExpectation ([](const SaveLayerOptions& options) {
6067
+ // first inner SaveLayer does not support group opacity
6068
+ return !options.can_distribute_opacity ();
6069
+ });
6070
+ expector.addExpectation ([](const SaveLayerOptions& options) {
6071
+ // second inner SaveLayer does not support group opacity
6072
+ return !options.can_distribute_opacity ();
6073
+ });
6074
+ display_list->Dispatch (expector);
6075
+ }
6076
+ }
6077
+
5951
6078
} // namespace testing
5952
6079
} // namespace flutter
0 commit comments