Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
flutter::DlCanvas Class Referenceabstract

Developer-facing API for rendering anything within the engine. More...

#include <dl_canvas.h>

Inheritance diagram for flutter::DlCanvas:
flutter::DisplayListBuilder flutter::DlSkCanvasAdapter flutter::testing::MockCanvas

Public Types

enum class  ClipOp { kDifference , kIntersect }
 
enum class  PointMode { kPoints , kLines , kPolygon }
 
enum class  SrcRectConstraint { kStrict , kFast }
 

Public Member Functions

virtual ~DlCanvas ()=default
 
virtual SkISize GetBaseLayerSize () const =0
 
virtual SkImageInfo GetImageInfo () const =0
 
virtual void Save ()=0
 
virtual void SaveLayer (const SkRect *bounds, const DlPaint *paint=nullptr, const DlImageFilter *backdrop=nullptr)=0
 
virtual void Restore ()=0
 
virtual int GetSaveCount () const =0
 
virtual void RestoreToCount (int restore_count)=0
 
virtual void Translate (SkScalar tx, SkScalar ty)=0
 
virtual void Scale (SkScalar sx, SkScalar sy)=0
 
virtual void Rotate (SkScalar degrees)=0
 
virtual void Skew (SkScalar sx, SkScalar sy)=0
 
virtual void Transform2DAffine (SkScalar mxx, SkScalar mxy, SkScalar mxt, SkScalar myx, SkScalar myy, SkScalar myt)=0
 
virtual void TransformFullPerspective (SkScalar mxx, SkScalar mxy, SkScalar mxz, SkScalar mxt, SkScalar myx, SkScalar myy, SkScalar myz, SkScalar myt, SkScalar mzx, SkScalar mzy, SkScalar mzz, SkScalar mzt, SkScalar mwx, SkScalar mwy, SkScalar mwz, SkScalar mwt)=0
 
virtual void TransformReset ()=0
 
virtual void Transform (const SkMatrix *matrix)=0
 
virtual void Transform (const SkM44 *matrix44)=0
 
void Transform (const SkMatrix &matrix)
 
void Transform (const SkM44 &matrix44)
 
virtual void SetTransform (const SkMatrix *matrix)=0
 
virtual void SetTransform (const SkM44 *matrix44)=0
 
virtual void SetTransform (const SkMatrix &matrix)
 
virtual void SetTransform (const SkM44 &matrix44)
 
virtual SkM44 GetTransformFullPerspective () const =0
 
virtual SkMatrix GetTransform () const =0
 
virtual void ClipRect (const SkRect &rect, ClipOp clip_op=ClipOp::kIntersect, bool is_aa=false)=0
 
virtual void ClipRRect (const SkRRect &rrect, ClipOp clip_op=ClipOp::kIntersect, bool is_aa=false)=0
 
virtual void ClipPath (const SkPath &path, ClipOp clip_op=ClipOp::kIntersect, bool is_aa=false)=0
 
virtual SkRect GetDestinationClipBounds () const =0
 
virtual SkRect GetLocalClipBounds () const =0
 
virtual bool QuickReject (const SkRect &bounds) const =0
 
virtual void DrawPaint (const DlPaint &paint)=0
 
virtual void DrawColor (DlColor color, DlBlendMode mode=DlBlendMode::kSrcOver)=0
 
void Clear (DlColor color)
 
virtual void DrawLine (const SkPoint &p0, const SkPoint &p1, const DlPaint &paint)=0
 
virtual void DrawDashedLine (const DlPoint &p0, const DlPoint &p1, DlScalar on_length, DlScalar off_length, const DlPaint &paint)=0
 
virtual void DrawRect (const SkRect &rect, const DlPaint &paint)=0
 
virtual void DrawOval (const SkRect &bounds, const DlPaint &paint)=0
 
virtual void DrawCircle (const SkPoint &center, SkScalar radius, const DlPaint &paint)=0
 
virtual void DrawRRect (const SkRRect &rrect, const DlPaint &paint)=0
 
