Flutter Engine
The Flutter Engine
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 29 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 29 of file raster_cache.cc.

33 : image_(std::move(image)),
34 logical_rect_(logical_rect),
35 flow_(type),
36 rtree_(std::move(rtree)) {}
GLenum type
sk_sp< const SkImage > image
Definition: SkRecords.h:269

◆ ~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 38 of file raster_cache.cc.

40 {
41 DlAutoCanvasRestore auto_restore(&canvas, true);
42
43 auto matrix = RasterCacheUtil::GetIntegralTransCTM(canvas.GetTransform());
46 FML_DCHECK(std::abs(bounds.width() - image_->dimensions().width()) <= 1 &&
47 std::abs(bounds.height() - image_->dimensions().height()) <= 1);
48 canvas.TransformReset();
49 flow_.Step();
50 if (!preserve_rtree || !rtree_) {
51 canvas.DrawImage(image_, {bounds.fLeft, bounds.fTop},
53 } else {
54 // On some platforms RTree from overlay layers is used for unobstructed
55 // platform views and hit testing. To preserve the RTree raster cache must
56 // paint individual rects instead of the whole image.
57 auto rects = rtree_->region().getRects(true);
58
59 canvas.Translate(bounds.fLeft, bounds.fTop);
60
61 SkRect rtree_bounds =
63 for (auto rect : rects) {
66 device_rect.offset(-rtree_bounds.fLeft, -rtree_bounds.fTop);
67 canvas.DrawImageRect(image_, device_rect, device_rect,
69 }
70 }
71}
void Step(const char *label=nullptr) const
Definition: trace_event.h:484
const Paint & paint
Definition: color_source.cc:38
#define FML_DCHECK(condition)
Definition: logging.h:103
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
Optional< SkRect > bounds
Definition: SkRecords.h:189
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
SIN Vec< N, float > abs(const Vec< N, float > &x)
Definition: SkVx.h:707
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 46 of file raster_cache.h.

46 {
47 return image_ ? image_->GetApproximateByteSize() : 0;
48 };

◆ image_dimensions()

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

Reimplemented in flutter::testing::MockRasterCacheResult.

Definition at line 42 of file raster_cache.h.

42 {
43 return image_ ? image_->dimensions() : SkISize::Make(0, 0);
44 };
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: