5#ifndef FLUTTER_FLOW_RASTER_CACHE_H_
6#define FLUTTER_FLOW_RASTER_CACHE_H_
11#include <unordered_map>
13#include "flutter/display_list/dl_canvas.h"
14#include "flutter/flow/raster_cache_key.h"
15#include "flutter/flow/raster_cache_util.h"
16#include "flutter/fml/macros.h"
17#include "flutter/fml/memory/weak_ptr.h"
18#include "flutter/fml/trace_event.h"
32 const SkRect& logical_rect,
40 bool preserve_rtree)
const;
47 return image_ ? image_->GetApproximateByteSize() : 0;
132 std::unique_ptr<RasterCacheResult>
Rasterize(
141 size_t picture_and_display_list_cache_limit_per_frame =
159 bool preserve_rtree =
false)
const;
220 return access_threshold_ != 0 && display_list_cached_this_frame_ <
221 display_list_cache_limit_per_frame_;
245 const Context& raster_cache_context,
251 bool encountered_this_frame =
false;
252 bool visible_this_frame =
false;
253 size_t accesses_since_visible = 0;
254 std::unique_ptr<RasterCacheResult>
image;
257 void UpdateMetrics();
261 const size_t access_threshold_;
262 const size_t display_list_cache_limit_per_frame_;
263 mutable size_t display_list_cached_this_frame_ = 0;
264 RasterCacheMetrics layer_metrics_;
265 RasterCacheMetrics picture_metrics_;
266 mutable RasterCacheKey::Map<Entry> cache_;
267 bool checkerboard_images_ =
false;
269 void TraceStatsToTimeline()
const;
Developer-facing API for rendering anything within the engine.
RasterCacheResult(sk_sp< DlImage > image, const SkRect &logical_rect, const char *type, sk_sp< const DlRTree > rtree=nullptr)
virtual SkISize image_dimensions() const
virtual void draw(DlCanvas &canvas, const DlPaint *paint, bool preserve_rtree) const
virtual int64_t image_bytes() const
virtual ~RasterCacheResult()=default
virtual ~RasterCache()=default
bool Draw(const RasterCacheKeyID &id, DlCanvas &canvas, const DlPaint *paint, bool preserve_rtree=false) const
CacheInfo MarkSeen(const RasterCacheKeyID &id, const SkMatrix &matrix, bool visible) const
The entry whose RasterCacheKey is generated by RasterCacheKeyID and matrix is marked as encountered b...
size_t access_threshold() const
Return the number of frames that a picture must be prepared before it will be cached....
const RasterCacheMetrics & picture_metrics() const
size_t EstimatePictureCacheByteSize() const
Estimate how much memory is used by picture raster cache entries in bytes.
const RasterCacheMetrics & layer_metrics() const
bool HasEntry(const RasterCacheKeyID &id, const SkMatrix &) const
bool UpdateCacheEntry(const RasterCacheKeyID &id, const Context &raster_cache_context, const std::function< void(DlCanvas *)> &render_function, sk_sp< const DlRTree > rtree=nullptr) const
bool GenerateNewCacheInThisFrame() const
RasterCache(size_t access_threshold=3, size_t picture_and_display_list_cache_limit_per_frame=RasterCacheUtil::kDefaultPictureAndDisplayListCacheLimitPerFrame)
int GetAccessCount(const RasterCacheKeyID &id, const SkMatrix &matrix) const
size_t GetCachedEntriesCount() const
size_t GetPictureCachedEntriesCount() const
size_t EstimateLayerCacheByteSize() const
Estimate how much memory is used by layer raster cache entries in bytes.
size_t GetLayerCachedEntriesCount() const
std::unique_ptr< RasterCacheResult > Rasterize(const RasterCache::Context &context, sk_sp< const DlRTree > rtree, const std::function< void(DlCanvas *)> &draw_function, const std::function< void(DlCanvas *, const SkRect &rect)> &draw_checkerboard) const
void EvictUnusedCacheEntries()
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Dart_NativeFunction function
unsigned useCenter Optional< SkMatrix > matrix
sk_sp< const SkImage > image
sk_sp< SkBlender > blender SkRect rect
static constexpr SkISize Make(int32_t w, int32_t h)
size_t total_count() const
size_t total_bytes() const
static constexpr int kDefaultPictureAndDisplayListCacheLimitPerFrame
const size_t accesses_since_visible
const SkRect & logical_rect
GrDirectContext * gr_context
const sk_sp< SkColorSpace > dst_color_space