virtual void DrawDRRect (const SkRRect &outer, const SkRRect &inner, const DlPaint &paint)=0
 
virtual void DrawPath (const SkPath &path, const DlPaint &paint)=0
 
virtual void DrawArc (const SkRect &bounds, SkScalar start, SkScalar sweep, bool useCenter, const DlPaint &paint)=0
 
virtual void DrawPoints (PointMode mode, uint32_t count, const SkPoint pts[], const DlPaint &paint)=0
 
virtual void DrawVertices (const DlVertices *vertices, DlBlendMode mode, const DlPaint &paint)=0
 
void DrawVertices (const std::shared_ptr< const DlVertices > &vertices, DlBlendMode mode, const DlPaint &paint)
 
virtual void DrawImage (const sk_sp< DlImage > &image, const SkPoint point, DlImageSampling sampling, const DlPaint *paint=nullptr)=0
 
virtual void DrawImageRect (const sk_sp< DlImage > &image, const SkRect &src, const SkRect &dst, DlImageSampling sampling, const DlPaint *paint=nullptr, SrcRectConstraint constraint=SrcRectConstraint::kFast)=0
 
virtual void DrawImageRect (const sk_sp< DlImage > &image, const SkIRect &src, const SkRect &dst, DlImageSampling sampling, const DlPaint *paint=nullptr, SrcRectConstraint constraint=SrcRectConstraint::kFast)
 
void DrawImageRect (const sk_sp< DlImage > &image, const SkRect &dst, DlImageSampling sampling, const DlPaint *paint=nullptr, SrcRectConstraint constraint=SrcRectConstraint::kFast)
 
virtual void DrawImageNine (const sk_sp< DlImage > &image, const SkIRect &center, const SkRect &dst, DlFilterMode filter, const DlPaint *paint=nullptr)=0
 
virtual void DrawAtlas (const sk_sp< DlImage > &atlas, const SkRSXform xform[], const SkRect tex[], const DlColor colors[], int count, DlBlendMode mode, DlImageSampling sampling, const SkRect *cullRect, const DlPaint *paint=nullptr)=0
 
virtual void DrawDisplayList (const sk_sp< DisplayList > display_list, SkScalar opacity=SK_Scalar1)=0
 
virtual void DrawTextFrame (const std::shared_ptr< impeller::TextFrame > &text_frame, SkScalar x, SkScalar y, const DlPaint &paint)=0
 
virtual void DrawTextBlob (const sk_sp< SkTextBlob > &blob, SkScalar x, SkScalar y, const DlPaint &paint)=0
 
virtual void DrawShadow (const SkPath &path, const DlColor color, const SkScalar elevation, bool transparent_occluder, SkScalar dpr)=0
 
virtual void Flush ()=0
 

Static Public Member Functions

static SkRect ComputeShadowBounds (const SkPath &path, float elevation, SkScalar dpr, const SkMatrix &ctm)
 

Static Public Attributes

static constexpr SkScalar kShadowLightHeight = 600
 
static constexpr SkScalar kShadowLightRadius = 800
 

Detailed Description

Developer-facing API for rendering anything within the engine.

|DlCanvas| should be used to render anything in the framework classes (i.e. lib/ui), flow and flow layers, embedders, shell, and elsewhere.

The only state carried by implementations of this interface are the clip and transform which are saved and restored by the |save|, |saveLayer|, and |restore| calls.

Note
The interface resembles closely the familiar |SkCanvas| interface used throughout the engine.

Definition at line 38 of file dl_canvas.h.

Member Enumeration Documentation

◆ ClipOp

enum class flutter::DlCanvas::ClipOp
strong
Enumerator
kDifference 
kIntersect 

Definition at line 40 of file dl_canvas.h.

40 {
43 };
@ kDifference
rc = s + d - 2*(min(s*da, d*sa)), ra = kSrcOver

◆ PointMode

enum class flutter::DlCanvas::PointMode
strong
Enumerator
kPoints 

draw each point separately

