Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
flutter::RasterCacheResult Class Reference

#include <raster_cache.h>

Inheritance diagram for flutter::RasterCacheResult:
flutter::testing::MockRasterCacheResult

Public Member Functions

 RasterCacheResult (sk_sp< DlImage > image, const SkRect &logical_rect, const char *type, sk_sp< const DlRTree > rtree=nullptr)
 
virtual ~RasterCacheResult ()=default
 
virtual void draw (DlCanvas &canvas, const DlPaint *paint, bool preserve_rtree) const
 
virtual SkISize image_dimensions () const
 
virtual int64_t image_bytes () const
 

Detailed Description

Definition at line 27 of file raster_cache.h.

Constructor & Destructor Documentation

◆ RasterCacheResult()

flutter::RasterCacheResult::RasterCacheResult ( sk_sp< DlImage image,
const SkRect logical_rect,
const char *  type,
sk_sp< const DlRTree rtree = nullptr 
)

Definition at line 27 of file raster_cache.cc.

31 : image_(std::move(image)),
32 logical_rect_(logical_rect),
33 flow_(type),
34 rtree_(std::move(rtree)) {}
sk_sp< SkImage > image
Definition examples.cpp:29

◆ ~RasterCacheResult()

virtual flutter::RasterCacheResult::~RasterCacheResult ( )
virtualdefault

Member Function Documentation

◆ draw()

void flutter::RasterCacheResult::draw ( DlCanvas canvas,
const DlPaint paint,
bool  preserve_rtree 
) const
virtual

Reimplemented in flutter::testing::MockRasterCacheResult.

Definition at line 36 of file raster_cache.cc.

38 {
39 DlAutoCanvasRestore auto_restore(&canvas, true);
40
41 auto matrix = RasterCacheUtil::GetIntegralTransCTM(canvas.GetTransform());
43 RasterCacheUtil::GetRoundedOutDeviceBounds(logical_rect_, matrix);
44 FML_DCHECK(std::abs(bounds.width() - image_->dimensions().width()) <= 1 &&
45 std::abs(bounds.height() - image_->dimensions().height()) <= 1);
46 canvas.TransformReset();
47 flow_.Step();
48 if (!preserve_rtree || !rtree_) {
49 canvas.DrawImage(image_, {bounds.fLeft, bounds.fTop},
51 } else {
52 // On some platforms RTree from overlay layers is used for unobstructed
53 // platform views and hit testing. To preserve the RTree raster cache must
54 // paint individual rects instead of the whole image.
55 auto rects = rtree_->region().getRects(true);
56
57 canvas.Translate(bounds.fLeft, bounds.fTop);
58
59 SkRect rtree_bounds =
60 RasterCacheUtil::GetRoundedOutDeviceBounds(rtree_->bounds(), matrix);
61 for (auto rect : rects) {
63 SkRect::Make(rect), matrix);
64 device_rect.offset(-rtree_bounds.fLeft, -rtree_bounds.fTop);
65 canvas.DrawImageRect(image_, device_rect, device_rect,
67 }
68 }
69}
void Step(const char *label=nullptr) const
const Paint & paint
#define FML_DCHECK(condition)
Definition logging.h:103
unsigned useCenter Optional< SkMatrix > matrix
Definition SkRecords.h:258
Optional< SkRect > bounds
Definition SkRecords.h:189
static SkRect Make(const SkISize &size)
Definition SkRect.h:669
SkScalar fLeft
smaller x-axis bounds
Definition extension.cpp:14
void offset(float dx, float dy)
Definition SkRect.h:1016
SkScalar fTop
smaller y-axis bounds
Definition extension.cpp:15
static SkMatrix GetIntegralTransCTM(const SkMatrix &ctm)
Snap the translation components of the matrix to integers.
static SkRect GetRoundedOutDeviceBounds(const SkRect &rect, const SkMatrix &ctm)

◆ image_bytes()

virtual int64_t flutter::RasterCacheResult::image_bytes ( ) const
inlinevirtual

Reimplemented in flutter::testing::MockRasterCacheResult.

Definition at line 44 of file raster_cache.h.

44 {
45 return image_ ? image_->GetApproximateByteSize() : 0;
46 };

◆ image_dimensions()

virtual SkISize flutter::RasterCacheResult::image_dimensions ( ) const
inlinevirtual

Reimplemented in flutter::testing::MockRasterCacheResult.

Definition at line 40 of file raster_cache.h.

40 {
41 return image_ ? image_->dimensions() : SkISize::Make(0, 0);
42 };
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20

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