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

Commit 2d8982f

Browse files
committed
fuchsia: Clamp compositor surface size
1 parent cfdcfca commit 2d8982f

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

shell/platform/fuchsia/flutter/compositor_context.cc

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include "compositor_context.h"
66

7+
#include <algorithm>
78
#include <vector>
89

910
#include "flutter/flow/layers/layer_tree.h"
@@ -65,12 +66,20 @@ class ScopedFrame final : public flutter::CompositorContext::ScopedFrame {
6566
// Image ops for the frame's paint tasks, then Present.
6667
TRACE_EVENT0("flutter", "SessionPresent");
6768
frame_paint_tasks = scene_update_context_->GetPaintTasks();
69+
70+
const SkISize& frame_size = layer_tree.frame_size();
6871
for (auto& task : frame_paint_tasks) {
69-
SkISize physical_size =
70-
SkISize::Make(layer_tree.device_pixel_ratio() * task.scale_x *
71-
task.paint_bounds.width(),
72-
layer_tree.device_pixel_ratio() * task.scale_y *
73-
task.paint_bounds.height());
72+
// Clamp the logical size to the logical frame size in order to avoid
73+
// huge surfaces.
74+
const SkISize logical_size = SkISize::Make(
75+
std::clamp(task.scale_x * task.paint_bounds.width(), 0.f,
76+
static_cast<float>(frame_size.width())),
77+
std::clamp(task.scale_y * task.paint_bounds.height(), 0.f,
78+
static_cast<float>(frame_size.height())));
79+
80+
SkISize physical_size = SkISize::Make(
81+
layer_tree.device_pixel_ratio() * logical_size.width(),
82+
layer_tree.device_pixel_ratio() * logical_size.height());
7483
if (physical_size.width() == 0 || physical_size.height() == 0) {
7584
frame_surfaces.emplace_back(nullptr);
7685
continue;

0 commit comments

Comments
 (0)