kLines 

draw each separate pair of points as a line segment

kPolygon 

draw each pair of overlapping points as a line segment

Definition at line 45 of file dl_canvas.h.

45 {
46 kPoints, //!< draw each point separately
47 kLines, //!< draw each separate pair of points as a line segment
48 kPolygon, //!< draw each pair of overlapping points as a line segment
49 };

◆ SrcRectConstraint

Enumerator
kStrict 
kFast 

Definition at line 51 of file dl_canvas.h.

51 {
52 kStrict,
53 kFast,
54 };
@ kStrict
Sample only within the source rectangle. May be slower.
@ kFast
Faster, but may sample outside the bounds of the source rectangle.

Constructor & Destructor Documentation

◆ ~DlCanvas()

virtual flutter::DlCanvas::~DlCanvas ( )
virtualdefault

Member Function Documentation

◆ Clear()

void flutter::DlCanvas::Clear ( DlColor  color)
inline

Definition at line 132 of file dl_canvas.h.

virtual void DrawColor(DlColor color, DlBlendMode mode=DlBlendMode::kSrcOver)=0
DlColor color

◆ ClipPath()

virtual void flutter::DlCanvas::ClipPath ( const SkPath path,
ClipOp  clip_op = ClipOp::kIntersect,
bool  is_aa = false 
)
pure virtual

◆ ClipRect()

virtual void flutter::DlCanvas::ClipRect ( const SkRect rect,
ClipOp  clip_op = ClipOp::kIntersect,
bool  is_aa = false 
)
pure virtual

◆ ClipRRect()

virtual void flutter::DlCanvas::ClipRRect ( const SkRRect rrect,
ClipOp  clip_op = ClipOp::kIntersect,
bool  is_aa = false 
)
pure virtual

◆ ComputeShadowBounds()

SkRect flutter::DlCanvas::ComputeShadowBounds ( const SkPath path,
float  elevation,
SkScalar  dpr,
const SkMatrix ctm 
)
static

Definition at line 12 of file dl_canvas.cc.

15 {
16 SkRect shadow_bounds(path.getBounds());
18 ctm, path, SkPoint3::Make(0, 0, dpr * elevation),
21 return shadow_bounds;
22}
@ kDirectionalLight_ShadowFlag
Definition: SkShadowUtils.h:31
static bool GetLocalBounds(const SkMatrix &ctm, const SkPath &path, const SkPoint3 &zPlaneParams, const SkPoint3 &lightPos, SkScalar lightRadius, uint32_t flags, SkRect *bounds)
static constexpr SkScalar kShadowLightRadius
Definition: dl_canvas.h:231
static constexpr SkScalar kShadowLightHeight
Definition: dl_canvas.h:230
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
static SkPoint3 Make(SkScalar x, SkScalar y, SkScalar z)
Definition: SkPoint3.h:18

◆ DrawArc()

virtual void flutter::DlCanvas::DrawArc ( const SkRect bounds,
SkScalar  start,
SkScalar  sweep,
bool  useCenter,
const DlPaint paint 
)
pure virtual

◆ DrawAtlas()

virtual void flutter::DlCanvas::DrawAtlas ( const sk_sp< DlImage > &  atlas,
const SkRSXform  xform[],
const SkRect  tex[],
const DlColor  colors[],
int  count,
DlBlendMode  mode,
DlImageSampling  sampling,
const SkRect cullRect,
const DlPaint paint = nullptr 
)
pure virtual

◆ DrawCircle()

virtual void flutter::DlCanvas::DrawCircle ( const SkPoint center,
SkScalar  radius,
const DlPaint paint 
)
pure virtual

◆ DrawColor()

virtual void flutter::DlCanvas::DrawColor ( DlColor  color,
DlBlendMode  mode = DlBlendMode::kSrcOver 
)
pure virtual

◆ DrawDashedLine()

virtual void flutter::DlCanvas::DrawDashedLine ( const DlPoint p0,
const DlPoint p1,
DlScalar  on_length,
DlScalar  off_length,
const DlPaint paint 
)
pure virtual

◆ DrawDisplayList()

virtual void flutter::DlCanvas::DrawDisplayList ( const sk_sp< DisplayList display_list,
SkScalar  opacity = SK_Scalar1 
)
pure virtual

◆ DrawDRRect()

virtual void flutter::DlCanvas::DrawDRRect ( const SkRRect outer,
const SkRRect inner,
const DlPaint paint 
)
pure virtual

◆ DrawImage()

virtual void flutter::DlCanvas::DrawImage ( const sk_sp< DlImage > &  image,
const SkPoint  point,
DlImageSampling  sampling,
const DlPaint paint = nullptr 
)
pure virtual

◆ DrawImageNine()

virtual void flutter::DlCanvas::DrawImageNine ( const sk_sp< DlImage > &  image,
const SkIRect center,
const SkRect dst,
DlFilterMode  filter,
const DlPaint paint = nullptr 
)
pure virtual

◆ DrawImageRect() [1/3]

virtual void flutter::DlCanvas::DrawImageRect ( const sk_sp< DlImage > &  image,
const SkIRect src,
const SkRect dst,
DlImageSampling  sampling,
const DlPaint paint = nullptr,
SrcRectConstraint  constraint = SrcRectConstraint::kFast 
)
inlinevirtual

Reimplemented in flutter::DisplayListBuilder.

Definition at line 179 of file dl_canvas.h.

185 {
187 }
virtual void DrawImageRect(const sk_sp< DlImage > &image, const SkRect &src, const SkRect &dst, DlImageSampling sampling, const DlPaint *paint=nullptr, SrcRectConstraint constraint=SrcRectConstraint::kFast)=0
const Paint & paint
Definition: color_source.cc:38
sk_sp< const SkImage > image
Definition: SkRecords.h:269
SkSamplingOptions sampling
Definition: SkRecords.h:337
dst
Definition: cp.py:12
static SkRect Make(const SkISize &size)
Definition: SkRect.h:669

◆ DrawImageRect() [2/3]

void flutter::DlCanvas::DrawImageRect ( const sk_sp< DlImage > &  image,
const SkRect dst,
DlImageSampling  sampling,
const DlPaint paint = nullptr,
SrcRectConstraint  constraint = SrcRectConstraint::kFast 
)
inline

Definition at line 188 of file dl_canvas.h.

192 {
193 DrawImageRect(image, image->bounds(), dst, sampling, paint, constraint);
194 }
SkIRect bounds() const
Definition: SkImage.h:303

◆ DrawImageRect() [3/3]

virtual void flutter::DlCanvas::DrawImageRect ( const sk_sp< DlImage > &  image,
const SkRect src,
const SkRect dst,
DlImageSampling  sampling,
const DlPaint paint = nullptr,
SrcRectConstraint  constraint = SrcRectConstraint::kFast 
)
pure virtual

◆ DrawLine()

virtual void flutter::DlCanvas::DrawLine ( const SkPoint p0,
const SkPoint p1,
const DlPaint paint 
)
pure virtual

◆ DrawOval()

virtual void flutter::DlCanvas::DrawOval ( const SkRect bounds,
const DlPaint paint 
)
pure virtual

◆ DrawPaint()

virtual void flutter::DlCanvas::DrawPaint ( const DlPaint paint)
pure virtual

◆ DrawPath()

virtual void flutter::DlCanvas::DrawPath ( const SkPath path,
const DlPaint paint 
)
pure virtual

◆ DrawPoints()

virtual void flutter::DlCanvas::DrawPoints ( PointMode  mode,
uint32_t  count,
const SkPoint  pts[],
const DlPaint paint 
)
pure virtual

◆ DrawRect()

virtual void flutter::DlCanvas::DrawRect ( const SkRect rect,
const DlPaint paint 
)
pure virtual

◆ DrawRRect()

virtual void flutter::DlCanvas::DrawRRect ( const SkRRect rrect,
const DlPaint paint 
)
pure virtual

