Flutter Engine
 
Loading...
Searching...
No Matches
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 30 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 28 of file raster_cache.cc.

32 : image_(std::move(image)),
33 logical_rect_(logical_rect),
34 flow_(type),
35 rtree_(std::move(rtree)) {}
GLenum type
FlutterVulkanImage * image

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

39 {
40 DlAutoCanvasRestore auto_restore(&canvas, true);
41
42 auto matrix =
44 SkRect bounds =
45 RasterCacheUtil::GetRoundedOutDeviceBounds(logical_rect_, matrix);
46 FML_DCHECK(std::abs(bounds.width() - image_->GetSize().width) <= 1 &&
47 std::abs(bounds.height() - image_->GetSize().height) <= 1);
48 canvas.TransformReset();
49 flow_.Step();
50 if (!preserve_rtree || !rtree_) {
51 canvas.DrawImage(image_, DlPoint(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
62 ToSkRect(rtree_->bounds()), matrix);
63 for (auto rect : rects) {
65 SkRect::Make(ToSkIRect(rect)), matrix));
66 device_rect = device_rect.Shift(-rtree_bounds.fLeft, -rtree_bounds.fTop);
67 canvas.DrawImageRect(image_, device_rect, device_rect,
69 }
70 }
71}
void Step(const char *label=nullptr) const
#define FML_DCHECK(condition)
Definition logging.h:122
impeller::Rect DlRect
const SkIRect & ToSkIRect(const DlIRect &rect)
SkMatrix ToSkMatrix(const DlMatrix &matrix)
impeller::Point DlPoint
const DlRect & ToDlRect(const SkRect &rect)
const SkRect & ToSkRect(const DlRect &rect)
static SkMatrix GetIntegralTransCTM(const SkMatrix &ctm)
Snap the translation components of the matrix to integers.
static SkRect GetRoundedOutDeviceBounds(const SkRect &rect, const SkMatrix &ctm)

References flutter::DlCanvas::DrawImage(), flutter::DlCanvas::DrawImageRect(), FML_DCHECK, flutter::RasterCacheUtil::GetIntegralTransCTM(), flutter::DlCanvas::GetMatrix(), flutter::RasterCacheUtil::GetRoundedOutDeviceBounds(), flutter::kNearestNeighbor, impeller::TRect< T >::Shift(), fml::tracing::TraceFlow::Step(), flutter::ToDlRect(), flutter::ToSkIRect(), flutter::ToSkMatrix(), flutter::ToSkRect(), flutter::DlCanvas::TransformReset(), and flutter::DlCanvas::Translate().

◆ image_bytes()

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

Reimplemented in flutter::testing::MockRasterCacheResult.

Definition at line 47 of file raster_cache.h.

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

◆ image_dimensions()

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

Reimplemented in flutter::testing::MockRasterCacheResult.

Definition at line 43 of file raster_cache.h.

43 {
44 return image_ ? ToSkISize(image_->GetSize()) : SkISize::Make(0, 0);
45 };
const SkISize & ToSkISize(const DlISize &size)

References flutter::ToSkISize().


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