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