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/layers/cacheable_layer.h"
6
7namespace flutter {
8
9AutoCache::AutoCache(RasterCacheItem* raster_cache_item,
10 PrerollContext* context,
11 const SkMatrix& matrix)
12 : raster_cache_item_(raster_cache_item),
13 context_(context),
14 matrix_(matrix) {
15 if (IsCacheEnabled()) {
16 raster_cache_item->PrerollSetup(context, matrix);
17 }
18}
19
20bool AutoCache::IsCacheEnabled() {
21 return raster_cache_item_ && context_ && context_->raster_cache;
22}
23
24AutoCache::~AutoCache() {
25 if (IsCacheEnabled()) {
26 raster_cache_item_->PrerollFinalize(context: context_, matrix: matrix_);
27 }
28}
29
30CacheableContainerLayer::CacheableContainerLayer(int layer_cached_threshold,
31 bool can_cache_children) {
32 layer_raster_cache_item_ = LayerRasterCacheItem::Make(
33 this, layer_cache_threshold: layer_cached_threshold, can_cache_children);
34}
35
36} // namespace flutter
37

source code of flutter_engine/flutter/flow/layers/cacheable_layer.cc