Flutter Engine
flutter::testing::MockRasterCache Class Reference

A RasterCache implementation that simulates the act of rendering a Layer or SkPicture without the overhead of rasterization or pixel storage. This implementation is used only for testing proper usage of the RasterCache in layer unit tests. More...

#include <mock_raster_cache.h>

Inheritance diagram for flutter::testing::MockRasterCache:
flutter::RasterCache

Public Member Functions

std::unique_ptr< RasterCacheResultRasterizePicture (SkPicture *picture, GrDirectContext *context, const SkMatrix &ctm, SkColorSpace *dst_color_space, bool checkerboard) const override
 Rasterize a picture object and produce a RasterCacheResult to be stored in the cache. More...
 
std::unique_ptr< RasterCacheResultRasterizeLayer (PrerollContext *context, Layer *layer, const SkMatrix &ctm, bool checkerboard) const override
 Rasterize an engine Layer and produce a RasterCacheResult to be stored in the cache. More...
 
- Public Member Functions inherited from flutter::RasterCache
 RasterCache (size_t access_threshold=3, size_t picture_cache_limit_per_frame=kDefaultPictureCacheLimitPerFrame)
 
virtual ~RasterCache ()=default
 
bool Prepare (GrDirectContext *context, SkPicture *picture, const SkMatrix &transformation_matrix, SkColorSpace *dst_color_space, bool is_complex, bool will_change)
 
void Prepare (PrerollContext *context, Layer *layer, const SkMatrix &ctm)
 
bool Draw (const SkPicture &picture, SkCanvas &canvas) const
 
bool Draw (const Layer *layer, SkCanvas &canvas, SkPaint *paint=nullptr) const
 
void SweepAfterFrame ()
 
void Clear ()
 
void SetCheckboardCacheImages (bool checkerboard)
 
size_t GetCachedEntriesCount () const
 
size_t GetLayerCachedEntriesCount () const
 
size_t GetPictureCachedEntriesCount () const
 
size_t EstimatePictureCacheByteSize () const
 Estimate how much memory is used by picture raster cache entries in bytes. More...
 
size_t EstimateLayerCacheByteSize () const
 Estimate how much memory is used by layer raster cache entries in bytes. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from flutter::RasterCache
static SkIRect GetDeviceBounds (const SkRect &rect, const SkMatrix &ctm)
 
static SkMatrix GetIntegralTransCTM (const SkMatrix &ctm)
 Snap the translation components of the matrix to integers. More...
 
- Static Public Attributes inherited from flutter::RasterCache
static constexpr int kDefaultPictureCacheLimitPerFrame = 3
 

Detailed Description

A RasterCache implementation that simulates the act of rendering a Layer or SkPicture without the overhead of rasterization or pixel storage. This implementation is used only for testing proper usage of the RasterCache in layer unit tests.

Definition at line 45 of file mock_raster_cache.h.

Member Function Documentation

◆ RasterizeLayer()

std::unique_ptr< RasterCacheResult > flutter::testing::MockRasterCache::RasterizeLayer ( PrerollContext context,
Layer layer,
const SkMatrix &  ctm,
bool  checkerboard 
) const
overridevirtual

Rasterize an engine Layer and produce a RasterCacheResult to be stored in the cache.

Parameters
contextthe PrerollContext containing important information needed for rendering a layer.
layerthe Layer object to be cached.
ctmthe transformation matrix used for rendering.
checkerboarda flag indicating whether or not a checkerboard pattern should be rendered into the cached image for debug analysis
Returns
a RasterCacheResult that can draw the rendered layer into the destination using a simple image blit

Reimplemented from flutter::RasterCache.

Definition at line 28 of file mock_raster_cache.cc.

References flutter::RasterCache::GetDeviceBounds(), and flutter::Layer::paint_bounds().

32  {
33  SkRect logical_rect = layer->paint_bounds();
34  SkIRect cache_rect = RasterCache::GetDeviceBounds(logical_rect, ctm);
35 
36  return std::make_unique<MockRasterCacheResult>(cache_rect);
37 }
static SkIRect GetDeviceBounds(const SkRect &rect, const SkMatrix &ctm)
Definition: raster_cache.h:98

◆ RasterizePicture()

std::unique_ptr< RasterCacheResult > flutter::testing::MockRasterCache::RasterizePicture ( SkPicture *  picture,
GrDirectContext *  context,
const SkMatrix &  ctm,
SkColorSpace *  dst_color_space,
bool  checkerboard 
) const
overridevirtual

Rasterize a picture object and produce a RasterCacheResult to be stored in the cache.

Parameters
picturethe SkPicture object to be cached.
contextthe GrDirectContext used for rendering.
ctmthe transformation matrix used for rendering.
dst_color_spacethe destination color space that the cached rendering will be drawn into
checkerboarda flag indicating whether or not a checkerboard pattern should be rendered into the cached image for debug analysis
Returns
a RasterCacheResult that can draw the rendered picture into the destination using a simple image blit

Reimplemented from flutter::RasterCache.

Definition at line 16 of file mock_raster_cache.cc.

References flutter::RasterCache::GetDeviceBounds().

21  {
22  SkRect logical_rect = picture->cullRect();
23  SkIRect cache_rect = RasterCache::GetDeviceBounds(logical_rect, ctm);
24 
25  return std::make_unique<MockRasterCacheResult>(cache_rect);
26 }
static SkIRect GetDeviceBounds(const SkRect &rect, const SkMatrix &ctm)
Definition: raster_cache.h:98

The documentation for this class was generated from the following files: