| 1 | // Copyright 2013 The Flutter Authors. All rights reserved. |
|---|---|
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "flutter/flow/raster_cache_key.h" |
| 6 | #include <optional> |
| 7 | #include "flutter/flow/layers/container_layer.h" |
| 8 | #include "flutter/flow/layers/display_list_layer.h" |
| 9 | #include "flutter/flow/layers/layer.h" |
| 10 | namespace flutter { |
| 11 | |
| 12 | // |
| 13 | |
| 14 | std::optional<std::vector<RasterCacheKeyID>> RasterCacheKeyID::LayerChildrenIds( |
| 15 | const Layer* layer) { |
| 16 | FML_DCHECK(layer->as_container_layer()); |
| 17 | auto& children_layers = layer->as_container_layer()->layers(); |
| 18 | auto children_count = children_layers.size(); |
| 19 | if (children_count == 0) { |
| 20 | return std::nullopt; |
| 21 | } |
| 22 | std::vector<RasterCacheKeyID> ids; |
| 23 | std::transform( |
| 24 | first: children_layers.begin(), last: children_layers.end(), result: std::back_inserter(x&: ids), |
| 25 | op: [](auto& layer) -> RasterCacheKeyID { return layer->caching_key_id(); }); |
| 26 | return ids; |
| 27 | } |
| 28 | |
| 29 | } // namespace flutter |
| 30 |
