165 {
166 TRACE_EVENT0(
"flutter",
"VulkanSurfacePool::AgeAndCollectOldBuffers");
167
168
169 size_t size_before = available_surfaces_.size();
170 available_surfaces_.erase(
171 std::remove_if(available_surfaces_.begin(), available_surfaces_.end(),
173 return !surface->IsValid() ||
174 surface->AdvanceAndGetAge() >= kMaxSurfaceAge;
175 }),
176 available_surfaces_.end());
177 TRACE_EVENT1(
"flutter",
"AgeAndCollect",
"aged surfaces",
178 (size_before - available_surfaces_.size()));
179
180
181
182 auto surface_to_remove_it = std::find_if(
183 available_surfaces_.begin(), available_surfaces_.end(),
185 return surface->IsOversized() && surface->HasStableSizeHistory();
186 });
187
188
189 if (surface_to_remove_it != available_surfaces_.end()) {
191 auto size = (*surface_to_remove_it)->GetSize();
192 available_surfaces_.erase(surface_to_remove_it);
195 available_surfaces_.push_back(std::move(
new_surface));
196 } else {
198 << "VulkanSurfaceProducer: Failed to create a new shrunk surface";
199 }
200 }
201
202 TraceStats();
203}
std::unique_ptr< VulkanSurface > CreateSurface(const SkISize &size)
static sk_sp< SkSurface > new_surface(int width, int height)
#define TRACE_EVENT0(category_group, name)
#define TRACE_EVENT_INSTANT0(category_group, name)
#define TRACE_EVENT1(category_group, name, arg1_name, arg1_val)