|
4 | 4 |
|
5 | 5 | #include "compositor_context.h" |
6 | 6 |
|
| 7 | +#include <algorithm> |
7 | 8 | #include <vector> |
8 | 9 |
|
9 | 10 | #include "flutter/flow/layers/layer_tree.h" |
@@ -65,12 +66,20 @@ class ScopedFrame final : public flutter::CompositorContext::ScopedFrame { |
65 | 66 | // Image ops for the frame's paint tasks, then Present. |
66 | 67 | TRACE_EVENT0("flutter", "SessionPresent"); |
67 | 68 | frame_paint_tasks = scene_update_context_->GetPaintTasks(); |
| 69 | + |
| 70 | + const SkISize& frame_size = layer_tree.frame_size(); |
68 | 71 | 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()); |
74 | 83 | if (physical_size.width() == 0 || physical_size.height() == 0) { |
75 | 84 | frame_surfaces.emplace_back(nullptr); |
76 | 85 | continue; |
|
0 commit comments