forked from flutter/flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Defer decisions about RasterCache actions until after Preroll is comp…
…lete (flutter#31892)
- Loading branch information
Showing
49 changed files
with
2,379 additions
and
1,038 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// 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/layers/cacheable_layer.h" | ||
#include "flutter/flow/raster_cache.h" | ||
#include "flutter/flow/raster_cache_item.h" | ||
|
||
namespace flutter { | ||
|
||
AutoCache::AutoCache(RasterCacheItem* raster_cache_item, | ||
PrerollContext* context, | ||
const SkMatrix& matrix) | ||
: raster_cache_item_(raster_cache_item), | ||
context_(context), | ||
matrix_(matrix) { | ||
if (IsCacheEnabled()) { | ||
raster_cache_item->PrerollSetup(context, matrix); | ||
} | ||
} | ||
|
||
bool AutoCache::IsCacheEnabled() { | ||
return raster_cache_item_ && context_ && context_->raster_cache; | ||
} | ||
|
||
AutoCache::~AutoCache() { | ||
if (IsCacheEnabled()) { | ||
raster_cache_item_->PrerollFinalize(context_, matrix_); | ||
} | ||
} | ||
|
||
CacheableContainerLayer::CacheableContainerLayer(int layer_cached_threshold, | ||
bool can_cache_children) { | ||
layer_raster_cache_item_ = LayerRasterCacheItem::Make( | ||
this, layer_cached_threshold, can_cache_children); | ||
} | ||
|
||
} // namespace flutter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// 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. | ||
|
||
#ifndef FLUTTER_FLOW_LAYERS_CACHEABLE_LAYER_H_ | ||
#define FLUTTER_FLOW_LAYERS_CACHEABLE_LAYER_H_ | ||
|
||
#include <memory> | ||
|
||
#include "flutter/flow/layers/container_layer.h" | ||
#include "flutter/flow/layers/display_list_raster_cache_item.h" | ||
#include "flutter/flow/layers/layer_raster_cache_item.h" | ||
|
||
namespace flutter { | ||
|
||
class AutoCache { | ||
public: | ||
AutoCache(RasterCacheItem* raster_cache_item, | ||
PrerollContext* context, | ||
const SkMatrix& matrix); | ||
|
||
void ShouldNotBeCached() { raster_cache_item_ = nullptr; } | ||
|
||
~AutoCache(); | ||
|
||
private: | ||
inline bool IsCacheEnabled(); | ||
RasterCacheItem* raster_cache_item_ = nullptr; | ||
PrerollContext* context_ = nullptr; | ||
const SkMatrix& matrix_; | ||
}; | ||
|
||
class CacheableContainerLayer : public ContainerLayer { | ||
public: | ||
explicit CacheableContainerLayer( | ||
int layer_cached_threshold = | ||
RasterCacheUtil::kMinimumRendersBeforeCachingFilterLayer, | ||
bool can_cache_children = false); | ||
|
||
const LayerRasterCacheItem* raster_cache_item() const { | ||
return layer_raster_cache_item_.get(); | ||
} | ||
|
||
protected: | ||
std::unique_ptr<LayerRasterCacheItem> layer_raster_cache_item_; | ||
}; | ||
|
||
} // namespace flutter | ||
|
||
#endif // FLUTTER_FLOW_LAYERS_CACHEABLE_LAYER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.