◆ DrawShadow()

virtual void flutter::DlCanvas::DrawShadow ( const SkPath path,
const DlColor  color,
const SkScalar  elevation,
bool  transparent_occluder,
SkScalar  dpr 
)
pure virtual

◆ DrawTextBlob()

virtual void flutter::DlCanvas::DrawTextBlob ( const sk_sp< SkTextBlob > &  blob,
SkScalar  x,
SkScalar  y,
const DlPaint paint 
)
pure virtual

◆ DrawTextFrame()

virtual void flutter::DlCanvas::DrawTextFrame ( const std::shared_ptr< impeller::TextFrame > &  text_frame,
SkScalar  x,
SkScalar  y,
const DlPaint paint 
)
pure virtual

◆ DrawVertices() [1/2]

virtual void flutter::DlCanvas::DrawVertices ( const DlVertices vertices,
DlBlendMode  mode,
const DlPaint paint 
)
pure virtual

◆ DrawVertices() [2/2]

void flutter::DlCanvas::DrawVertices ( const std::shared_ptr< const DlVertices > &  vertices,
DlBlendMode  mode,
const DlPaint paint 
)
inline

Definition at line 163 of file dl_canvas.h.

165 {
166 DrawVertices(vertices.get(), mode, paint);
167 }
virtual void DrawVertices(const DlVertices *vertices, DlBlendMode mode, const DlPaint &paint)=0
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
Definition: switches.h:228

◆ Flush()

virtual void flutter::DlCanvas::Flush ( )
pure virtual

◆ GetBaseLayerSize()

virtual SkISize flutter::DlCanvas::GetBaseLayerSize ( ) const
pure virtual

◆ GetDestinationClipBounds()

virtual SkRect flutter::DlCanvas::GetDestinationClipBounds ( ) const
pure virtual

Conservative estimate of the bounds of all outstanding clip operations measured in the coordinate space within which this DisplayList will be rendered.

Implemented in flutter::DisplayListBuilder, flutter::DlSkCanvasAdapter, and flutter::testing::MockCanvas.

◆ GetImageInfo()

virtual SkImageInfo flutter::DlCanvas::GetImageInfo ( ) const
pure virtual

◆ GetLocalClipBounds()

virtual SkRect flutter::DlCanvas::GetLocalClipBounds ( ) const
pure virtual

Conservative estimate of the bounds of all outstanding clip operations transformed into the local coordinate space in which currently recorded rendering operations are interpreted.

Implemented in flutter::DisplayListBuilder, flutter::DlSkCanvasAdapter, and flutter::testing::MockCanvas.

◆ GetSaveCount()

virtual int flutter::DlCanvas::GetSaveCount ( ) const
pure virtual

◆ GetTransform()

virtual SkMatrix flutter::DlCanvas::GetTransform ( ) const
pure virtual

Returns the 3x3 partial perspective transform representing all transform operations executed so far in this DisplayList within the enclosing save stack.

Implemented in flutter::DisplayListBuilder, flutter::DlSkCanvasAdapter, and flutter::testing::MockCanvas.

◆ GetTransformFullPerspective()

virtual SkM44 flutter::DlCanvas::GetTransformFullPerspective ( ) const
pure virtual

Returns the 4x4 full perspective transform representing all transform operations executed so far in this DisplayList within the enclosing save stack.

Implemented in flutter::DisplayListBuilder, flutter::DlSkCanvasAdapter, and flutter::testing::MockCanvas.

◆ QuickReject()

virtual bool flutter::DlCanvas::QuickReject ( const SkRect bounds) const
pure virtual

Return true iff the supplied bounds are easily shown to be outside of the current clip bounds. This method may conservatively return false if it cannot make the determination.

Implemented in flutter::DisplayListBuilder, flutter::DlSkCanvasAdapter, and flutter::testing::MockCanvas.

◆ Restore()

virtual void flutter::DlCanvas::Restore ( )
pure virtual

