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

Commit 777583f

Browse files
authored
uncomment a DL raster cache unittest enhancement now that it is feasible (#39845)
uncomment a DL raster cache unittest enhancement now that it is feasible
1 parent 527a8bd commit 777583f

File tree

1 file changed

+36
-43
lines changed

1 file changed

+36
-43
lines changed

flow/layers/display_list_layer_unittests.cc

Lines changed: 36 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -262,49 +262,42 @@ TEST_F(DisplayListLayerTest, CachedIncompatibleDisplayListOpacityInheritance) {
262262
opacity_layer->Preroll(context);
263263
EXPECT_TRUE(opacity_layer->children_can_accept_opacity());
264264

265-
// The following would be a great test of the painting of the above
266-
// setup, but for the fact that the raster cache stores raw pointers
267-
// to sk_sp<SkImage> and the canvas recorder then wraps each of those
268-
// in a unique DlImage - which means the DisplayList objects will not
269-
// compare with the Equals method since the addresses of the two
270-
// DlImage objects will not be equal even if they point to the same
271-
// SkImage on each frame.
272-
// See https://github.com/flutter/flutter/issues/102331
273-
// auto display_list_bounds = picture1_bounds;
274-
// display_list_bounds.join(picture2_bounds);
275-
// auto save_layer_bounds =
276-
// display_list_bounds.makeOffset(layer_offset.fX, layer_offset.fY);
277-
// save_layer_bounds.roundOut(&save_layer_bounds);
278-
// auto opacity_integral_matrix =
279-
// RasterCacheUtil::GetIntegralTransCTM(SkMatrix::Translate(opacity_offset));
280-
// SkMatrix layer_offset_matrix = opacity_integral_matrix;
281-
// layer_offset_matrix.postTranslate(layer_offset.fX, layer_offset.fY);
282-
// auto layer_offset_integral_matrix =
283-
// RasterCacheUtil::GetIntegralTransCTM(layer_offset_matrix);
284-
// // Using a recorder instead of a DisplayListBuilder so we can hand it
285-
// // off to the RasterCache::Draw() method
286-
// DisplayListCanvasRecorder recorder(SkRect::MakeWH(1000, 1000));
287-
// /* opacity_layer::Paint() */ {
288-
// recorder.save();
289-
// {
290-
// recorder.translate(opacity_offset.fX, opacity_offset.fY);
291-
// /* display_list_layer::Paint() */ {
292-
// recorder.save();
293-
// {
294-
// recorder.translate(layer_offset.fX, layer_offset.fY);
295-
// SkPaint p;
296-
// p.setAlpha(opacity_alpha);
297-
// context->raster_cache->Draw(*display_list, recorder, &p);
298-
// }
299-
// recorder.restore();
300-
// }
301-
// }
302-
// recorder.restore();
303-
// }
304-
305-
// opacity_layer->Paint(display_list_paint_context());
306-
// EXPECT_TRUE(
307-
// DisplayListsEQ_Verbose(recorder.Build(), this->display_list()));
265+
auto display_list_bounds = picture1_bounds;
266+
display_list_bounds.join(picture2_bounds);
267+
auto save_layer_bounds =
268+
display_list_bounds.makeOffset(layer_offset.fX, layer_offset.fY);
269+
save_layer_bounds.roundOut(&save_layer_bounds);
270+
auto opacity_integral_matrix =
271+
RasterCacheUtil::GetIntegralTransCTM(SkMatrix::Translate(opacity_offset));
272+
SkMatrix layer_offset_matrix = opacity_integral_matrix;
273+
layer_offset_matrix.postTranslate(layer_offset.fX, layer_offset.fY);
274+
auto layer_offset_integral_matrix =
275+
RasterCacheUtil::GetIntegralTransCTM(layer_offset_matrix);
276+
DisplayListBuilder expected(SkRect::MakeWH(1000, 1000));
277+
/* opacity_layer::Paint() */ {
278+
expected.Save();
279+
{
280+
expected.Translate(opacity_offset.fX, opacity_offset.fY);
281+
expected.TransformReset();
282+
expected.Transform(opacity_integral_matrix);
283+
/* display_list_layer::Paint() */ {
284+
expected.Save();
285+
{
286+
expected.Translate(layer_offset.fX, layer_offset.fY);
287+
expected.TransformReset();
288+
expected.Transform(layer_offset_integral_matrix);
289+
context->raster_cache->Draw(display_list_layer->caching_key_id(),
290+
expected,
291+
&DlPaint().setAlpha(opacity_alpha));
292+
}
293+
expected.Restore();
294+
}
295+
}
296+
expected.Restore();
297+
}
298+
299+
opacity_layer->Paint(display_list_paint_context());
300+
EXPECT_TRUE(DisplayListsEQ_Verbose(expected.Build(), this->display_list()));
308301
}
309302

310303
using DisplayListLayerDiffTest = DiffContextTest;

0 commit comments

Comments
 (0)