Fix PerformanceOverlay do not resize (flutter/engine#33872)

This commit is contained in:
Bruno Leroux
2022-06-07 19:13:06 +02:00
committed by GitHub
parent ef8d0d07ca
commit 69a99351f2
2 changed files with 33 additions and 0 deletions

View File

@@ -86,6 +86,14 @@ fml::TimeDelta Stopwatch::AverageDelta() const {
// Initialize the SkSurface for drawing into. Draws the base background and any
// timing data from before the initial Visualize() call.
void Stopwatch::InitVisualizeSurface(const SkRect& rect) const {
// Mark as dirty if the size has changed.
if (visualize_cache_surface_) {
if (rect.width() != visualize_cache_surface_->width() ||
rect.height() != visualize_cache_surface_->height()) {
cache_dirty_ = true;
};
}
if (!cache_dirty_) {
return;
}

View File

@@ -191,6 +191,31 @@ TEST_F(PerformanceOverlayLayerTest, SimpleRasterizerStatistics) {
text_position}}}));
}
TEST_F(PerformanceOverlayLayerTest, MarkAsDirtyWhenResized) {
// Regression test for https://github.com/flutter/flutter/issues/54188
// Create a PerformanceOverlayLayer.
const uint64_t overlay_opts = kVisualizeRasterizerStatistics;
auto layer = std::make_shared<PerformanceOverlayLayer>(overlay_opts);
layer->set_paint_bounds(SkRect::MakeLTRB(0.0f, 0.0f, 48.0f, 48.0f));
layer->Preroll(preroll_context(), SkMatrix());
layer->Paint(paint_context());
auto data = mock_canvas().draw_calls().front().data;
auto imageData = std::get<MockCanvas::DrawImageDataNoPaint>(data);
auto first_draw_width = imageData.image->width();
// Create a second PerformanceOverlayLayer with different bounds.
layer = std::make_shared<PerformanceOverlayLayer>(overlay_opts);
layer->set_paint_bounds(SkRect::MakeLTRB(0.0f, 0.0f, 64.0f, 64.0f));
layer->Preroll(preroll_context(), SkMatrix());
layer->Paint(paint_context());
data = mock_canvas().draw_calls().back().data;
imageData = std::get<MockCanvas::DrawImageDataNoPaint>(data);
auto refreshed_draw_width = imageData.image->width();
EXPECT_NE(first_draw_width, refreshed_draw_width);
}
TEST(PerformanceOverlayLayerDefault, Gold) {
TestPerformanceOverlayLayerGold(60);
}