◆ RestoreToCount()

virtual void flutter::DlCanvas::RestoreToCount ( int  restore_count)
pure virtual

◆ Rotate()

virtual void flutter::DlCanvas::Rotate ( SkScalar  degrees)
pure virtual

◆ Save()

virtual void flutter::DlCanvas::Save ( )
pure virtual

◆ SaveLayer()

virtual void flutter::DlCanvas::SaveLayer ( const SkRect bounds,
const DlPaint paint = nullptr,
const DlImageFilter backdrop = nullptr 
)
pure virtual

◆ Scale()

virtual void flutter::DlCanvas::Scale ( SkScalar  sx,
SkScalar  sy 
)
pure virtual

◆ SetTransform() [1/4]

virtual void flutter::DlCanvas::SetTransform ( const SkM44 matrix44)
inlinevirtual

Reimplemented in flutter::DlSkCanvasAdapter, and flutter::testing::MockCanvas.

Definition at line 94 of file dl_canvas.h.

94{ SetTransform(&matrix44); }
virtual void SetTransform(const SkMatrix *matrix)=0

◆ SetTransform() [2/4]

virtual void flutter::DlCanvas::SetTransform ( const SkM44 matrix44)
pure virtual

◆ SetTransform() [3/4]

virtual void flutter::DlCanvas::SetTransform ( const SkMatrix matrix)
inlinevirtual

Reimplemented in flutter::DlSkCanvasAdapter, and flutter::testing::MockCanvas.

Definition at line 93 of file dl_canvas.h.

unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258

◆ SetTransform() [4/4]

virtual void flutter::DlCanvas::SetTransform ( const SkMatrix matrix)
pure virtual

◆ Skew()

virtual void flutter::DlCanvas::Skew ( SkScalar  sx,
SkScalar  sy 
)
pure virtual

◆ Transform() [1/4]

void flutter::DlCanvas::Transform ( const SkM44 matrix44)
inline

Definition at line 90 of file dl_canvas.h.

90{ Transform(&matrix44); }
virtual void Transform(const SkMatrix *matrix)=0

◆ Transform() [2/4]

virtual void flutter::DlCanvas::Transform ( const SkM44 matrix44)
pure virtual

◆ Transform() [3/4]

void flutter::DlCanvas::Transform ( const SkMatrix matrix)
inline

Definition at line 89 of file dl_canvas.h.

89{ Transform(&matrix); }

◆ Transform() [4/4]

virtual void flutter::DlCanvas::Transform ( const SkMatrix matrix)
pure virtual

◆ Transform2DAffine()

virtual void flutter::DlCanvas::Transform2DAffine ( SkScalar  mxx,
SkScalar  mxy,
SkScalar  mxt,
SkScalar  myx,
SkScalar  myy,
SkScalar  myt 
)
pure virtual

◆ TransformFullPerspective()

virtual void flutter::DlCanvas::TransformFullPerspective ( SkScalar  mxx,
SkScalar  mxy,
SkScalar  mxz,
SkScalar  mxt,
SkScalar  myx,
SkScalar  myy,
SkScalar  myz,
SkScalar  myt,
SkScalar  mzx,
SkScalar  mzy,
SkScalar  mzz,
SkScalar  mzt,
SkScalar  mwx,
SkScalar  mwy,
SkScalar  mwz,
SkScalar  mwt 
)
pure virtual

◆ TransformReset()

virtual void flutter::DlCanvas::TransformReset ( )
pure virtual

◆ Translate()

virtual void flutter::DlCanvas::Translate ( SkScalar  tx,
SkScalar  ty 
)
pure virtual

Member Data Documentation

◆ kShadowLightHeight

constexpr SkScalar flutter::DlCanvas::kShadowLightHeight = 600
staticconstexpr

Definition at line 230 of file dl_canvas.h.

◆ kShadowLightRadius

constexpr SkScalar flutter::DlCanvas::kShadowLightRadius = 800
staticconstexpr

Definition at line 231 of file dl_canvas.h.


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